KiCad PCB EDA Suite
widget_hotkey_list.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2016 Chris Pavlina <pavlina.chris@gmail.com>
5  * Copyright (C) 2016-2017 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
29 #ifndef __widget_hotkey_list__
30 #define __widget_hotkey_list__
31 
32 #include <utility>
33 #include <vector>
34 
35 #include <wx/treelist.h>
37 
38 #include <hotkeys_basic.h>
39 #include <hotkey_store.h>
40 
41 
43 
45 {
47  bool m_readOnly;
48 
49  wxTreeListItem m_context_menu_item;
50 
56  WIDGET_HOTKEY_CLIENT_DATA* GetHKClientData( wxTreeListItem aItem );
57 
64 
70  WIDGET_HOTKEY_CLIENT_DATA* getExpectedHkClientData( wxTreeListItem aItem );
71 
76  void UpdateFromClientData();
77 
85  void updateShownItems( const wxString& aFilterStr );
86 
96  void changeHotkey( CHANGED_HOTKEY& aHotkey, long aKey );
97 
98 protected:
99 
104  void EditItem( wxTreeListItem aItem );
105 
110  void ResetItem( wxTreeListItem aItem );
111 
116  void ResetItemToDefault( wxTreeListItem aItem );
117 
122  void OnActivated( wxTreeListEvent& aEvent );
123 
128  void OnContextMenu( wxTreeListEvent& aEvent );
129 
134  void OnMenu( wxCommandEvent& aEvent );
135 
140  void OnSize( wxSizeEvent& aEvent );
141 
157  bool ResolveKeyConflicts( long aKey, const wxString& aSectionTag );
158 
159 public:
168  WIDGET_HOTKEY_LIST( wxWindow* aParent, HOTKEY_STORE& aHotkeyStore, bool aReadOnly );
169 
177  void ApplyFilterString( const wxString& aFilterStr );
178 
184  void ResetAllHotkeys( bool aResetToDefault );
185 
191  bool TransferDataToControl();
192 
199 
204  static long MapKeypressToKeycode( const wxKeyEvent& aEvent );
205 };
206 
207 #endif // __widget_hotkey_list__
void ResetItemToDefault(wxTreeListItem aItem)
Method ResetItemToDefault Reset the item to the default value.
void OnActivated(wxTreeListEvent &aEvent)
Method OnActivated Handle activation of a row.
static long MapKeypressToKeycode(const wxKeyEvent &aEvent)
Static method MapKeypressToKeycode Map a keypress event to the correct key code for use as a hotkey...
Modified wxTreeListCtrl designed for use with two columns, with better column resizing.
Class that manages a hotkey that can be changed, reset to its old value, a default or saved...
Definition: hotkey_store.h:39
A class that contains a set of hotkeys, arranged into "sections" and provides some book-keeping funct...
Definition: hotkey_store.h:123
void OnMenu(wxCommandEvent &aEvent)
Method OnMenu Handle activation of a context menu item.
void changeHotkey(CHANGED_HOTKEY &aHotkey, long aKey)
Attempt to change the given hotkey to the given key code.
bool TransferDataToControl()
Method TransferDataToControl Load the hotkey data from the store into the control.
void OnSize(wxSizeEvent &aEvent)
Function OnSize Handle resizing of the control.
WIDGET_HOTKEY_CLIENT_DATA * getExpectedHkClientData(wxTreeListItem aItem)
Get the WIDGET_HOTKEY_CLIENT_DATA form an item and assert if it isn&#39;t found.
HOTKEY_STORE & m_hk_store
void UpdateFromClientData()
Method UpdateFromClientData Refresh the visible text on the widget from the rows&#39; client data objects...
WIDGET_HOTKEY_CLIENT_DATA * GetSelHKClientData()
Method GetSelHKClientData Return the WIDGET_HOTKEY_CLIENT_DATA for the item being edited...
void updateShownItems(const wxString &aFilterStr)
Method updateShownItems.
wxTreeListItem m_context_menu_item
Class WIDGET_HOTKEY_CLIENT_DATA Stores the hotkey change data associated with each row...
void ApplyFilterString(const wxString &aFilterStr)
Method ApplyFilterString Apply a filter string to the hotkey list, selecting which hotkeys to show...
WIDGET_HOTKEY_LIST(wxWindow *aParent, HOTKEY_STORE &aHotkeyStore, bool aReadOnly)
Constructor WIDGET_HOTKEY_LIST Create a WIDGET_HOTKEY_LIST.
WIDGET_HOTKEY_CLIENT_DATA * GetHKClientData(wxTreeListItem aItem)
Method GetHKClientData Return the WIDGET_HOTKEY_CLIENT_DATA for the given item, or NULL if the item i...
bool ResolveKeyConflicts(long aKey, const wxString &aSectionTag)
Method ResolveKeyConflicts Check if we can set a hotkey, and prompt the user if there is a conflict b...
void ResetItem(wxTreeListItem aItem)
Method ResetItem Reset the item to the original from the dialog was created.
Some functions to handle hotkeys in KiCad.
void EditItem(wxTreeListItem aItem)
Method EditItem Prompt the user for a new hotkey given a list item.
void ResetAllHotkeys(bool aResetToDefault)
Set hotkeys in the control to default or original values.
void OnContextMenu(wxTreeListEvent &aEvent)
Method OnContextMenu Handle right-click on a row.
bool TransferDataFromControl()
Method TransferDataFromControl Save the hotkey data from the control.