33#include <magic_enum.hpp>
34#include <wx/listctrl.h>
132 const std::vector<TOOL_ACTION*>& aTools,
133 const std::vector<ACTION_TOOLBAR_CONTROL*>& aControls ) :
141 for(
auto& tool : aTools )
144 for(
auto& control : aControls )
184 for(
auto& tb : magic_enum::enum_values<TOOLBAR_LOC>() )
189 if( tbConfig.has_value() )
196 auto firstTb = magic_enum::enum_cast<TOOLBAR_LOC>( 0 );
198 if( firstTb.has_value() )
208 wxArrayString tbChoices;
211 for(
auto& tb : magic_enum::enum_values<TOOLBAR_LOC>() )
216 if( tbConfig.has_value() )
223 wxString::Format(
"Unknown toolbar: %s", magic_enum::enum_name( tb ) ) );
225 tbChoices.Add( tbName->second );
236 auto firstTb = magic_enum::enum_cast<TOOLBAR_LOC>( 0 );
238 if( firstTb.has_value() )
258 if( currentTb.has_value() )
275 wxTreeItemIdValue mainCookie;
282 while( mainId.IsOk() )
284 wxTreeItemData* treeData =
m_toolbarTree->GetItemData( mainId );
288 wxCHECK2( tbData,
continue );
313 wxTreeItemIdValue childCookie;
314 wxTreeItemId childId =
m_toolbarTree->GetFirstChild( mainId, childCookie );
316 while( childId.IsOk() )
318 wxTreeItemData* childTreeData =
m_toolbarTree->GetItemData( childId );
322 wxCHECK2( childTbData,
break );
324 switch( childTbData->
GetType() )
330 wxASSERT_MSG(
false,
"Invalid entry in a group" );
338 childId =
m_toolbarTree->GetNextChild( mainId, childCookie );
342 config.AppendGroup( grpConfig );
375 switch( item.m_Type )
381 m_toolbarTree->AppendItem( root,
_(
"Separator" ), -1, -1, sepTreeItem );
389 spacerTreeItem->
SetSize( item.m_Size );
390 m_toolbarTree->AppendItem( root, wxString::Format(
_(
"Spacer: %i" ), item.m_Size ), -1, -1,
401 wxASSERT_MSG(
false, wxString::Format(
"Unable to find control %s", item.m_ControlName ) );
407 controlTreeItem->
SetControl( controlIter->second );
408 m_toolbarTree->AppendItem( root, controlIter->second->GetUiName(), -1, -1, controlTreeItem );
419 wxASSERT_MSG(
false, wxString::Format(
"Unable to find tool %s", item.m_ActionName ) );
424 toolTreeItem->
SetAction( toolIter->second );
430 imgIdx = imgMap->second;
432 m_toolbarTree->AppendItem( root, toolIter->second->GetFriendlyName(), imgIdx, -1, toolTreeItem );
440 groupTreeItem->
SetName( item.m_GroupName );
442 wxTreeItemId groupId =
m_toolbarTree->AppendItem( root, item.m_GroupName, -1, -1, groupTreeItem );
451 wxASSERT_MSG(
false, wxString::Format(
"Unable to find group tool %s", groupItem.
m_ActionName ) );
456 toolTreeItem->
SetAction( toolMap->second );
462 imgIdx = imgMap->second;
464 m_toolbarTree->AppendItem( groupId, toolMap->second->GetFriendlyName(), imgIdx, -1, toolTreeItem );
474 wxTreeItemIdValue temp;
475 wxTreeItemId firstItem =
m_toolbarTree->GetFirstChild( root, temp );
477 if( firstItem.IsOk() )
487 const int c_defSize = 24;
496 m_actionsList->InsertColumn( 0,
"", wxLIST_FORMAT_LEFT, wxLIST_AUTOSIZE );
508 item.SetText( tool->GetFriendlyName() );
509 item.SetFont( listFont );
510 item.SetData(
static_cast<void*
>( tool ) );
511 item.SetId( itemIdx++ );
519 item.SetImage( imgIdx );
534 item.SetText( control->GetUiName() );
535 item.SetFont( listFont );
536 item.SetData(
static_cast<void*
>( control ) );
537 item.SetId( itemIdx++ );
554 wxTreeItemId newItem;
560 wxTreeItemId parent =
m_toolbarTree->GetItemParent( selItem );
564 wxTreeItemId secondParent =
m_toolbarTree->GetItemParent( parent );
566 if( secondParent.IsOk() )
594 wxString label = wxString::Format(
"Spacer: %i", treeItem->
GetSize() );
596 wxTreeItemId newItem;
602 wxTreeItemId parent =
m_toolbarTree->GetItemParent( selItem );
607 wxTreeItemId secondParent =
m_toolbarTree->GetItemParent( parent );
609 if( secondParent.IsOk() )
616 newItem =
m_toolbarTree->InsertItem( parent, selItem, label, -1, -1, treeItem );
635 wxTreeItemId newItem;
641 wxTreeItemId parent =
m_toolbarTree->GetItemParent( selItem );
646 wxTreeItemId secondParent =
m_toolbarTree->GetItemParent( parent );
648 if( secondParent.IsOk() )
655 newItem =
m_toolbarTree->InsertItem( parent, selItem,
_(
"Separator" ), -1, -1, treeItem );
712 if( !item.IsOk() && prev.IsOk() )
735 long actionIdx =
m_actionsList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
764 imgIdx = imgMap->second;
768 wxString label = action ? action->
GetFriendlyName() : control->GetUiName();
770 wxTreeItemId newItem;
780 newItem =
m_toolbarTree->AppendItem( selItem, label, imgIdx, -1, toolTreeItem );
785 wxTreeItemId parent =
m_toolbarTree->GetItemParent( selItem );
786 newItem =
m_toolbarTree->InsertItem( parent, selItem, label, imgIdx, -1, toolTreeItem );
801 if( ++actionIdx < m_actionsList->GetItemCount() )
802 m_actionsList->SetItemState( actionIdx, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
809 wxTreeItemId
id =
event.GetItem();
817 switch( tbData->GetType() )
847 if( currentTb.has_value() )
851 auto newTb = magic_enum::enum_cast<TOOLBAR_LOC>( event.GetInt() );
853 if( newTb.has_value() )
863 wxCommandEvent
dummy;
wxBitmapBundle KiBitmapBundleDef(BITMAPS aBitmap, int aDefHeight)
Constructs and returns a bitmap bundle for the given icon ID, with the default bitmap size being aDef...
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
std::vector< FAB_LAYER_COLOR > dummy
Functions to provide common constants and other functions to assist in making a consistent UI.