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 
63  WIDGET_HOTKEY_CLIENT_DATA* getExpectedHkClientData( wxTreeListItem aItem );
64 
69  void UpdateFromClientData();
70 
78  void updateShownItems( const wxString& aFilterStr );
79 
89  void changeHotkey( HOTKEY& aHotkey, long aKey );
90 
91 protected:
92 
97  void EditItem( wxTreeListItem aItem );
98 
103  void ResetItem( wxTreeListItem aItem, int aResetId );
104 
109  void OnActivated( wxTreeListEvent& aEvent );
110 
115  void OnContextMenu( wxTreeListEvent& aEvent );
116 
121  void OnMenu( wxCommandEvent& aEvent );
122 
127  void OnSize( wxSizeEvent& aEvent );
128 
144  bool ResolveKeyConflicts( TOOL_ACTION* aAction, long aKey );
145 
146 public:
155  WIDGET_HOTKEY_LIST( wxWindow* aParent, HOTKEY_STORE& aHotkeyStore, bool aReadOnly );
156 
164  void ApplyFilterString( const wxString& aFilterStr );
165 
171  void ResetAllHotkeys( bool aResetToDefault );
172 
178  bool TransferDataToControl();
179 
186 
191  static long MapKeypressToKeycode( const wxKeyEvent& aEvent );
192 };
193 
194 #endif // __widget_hotkey_list__
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.
void changeHotkey(HOTKEY &aHotkey, long aKey)
Attempt to change the given hotkey to the given key code.
Modified wxTreeListCtrl designed for use with two columns, with better column resizing.
A class that contains a set of hotkeys, arranged into "sections" and provides some book-keeping funct...
Definition: hotkey_store.h:61
void OnMenu(wxCommandEvent &aEvent)
Method OnMenu Handle activation of a context menu item.
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't found.
HOTKEY_STORE & m_hk_store
void UpdateFromClientData()
Method UpdateFromClientData Refresh the visible text on the widget from the rows' client data objects...
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.
bool ResolveKeyConflicts(TOOL_ACTION *aAction, long aKey)
Method ResolveKeyConflicts Check if we can set a hotkey, and prompt the user if there is a conflict b...
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.
void ResetItem(wxTreeListItem aItem, int aResetId)
Method ResetItem Reset the item to either the default, the value when the dialog was opened,...
Class TOOL_ACTION.
Definition: tool_action.h:46
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...
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.