KiCad PCB EDA Suite
WIDGET_HOTKEY_LIST Class Reference

#include <widget_hotkey_list.h>

Inheritance diagram for WIDGET_HOTKEY_LIST:

Public Member Functions

 WIDGET_HOTKEY_LIST (wxWindow *aParent, HOTKEY_STORE &aHotkeyStore, bool aReadOnly)
 Constructor WIDGET_HOTKEY_LIST Create a WIDGET_HOTKEY_LIST. More...
 
void ApplyFilterString (const wxString &aFilterStr)
 Method ApplyFilterString Apply a filter string to the hotkey list, selecting which hotkeys to show. More...
 
void ResetAllHotkeys (bool aResetToDefault)
 Set hotkeys in the control to default or original values. More...
 
bool TransferDataToControl ()
 Method TransferDataToControl Load the hotkey data from the store into the control. More...
 
bool TransferDataFromControl ()
 Method TransferDataFromControl Save the hotkey data from the control. More...
 

Static Public Member Functions

static long MapKeypressToKeycode (const wxKeyEvent &aEvent)
 Static method MapKeypressToKeycode Map a keypress event to the correct key code for use as a hotkey. More...
 

Protected Member Functions

void editItem (wxTreeListItem aItem)
 Method editItem Prompt the user for a new hotkey given a list item. More...
 
void resetItem (wxTreeListItem aItem, int aResetId)
 Method resetItem Reset the item to either the default, the value when the dialog was opened, or none. More...
 
void onActivated (wxTreeListEvent &aEvent)
 Method onActivated Handle activation of a row. More...
 
void onContextMenu (wxTreeListEvent &aEvent)
 Method onContextMenu Handle right-click on a row. More...
 
void onMenu (wxCommandEvent &aEvent)
 Method onMenu Handle activation of a context menu item. More...
 
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 between keys. More...
 

Private Member Functions

WIDGET_HOTKEY_CLIENT_DATAgetHKClientData (wxTreeListItem aItem)
 Method getHKClientData Return the WIDGET_HOTKEY_CLIENT_DATA for the given item, or NULL if the item is invalid. More...
 
WIDGET_HOTKEY_CLIENT_DATAgetExpectedHkClientData (wxTreeListItem aItem)
 Get the WIDGET_HOTKEY_CLIENT_DATA form an item and assert if it isn't found. More...
 
void updateFromClientData ()
 Method updateFromClientData Refresh the visible text on the widget from the rows' client data objects. More...
 
void updateShownItems (const wxString &aFilterStr)
 Method updateShownItems. More...
 
void changeHotkey (HOTKEY &aHotkey, long aKey)
 Attempt to change the given hotkey to the given key code. More...
 
void updateColumnWidths ()
 Recalculates column widths after model has changed. More...
 

Private Attributes

HOTKEY_STOREm_hk_store
 
bool m_readOnly
 
wxTreeListItem m_context_menu_item
 

Detailed Description

Definition at line 40 of file widget_hotkey_list.h.

Constructor & Destructor Documentation

◆ WIDGET_HOTKEY_LIST()

WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST ( wxWindow *  aParent,
HOTKEY_STORE aHotkeyStore,
bool  aReadOnly 
)

Constructor WIDGET_HOTKEY_LIST Create a WIDGET_HOTKEY_LIST.

Parameters
aParent- parent widget
aHotkeys- EDA_HOTKEY_CONFIG data - a hotkey store is constructed from this.

Definition at line 438 of file widget_hotkey_list.cpp.

439  :
440  wxTreeListCtrl( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTL_SINGLE ),
441  m_hk_store( aHotkeyStore ),
442  m_readOnly( aReadOnly )
443 {
444  wxString command_header = _( "Command" );
445 
446  if( !m_readOnly )
447  command_header << " " << _( "(double-click to edit)" );
448 
449  AppendColumn( command_header, 450, wxALIGN_LEFT, wxCOL_RESIZABLE | wxCOL_SORTABLE );
450  AppendColumn( _( "Hotkey" ), 120, wxALIGN_LEFT, wxCOL_RESIZABLE | wxCOL_SORTABLE );
451  AppendColumn( _( "Description" ), 900, wxALIGN_LEFT, wxCOL_RESIZABLE | wxCOL_SORTABLE );
452 
453 
454 #if defined( __WXGTK__ )// && !wxCHECK_VERSION( 3, 1, 0 )
455  // Automatic column widths are broken in wxGTK 3.0.x; set min widths to ensure visibility
456  // They are also broken in wxGTK 3.1.4
457 
458  wxDataViewCtrl* dv = GetDataView();
459 
460  wxString longKey = wxT( "Ctrl+Alt+Shift+X" );
461  int pad = 20;
462 
463  dv->GetColumn( 0 )->SetMinWidth( dv->GetMainWindow()->GetTextExtent( command_header ).x + pad );
464  dv->GetColumn( 1 )->SetMinWidth( dv->GetMainWindow()->GetTextExtent( longKey ).x + pad );
465 #endif
466 
467  GetDataView()->SetIndent( 10 );
468 
469  if( !m_readOnly )
470  {
471  // The event only apply if the widget is in editable mode
472  Bind( wxEVT_TREELIST_ITEM_ACTIVATED, &WIDGET_HOTKEY_LIST::onActivated, this );
473  Bind( wxEVT_TREELIST_ITEM_CONTEXT_MENU, &WIDGET_HOTKEY_LIST::onContextMenu, this );
474  Bind( wxEVT_MENU, &WIDGET_HOTKEY_LIST::onMenu, this );
475  }
476 }
void onActivated(wxTreeListEvent &aEvent)
Method onActivated Handle activation of a row.
void onContextMenu(wxTreeListEvent &aEvent)
Method onContextMenu Handle right-click on a row.
HOTKEY_STORE & m_hk_store
void onMenu(wxCommandEvent &aEvent)
Method onMenu Handle activation of a context menu item.
#define _(s)
Definition: 3d_actions.cpp:33

References _, m_readOnly, onActivated(), onContextMenu(), onMenu(), and pad.

Member Function Documentation

◆ ApplyFilterString()

void WIDGET_HOTKEY_LIST::ApplyFilterString ( const wxString &  aFilterStr)

Method ApplyFilterString Apply a filter string to the hotkey list, selecting which hotkeys to show.

Parameters
aFilterStrthe string to filter by

Definition at line 479 of file widget_hotkey_list.cpp.

480 {
481  updateShownItems( aFilterStr );
482 }
void updateShownItems(const wxString &aFilterStr)
Method updateShownItems.

References updateShownItems().

Referenced by PANEL_HOTKEYS_EDITOR::OnFilterSearch().

◆ changeHotkey()

void WIDGET_HOTKEY_LIST::changeHotkey ( HOTKEY aHotkey,
long  aKey 
)
private

Attempt to change the given hotkey to the given key code.

If the hotkey conflicts, the user is prompted to change anyway (and in doing so, unset the conflicting key), or cancel the attempt.

Parameters
aHotkeythe change-able hotkey to try to change
aKeythe key code to change it to

Definition at line 306 of file widget_hotkey_list.cpp.

307 {
308  // See if this key code is handled in hotkeys names list
309  bool exists;
310  KeyNameFromKeyCode( aKey, &exists );
311 
312  if( exists && aHotkey.m_EditKeycode != aKey )
313  {
314  if( aKey == 0 || resolveKeyConflicts( aHotkey.m_Actions[ 0 ], aKey ) )
315  aHotkey.m_EditKeycode = aKey;
316  }
317 }
std::vector< TOOL_ACTION * > m_Actions
Definition: hotkey_store.h:36
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Return the key name from the key code.
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...
int m_EditKeycode
Definition: hotkey_store.h:37

References KeyNameFromKeyCode(), HOTKEY::m_Actions, HOTKEY::m_EditKeycode, and resolveKeyConflicts().

Referenced by editItem(), and resetItem().

◆ editItem()

void WIDGET_HOTKEY_LIST::editItem ( wxTreeListItem  aItem)
protected

Method editItem Prompt the user for a new hotkey given a list item.

Definition at line 320 of file widget_hotkey_list.cpp.

321 {
323 
324  if( !hkdata )
325  return;
326 
327  wxString name = GetItemText( aItem, 0 );
328  wxString current_key = GetItemText( aItem, 1 );
329 
330  wxKeyEvent key_event = HK_PROMPT_DIALOG::PromptForKey( GetParent(), name, current_key );
331  long key = MapKeypressToKeycode( key_event );
332 
333  if( key )
334  {
335  changeHotkey( hkdata->GetChangedHotkey(), key );
337  }
338 }
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.
static wxKeyEvent PromptForKey(wxWindow *aParent, const wxString &aName, const wxString &aCurrentKey)
WIDGET_HOTKEY_CLIENT_DATA * getExpectedHkClientData(wxTreeListItem aItem)
Get the WIDGET_HOTKEY_CLIENT_DATA form an item and assert if it isn't found.
void updateFromClientData()
Method updateFromClientData Refresh the visible text on the widget from the rows' client data objects...
Store the hotkey change data associated with each row.
const char * name
Definition: DXF_plotter.cpp:59

References changeHotkey(), WIDGET_HOTKEY_CLIENT_DATA::GetChangedHotkey(), getExpectedHkClientData(), MapKeypressToKeycode(), name, HK_PROMPT_DIALOG::PromptForKey(), and updateFromClientData().

Referenced by onActivated(), and onMenu().

◆ getExpectedHkClientData()

WIDGET_HOTKEY_CLIENT_DATA * WIDGET_HOTKEY_LIST::getExpectedHkClientData ( wxTreeListItem  aItem)
private

Get the WIDGET_HOTKEY_CLIENT_DATA form an item and assert if it isn't found.

This is for use when the data not being present indicates an error.

Definition at line 266 of file widget_hotkey_list.cpp.

267 {
268  const auto hkdata = getHKClientData( aItem );
269 
270  // This probably means a hotkey-only action is being attempted on
271  // a row that is not a hotkey (like a section heading)
272  wxASSERT_MSG( hkdata != nullptr, "No hotkey data found for list item" );
273 
274  return hkdata;
275 }
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...

References getHKClientData().

Referenced by editItem(), and resetItem().

◆ getHKClientData()

WIDGET_HOTKEY_CLIENT_DATA * WIDGET_HOTKEY_LIST::getHKClientData ( wxTreeListItem  aItem)
private

Method getHKClientData Return the WIDGET_HOTKEY_CLIENT_DATA for the given item, or NULL if the item is invalid.

Definition at line 252 of file widget_hotkey_list.cpp.

253 {
254  if( aItem.IsOk() )
255  {
256  wxClientData* data = GetItemData( aItem );
257 
258  if( data )
259  return static_cast<WIDGET_HOTKEY_CLIENT_DATA*>( data );
260  }
261 
262  return nullptr;
263 }

Referenced by getExpectedHkClientData(), onContextMenu(), and updateFromClientData().

◆ MapKeypressToKeycode()

long WIDGET_HOTKEY_LIST::MapKeypressToKeycode ( const wxKeyEvent &  aEvent)
static

Static method MapKeypressToKeycode Map a keypress event to the correct key code for use as a hotkey.

Definition at line 569 of file widget_hotkey_list.cpp.

570 {
571  long key = aEvent.GetKeyCode();
572 
573  if( key == WXK_ESCAPE )
574  {
575  return 0;
576  }
577  else
578  {
579  if( key >= 'a' && key <= 'z' ) // convert to uppercase
580  key = key + ('A' - 'a');
581 
582  // Remap Ctrl A (=1+GR_KB_CTRL) to Ctrl Z(=26+GR_KB_CTRL)
583  // to GR_KB_CTRL+'A' .. GR_KB_CTRL+'Z'
584  if( aEvent.ControlDown() && key >= WXK_CONTROL_A && key <= WXK_CONTROL_Z )
585  key += 'A' - 1;
586 
587  /* Disallow shift for keys that have two keycodes on them (e.g. number and
588  * punctuation keys) leaving only the "letter keys" of A-Z.
589  * Then, you can have, e.g. Ctrl-5 and Ctrl-% (GB layout)
590  * and Ctrl-( and Ctrl-5 (FR layout).
591  * Otherwise, you'd have to have to say Ctrl-Shift-5 on a FR layout
592  */
593  bool keyIsLetter = key >= 'A' && key <= 'Z';
594 
595  if( aEvent.ShiftDown() && ( keyIsLetter || key > 256 ) )
596  key |= MD_SHIFT;
597 
598  if( aEvent.ControlDown() )
599  key |= MD_CTRL;
600 
601  if( aEvent.AltDown() )
602  key |= MD_ALT;
603 
604  return key;
605  }
606 }

References MD_ALT, MD_CTRL, and MD_SHIFT.

Referenced by editItem().

◆ onActivated()

void WIDGET_HOTKEY_LIST::onActivated ( wxTreeListEvent &  aEvent)
protected

Method onActivated Handle activation of a row.

Definition at line 361 of file widget_hotkey_list.cpp.

362 {
363  editItem( aEvent.GetItem());
364 }
void editItem(wxTreeListItem aItem)
Method editItem Prompt the user for a new hotkey given a list item.

References editItem().

Referenced by WIDGET_HOTKEY_LIST().

◆ onContextMenu()

void WIDGET_HOTKEY_LIST::onContextMenu ( wxTreeListEvent &  aEvent)
protected

Method onContextMenu Handle right-click on a row.

Definition at line 367 of file widget_hotkey_list.cpp.

368 {
369  // Save the active event for use in OnMenu
370  m_context_menu_item = aEvent.GetItem();
371 
372  wxMenu menu;
373 
375 
376  // Some actions only apply if the row is hotkey data
377  if( hkdata )
378  {
379  menu.Append( ID_EDIT_HOTKEY, _( "Edit..." ) );
380  menu.Append( ID_RESET, _( "Undo Changes" ) );
381  menu.Append( ID_CLEAR, _( "Clear Assigned Hotkey" ) );
382  menu.Append( ID_DEFAULT, _( "Restore Default" ) );
383  menu.Append( wxID_SEPARATOR );
384 
385  PopupMenu( &menu );
386  }
387 }
wxTreeListItem m_context_menu_item
Store the hotkey change data associated with each row.
#define _(s)
Definition: 3d_actions.cpp:33
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...

References _, getHKClientData(), ID_CLEAR, ID_DEFAULT, ID_EDIT_HOTKEY, ID_RESET, and m_context_menu_item.

Referenced by WIDGET_HOTKEY_LIST().

◆ onMenu()

void WIDGET_HOTKEY_LIST::onMenu ( wxCommandEvent &  aEvent)
protected

Method onMenu Handle activation of a context menu item.

Definition at line 390 of file widget_hotkey_list.cpp.

391 {
392  switch( aEvent.GetId() )
393  {
395  break;
396 
397  case ID_RESET:
398  case ID_CLEAR:
399  case ID_DEFAULT:resetItem( m_context_menu_item, aEvent.GetId());
400  break;
401 
402  default:
403  wxFAIL_MSG( wxT( "Unknown ID in context menu event" ) );
404  }
405 }
void editItem(wxTreeListItem aItem)
Method editItem Prompt the user for a new hotkey given a list item.
wxTreeListItem m_context_menu_item
void resetItem(wxTreeListItem aItem, int aResetId)
Method resetItem Reset the item to either the default, the value when the dialog was opened,...

References editItem(), ID_CLEAR, ID_DEFAULT, ID_EDIT_HOTKEY, ID_RESET, m_context_menu_item, and resetItem().

Referenced by WIDGET_HOTKEY_LIST().

◆ ResetAllHotkeys()

void WIDGET_HOTKEY_LIST::ResetAllHotkeys ( bool  aResetToDefault)

Set hotkeys in the control to default or original values.

Parameters
aResetToDefaultif true, reset to the defaults inherent to the hotkeys, else reset to the value they had when the dialog was invoked.

Definition at line 485 of file widget_hotkey_list.cpp.

486 {
487  Freeze();
488 
489  // Reset all the hotkeys, not just the ones shown
490  // Should not need to check conflicts, as the state we're about
491  // to set to a should be consistent
492  if( aResetToDefault )
494  else
496 
499 
500  Thaw();
501 }
HOTKEY_STORE & m_hk_store
void updateFromClientData()
Method updateFromClientData Refresh the visible text on the widget from the rows' client data objects...
void ResetAllHotkeysToDefault()
Reset every hotkey in the store to the default values.
void updateColumnWidths()
Recalculates column widths after model has changed.
void ResetAllHotkeysToOriginal()
Resets every hotkey to the original values.

References m_hk_store, HOTKEY_STORE::ResetAllHotkeysToDefault(), HOTKEY_STORE::ResetAllHotkeysToOriginal(), updateColumnWidths(), and updateFromClientData().

Referenced by PANEL_HOTKEYS_EDITOR::installButtons(), and PANEL_HOTKEYS_EDITOR::ResetPanel().

◆ resetItem()

void WIDGET_HOTKEY_LIST::resetItem ( wxTreeListItem  aItem,
int  aResetId 
)
protected

Method resetItem Reset the item to either the default, the value when the dialog was opened, or none.

Definition at line 341 of file widget_hotkey_list.cpp.

342 {
344 
345  if( !hkdata )
346  return;
347 
348  HOTKEY& changed_hk = hkdata->GetChangedHotkey();
349 
350  if( aResetId == ID_RESET )
351  changeHotkey( changed_hk, changed_hk.m_Actions[ 0 ]->GetHotKey() );
352  else if( aResetId == ID_CLEAR )
353  changeHotkey( changed_hk, 0 );
354  else if( aResetId == ID_DEFAULT )
355  changeHotkey( changed_hk, changed_hk.m_Actions[ 0 ]->GetDefaultHotKey() );
356 
358 }
void changeHotkey(HOTKEY &aHotkey, long aKey)
Attempt to change the given hotkey to the given key code.
WIDGET_HOTKEY_CLIENT_DATA * getExpectedHkClientData(wxTreeListItem aItem)
Get the WIDGET_HOTKEY_CLIENT_DATA form an item and assert if it isn't found.
void updateFromClientData()
Method updateFromClientData Refresh the visible text on the widget from the rows' client data objects...
Store the hotkey change data associated with each row.
std::vector< TOOL_ACTION * > m_Actions
Definition: hotkey_store.h:36

References changeHotkey(), WIDGET_HOTKEY_CLIENT_DATA::GetChangedHotkey(), getExpectedHkClientData(), ID_CLEAR, ID_DEFAULT, ID_RESET, HOTKEY::m_Actions, and updateFromClientData().

Referenced by onMenu().

◆ resolveKeyConflicts()

bool WIDGET_HOTKEY_LIST::resolveKeyConflicts ( TOOL_ACTION aAction,
long  aKey 
)
protected

Method resolveKeyConflicts Check if we can set a hotkey, and prompt the user if there is a conflict between keys.

The key code should already have been checked that it's not for the same entry as it's current in, or else this method will prompt for the self-change.

The method will do conflict resolution depending on aSectionTag. g_CommonSectionTag means the key code must only be checkd with the aSectionTag section and g_CommonSectionTag section.

Parameters
aKey- key to check
aActionName- name of the action into which the key is proposed to be installed
Returns
true iff the user accepted the overwrite or no conflict existed

Definition at line 408 of file widget_hotkey_list.cpp.

409 {
410  HOTKEY* conflictingHotKey = nullptr;
411 
412  m_hk_store.CheckKeyConflicts( aAction, aKey, &conflictingHotKey );
413 
414  if( !conflictingHotKey )
415  return true;
416 
417  TOOL_ACTION* conflictingAction = conflictingHotKey->m_Actions[ 0 ];
418  wxString msg = wxString::Format( _( "\"%s\" is already assigned to \"%s\" in section \"%s\". "
419  "Are you sure you want to change its assignment?" ),
420  KeyNameFromKeyCode( aKey ),
421  conflictingAction->GetLabel(),
422  HOTKEY_STORE::GetSectionName( conflictingAction ) );
423 
424  wxMessageDialog dlg( GetParent(), msg, _( "Confirm change" ), wxYES_NO | wxNO_DEFAULT );
425 
426  if( dlg.ShowModal() == wxID_YES )
427  {
428  // Reset the other hotkey
429  conflictingHotKey->m_EditKeycode = 0;
431  return true;
432  }
433 
434  return false;
435 }
HOTKEY_STORE & m_hk_store
void updateFromClientData()
Method updateFromClientData Refresh the visible text on the widget from the rows' client data objects...
bool CheckKeyConflicts(TOOL_ACTION *aAction, long aKey, HOTKEY **aConflict)
Check whether the given key conflicts with anything in this store.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
std::vector< TOOL_ACTION * > m_Actions
Definition: hotkey_store.h:36
wxString GetLabel() const
Definition: tool_action.cpp:70
#define _(s)
Definition: 3d_actions.cpp:33
Represent a single user action.
Definition: tool_action.h:49
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Return the key name from the key code.
int m_EditKeycode
Definition: hotkey_store.h:37
static wxString GetSectionName(TOOL_ACTION *aAction)

References _, HOTKEY_STORE::CheckKeyConflicts(), Format(), TOOL_ACTION::GetLabel(), HOTKEY_STORE::GetSectionName(), KeyNameFromKeyCode(), HOTKEY::m_Actions, HOTKEY::m_EditKeycode, m_hk_store, and updateFromClientData().

Referenced by changeHotkey().

◆ TransferDataFromControl()

bool WIDGET_HOTKEY_LIST::TransferDataFromControl ( )

Method TransferDataFromControl Save the hotkey data from the control.

Returns
true iff the operation was successful

Definition at line 562 of file widget_hotkey_list.cpp.

563 {
565  return true;
566 }
void SaveAllHotkeys()
Persist all changes to hotkeys in the store to the underlying data structures.
HOTKEY_STORE & m_hk_store

References m_hk_store, and HOTKEY_STORE::SaveAllHotkeys().

Referenced by PANEL_HOTKEYS_EDITOR::TransferDataFromWindow().

◆ TransferDataToControl()

bool WIDGET_HOTKEY_LIST::TransferDataToControl ( )

Method TransferDataToControl Load the hotkey data from the store into the control.

Returns
true iff the operation was successful

Definition at line 504 of file widget_hotkey_list.cpp.

505 {
506  updateShownItems( "" );
508 
509  return true;
510 }
void updateShownItems(const wxString &aFilterStr)
Method updateShownItems.
void updateColumnWidths()
Recalculates column widths after model has changed.

References updateColumnWidths(), and updateShownItems().

Referenced by PANEL_HOTKEYS_EDITOR::ImportHotKeys(), and PANEL_HOTKEYS_EDITOR::TransferDataToWindow().

◆ updateColumnWidths()

void WIDGET_HOTKEY_LIST::updateColumnWidths ( )
private

Recalculates column widths after model has changed.

Definition at line 513 of file widget_hotkey_list.cpp.

514 {
515  wxDataViewColumn* col = GetDataView()->GetColumn( 0 );
516  col->SetWidth( wxCOL_WIDTH_AUTOSIZE );
517  col->SetWidth( col->GetWidth() );
518 
519 #if defined( __WXGTK__ ) && !wxCHECK_VERSION( 3, 1, 0 )
520  col->SetResizeable( true );
521 #endif
522 
523  col = GetDataView()->GetColumn( 1 );
524  col->SetWidth( wxCOL_WIDTH_AUTOSIZE );
525  col->SetWidth( col->GetWidth() );
526 
527 #if defined( __WXGTK__ ) && !wxCHECK_VERSION( 3, 1, 0 )
528  col->SetResizeable( true );
529 #endif
530 }

Referenced by ResetAllHotkeys(), and TransferDataToControl().

◆ updateFromClientData()

void WIDGET_HOTKEY_LIST::updateFromClientData ( )
private

Method updateFromClientData Refresh the visible text on the widget from the rows' client data objects.

Definition at line 278 of file widget_hotkey_list.cpp.

279 {
280  for( wxTreeListItem i = GetFirstItem(); i.IsOk(); i = GetNextItem( i ) )
281  {
283 
284  if( hkdata )
285  {
286  const HOTKEY& changed_hk = hkdata->GetChangedHotkey();
287  wxString label = changed_hk.m_Actions[ 0 ]->GetLabel();
288  wxString key_text = KeyNameFromKeyCode( changed_hk.m_EditKeycode );
289  wxString description = changed_hk.m_Actions[ 0 ]->GetDescription( false );
290 
291  if( label.IsEmpty() )
292  label = changed_hk.m_Actions[ 0 ]->GetName();
293 
294  // mark unsaved changes
295  if( changed_hk.m_EditKeycode != changed_hk.m_Actions[ 0 ]->GetHotKey() )
296  label += " *";
297 
298  SetItemText( i, 0, label );
299  SetItemText( i, 1, key_text);
300  SetItemText( i, 2, description );
301  }
302  }
303 }
Store the hotkey change data associated with each row.
wxDataViewItem GetNextItem(wxDataViewCtrl const &aView, wxDataViewItem const &aItem)
Get the next item in list order.
std::vector< TOOL_ACTION * > m_Actions
Definition: hotkey_store.h:36
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Return the key name from the key code.
int m_EditKeycode
Definition: hotkey_store.h:37
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...

References WIDGET_HOTKEY_CLIENT_DATA::GetChangedHotkey(), getHKClientData(), GetNextItem(), KeyNameFromKeyCode(), HOTKEY::m_Actions, and HOTKEY::m_EditKeycode.

Referenced by editItem(), ResetAllHotkeys(), resetItem(), resolveKeyConflicts(), and updateShownItems().

◆ updateShownItems()

void WIDGET_HOTKEY_LIST::updateShownItems ( const wxString &  aFilterStr)
private

Method updateShownItems.

Update the items shown in the widget based on a given filter string.

Parameters
aFilterStrthe string to filter with. Empty means no filter.

Definition at line 533 of file widget_hotkey_list.cpp.

534 {
535  Freeze();
536  DeleteAllItems();
537 
538  HOTKEY_FILTER filter( aFilterStr );
539 
540  for( HOTKEY_SECTION& section: m_hk_store.GetSections() )
541  {
542  // Create parent tree item
543  wxTreeListItem parent = AppendItem( GetRootItem(), section.m_SectionName );
544 
545  for( HOTKEY& hotkey: section.m_HotKeys )
546  {
547  if( filter.FilterMatches( hotkey ) )
548  {
549  wxTreeListItem item = AppendItem( parent, wxEmptyString );
550  SetItemData( item, new WIDGET_HOTKEY_CLIENT_DATA( hotkey ) );
551  }
552  }
553 
554  Expand( parent );
555  }
556 
558  Thaw();
559 }
HOTKEY_STORE & m_hk_store
void updateFromClientData()
Method updateFromClientData Refresh the visible text on the widget from the rows' client data objects...
Store the hotkey change data associated with each row.
std::vector< HOTKEY_SECTION > & GetSections()
Get the list of sections managed by this store.
Class to manage logic for filtering hotkeys based on user input.

References filter, HOTKEY_STORE::GetSections(), m_hk_store, and updateFromClientData().

Referenced by ApplyFilterString(), and TransferDataToControl().

Member Data Documentation

◆ m_context_menu_item

wxTreeListItem WIDGET_HOTKEY_LIST::m_context_menu_item
private

Definition at line 185 of file widget_hotkey_list.h.

Referenced by onContextMenu(), and onMenu().

◆ m_hk_store

HOTKEY_STORE& WIDGET_HOTKEY_LIST::m_hk_store
private

◆ m_readOnly

bool WIDGET_HOTKEY_LIST::m_readOnly
private

Definition at line 183 of file widget_hotkey_list.h.

Referenced by WIDGET_HOTKEY_LIST().


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