#include <keybinder.h>
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. | |
wxKeyProfile * | GetProfile (size_t n) const |
Returns the n-th key profile of the profile combo box. | |
wxKeyProfile * | GetSelProfile () 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. | |
wxCmd * | GetSelCmd () 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. | |
wxCmd * | m_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. | |
wxKeyMonitorTextCtrl * | m_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 |
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().
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.
void wxKeyConfigPanel::AddProfile | ( | const wxKeyProfile & | p | ) | [virtual] |
Adds a new keyprofile to the keyprofile combo box.
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.
References wxKeyProfileArray::GetCount(), wxKeyProfile::GetName(), wxKeyProfileArray::GetSelProfileIdx(), wxKeyProfileArray::Item(), m_pKeyProfiles, and SetSelProfile().
void wxKeyConfigPanel::AddRootIfMissing | ( | const wxString & | rootname | ) | [protected, virtual] |
References IsUsingTreeCtrl(), and m_pCommandsTree.
Referenced by ImportKeyProfileCmd(), and ImportMenuBarCmd().
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] |
References m_pCategories, m_pCommandsList, m_pCommandsTree, and wxKEYBINDER_USE_TREECTRL.
Referenced by Create().
wxSizer * wxKeyConfigPanel::BuildColumn2 | ( | ) | [protected, virtual] |
References m_pAssignBtn, m_pBindings, m_pCurrCmdField, m_pKeyField, m_pRemoveAllBtn, and m_pRemoveBtn.
Referenced by Create().
void wxKeyConfigPanel::BuildCtrls | ( | ) | [protected, virtual] |
References m_bEnableKeyProfiles, m_pAssignBtn, m_pBindings, m_pCategories, m_pCommandsList, m_pCommandsTree, m_pCurrCmdField, m_pDescLabel, m_pKeyField, m_pKeyProfiles, m_pKeyProfilesSizer, m_pRemoveAllBtn, m_pRemoveBtn, wxKEYBINDER_ENABLE_PROFILE_EDITING, wxKEYBINDER_SHOW_ADDREMOVE_PROFILE, and wxKEYBINDER_USE_TREECTRL.
Referenced by Create().
wxSizer * wxKeyConfigPanel::BuildMain | ( | wxSizer * | column1, | |
wxSizer * | column2, | |||
bool | bApplyBtn | |||
) | [protected, virtual] |
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.
References m_bEnableKeyProfiles, m_pKeyProfilesSizer, and ShowSizer().
void wxKeyConfigPanel::FillInBindings | ( | ) | [protected, virtual] |
References GetSelCmd(), wxCmd::GetShortcutsList(), and m_pBindings.
Referenced by OnAssignKey(), OnListCommandSelected(), OnRemoveAllKey(), OnRemoveKey(), and OnTreeCommandSelected().
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).
References wxKeyProfileArray::Add(), GetProfile(), GetSelProfileIdx(), m_pKeyProfiles, and wxKeyProfileArray::SetSelProfile().
wxCmd * wxKeyConfigPanel::GetSelCmd | ( | ) | const [protected] |
Returns the selected command.
References wxKeyBinder::GetCmd(), GetSelCmdId(), IsUsingTreeCtrl(), m_kBinder, m_pCommandsList, and m_pCommandsTree.
Referenced by FillInBindings(), OnAssignKey(), OnRemoveAllKey(), OnRemoveKey(), and UpdateDesc().
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] |
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.
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] |
References wxExComboItemData::GetCmdNameArr(), wxExComboItemData::GetID(), m_pCategories, m_pCommandsList, OnListCommandSelected(), and wxKBLogDebug.
Referenced by ImportMenuBarCmd().
void wxKeyConfigPanel::OnIdle | ( | wxIdleEvent & | event | ) | [protected] |
Updates the wxKeyMonitorTextCtrl control...
void wxKeyConfigPanel::OnKeyPressed | ( | wxCommandEvent & | event | ) | [protected] |
void wxKeyConfigPanel::OnListCommandSelected | ( | wxCommandEvent & | event | ) | [protected] |
References FillInBindings(), UpdateButtons(), UpdateDesc(), and wxKBLogDebug.
Referenced by OnCategorySelected(), and OnProfileSelected().
void wxKeyConfigPanel::OnProfileEditing | ( | wxCommandEvent & | event | ) | [protected] |
void wxKeyConfigPanel::OnProfileSelected | ( | wxCommandEvent & | event | ) | [protected] |
void wxKeyConfigPanel::OnRemoveAllKey | ( | wxCommandEvent & | event | ) | [protected] |
References FillInBindings(), GetSelCmd(), m_bProfileHasBeenModified, wxCmd::RemoveAllShortcuts(), and UpdateButtons().
void wxKeyConfigPanel::OnRemoveKey | ( | wxCommandEvent & | event | ) | [protected] |
References FillInBindings(), GetSelCmd(), m_bProfileHasBeenModified, m_pBindings, wxCmd::RemoveShortcut(), and UpdateButtons().
void wxKeyConfigPanel::OnRemoveProfile | ( | wxCommandEvent & | event | ) | [protected] |
References m_nCurrentProf, m_pKeyProfiles, and SetSelProfile().
void wxKeyConfigPanel::OnTreeCommandSelected | ( | wxTreeEvent & | event | ) | [protected] |
References FillInBindings(), UpdateButtons(), UpdateDesc(), and wxKBLogDebug.
Referenced by OnProfileSelected().
void wxKeyConfigPanel::Reset | ( | ) | [protected, virtual] |
References IsUsingTreeCtrl(), m_pBindings, m_pCategories, m_pCommandsList, m_pCommandsTree, m_pDescLabel, and m_pKeyField.
Referenced by ImportKeyProfileCmd(), and ImportMenuBarCmd().
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] |
References wxKeyBinder::GetCmdBindTo(), wxCmd::GetName(), IsSelectedValidCmd(), wxKeyMonitorTextCtrl::IsValidKeyComb(), m_kBinder, m_pAssignBtn, m_pBindings, m_pCurrCmd, m_pCurrCmdField, m_pKeyField, m_pRemoveAllBtn, m_pRemoveBtn, and wxKBLogDebug.
Referenced by Create(), OnBindingSelected(), OnKeyPressed(), OnListCommandSelected(), OnRemoveAllKey(), OnRemoveKey(), and OnTreeCommandSelected().
void wxKeyConfigPanel::UpdateDesc | ( | ) | [protected, virtual] |
References wxCmd::GetDescription(), GetSelCmd(), m_pDescLabel, and wxKBLogDebug.
Referenced by OnListCommandSelected(), and OnTreeCommandSelected().
bool wxKeyConfigPanel::m_bEnableKeyProfiles [protected] |
If TRUE, a keyprofiles combobox will be shown to allow the user to choose the keyprofile to modify.
Referenced by BuildCtrls(), EnableKeyProfiles(), and ShowSizer().
bool wxKeyConfigPanel::m_bProfileHasBeenModified [protected] |
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().
wxKeyProfile wxKeyConfigPanel::m_kBinder [protected] |
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().
int wxKeyConfigPanel::m_nCurrentProf [protected] |
The index of the currently selected profile.
Referenced by OnProfileEditing(), OnProfileSelected(), OnRemoveProfile(), and SetSelProfile().
wxButton* wxKeyConfigPanel::m_pAssignBtn [protected] |
Referenced by BuildColumn2(), BuildCtrls(), and UpdateButtons().
wxListBox* wxKeyConfigPanel::m_pBindings [protected] |
Referenced by BuildColumn2(), BuildCtrls(), FillInBindings(), OnRemoveKey(), Reset(), and UpdateButtons().
wxComboBox* wxKeyConfigPanel::m_pCategories [protected] |
Referenced by BuildColumn1(), BuildCtrls(), ImportKeyProfileCmd(), ImportMenuBarCmd(), OnCategorySelected(), and Reset().
wxListBox* wxKeyConfigPanel::m_pCommandsList [protected] |
Referenced by BuildColumn1(), BuildCtrls(), GetMainCtrl(), GetSelCmd(), ImportKeyProfileCmd(), IsSelectedValidCmd(), OnCategorySelected(), and Reset().
wxTreeCtrl* wxKeyConfigPanel::m_pCommandsTree [protected] |
Referenced by AddRootIfMissing(), BuildColumn1(), BuildCtrls(), GetMainCtrl(), GetSelCmd(), GetSelCmdId(), GetSelCmdStr(), ImportKeyProfileCmd(), ImportMenuBarCmd(), and Reset().
wxCmd* wxKeyConfigPanel::m_pCurrCmd [protected] |
wxStaticText* wxKeyConfigPanel::m_pCurrCmdField [protected] |
Referenced by BuildColumn2(), BuildCtrls(), and UpdateButtons().
wxStaticText* wxKeyConfigPanel::m_pDescLabel [protected] |
Referenced by BuildCtrls(), BuildMain(), Reset(), and UpdateDesc().
wxKeyMonitorTextCtrl* wxKeyConfigPanel::m_pKeyField [protected] |
The special text control used to intercept keypresses.
Referenced by BuildColumn2(), BuildCtrls(), OnAssignKey(), Reset(), and UpdateButtons().
wxComboBox* wxKeyConfigPanel::m_pKeyProfiles [protected] |
wxSizer* wxKeyConfigPanel::m_pKeyProfilesSizer [protected] |
Referenced by BuildCtrls(), BuildMain(), and EnableKeyProfiles().
wxButton* wxKeyConfigPanel::m_pRemoveAllBtn [protected] |
Referenced by BuildColumn2(), BuildCtrls(), and UpdateButtons().
wxButton* wxKeyConfigPanel::m_pRemoveBtn [protected] |
Referenced by BuildColumn2(), BuildCtrls(), and UpdateButtons().