KiCad PCB EDA Suite
Loading...
Searching...
No Matches
toolbars_pl_editor.cpp
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 The KiCad Developers, see AUTHORS.txt for contributors.
5 * Copyright (C) 2013-2019 CERN
6 * @author Jean-Pierre Charras, jp.charras at wanadoo.fr
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include <bitmaps.h>
23#include <tool/action_toolbar.h>
24#include <tool/tool_manager.h>
25#include <tools/pl_actions.h>
27#include <wx/choice.h>
28
29#include "pl_editor_id.h"
30#include "pl_editor_frame.h"
31#include <toolbars_pl_editor.h>
32
33
34std::optional<TOOLBAR_CONFIGURATION> PL_EDITOR_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
35{
37
38 // clang-format off
39 switch( aToolbar )
40 {
41 // No aux toolbar
43 return std::nullopt;
44
46 config.AppendAction( ACTIONS::toggleGrid )
47 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
48 .AddAction( ACTIONS::millimetersUnits )
49 .AddAction( ACTIONS::inchesUnits )
50 .AddAction( ACTIONS::milsUnits ) );
51
52 /* TODO: Implement context menus
53 PL_SELECTION_TOOL* selTool = m_toolManager->GetTool<PL_SELECTION_TOOL>();
54 std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
55 gridMenu->Add( ACTIONS::gridProperties );
56 m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
57 */
58 break;
59
61 config.AppendAction( ACTIONS::selectionTool );
62
63 config.AppendSeparator()
64 .AppendAction( PL_ACTIONS::drawLine )
65 .AppendAction( PL_ACTIONS::drawRectangle )
66 .AppendAction( PL_ACTIONS::placeText )
67 .AppendAction( PL_ACTIONS::placeImage )
69
70 config.AppendSeparator()
71 .AppendAction( ACTIONS::deleteTool );
72 break;
73
75 config.AppendAction( ACTIONS::doNew )
76 .AppendAction( ACTIONS::open )
77 .AppendAction( ACTIONS::save );
78
79 config.AppendSeparator()
80 .AppendAction( ACTIONS::print );
81
82 config.AppendSeparator()
83 .AppendAction( ACTIONS::undo )
84 .AppendAction( ACTIONS::redo );
85
86 config.AppendSeparator()
87 .AppendAction( ACTIONS::zoomRedraw )
88 .AppendAction( ACTIONS::zoomInCenter )
89 .AppendAction( ACTIONS::zoomOutCenter )
90 .AppendAction( ACTIONS::zoomFitScreen )
91 .AppendAction( ACTIONS::zoomTool );
92
93 config.AppendSeparator()
94 .AppendAction( PL_ACTIONS::showInspector )
95 .AppendAction( PL_ACTIONS::previewSettings );
96
97 // Display mode switch
98 config.AppendSeparator()
99 .AppendAction( PL_ACTIONS::layoutNormalMode )
100 .AppendAction( PL_ACTIONS::layoutEditMode );
101
102 config.AppendSeparator()
105 break;
106 }
107
108 // clang-format on
109 return config;
110}
111
112
114{
116
117 auto originSelectorFactory =
118 [this]( ACTION_TOOLBAR* aToolbar )
119 {
120 if( !m_originSelectBox )
121 {
122 m_originSelectBox = new wxChoice( aToolbar, ID_SELECT_COORDINATE_ORIGIN,
123 wxDefaultPosition, wxDefaultSize, 5, m_originChoiceList );
124 }
125
126 m_originSelectBox->SetToolTip( _("Origin of coordinates displayed to the status bar") );
128
129 aToolbar->Add( m_originSelectBox );
130 };
131
133
134
135 auto pageSelectorFactory =
136 [this]( ACTION_TOOLBAR* aToolbar )
137 {
138 wxString pageList[5] =
139 {
140 _("Page 1"),
141 _("Other pages")
142 };
143
144 if( !m_pageSelectBox )
145 {
146 m_pageSelectBox = new wxChoice( aToolbar, ID_SELECT_PAGE_NUMBER,
147 wxDefaultPosition, wxDefaultSize, 2, pageList );
148 }
149
150 m_pageSelectBox->SetToolTip( _("Simulate page 1 or other pages to show how items\n"\
151 "which are not on all page are displayed") );
152 m_pageSelectBox->SetSelection( 0 );
153
154 aToolbar->Add( m_pageSelectBox );
155 };
156
158}
159
160
161ACTION_TOOLBAR_CONTROL PL_EDITOR_ACTION_TOOLBAR_CONTROLS::originSelector( "control.OriginSelector", _( "Origin Selector" ),
162 _( "Select the origin of the status bar coordinates" ) );
163ACTION_TOOLBAR_CONTROL PL_EDITOR_ACTION_TOOLBAR_CONTROLS::pageSelect( "control.PageSelect", _( "Page Selector" ),
164 _( "Select the page to simulate item displays" ));
165
166
167
169{
170 // Ensure the origin selector is a minimum size
171 int minwidth = 0;
172
173 for( int ii = 0; ii < 5; ii++ )
174 {
176 minwidth = std::max( minwidth, width );
177 }
178
179 m_originSelectBox->SetMinSize( wxSize( minwidth, -1 ) );
180
181 // Base class actually will go through and update the sizes of the controls
183}
static TOOL_ACTION toggleGrid
Definition actions.h:197
static TOOL_ACTION zoomRedraw
Definition actions.h:131
static TOOL_ACTION millimetersUnits
Definition actions.h:205
static TOOL_ACTION zoomOutCenter
Definition actions.h:135
static TOOL_ACTION milsUnits
Definition actions.h:204
static TOOL_ACTION open
Definition actions.h:57
static TOOL_ACTION undo
Definition actions.h:75
static TOOL_ACTION inchesUnits
Definition actions.h:203
static TOOL_ACTION selectionTool
Definition actions.h:250
static TOOL_ACTION save
Definition actions.h:58
static TOOL_ACTION zoomFitScreen
Definition actions.h:141
static TOOL_ACTION redo
Definition actions.h:76
static TOOL_ACTION deleteTool
Definition actions.h:86
static TOOL_ACTION zoomTool
Definition actions.h:145
static TOOL_ACTION print
Definition actions.h:64
static TOOL_ACTION doNew
Definition actions.h:54
static TOOL_ACTION zoomInCenter
Definition actions.h:134
Class to hold basic information about controls that can be added to the toolbars.
Define the structure of a toolbar with buttons that invoke ACTIONs.
virtual void UpdateToolbarControlSizes()
Update the sizes of any controls in the toolbars of the frame.
void RegisterCustomToolbarControlFactory(const ACTION_TOOLBAR_CONTROL &aControlDesc, const ACTION_TOOLBAR_CONTROL_FACTORY &aControlFactory)
Register a creation factory for toolbar controls that are present in this frame.
void configureToolbars() override
static TOOL_ACTION placeImage
Definition pl_actions.h:41
static TOOL_ACTION drawRectangle
Definition pl_actions.h:42
static TOOL_ACTION showInspector
Definition pl_actions.h:54
static TOOL_ACTION previewSettings
Definition pl_actions.h:55
static TOOL_ACTION layoutNormalMode
Definition pl_actions.h:49
static TOOL_ACTION placeText
Definition pl_actions.h:40
static TOOL_ACTION layoutEditMode
Definition pl_actions.h:50
static TOOL_ACTION appendImportedDrawingSheet
Definition pl_actions.h:44
static TOOL_ACTION drawLine
Definition pl_actions.h:43
static ACTION_TOOLBAR_CONTROL pageSelect
static ACTION_TOOLBAR_CONTROL originSelector
void configureToolbars() override
void UpdateToolbarControlSizes() override
Update the sizes of any controls in the toolbars of the frame.
wxChoice * m_originSelectBox
wxString m_originChoiceList[5]
wxChoice * m_pageSelectBox
std::optional< TOOLBAR_CONFIGURATION > DefaultToolbarConfig(TOOLBAR_LOC aToolbar) override
Get the default tools to show on the specified canvas toolbar.
#define _(s)
KICOMMON_API wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
Definition ui_common.cpp:78
@ ID_SELECT_PAGE_NUMBER
@ ID_SELECT_COORDINATE_ORIGIN
@ RIGHT
Toolbar on the right side of the canvas.
@ LEFT
Toolbar on the left side of the canvas.
@ TOP_AUX
Toolbar on the top of the canvas.
@ TOP_MAIN
Toolbar on the top of the canvas.