wxKeyConfigPanel Class Reference

A powerful keybinding editing panel. More...

#include <keybinder.h>

Collaboration diagram for wxKeyConfigPanel:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 wxKeyConfigPanel (wxWindow *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxKEYBINDER_DEFAULT_STYLE, const wxString &name=wxT("wxKeyConfigPanel"))
 Constructs this panel and links it with the given key binder.
bool Create (wxWindow *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxKEYBINDER_DEFAULT_STYLE, const wxString &name=wxT("wxKeyConfigPanel"))
virtual ~wxKeyConfigPanel ()
virtual void ImportMenuBarCmd (wxMenuBar *menuitems, const wxString &rootname=wxT("Menu bar"))
 Adds to the tree of user-editable commands, the menuitems contained in the given menubar.
virtual void ImportKeyProfileCmd (const wxKeyProfile &toimport, const wxString &rootname=wxT("Commands"))
 Adds to the tree of user-editable commands, the raw list of the commmands contained in the n-th key profile.
virtual void AddProfile (const wxKeyProfile &p)
 Adds a new keyprofile to the keyprofile combo box.
virtual void AddProfiles (const wxKeyProfileArray &arr)
 Adds all the profiles stored in the given array to the keyprofile combo box copying them into the panel for user modifications.
virtual void SetSelProfile (int n)
 Forces the panel to select the n-th profile in the keyprofile combo box.
wxKeyProfileGetProfile (size_t n) const
 Returns the n-th key profile of the profile combo box.
wxKeyProfileGetSelProfile () const
 Returns the currently selected key profile using GetSelProfileIdx().
int GetSelProfileIdx () const
 Returns the index of the currently selected key profile.
wxKeyProfileArray GetProfiles () const
 Returns an array containing the pointers to the keyprofiles edited by this dialog.
virtual void ApplyChanges ()
 Copies the internal key binder used to allow a sort of "undo" feature into the original binder set through the SetBinder function.
void EnableKeyProfiles (bool bEnable=TRUE)
 Enables the key profiles combo box and thus you should check the keyprofiles.
void DisableKeyProfiles ()
 Disables the key profiles combo box.

Protected Member Functions

void OnIdle (wxIdleEvent &event)
 Updates the wxKeyMonitorTextCtrl control...
void OnTreeCommandSelected (wxTreeEvent &event)
void OnListCommandSelected (wxCommandEvent &event)
void OnBindingSelected (wxCommandEvent &event)
void OnProfileSelected (wxCommandEvent &event)
void OnCategorySelected (wxCommandEvent &event)
void OnProfileEditing (wxCommandEvent &event)
void OnApplyChanges (wxCommandEvent &event)
void OnAssignKey (wxCommandEvent &event)
void OnRemoveKey (wxCommandEvent &event)
void OnRemoveAllKey (wxCommandEvent &event)
void OnAddProfile (wxCommandEvent &event)
void OnRemoveProfile (wxCommandEvent &event)
void OnKeyPressed (wxCommandEvent &event)
 Handles the notifications received from the wxKeyMonitorTextCtrl.
virtual void BuildCtrls ()
virtual wxSizer * BuildColumn1 ()
virtual wxSizer * BuildColumn2 ()
virtual wxSizer * BuildMain (wxSizer *, wxSizer *, bool)
virtual void UpdateButtons ()
virtual void UpdateDesc ()
virtual void FillInBindings ()
virtual void Reset ()
virtual void AddRootIfMissing (const wxString &rootname)
wxTreeItemId GetSelCmdId () const
 Returns the tree item ID of the currently selected command.
wxControl * GetMainCtrl () const
 Returns the control with the list of the customizable commands.
bool IsUsingTreeCtrl () const
 Returns TRUE if the m_pCommandsTree control is being used.
bool IsSelectedValidCmd () const
 Returns TRUE if the currently selected command is valid.
wxString GetSelCmdStr () const
 Returns the name of the currently selected command.
wxCmdGetSelCmd () const
 Returns the selected command.
virtual void ShowSizer (wxSizer *toshow, bool show)
 Hides/Shows the given sizer detaching it from the main sizer of this window or prepending it to the main sizer.

Protected Attributes

bool m_bEnableKeyProfiles
 If TRUE, a keyprofiles combobox will be shown to allow the user to choose the keyprofile to modify.
wxCmdm_pCurrCmd
 The currently selected command.
wxKeyProfile m_kBinder
 The temporary keybinder used while interactively editing shortcuts to allow to eventually discard the changes.
int m_nCurrentProf
 The index of the currently selected profile.
bool m_bProfileHasBeenModified
 TRUE if the current profile has been modified by the user.
wxKeyMonitorTextCtrlm_pKeyField
 The special text control used to intercept keypresses.
wxButton * m_pAssignBtn
wxButton * m_pRemoveBtn
wxButton * m_pRemoveAllBtn
wxTreeCtrl * m_pCommandsTree
wxComboBox * m_pCategories
wxListBox * m_pCommandsList
wxListBox * m_pBindings
wxComboBox * m_pKeyProfiles
wxSizer * m_pKeyProfilesSizer
wxStaticText * m_pDescLabel
wxStaticText * m_pCurrCmdField


Detailed Description

A powerful keybinding editing panel.

This is a flexible panel since it can be configured through the "build flags" and thus can be built in various different ways and because it is conceived to be eventually used as a base class of another panel which can modify its behaviour just overloading one of its various functions. The panel contains 4 main controls:

If you want to use this panel you must:

1) create it as all other wxPanels.

2) use the AddProfiles() or the AddProfile() functions to init the panel with the original keybindings.

3) call one of the ImportXXXX() functions in order to create the tree control which will be used by the user to edit the key bindings. This is a step different from step #2 because wxKeyProfile does not contain hierarchical informations about the commands; also, you can fill the tree control of the panel with only some of the commands contained in the profiles you added with step #2: that way the user will be able to modify the keybindings only of the commands shown in the tree control which can thus be used as a "command filter". However, if you just want to make user-editable all the commands of a wxKeyProfile (and you don't care about hierarchical disposition), you can just use the ImportKeyProfileCmd function.

4) when the user has finished to edit the key bindings, the ApplyChanges() function is called by wxKeyConfigPanel and the temporary contents of the wxKeyBinder edited by the user are copied in the original wxKeyProfile. You can then retrieve the new array of wxKeyProfile (the user could have added/removed profiles) using GetProfiles(). The last selected profile can be obtained using GetSelProfile().


Constructor & Destructor Documentation

wxKeyConfigPanel::wxKeyConfigPanel ( wxWindow *  parent,
wxWindowID  id = -1,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = wxKEYBINDER_DEFAULT_STYLE,
const wxString &  name = wxT("wxKeyConfigPanel") 
) [inline]

Constructs this panel and links it with the given key binder.

wxKeyConfigPanel::~wxKeyConfigPanel (  )  [virtual]

References m_pKeyProfiles.


Member Function Documentation

void wxKeyConfigPanel::AddProfile ( const wxKeyProfile p  )  [virtual]

Adds a new keyprofile to the keyprofile combo box.

Note:
This function does not select the given keyprofile (except in the case it's the first keyprofile added). To force the selection of a profile, you should use the SetSelProfile() function.

References wxKeyProfile::GetName(), m_pKeyProfiles, and SetSelProfile().

Referenced by OnAddProfile().

void wxKeyConfigPanel::AddProfiles ( const wxKeyProfileArray arr  )  [virtual]

Adds all the profiles stored in the given array to the keyprofile combo box copying them into the panel for user modifications.

Note:
The profile which is marked as selected into the given wxKeyProfileArray is selected (see wxKeyProfileArray::m_nSelected).

References wxKeyProfileArray::GetCount(), wxKeyProfile::GetName(), wxKeyProfileArray::GetSelProfileIdx(), wxKeyProfileArray::Item(), m_pKeyProfiles, and SetSelProfile().

void wxKeyConfigPanel::AddRootIfMissing ( const wxString &  rootname  )  [protected, virtual]

void wxKeyConfigPanel::ApplyChanges (  )  [virtual]

Copies the internal key binder used to allow a sort of "undo" feature into the original binder set through the SetBinder function.

References wxKeyProfile::DeepCopy(), wxKeyProfile::GetName(), GetSelProfile(), GetSelProfileIdx(), m_kBinder, m_pKeyProfiles, and wxKBLogDebug.

Referenced by OnApplyChanges(), and OnProfileSelected().

wxSizer * wxKeyConfigPanel::BuildColumn1 (  )  [protected, virtual]

wxSizer * wxKeyConfigPanel::BuildColumn2 (  )  [protected, virtual]

void wxKeyConfigPanel::BuildCtrls (  )  [protected, virtual]

wxSizer * wxKeyConfigPanel::BuildMain ( wxSizer *  column1,
wxSizer *  column2,
bool  bApplyBtn 
) [protected, virtual]

References m_pDescLabel, and m_pKeyProfilesSizer.

Referenced by Create().

bool wxKeyConfigPanel::Create ( wxWindow *  parent,
wxWindowID  id = -1,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = wxKEYBINDER_DEFAULT_STYLE,
const wxString &  name = wxT("wxKeyConfigPanel") 
)

void wxKeyConfigPanel::DisableKeyProfiles (  )  [inline]

Disables the key profiles combo box.

The profile used will be the first given.

void wxKeyConfigPanel::EnableKeyProfiles ( bool  bEnable = TRUE  ) 

Enables the key profiles combo box and thus you should check the keyprofiles.

Note:
The key profiles are enabled by default.

References m_bEnableKeyProfiles, m_pKeyProfilesSizer, and ShowSizer().

void wxKeyConfigPanel::FillInBindings (  )  [protected, virtual]

wxControl * wxKeyConfigPanel::GetMainCtrl (  )  const [protected]

Returns the control with the list of the customizable commands.

References m_pCommandsList, m_pCommandsTree, and wxKEYBINDER_USE_TREECTRL.

Referenced by Create().

wxKeyProfile* wxKeyConfigPanel::GetProfile ( size_t  n  )  const [inline]

Returns the n-th key profile of the profile combo box.

Referenced by GetProfiles(), OnAddProfile(), and OnProfileSelected().

wxKeyProfileArray wxKeyConfigPanel::GetProfiles (  )  const

Returns an array containing the pointers to the keyprofiles edited by this dialog.

This function is typically used after the ShowModal() function has been called to retrieve the user-edited keyprofiles in case the user chose OK (and not cancel).

Note:
The returned array has a valid profile selected which coincide with the last keyprofile selected in the combobox; i.e. you can use the wxKeyProfileArray::GetSelProfile function to retrieve the profile the user has chosen to select.

References wxKeyProfileArray::Add(), GetProfile(), GetSelProfileIdx(), m_pKeyProfiles, and wxKeyProfileArray::SetSelProfile().

wxCmd * wxKeyConfigPanel::GetSelCmd (  )  const [protected]

wxTreeItemId wxKeyConfigPanel::GetSelCmdId (  )  const [protected]

Returns the tree item ID of the currently selected command.

References m_pCommandsTree.

Referenced by GetSelCmd(), GetSelCmdStr(), and IsSelectedValidCmd().

wxString wxKeyConfigPanel::GetSelCmdStr (  )  const [protected]

Returns the name of the currently selected command.

References GetSelCmdId(), and m_pCommandsTree.

wxKeyProfile* wxKeyConfigPanel::GetSelProfile (  )  const [inline]

Returns the currently selected key profile using GetSelProfileIdx().

This is the profile owned by the profile combo box.

Referenced by ApplyChanges(), OnAddProfile(), and OnProfileSelected().

int wxKeyConfigPanel::GetSelProfileIdx (  )  const [inline]

Returns the index of the currently selected key profile.

The currently selected key profile is the profile which is currently displayed by the keyprofile combobox; thus, this function needs the m_pKeyProfiles combobox created (and initialized) to work.

Note:
This function won't use wxComboBox::GetSelection() because when the label of the key profile has been edited, the function returns always -1... we will use the m_nCurrentProf variable.

Referenced by ApplyChanges(), and GetProfiles().

void wxKeyConfigPanel::ImportKeyProfileCmd ( const wxKeyProfile toimport,
const wxString &  rootname = wxT("Commands") 
) [virtual]

Adds to the tree of user-editable commands, the raw list of the commmands contained in the n-th key profile.

Instead of a tree structure (like the one generated by ImportMenuBarCmd), this function creates a raw list of the commands contained in the key binder since a wxKeyBinder does not contain hierarchical info about the keybindings.

References AddRootIfMissing(), wxKeyBinder::GetArray(), wxCmdArray::GetCount(), wxCmd::GetId(), wxCmd::GetName(), IsUsingTreeCtrl(), wxCmdArray::Item(), m_pCategories, m_pCommandsList, m_pCommandsTree, and Reset().

void wxKeyConfigPanel::ImportMenuBarCmd ( wxMenuBar *  menuitems,
const wxString &  rootname = wxT("Menu bar") 
) [virtual]

Adds to the tree of user-editable commands, the menuitems contained in the given menubar.

If the root of the tree control doesn't exist (because none of the ImportXXXX functions have been called yet), this function creates it with the "rootname" label.

References AddRootIfMissing(), wxMenuComboListWalker::FillComboListCtrl(), wxMenuTreeWalker::FillTreeCtrl(), IsUsingTreeCtrl(), m_pCategories, m_pCommandsTree, OnCategorySelected(), and Reset().

bool wxKeyConfigPanel::IsSelectedValidCmd (  )  const [protected]

Returns TRUE if the currently selected command is valid.

References GetSelCmdId(), IsUsingTreeCtrl(), and m_pCommandsList.

Referenced by UpdateButtons().

bool wxKeyConfigPanel::IsUsingTreeCtrl (  )  const [inline, protected]

Returns TRUE if the m_pCommandsTree control is being used.

Returns FALSE if the m_pCommandsList and m_pCategories are being used.

References wxKEYBINDER_USE_TREECTRL.

Referenced by AddRootIfMissing(), GetSelCmd(), ImportKeyProfileCmd(), ImportMenuBarCmd(), IsSelectedValidCmd(), OnProfileSelected(), and Reset().

void wxKeyConfigPanel::OnAddProfile ( wxCommandEvent &  event  )  [protected]

void wxKeyConfigPanel::OnApplyChanges ( wxCommandEvent &  event  )  [protected]

References ApplyChanges().

void wxKeyConfigPanel::OnAssignKey ( wxCommandEvent &  event  )  [protected]

void wxKeyConfigPanel::OnBindingSelected ( wxCommandEvent &  event  )  [protected]

References UpdateButtons(), and wxKBLogDebug.

void wxKeyConfigPanel::OnCategorySelected ( wxCommandEvent &  event  )  [protected]

void wxKeyConfigPanel::OnIdle ( wxIdleEvent &  event  )  [protected]

Updates the wxKeyMonitorTextCtrl control...

void wxKeyConfigPanel::OnKeyPressed ( wxCommandEvent &  event  )  [protected]

Handles the notifications received from the wxKeyMonitorTextCtrl.

References UpdateButtons().

void wxKeyConfigPanel::OnListCommandSelected ( wxCommandEvent &  event  )  [protected]

void wxKeyConfigPanel::OnProfileEditing ( wxCommandEvent &  event  )  [protected]

void wxKeyConfigPanel::OnProfileSelected ( wxCommandEvent &  event  )  [protected]

void wxKeyConfigPanel::OnRemoveAllKey ( wxCommandEvent &  event  )  [protected]

void wxKeyConfigPanel::OnRemoveKey ( wxCommandEvent &  event  )  [protected]

void wxKeyConfigPanel::OnRemoveProfile ( wxCommandEvent &  event  )  [protected]

void wxKeyConfigPanel::OnTreeCommandSelected ( wxTreeEvent &  event  )  [protected]

void wxKeyConfigPanel::Reset (  )  [protected, virtual]

void wxKeyConfigPanel::SetSelProfile ( int  n  )  [virtual]

Forces the panel to select the n-th profile in the keyprofile combo box.

References m_nCurrentProf, m_pKeyProfiles, and OnProfileSelected().

Referenced by AddProfile(), AddProfiles(), OnAddProfile(), and OnRemoveProfile().

void wxKeyConfigPanel::ShowSizer ( wxSizer *  toshow,
bool  show 
) [protected, virtual]

Hides/Shows the given sizer detaching it from the main sizer of this window or prepending it to the main sizer.

References m_bEnableKeyProfiles.

Referenced by EnableKeyProfiles().

void wxKeyConfigPanel::UpdateButtons (  )  [protected, virtual]

void wxKeyConfigPanel::UpdateDesc (  )  [protected, virtual]


Member Data Documentation

If TRUE, a keyprofiles combobox will be shown to allow the user to choose the keyprofile to modify.

Referenced by BuildCtrls(), EnableKeyProfiles(), and ShowSizer().

TRUE if the current profile has been modified by the user.

This is used to detect changes when the user choose to edit another profile using the m_pKeyProfiles control: if the current profile has been modified, a dialog will ask to the user if he wants to save its changes or not...

Referenced by Create(), OnAssignKey(), OnProfileEditing(), OnProfileSelected(), OnRemoveAllKey(), and OnRemoveKey().

The temporary keybinder used while interactively editing shortcuts to allow to eventually discard the changes.

See m_bProfileHasBeenModified.

Referenced by ApplyChanges(), GetSelCmd(), OnProfileEditing(), OnProfileSelected(), and UpdateButtons().

The index of the currently selected profile.

Referenced by OnProfileEditing(), OnProfileSelected(), OnRemoveProfile(), and SetSelProfile().

wxButton* wxKeyConfigPanel::m_pAssignBtn [protected]

wxListBox* wxKeyConfigPanel::m_pBindings [protected]

wxComboBox* wxKeyConfigPanel::m_pCategories [protected]

wxListBox* wxKeyConfigPanel::m_pCommandsList [protected]

wxTreeCtrl* wxKeyConfigPanel::m_pCommandsTree [protected]

The currently selected command.

Referenced by OnAssignKey(), and UpdateButtons().

wxStaticText* wxKeyConfigPanel::m_pCurrCmdField [protected]

wxStaticText* wxKeyConfigPanel::m_pDescLabel [protected]

The special text control used to intercept keypresses.

Referenced by BuildColumn2(), BuildCtrls(), OnAssignKey(), Reset(), and UpdateButtons().

wxComboBox* wxKeyConfigPanel::m_pKeyProfiles [protected]

wxButton* wxKeyConfigPanel::m_pRemoveAllBtn [protected]

wxButton* wxKeyConfigPanel::m_pRemoveBtn [protected]


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

Generated on Sun Nov 23 00:06:39 2008 for Keybinder by  doxygen 1.5.7.1