#include <OptBasePanel.h>
Inheritance diagram for mgOptBasePanel:
Edit
| Options
dialog box: optionwxT('s panel')s base class.
CommitChanges
and Setup
virtual function.Classes derived from this class should only define the default constructor that should not do anything. In particular, the default ctor should not set window's properties such as fonts or background color nor it does not create any child window.
This is because classes derived from mgOptBasePanel are instantiated dynamically at run-time using the ::wxCreateDynamicObject
function that accepts a string as a parameter: the string represents the class name of the object to be instantiated.
But that function only accepts one parameter, the class name, so you do not have the possibility to pass parameters to the ctor of the class. In fact, only objects with the default ctor can be instantiated dynamically.
As a conseguence, the default ctor of the panel calls the default ctor of wxWindow class and derivates. The default ctor of the wxWindow's windows objects inits their internal structure but does not create the underlying GUI structures (that is window handle and GTK widgets) so that it is not possibile to set properties or to create child windows. The underlying structures are created with the Create
function.
So, the mgOptDlg::CreatePanel function, which is responsible to create the mgOptBasePanel
-derived class from the class name constructs the object dynamically (default ctor) then calls wxPanel::Create
to fully create the underlying GUI structure and then the virtual mgOptBasePanel::Setup
function in which the programmer inserts code to setup the layout of the panel, change window's property, create child controls, etc
Althrough the dynamic instantation is, by now, not used, I want to used this organization: maybe in the future I will used it.
To add a new panel in the mgOptDlg class you have to:
Setup
and CommitChanges
functions
mgOptionsTreeCtrl.cpp (ctor) wxTreeItemId newId = AppendItem( idRoot, // the parent item of this item (root if applicable) wxT("MySettings"), // the label of the item, passed as parameter in // mgOptBasePanel::Setup() function -1, -1, // icons for tree nodes new mgOptTreeCtrlItemData( // the item-data structure Id_MySettingsClass ) ); // the class ID of the panel
then write your specialized MySettingsClassName
class derived from this class
Definition at line 116 of file OptBasePanel.h.
Public Member Functions | |
mgOptBasePanel () | |
Constructor - it does nothing at all. | |
virtual | ~mgOptBasePanel () |
Destructor - It does nothing at all. | |
virtual mgOptDlg::mgOptChangedType | CommitChanges (wxConfig *config)=0 |
Commits the changes made by the user. | |
virtual void | Setup (const wxString &itemLabel)=0 |
The alter ego of the constructor. |
|
Commits the changes made by the user.
The virtual function is called with a pointer to a The function should change the variables used by MathCore and MathGUI in order to reflect changes in the configuration. In other words, if the user changed the font family and / or size this function should delete the font object used by the application and replace it with a new font ehich caracteristics are those specified by the user and store the pointer of the newly created font object in the MathCore library. There is no need for the function to store the settings in the configuration objevt because they will be stored automatically at program exit in CMathApp::OnExit() function. In order to refresh the application apareance when the user changes options settings (such as a font), the function returns a constant value, which is an enum, that represent what aspect of the application is to be refreshed. It is the caller responsability to do the actual work.
Implemented in mgOptFontSettingsPanel, mgOptGeneralPanel, and mgOptKeyBindingsPanel. Referenced by mgOptDlg::CommitChanges(). |
|
The alter ego of the constructor.
This function is the real ctor of the class. It is called from As you cannot set properies for the panel such as fonts, background color atc. in the class's ctor you have to set them in this function.
The The default implementation of this class just creates a wxStaticBoxSizer equal to the size of the panel and sets its label as the treelist's item's label. Specialized derived classes should construct the child controls and the sizer or layout constarints objects to be bounded to childs. Implemented in mgOptFontSettingsPanel, mgOptGeneralPanel, and mgOptKeyBindingsPanel. Referenced by mgOptDlg::CreatePanel(). |
[ Top ] |