KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <[email protected]>
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
25#ifndef __widget_hotkey_list__
26#define __widget_hotkey_list__
27
28#include <unordered_map>
29#include <utility>
30#include <vector>
31
32#include <wx/treelist.h>
33#include <wx/dataview.h>
34
35#include <hotkeys_basic.h>
36#include <hotkey_store.h>
37
38
40
41class WIDGET_HOTKEY_LIST : public wxTreeListCtrl
42{
43public:
52 WIDGET_HOTKEY_LIST( wxWindow* aParent, HOTKEY_STORE& aHotkeyStore, bool aReadOnly );
53
61 void ApplyFilterString( const wxString& aFilterStr );
62
68 void ResetAllHotkeys( bool aResetToDefault );
69
76
83
88 static long MapKeypressToKeycode( const wxKeyEvent& aEvent );
89
90protected:
95 void editItem( wxTreeListItem aItem, int aEditId );
96
101 void resetItem( wxTreeListItem aItem, int aResetId );
102
107 void onActivated( wxTreeListEvent& aEvent );
108
113 void onContextMenu( wxTreeListEvent& aEvent );
114
119 void onMenu( wxCommandEvent& aEvent );
120
136 bool resolveKeyConflicts( TOOL_ACTION* aAction, long aKey );
137
138private:
143 WIDGET_HOTKEY_CLIENT_DATA* getHKClientData( wxTreeListItem aItem );
144
149 WIDGET_HOTKEY_CLIENT_DATA* getExpectedHkClientData( wxTreeListItem aItem );
150
156
164 void updateShownItems( const wxString& aFilterStr );
165
176 void changeHotkey( HOTKEY& aHotkey, long aKey, bool alternate );
177
181 void updateColumnWidths();
182
183private:
186
187 std::unordered_map<long, wxString> m_reservedHotkeys;
188
189 wxTreeListItem m_context_menu_item;
190};
191
192#endif // __widget_hotkey_list__
A class that contains a set of hotkeys, arranged into "sections" and provides some book-keeping funct...
Definition: hotkey_store.h:66
Represent a single user action.
Definition: tool_action.h:269
Store the hotkey change data associated with each row.
void ResetAllHotkeys(bool aResetToDefault)
Set hotkeys in the control to default or original values.
void onActivated(wxTreeListEvent &aEvent)
Method onActivated Handle activation of a row.
void updateShownItems(const wxString &aFilterStr)
Method updateShownItems.
void changeHotkey(HOTKEY &aHotkey, long aKey, bool alternate)
Attempt to change the given hotkey to the given key code.
void editItem(wxTreeListItem aItem, int aEditId)
Method editItem Prompt the user for a new hotkey given a list item.
bool TransferDataToControl()
Method TransferDataToControl Load the hotkey data from the store into the control.
void onMenu(wxCommandEvent &aEvent)
Method onMenu Handle activation of a context menu item.
wxTreeListItem m_context_menu_item
bool TransferDataFromControl()
Method TransferDataFromControl Save the hotkey data from the control.
void updateColumnWidths()
Recalculates column widths after model has changed.
void ApplyFilterString(const wxString &aFilterStr)
Method ApplyFilterString Apply a filter string to the hotkey list, selecting which hotkeys to show.
void updateFromClientData()
Method updateFromClientData Refresh the visible text on the widget from the rows' client data objects...
void resetItem(wxTreeListItem aItem, int aResetId)
Method resetItem Reset the item to either the default, the value when the dialog was opened,...
WIDGET_HOTKEY_CLIENT_DATA * getExpectedHkClientData(wxTreeListItem aItem)
Get the WIDGET_HOTKEY_CLIENT_DATA form an item and assert if it isn't found.
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 onContextMenu(wxTreeListEvent &aEvent)
Method onContextMenu Handle right-click on 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.
HOTKEY_STORE & m_hk_store
std::unordered_map< long, wxString > m_reservedHotkeys
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...