Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

How does the Options dialog box work

The dialog box is made of: Each item in the treelist control represents an option's family: for example the Font item displays an option's panel that contains options values specific for a font.

Every item in the treelist is associated with a custom wxTreeItemData -derived class that holds informations about the relevant option's panel. The m_panel data member of this structure is used to store the pointer of the wxPanel-derived option's panel. This pointer may be NULL so that the relevant panel was not yet created.

The other data member is m_className that is a string containing the class name of the mgOptBasePanel derived class to be instantiated when the user selects the treelist item. Specialized classes are created at run-time using the wxWindow's RTTI facility: it can create an object of a wxObject derived class by supplying the className as a string. WARNING: because this feature seems to work only on some platform, the m_className member is not used. Instead, an enum is used and stored in the m_classID memebr of this structure.

At dialog startup, the mgOptDlg class constructs the treelist control and the button panel but no option's panel are constructed: they are constructed only on request when the user clicks the relevant item in the treelist control.

Then, the ctor constructs three wxLayoutConstraints (or, if OPTIONSDLG_USE_LAYOUTCONSTRAINTS is not defined, sizers) objects, one for each child window and bounds the treelist control and the button panel to their respective layout objects. The layout object for option's panels is stored in a data member because no option's panel was yet been created. Each newly created option's panel object will be bound to a copy of the layout object.

When the user selects an item in the treelist, the event handler (located in the dialog box itself, and not in the child window) obtains the associated item-data structure and calls the DisplayPanel function passing a pointer to the item-data as argument. This function checks the item-data's m_panel data member for NULL. If it is not NULL, the option's panel was already created and its Show(TRUE) function is called followed by a Show(FALSE) call to the actually displayed option's panel (stored in the m_actualPanel data member).

If the m_panel data member is NULL the CreatePanel function is called passing the itemID as argument. This function returns a pointer to the newly created option's panel. The pointer is stored in the itam-data m_panel data member.

The changes made in the option's panels by the user are not stored immediatly in the configuration object because the user might discard changes by clicking the Cancel button.

When the user clicks Apply the event handler calls mgOptDlg::CommitChanges function. If OK is clicked the function above is called and then the EndModal function. If Cancel is clicked only EndModal is called and the dialog destroyed.

The CommitChanges function.

This function is responsible of storing option's changes permanently on the configuration object passed as argument to the dialog boxes's contructor.

In order to have the maximum flexibility, this function does nothing special: it iterates through all items in the treelist control retriving the m_panel item-data's data member and, if not NULL, calls the CommitChnages pure virtual function of the mgOptBasePanel-derived class. In this way, the real work is delegated to the specialized option's panel which should also refresh the GUI if the changes affect it.

To add a new panel in the Options dialog box you have to:



Documentation generated with Doxygen on Sun Feb 6 17:19:28 2005
Visit MathStudio home page for more info

[ Top ]