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

mgOptDlg Class Reference

#include <OptDlg.h>

List of all members.


Detailed Description

The Edit | Options dialog box: m_mainSizer window class.

The option's dialog box is made of:

When the user clicks on a item in the tree list, the corresponding mgOptBasePanel- derived class window containing all applicable options, is displayed on the right side. The changes in any optionwxT('s value are made by the specialized option')s panel and not by this class

To use this class is very simple. In the Edit | Options menu event handler write something similar to this:

   mgOptDlg* opt( frame, -1, 0 );
   opt->ShowModal();

There is no need to test if the user selects OK or Cancel because it is mgOptDlg's responsability to store the changes permanently and to redraw the UI in case option's changes affect the UI appearance. For more info read How does the Options dialog box work.

Author:
L. Cattani
Date:
8-11-2003

Definition at line 147 of file OptDlg.h.

Public Types

enum  mgOptChangedType {
  OptChanged_None = 0, OptChanged_App = 1, OptChanged_MainWnd = 2,
  OptChanged_ParamWnd = 4, OptChanged_UnknonwWnd = 8, OptChanged_ConstWnd = 16
}
 The type of changes made by the user. More...

Public Member Functions

 mgOptDlg (wxWindow *parent, wxWindowID id, wxConfig *config=0)
 Constructor.
virtual ~mgOptDlg ()
 Destructor - It does nothing.
void CreateLayout (wxWindow *parent)
 Creates the three child windows and the initial layout.
mgOptBasePanelCreatePanel (mgOptTreeCtrlItemData *itemData, const wxString &itemLabel)
 Creates the option's panel identified by its ID.
void DisplayPanel (wxTreeItemId id)
 Display the option's panel related to the selected item.
void CommitChanges ()
 Commits the changes made by the user in the option's values.
void SetClientEvtHandler (wxEvtHandler *p)
 Sets the event handler which will receive the notification events.

Protected Member Functions

void OnOkButton (wxCommandEvent &ev)
 The event handler for the OK button.
void OnCancelButton (wxCommandEvent &ev)
 The event handler for the Cancel button.
void OnApplyButton (wxCommandEvent &ev)
 The event handler for the Apply button.
void OnItemSelected (wxTreeEvent &ev)
 The event handler for a selection in the treelist control.

Protected Attributes

wxConfig * m_config
 The configuration object in which changes are stored (not used).
mgOptionsBtnPanelm_buttonWnd
 The OK, Cancel, Apply button's panel.
mgOptionsTreeCtrlm_treeWnd
 The treelist control panel.
wxPanel * m_actualPanel
 The actually displayed option's panel.
wxEvtHandler * m_pClientEvtHandler
 The event handler which receives notification events.
wxBoxSizer * m_mainSizer
 The main sizer of the entire dialog box.
wxBoxSizer * m_optionSizer
 The sizer which contains the current active panel.


Member Enumeration Documentation

enum mgOptDlg::mgOptChangedType
 

The type of changes made by the user.

This enum is used to let the application know what type of changes the user made in the options panel.

Changes may affect the UI (for example a font) or the application or the math engine of MathStudio. Instead of redrawing and re-initializing all the application when the user makes a change, each optionwxT('s panel')s CommitChanges function returns a mgOptChangedType that is OR'ed with all other return values.

The main CommitChanges function in this object sets up a custom event and stores the mgOptChangedType value in a data member of the event class so that the custom event handler - located in the CMathApp object - only resfresh those aspects of the application that should be refreshed.

Enumeration values:
OptChanged_None  no changes
OptChanged_App  application
OptChanged_MainWnd  main window
OptChanged_ParamWnd  parameters window
OptChanged_UnknonwWnd  unknows window
OptChanged_ConstWnd  constants window

Definition at line 167 of file OptDlg.h.


Constructor & Destructor Documentation

mgOptDlg::mgOptDlg wxWindow *  parent,
wxWindowID  id,
wxConfig *  config = 0
 

Constructor.

Constructs the Options dialog box. The function simply creates the 2 panels: the button panel and the treelist panel and the constraints objects used to laying out the three panels. Option's panel are not created at dialog startup but on the fly when the user selectes one item in the tree list.

For example, if the user selects the Key-bindings item in the tree list then the mgOptKeyBindingsPanel class is istantiated and displayed.

Parameters:
parent the parent window (usually the m_mainSizer frame)
id the window identifier (should be -1)
config the configuration object from which the options settings are read from and stored to (not used yet, should be NULL)
See also:
CreateLayout

Definition at line 75 of file OptDlg.cpp.


Member Function Documentation

void mgOptDlg::CommitChanges  ) 
 

Commits the changes made by the user in the option's values.

This function iterates through all itemData structure of the treelist control and obtains the pointer of the mgOptBasePanel -derived class for every option item.

The function calls the mgOptBasePanel::CommitChange function of all option's panels which are responsible of doing the actual work.

Definition at line 317 of file OptDlg.cpp.

References mgOptBasePanel::CommitChanges(), m_config, mgOptTreeCtrlItemData::m_panel, m_pClientEvtHandler, and m_treeWnd.

Referenced by OnApplyButton(), and OnOkButton().

void mgOptDlg::CreateLayout wxWindow *  parent  ) 
 

Creates the three child windows and the initial layout.

This function creates the three wxLayoutConstraints objects used to laying out the three child windows: a treelist control and the two panels. The layout constraints for the treelist and the button panel are bounded to their respective windows in this function. If OPTIONSDLG_USE_LAYOUTCONSTRAINTS is not defined, then this function uses sizers to accomplish its task. This behaviour should be the preffered one: wxLayoutConstraints are deprecated in the new versions of wxWin...

The layout for the option's panel is not set for the panel because there is no option's panel yet: they are created on request. The layout for the option's panel is stored in the m_optionLayout data member and a copy of it is made for every created option's panel in the CreatePanel function.

Parameters:
parent the parent window as specified in the ctor
See also:
CreatePanel #m_optionLayout

Definition at line 109 of file OptDlg.cpp.

References m_buttonWnd, m_mainSizer, m_optionSizer, and m_treeWnd.

mgOptBasePanel * mgOptDlg::CreatePanel mgOptTreeCtrlItemData itemData,
const wxString &  itemLabel
 

Creates the option's panel identified by its ID.

The panel is created and constrained with a newly created copy of the m_optionLayout object.

The function uses a switch statement to create the correct mgOptionsBanePanel -derived class that handles the options for the selected item in the treelist control.

Returns the pointer of the created panel window or NULL if the panel could not be created.

Parameters:
itemData the wxTreeCtrlItemData -derived class associated with the selected item in the treelist
itemLabel the label of the selected item in the trelist control

Definition at line 179 of file OptDlg.cpp.

References mgOptBasePanel::Setup().

Referenced by DisplayPanel().

void mgOptDlg::DisplayPanel wxTreeItemId  id  ) 
 

Display the option's panel related to the selected item.

The function hides the actually displayed option's panel and shows the panel associated in the selected item in the treelist control.

If the relevant panel class was not yet created, the CreatePanel function is called.

Parameters:
itemId the identifier of the selected item in the treelist control (must be valid otherwise an ASSERT failure occurs).

Definition at line 247 of file OptDlg.cpp.

References CreatePanel(), m_actualPanel, mgOptTreeCtrlItemData::m_className, m_mainSizer, m_optionSizer, mgOptTreeCtrlItemData::m_panel, and m_treeWnd.

Referenced by OnItemSelected().

void mgOptDlg::OnApplyButton wxCommandEvent &  ev  )  [protected]
 

The event handler for the Apply button.

Calls CommitChanges.

Definition at line 409 of file OptDlg.cpp.

References CommitChanges().

void mgOptDlg::OnCancelButton wxCommandEvent &  ev  )  [protected]
 

The event handler for the Cancel button.

Calls EndModal( wxID_CANCEL )

Definition at line 404 of file OptDlg.cpp.

void mgOptDlg::OnItemSelected wxTreeEvent &  ev  )  [protected]
 

The event handler for a selection in the treelist control.

The function obtains the itemID of the selected item in the treelist control and calls the DisplayItem function

Definition at line 414 of file OptDlg.cpp.

References DisplayPanel().

void mgOptDlg::SetClientEvtHandler wxEvtHandler *  p  )  [inline]
 

Sets the event handler which will receive the notification events.

By default, the client event handler is set by constructor as the parent window. Use NULL to disable event notification.

Definition at line 274 of file OptDlg.h.


The documentation for this class was generated from the following files:

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

[ Top ]