KiCad PCB EDA Suite
PANEL_HOTKEYS_EDITOR Class Reference

#include <panel_hotkeys_editor.h>

Inheritance diagram for PANEL_HOTKEYS_EDITOR:

Public Member Functions

 PANEL_HOTKEYS_EDITOR (EDA_BASE_FRAME *aFrame, wxWindow *aWindow, bool aReadOnly, EDA_HOTKEY_CONFIG *aHotkeys, EDA_HOTKEY_CONFIG *aShowHotkeys, const wxString &aNickname)
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 

Protected Attributes

EDA_BASE_FRAMEm_frame
 
bool m_readOnly
 
struct EDA_HOTKEY_CONFIGm_hotkeys
 
wxString m_nickname
 
HOTKEY_STORE m_hotkeyStore
 
WIDGET_HOTKEY_LISTm_hotkeyListCtrl
 

Private Member Functions

void installButtons (wxSizer *aSizer)
 Install the button panel (global reset/default, import/export) More...
 
void OnFilterSearch (wxCommandEvent &aEvent)
 Function OnFilterSearch Handle a change in the hoteky filter text. More...
 

Detailed Description

Definition at line 39 of file panel_hotkeys_editor.h.

Constructor & Destructor Documentation

PANEL_HOTKEYS_EDITOR::PANEL_HOTKEYS_EDITOR ( EDA_BASE_FRAME aFrame,
wxWindow *  aWindow,
bool  aReadOnly,
EDA_HOTKEY_CONFIG aHotkeys,
EDA_HOTKEY_CONFIG aShowHotkeys,
const wxString &  aNickname 
)

Definition at line 60 of file panel_hotkeys_editor.cpp.

References CreateTextFilterBox(), KIUI::GetStdMargin(), installButtons(), m_hotkeyListCtrl, m_hotkeyStore, m_readOnly, and OnFilterSearch().

64  :
65  wxPanel( aWindow, wxID_ANY, wxDefaultPosition, default_dialog_size ),
66  m_frame( aFrame ),
67  m_readOnly( aReadOnly ),
68  m_hotkeys( aHotkeys ),
69  m_nickname( aNickname ),
70  m_hotkeyStore( aShowHotkeys )
71 {
72  const auto margin = KIUI::GetStdMargin();
73  auto mainSizer = new wxBoxSizer( wxVERTICAL );
74 
75  // Sub-sizer for setting a wider side margin
76  // TODO: Can this be set by the parent widget- doesn't seem to be
77  // this panel's responsibility?
78  const int side_margins = 10; // seems to be hardcoded in wxFB
79  auto bMargins = new wxBoxSizer( wxVERTICAL );
80 
81  auto filterSearch = CreateTextFilterBox( this, _( "Type filter text" ) );
82  bMargins->Add( filterSearch, 0, wxBOTTOM | wxEXPAND | wxTOP, margin );
83 
85  bMargins->Add( m_hotkeyListCtrl, 1, wxALL | wxEXPAND, margin );
86 
87  if( !m_readOnly )
88  installButtons( bMargins );
89 
90  mainSizer->Add( bMargins, 1, wxEXPAND | wxRIGHT | wxLEFT, side_margins );
91 
92  this->SetSizer( mainSizer );
93  this->Layout();
94 
95  // Connect Events
96  filterSearch->Bind( wxEVT_COMMAND_TEXT_UPDATED,
98 }
void OnFilterSearch(wxCommandEvent &aEvent)
Function OnFilterSearch Handle a change in the hoteky filter text.
static wxSearchCtrl * CreateTextFilterBox(wxWindow *aParent, const wxString &aDescriptiveText)
Helper function to add a filter box to a panel, with some sensible defaults for that purpose...
static const wxSize default_dialog_size
int GetStdMargin()
Get the standard margin around a widget in the KiCad UI.
Definition: ui_common.cpp:23
EDA_BASE_FRAME * m_frame
void installButtons(wxSizer *aSizer)
Install the button panel (global reset/default, import/export)
struct EDA_HOTKEY_CONFIG * m_hotkeys
WIDGET_HOTKEY_LIST * m_hotkeyListCtrl

Member Function Documentation

void PANEL_HOTKEYS_EDITOR::installButtons ( wxSizer *  aSizer)
private

Install the button panel (global reset/default, import/export)

Parameters
aSizerthe dialog to install on

Definition at line 101 of file panel_hotkeys_editor.cpp.

References EDA_BASE_FRAME::ExportHotkeyConfigToFile(), KIUI::GetStdMargin(), EDA_BASE_FRAME::ImportHotkeyConfigFromFile(), m_frame, m_hotkeyListCtrl, m_hotkeys, m_nickname, and WIDGET_HOTKEY_LIST::ResetAllHotkeys().

Referenced by PANEL_HOTKEYS_EDITOR().

102 {
103  const BUTTON_ROW_PANEL::BTN_DEF_LIST l_btn_defs = {
104  {
105  wxID_RESET,
106  _( "Reset Hotkeys" ),
107  _( "Undo all changes made so far in this dialog" ),
108  [this]( wxCommandEvent ){
110  }
111  },
112  {
113  wxID_ANY,
114  _( "Set to Defaults" ),
115  _( "Set all hotkeys to the built-in KiCad defaults" ),
116  [this]( wxCommandEvent ){
118  }
119  }
120  };
121 
122  const BUTTON_ROW_PANEL::BTN_DEF_LIST r_btn_defs = {
123  {
124  wxID_ANY,
125  _( "Import..." ),
126  _( "Import hotkey definitions from an external file, replacing the current values" ),
127  [this]( wxCommandEvent ){
129  }
130  },
131  {
132  wxID_ANY,
133  _( "Export..." ),
134  _( "Export these hotkey definitions to an external file" ),
135  [this]( wxCommandEvent ){
137  }
138  },
139  };
140 
141  auto btnPanel = new BUTTON_ROW_PANEL( this, l_btn_defs, r_btn_defs );
142 
143  aSizer->Add( btnPanel, 0, wxEXPAND | wxTOP, KIUI::GetStdMargin() );
144 }
void ExportHotkeyConfigToFile(EDA_HOTKEY_CONFIG *aDescList, const wxString &aDefaultShortname)
Function ExportHotkeyConfigToFile Prompt the user for an old hotkey file to read, and read it...
int GetStdMargin()
Get the standard margin around a widget in the KiCad UI.
Definition: ui_common.cpp:23
EDA_BASE_FRAME * m_frame
A panel that contains buttons, arranged on the left and/or right sides.
struct EDA_HOTKEY_CONFIG * m_hotkeys
std::vector< BTN_DEF > BTN_DEF_LIST
A list of BTN_DEFs, used to group buttons into the left/right groups.
WIDGET_HOTKEY_LIST * m_hotkeyListCtrl
void ImportHotkeyConfigFromFile(EDA_HOTKEY_CONFIG *aDescList, const wxString &aDefaultShortname)
Function ImportHotkeyConfigFromFile Prompt the user for an old hotkey file to read, and read it.
void ResetAllHotkeys(bool aResetToDefault)
Set hotkeys in the control to default or original values.
void PANEL_HOTKEYS_EDITOR::OnFilterSearch ( wxCommandEvent &  aEvent)
private

Function OnFilterSearch Handle a change in the hoteky filter text.

Parameters
aEventthe search event, used to get the search query

Definition at line 165 of file panel_hotkeys_editor.cpp.

References WIDGET_HOTKEY_LIST::ApplyFilterString(), and m_hotkeyListCtrl.

Referenced by PANEL_HOTKEYS_EDITOR().

166 {
167  const auto searchStr = aEvent.GetString();
168  m_hotkeyListCtrl->ApplyFilterString( searchStr );
169 }
void ApplyFilterString(const wxString &aFilterStr)
Method ApplyFilterString Apply a filter string to the hotkey list, selecting which hotkeys to show...
WIDGET_HOTKEY_LIST * m_hotkeyListCtrl
bool PANEL_HOTKEYS_EDITOR::TransferDataFromWindow ( )
override

Definition at line 153 of file panel_hotkeys_editor.cpp.

References m_frame, m_hotkeyListCtrl, m_hotkeys, WIDGET_HOTKEY_LIST::TransferDataFromControl(), and EDA_BASE_FRAME::WriteHotkeyConfig().

154 {
156  return false;
157 
158  // save the hotkeys
160 
161  return true;
162 }
EDA_BASE_FRAME * m_frame
struct EDA_HOTKEY_CONFIG * m_hotkeys
virtual int WriteHotkeyConfig(struct EDA_HOTKEY_CONFIG *aDescList, wxString *aFullFileName=NULL)
Function WriteHotkeyConfig Store the current hotkey list It is stored using the standard wxConfig mec...
WIDGET_HOTKEY_LIST * m_hotkeyListCtrl
bool TransferDataFromControl()
Method TransferDataFromControl Save the hotkey data from the control.
bool PANEL_HOTKEYS_EDITOR::TransferDataToWindow ( )
override

Definition at line 147 of file panel_hotkeys_editor.cpp.

References m_hotkeyListCtrl, and WIDGET_HOTKEY_LIST::TransferDataToControl().

Referenced by DIALOG_LIST_HOTKEYS::TransferDataToWindow().

148 {
150 }
bool TransferDataToControl()
Method TransferDataToControl Load the hotkey data from the store into the control.
WIDGET_HOTKEY_LIST * m_hotkeyListCtrl

Member Data Documentation

EDA_BASE_FRAME* PANEL_HOTKEYS_EDITOR::m_frame
protected

Definition at line 42 of file panel_hotkeys_editor.h.

Referenced by installButtons(), and TransferDataFromWindow().

WIDGET_HOTKEY_LIST* PANEL_HOTKEYS_EDITOR::m_hotkeyListCtrl
protected
struct EDA_HOTKEY_CONFIG* PANEL_HOTKEYS_EDITOR::m_hotkeys
protected

Definition at line 44 of file panel_hotkeys_editor.h.

Referenced by installButtons(), and TransferDataFromWindow().

HOTKEY_STORE PANEL_HOTKEYS_EDITOR::m_hotkeyStore
protected

Definition at line 47 of file panel_hotkeys_editor.h.

Referenced by PANEL_HOTKEYS_EDITOR().

wxString PANEL_HOTKEYS_EDITOR::m_nickname
protected

Definition at line 45 of file panel_hotkeys_editor.h.

Referenced by installButtons().

bool PANEL_HOTKEYS_EDITOR::m_readOnly
protected

Definition at line 43 of file panel_hotkeys_editor.h.

Referenced by PANEL_HOTKEYS_EDITOR().


The documentation for this class was generated from the following files: