I am writing a code for a GUI in c++ using wxwidgets. In the GUI I have an input panel that recieves information from the user, and an output panel that displays the results of a numeric simulation based on the received data. How can I transfer information from the input panel to the output panel? Is it possible to have a global structure that belongs to the parent wxwindow, or better yet, to wxapp, such that all children windows and panels have read and write access to this structure? (looking online, it seems wxclientdata might fit what I'm looking for, but I can't figure out how to use it in the way I described above, or whether it is at all possible).
1 Answer
In general, when UI objects receive inputs and they don't know (or shouldn't know) where those inputs will be used, I have them tell the App object. That is, I'll write a method in the App class, something like User_Requests_The_Oven_Timer_Be_Set(), or User_Provided_Their_Shirt_Size(int size), or the like. The UI can call that method whenever. Then the App can do whatever calculations, lookups, or other actions it needs to do, and then it can tell the UI to display the results.
Startbutton that initiates the process. The button handler would read the data, perform the operations, then post the data to the output widget.