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 
45 {
46  wxString m_name;
48 };
49 
50 typedef std::vector<HOTKEY_SECTION> HOTKEY_SECTIONS;
51 typedef std::vector<EDA_HOTKEY> HOTKEY_LIST;
52 
54 
56 {
58  std::vector<HOTKEY_LIST> m_hotkeys;
59  wxTreeListItem m_context_menu_item;
60 
66  WIDGET_HOTKEY_CLIENT_DATA* GetHKClientData( wxTreeListItem aItem );
67 
73  WIDGET_HOTKEY_CLIENT_DATA* GetSelHKClientData();
74 
79  void UpdateFromClientData();
80 
81 protected:
87  void LoadSection( EDA_HOTKEY_CONFIG* aSection );
88 
93  void EditItem( wxTreeListItem aItem );
94 
99  void ResetItem( wxTreeListItem aItem );
100 
105  void ResetItemToDefault( wxTreeListItem aItem );
106 
111  void OnActivated( wxTreeListEvent& aEvent );
112 
117  void OnContextMenu( wxTreeListEvent& aEvent );
118 
123  void OnMenu( wxCommandEvent& aEvent );
124 
129  void OnSize( wxSizeEvent& aEvent );
130 
140  bool CheckKeyConflicts( long aKey, const wxString& aSectionTag,
141  EDA_HOTKEY** aConfKey, EDA_HOTKEY_CONFIG** aConfSect );
142 
158  bool ResolveKeyConflicts( long aKey, const wxString& aSectionTag );
159 
160 public:
170  WIDGET_HOTKEY_LIST( wxWindow* aParent, const HOTKEY_SECTIONS& aSections );
171 
177  static HOTKEY_SECTIONS GenSections( EDA_HOTKEY_CONFIG* aHotkeys );
178 
185  void InstallOnPanel( wxPanel* aPanel );
186 
192  bool TransferDefaultsToControl();
193 
200  bool TransferDataToControl();
201 
207  bool TransferDataFromControl();
208 
213  static long MapKeypressToKeycode( const wxKeyEvent& aEvent );
214 };
215 
216 #endif // __widget_hotkey_list__
Structure EDA_HOTKEY_CONFIG contains the information required to save hot key information to a config...
Definition: hotkeys_basic.h:89
HOTKEY_SECTIONS m_sections
Modified wxTreeListCtrl designed for use with two columns, with better column resizing.
std::vector< HOTKEY_LIST > m_hotkeys
wxTreeListItem m_context_menu_item
Class WIDGET_HOTKEY_CLIENT_DATA Stores the hotkey and section tag associated with each row...
std::vector< HOTKEY_SECTION > HOTKEY_SECTIONS
class EDA_HOTKEY is a class to handle hot key commands.
Definition: hotkeys_basic.h:59
std::vector< EDA_HOTKEY > HOTKEY_LIST
Some functions to handle hotkeys in KiCad.
EDA_HOTKEY_CONFIG * m_section
struct HOTKEY_SECTION Associates a hotkey configuration with a name.