40 #include <wx/popupwin.h> 41 #include <wx/renderer.h> 46 wxASSERT_MSG( aActions.size() > 0,
"Action groups must have at least one action" );
63 return aAction->GetId() == aDefault.
GetId();
66 wxASSERT_MSG( valid,
"Action must be present in a group to be the default" );
72 #define PALETTE_BORDER 4 // The border around the palette buttons on all sides 73 #define BUTTON_BORDER 1 // The border on the sides of the buttons that touch other buttons 77 wxPopupTransientWindow( aParent, wxBORDER_NONE ),
79 m_isVertical( aVertical ),
81 m_mainSizer( nullptr ),
82 m_buttonSizer( nullptr )
84 m_panel =
new wxPanel(
this, wxID_ANY );
85 m_panel->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
88 m_buttonSizer =
new wxBoxSizer( aVertical ? wxVERTICAL : wxHORIZONTAL );
91 m_mainSizer =
new wxBoxSizer( aVertical ? wxVERTICAL : wxHORIZONTAL );
104 wxBitmap disabledBmp = normalBmp.ConvertToDisabled();
106 int padding = (
m_buttonSize.GetWidth() - normalBmp.GetWidth() ) / 2;
131 it->second->Enable( aEnable );
140 it->second->Check( aCheck );
147 SetClientSize(
m_panel->GetSize() );
149 wxPopupTransientWindow::Popup( aFocus );
156 if( aEvent.GetKeyCode() == WXK_ESCAPE )
164 const wxSize& size,
long style ) :
165 wxAuiToolBar( parent, id, pos, size, style ),
166 m_paletteTimer( nullptr ),
167 m_auiManager( nullptr ),
168 m_toolManager( parent->GetToolManager() ),
176 #if !wxCHECK_VERSION( 3, 1, 0 ) 179 SetArtProvider( newArt );
213 wxASSERT( GetParent() );
214 wxASSERT_MSG( !( aIsCancellable && !aIsToggleEntry ),
"aIsCancellable requires aIsToggleEntry" );
216 int toolId = aAction.
GetUIId();
219 aAction.
GetDescription(), aIsToggleEntry ? wxITEM_CHECK : wxITEM_NORMAL );
229 int toolId = aAction.
GetUIId();
232 aAction.
GetName(), wxITEM_NORMAL );
241 int scale =
Pgm().GetCommonSettings()->m_Appearance.icon_scale;
247 AddSpacer( 16 * (
scale - 4 ) / 4 );
252 AddSpacer( 16 * (
scale - 4 ) / 4 );
257 std::unique_ptr<ACTION_MENU> aMenu )
259 int toolId = aAction.
GetUIId();
267 int groupId = aGroup->
GetUIId();
270 wxASSERT( GetParent() );
271 wxASSERT( defaultAction );
279 wxEmptyString, aIsToggleEntry ? wxITEM_CHECK : wxITEM_NORMAL );
292 return aAction.
GetId() == action2->GetId();
302 wxASSERT( GetParent() );
304 int groupId = aGroup->
GetUIId();
306 wxAuiToolBarItem* item = FindTool( groupId );
314 item->SetDisabledBitmap( item->GetBitmap().ConvertToDisabled() );
351 int toolId = aAction.
GetUIId();
352 wxAuiToolBar::SetToolBitmap( toolId, aBitmap );
356 wxAuiToolBarItem* tb_item = wxAuiToolBar::FindTool( toolId );
359 tb_item->SetDisabledBitmap( aBitmap.ConvertToDisabled() );
365 int toolId = aAction.
GetUIId();
368 ToggleTool( toolId, aState );
370 EnableTool( toolId, aState );
376 int toolId = aAction.
GetUIId();
378 EnableTool( toolId, aEnabled );
379 ToggleTool( toolId, aEnabled && aChecked );
385 int id = aEvent.GetId();
386 wxEventType type = aEvent.GetEventType();
389 bool handled =
false;
406 evt = actionIt->second->MakeEvent();
407 evt->SetHasPosition(
false );
421 int toolId = aEvent.GetToolId();
433 toolId = actionIt->second->GetUIId();
442 std::unique_ptr<ACTION_MENU>& owningMenu = menuIt->second;
449 condMenu->Evaluate( dummySel );
456 SetHoverItem(
nullptr );
460 #define PALETTE_OPEN_DELAY 500 465 wxAuiToolBarItem* item = FindToolByPosition( aEvent.GetX(), aEvent.GetY() );
482 if( aEvent.LeftUp() )
493 int toolId = aEvent.GetToolId();
497 wxAuiToolBarItem* item = FindTool( toolId );
515 wxPoint mousePos = ScreenToClient( wxGetMousePosition() );
517 wxAuiToolBarItem* item = FindToolByPosition( mousePos.x, mousePos.y );
536 return aAction->GetUIId() == aEvent.GetId();
566 wxASSERT( GetParent() );
568 wxASSERT( toolParent );
581 wxRect toolRect = GetToolRect( aItem->GetId() );
584 wxPoint pos( ClientToScreen( toolRect.GetPosition() ) );
588 size_t numActions = group->
m_actions.size();
594 + ( numActions * toolRect.GetHeight() );
597 switch( pane.dock_direction )
602 pos = ClientToScreen( toolRect.GetBottomLeft() );
607 case wxAUI_DOCK_BOTTOM:
610 pos = ClientToScreen( toolRect.GetTopLeft() );
612 -( paletteLongDim + m_topPadding ) );
615 case wxAUI_DOCK_LEFT:
618 pos = ClientToScreen( toolRect.GetTopRight() );
619 pos += wxPoint( m_rightPadding,
623 case wxAUI_DOCK_RIGHT:
626 pos = ClientToScreen( toolRect.GetTopLeft() );
627 pos += wxPoint( -( paletteLongDim + m_leftPadding ),
645 wxUpdateUIEvent evt( action->
GetUIId() );
647 toolParent->ProcessWindowEvent( evt );
651 if( evt.GetSetEnabled() )
664 RefreshOverflowState();
665 SetHoverItem(
nullptr );
666 SetPressedItem(
nullptr );
670 m_actionPos = wxPoint( -1, -1 );
671 m_actionItem =
nullptr;
676 const wxRect& aRect )
686 if( aItem.GetState() & wxAUI_BUTTON_STATE_DISABLED )
687 clr = wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT );
689 clr = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT );
692 aDc.SetPen( wxPen( clr ) );
693 aDc.SetBrush( wxBrush( clr ) );
696 int sideLength =
KiROUND( aRect.height / 5.0 );
700 wxPoint btmRight = aRect.GetBottomRight();
701 wxPoint topCorner( btmRight.x, btmRight.y - sideLength );
702 wxPoint btmCorner( btmRight.x - sideLength, btmRight.y );
705 points.Append( &btmRight );
706 points.Append( &topCorner );
707 points.Append( &btmCorner );
709 aDc.DrawPolygon( &points );
715 wxClientDC dc(
this );
724 if( m_orientation == wxHORIZONTAL )
726 if( !( GetWindowStyle() & wxAUI_TB_HORIZONTAL ) )
728 m_vertHintSize = GetSize();
729 retval = RealizeHelper( dc,
false );
732 if( retval && RealizeHelper( dc,
true ) )
734 m_horzHintSize = GetSize();
743 if( !( GetWindowStyle() & wxAUI_TB_VERTICAL ) )
745 m_horzHintSize = GetSize();
746 retval = RealizeHelper( dc,
true );
749 if( retval && RealizeHelper( dc,
false ) )
751 m_vertHintSize = GetSize();
const TOOL_ACTION * m_defaultAction
The actions that compose the group.
static int MakeActionId(const std::string &aActionName)
Generate an unique ID from for an action with given name.
int KiIconScale(wxWindow *aWindow)
Return the automatic scale factor that would be used for a given window by KiScaledBitmap and KiScale...
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, wxWindow *aWindow)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
void SetDefaultAction(const TOOL_ACTION &aDefault)
Set the default action to use when first creating the toolbar palette icon.
A group of actions that will be displayed together on a toolbar palette.
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
std::vector< const TOOL_ACTION * > m_actions
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
const TOOL_ACTION * GetDefaultAction() const
Get the default action to use when first creating this group's toolbar palette icon.
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
The base frame for deriving all KiCad main window classes.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
int GetUIId() const
Get the ID used in the UI to reference this group.
const ACTION_CONDITIONS * GetCondition(const TOOL_ACTION &aAction) const
Get the conditions to use for a specific tool action.
int m_id
< The action ID for this action group
const std::vector< const TOOL_ACTION * > & GetActions() const
Get a vector of all the actions contained inside this group.
ACTION_GROUP(std::string aName, const std::vector< const TOOL_ACTION * > &aActions)
std::string m_name
The default action to display on the toolbar item.