Lets say we have...
1) A really simple class which takes strings and stores them in a kind of list, ...lets call the class: list_manager.
2) A GUI consisting of a text box and list box on a panel.
What is the usual practice for connecting the two, so they can elegantly interact with each other?
Should our Panel class have a list_manager as one of it's member variables?
Best practice: Linking GUI to function code. Topic is solved
Best practice: Linking GUI to function code.
wxWidgets(v3.2.2.1) - Vs2022(v143) - Win10(x64) - DialogBlocks(v5.16.5_Unicode)
Re: Best practice: Linking GUI to function code.
Hi,
The best would probably be to use std::vector of std::{w}string and use GUI to manage it through the list box.
But it depends on the task at hand...
Thank you.
The best would probably be to use std::vector of std::{w}string and use GUI to manage it through the list box.
But it depends on the task at hand...
Thank you.
Re: Best practice: Linking GUI to function code.
I'm probably not being clear, my question is more about how the GUI layer and function layer should connect.
We cant just randomly use a vector, ...in my example the list_manager class has to interact with the GUI class and vice versa.
I'm asking for the best way to link the two? ...for eg, the GUI class could have a list_manager as one of its member variable, then its easy for the GUI object to find, manage and drive the list_manager object .
We cant just randomly use a vector, ...in my example the list_manager class has to interact with the GUI class and vice versa.
I'm asking for the best way to link the two? ...for eg, the GUI class could have a list_manager as one of its member variable, then its easy for the GUI object to find, manage and drive the list_manager object .
wxWidgets(v3.2.2.1) - Vs2022(v143) - Win10(x64) - DialogBlocks(v5.16.5_Unicode)
Re: Best practice: Linking GUI to function code.
it sounds like what youre looking for is MVVM
- eranon
- Can't get richer than this
- Posts: 867
- Joined: Sun May 13, 2012 11:42 pm
- Location: France
- Contact:
Re: Best practice: Linking GUI to function code.
In wxWidgets, the mechanism to easily transfer values from variables to controls and reversely is done through the concept of validator (see wxValidator and derived classes). Of course, if the kind of controls and/or values you want to support has no wxWidgets validator yet, you can create your own deriving the stock validator you want.
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
- shawnhcorey
- Knows some wx things
- Posts: 41
- Joined: Mon Nov 19, 2012 3:29 pm
- Location: The Great White North
Re: Best practice: Linking GUI to function code.
The Document/View Framework was created to separate documents from views, although some might think it is overkill for a single list.
WARNING: Highly caffeinated . Approach with caution .
Re: Best practice: Linking GUI to function code.
Thanks!!!
wxWidgets(v3.2.2.1) - Vs2022(v143) - Win10(x64) - DialogBlocks(v5.16.5_Unicode)