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

mgOptKeyBindingsPanel Class Reference

#include <OptKeyBindings.h>

Inheritance diagram for mgOptKeyBindingsPanel:

mgOptBasePanel List of all members.

Detailed Description

This panel wraps the wxKeyConfigPanel class which is used to allow the user to modify ANY shortcut key used in the menu system of the application which is running.

To allow the presence of the menu-shortcuts in this panel, the application using MathGUI must use wxCustomMenu instead of wxMenu when creating the menu bar:

        // get a pointer to the global (static) key binder
      wxKeyProfile *main = mgOptKeyBindingsPanel::GetBinder();
   
        // then, all your menus can be created, maybe using also
        // the mgMathMenu class...
          wxCustomMenu *file = new wxCustomMenu();
        file->Append(id, wxT("menu item name"), "menu help string");
        mgMathMenu *p = new mgMathMenu(wnd, box, this, &wxGetApp());
        p->AppendFileCommands(file);
   
        // and finally, the menu must be appended to the wxKeyProfile
        // (instead of wxMenuBar).
      main->Append(file, "&File");  // VERY IMPORTANT: this call must be
                                        // done AFTER all menu items have been
                                        // appended to 'file'
   
        // last, we ask our wxKeyProfile to create the menu bar for this frame...
      main->CreateMenuBar(this);

Definition at line 93 of file OptKeyBindings.h.

Public Member Functions

virtual bool Show (bool show=TRUE)
 Shows this panel.

Static Public Member Functions

static void Setup ()
 Creates the wxKeyProfile.
static void Cleanup ()
 Deletes the wxKeyProfile associated with this panel.
static void SetBinder (wxKeyProfile *p)
 Replaces the current global key binder with the given one.
static wxKeyProfile * GetBinder ()
 Returns the STATIC instance of the wxKeyProfile associated to this panel.
static void ImportMenuBarCmd (wxMenuBar *p)

Static Public Attributes

static wxMenuBar * m_pMenuBar = NULL

Protected Member Functions

virtual mgOptDlg::mgOptChangedType CommitChanges (wxConfig *config)
 Commits the changes made by the user.
virtual void Setup (const wxString &itemLabel)
 The alter ego of the constructor.

Protected Attributes

wxKeyConfigPanel * m_pKeyConfig
 The panel which modifies key bindings.
wxFrame * m_pFrame
 The frame whose menu bar is handled by this panel.

Static Protected Attributes

static wxKeyProfile * m_pBinder = NULL
 The key binder handler.


Member Function Documentation

mgOptDlg::mgOptChangedType mgOptKeyBindingsPanel::CommitChanges wxConfig *  config  )  [protected, virtual]
 

Commits the changes made by the user.

The virtual function is called with a pointer to a wxConfig object by the mgOptDlg::CommitChanges function when the user clicks the OK or Apply button.

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.

See also:
mgOptDlg::CommitChanges mgOptDlg::mgOptChangedType

Implements mgOptBasePanel.

Definition at line 94 of file OptKeyBindings.cpp.

References m_pKeyConfig.

static wxKeyProfile* mgOptKeyBindingsPanel::GetBinder  )  [inline, static]
 

Returns the STATIC instance of the wxKeyProfile associated to this panel.

The user of MathGUI should use it to append menu items; see the class description of mgOptKeyBindingsPanel for more info.

Definition at line 141 of file OptKeyBindings.h.

References m_pBinder.

static void mgOptKeyBindingsPanel::SetBinder wxKeyProfile *  p  )  [inline, static]
 

Replaces the current global key binder with the given one.

This function can be used to force mgOptKeyBindingsPanel to use a wxKeyProfile-derived class instead of wxKeyProfile.

Definition at line 133 of file OptKeyBindings.h.

References m_pBinder, and mgSAFE_DELETE.

Referenced by Setup().

static void mgOptKeyBindingsPanel::Setup  )  [inline, static]
 

Creates the wxKeyProfile.

Use the Cleanup() function to delete it when it's no longer necessary; this is an important step to avoid huge memory leaks.

Definition at line 121 of file OptKeyBindings.h.

References SetBinder().

void mgOptKeyBindingsPanel::Setup const wxString &  itemLabel  )  [protected, virtual]
 

The alter ego of the constructor.

This function is the real ctor of the class. It is called from mgOptDlg::CreatePanel function just after the dynamic istantiation of the class and after calling wxPanel::Create.

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 itemLabel string contains the label of the treelist's item associated with this option's panel.

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.

Implements mgOptBasePanel.

Definition at line 71 of file OptKeyBindings.cpp.

References m_pBinder, and m_pKeyConfig.


Member Data Documentation

wxKeyProfile * mgOptKeyBindingsPanel::m_pBinder = NULL [static, protected]
 

The key binder handler.

Use the Setup/SetBinder function to create/set it and don't forget to use the Cleanup function to delete it !!!

Definition at line 56 of file OptKeyBindings.cpp.

Referenced by Cleanup(), GetBinder(), SetBinder(), and Setup().


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 ]