KiCad PCB EDA Suite
Loading...
Searching...
No Matches
toolbars_symbol_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 (C) 2004 Jean-Pierre Charras, [email protected]
5 * Copyright (C) 2008 Wayne Stambaugh <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <advanced_config.h>
27#include <eeschema_id.h>
28#include <symbol_edit_frame.h>
29#include <sch_painter.h>
33#include <tool/action_menu.h>
34#include <tool/action_toolbar.h>
35#include <tool/tool_manager.h>
37#include <tools/sch_actions.h>
42#include <wx/combobox.h>
43
44#ifdef __UNIX__
45#define LISTBOX_WIDTH 140
46#else
47#define LISTBOX_WIDTH 120
48#endif
49
50
51std::optional<TOOLBAR_CONFIGURATION> SYMBOL_EDIT_TOOLBAR_SETTINGS::DefaultToolbarConfig( TOOLBAR_LOC aToolbar )
52{
54
55 // clang-format off
56 switch( aToolbar )
57 {
59 return std::nullopt;
60
62 config.AppendAction( ACTIONS::toggleGrid )
63 .WithContextMenu(
64 []( TOOL_MANAGER* aToolMgr )
65 {
66 SCH_SELECTION_TOOL* selTool = aToolMgr->GetTool<SCH_SELECTION_TOOL>();
67 auto menu = std::make_unique<ACTION_MENU>( false, selTool );
68 menu->Add( ACTIONS::gridProperties );
69 return menu;
70 } )
71 .AppendAction( ACTIONS::toggleGridOverrides )
72 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
73 .AddAction( ACTIONS::millimetersUnits )
74 .AddAction( ACTIONS::inchesUnits )
75 .AddAction( ACTIONS::milsUnits ) )
76 .AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
79 .AddAction( ACTIONS::cursor45Crosshairs ) );
80
81 config.AppendSeparator()
83 .AppendAction( SCH_ACTIONS::showHiddenPins )
84 .AppendAction( SCH_ACTIONS::showHiddenFields );
85 // .AppendAction( SCH_ACTIONS::togglePinAltIcons );
86
87 if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
89
90 config.AppendSeparator()
91 .AppendAction( ACTIONS::showLibraryTree )
92 .AppendAction( ACTIONS::showProperties );
93 break;
94
96 config.AppendAction( ACTIONS::selectionTool );
97
98 config.AppendSeparator()
99 .AppendAction( SCH_ACTIONS::placeSymbolPin )
100 .AppendAction( SCH_ACTIONS::placeSymbolText )
101 .AppendAction( SCH_ACTIONS::drawSymbolTextBox )
102 .AppendAction( SCH_ACTIONS::drawRectangle )
103 .AppendAction( SCH_ACTIONS::drawCircle )
104 .AppendAction( SCH_ACTIONS::drawArc )
105 .AppendAction( SCH_ACTIONS::drawBezier )
106 .AppendAction( SCH_ACTIONS::drawSymbolLines )
107 .AppendAction( SCH_ACTIONS::drawSymbolPolygon )
108 .AppendAction( SCH_ACTIONS::placeSymbolAnchor )
109 .AppendAction( ACTIONS::deleteTool);
110 break;
111
113 config.AppendAction( SCH_ACTIONS::newSymbol );
114
115/* TODO (ISM): Handle visibility changes
116 if( !IsSymbolFromSchematic() )
117 config.AppendAction( ACTIONS::saveAll );
118 else
119 config.AppendAction( ACTIONS::save );
120*/
121
122 config.AppendSeparator()
123 .AppendAction( ACTIONS::undo )
124 .AppendAction( ACTIONS::redo );
125
126 config.AppendSeparator()
127 .AppendAction( ACTIONS::find )
128 .AppendAction( ACTIONS::findAndReplace );
129
130 config.AppendSeparator()
131 .AppendAction( ACTIONS::zoomRedraw )
132 .AppendAction( ACTIONS::zoomInCenter )
133 .AppendAction( ACTIONS::zoomOutCenter )
134 .AppendAction( ACTIONS::zoomFitScreen )
135 .AppendAction( ACTIONS::zoomTool );
136
137 config.AppendSeparator()
138 .AppendAction( SCH_ACTIONS::rotateCCW )
139 .AppendAction( SCH_ACTIONS::rotateCW )
140 .AppendAction( SCH_ACTIONS::mirrorV )
141 .AppendAction( SCH_ACTIONS::mirrorH );
142
143 config.AppendSeparator()
144 .AppendAction( SCH_ACTIONS::symbolProperties )
145 .AppendAction( SCH_ACTIONS::pinTable );
146
147 config.AppendSeparator()
148 .AppendAction( ACTIONS::showDatasheet )
149 .AppendAction( SCH_ACTIONS::checkSymbol );
150
151 config.AppendSeparator()
153
154 config.AppendSeparator()
156
157 config.AppendSeparator()
158 .AppendAction( SCH_ACTIONS::toggleSyncedPinsMode );
159
160 config.AppendSeparator()
161 .AppendAction( SCH_ACTIONS::addSymbolToSchematic );
162 break;
163 }
164
165 // clang-format on
166 return config;
167}
168
169
171{
173
174 auto unitDisplayFactory =
175 [this]( ACTION_TOOLBAR* aToolbar )
176 {
177 if( !m_unitSelectBox )
178 {
179 m_unitSelectBox = new wxComboBox( aToolbar, ID_LIBEDIT_SELECT_UNIT_NUMBER,
180 wxEmptyString, wxDefaultPosition,
181 wxSize( LISTBOX_WIDTH, -1 ), 0,
182 nullptr, wxCB_READONLY );
183 }
184
185 aToolbar->Add( m_unitSelectBox );
186 };
187
188 auto bodyDisplayFactory =
189 [this]( ACTION_TOOLBAR* aToolbar )
190 {
192 {
193 m_bodyStyleSelectBox = new wxComboBox( aToolbar, ID_LIBEDIT_SELECT_BODY_STYLE,
194 wxEmptyString, wxDefaultPosition,
195 wxSize( LISTBOX_WIDTH, -1 ), 0,
196 nullptr, wxCB_READONLY );
197 }
198
199 aToolbar->Add( m_bodyStyleSelectBox );
200 };
201
204}
205
206
208{
210
211 switch( aId )
212 {
213 case ID_LIBEDIT_SELECT_UNIT_NUMBER: m_unitSelectBox = nullptr; break;
215 }
216}
217
218
static TOOL_ACTION gridProperties
Definition actions.h:200
static TOOL_ACTION toggleGrid
Definition actions.h:198
static TOOL_ACTION zoomRedraw
Definition actions.h:132
static TOOL_ACTION millimetersUnits
Definition actions.h:206
static TOOL_ACTION showLibraryTree
Definition actions.h:164
static TOOL_ACTION cursorSmallCrosshairs
Definition actions.h:152
static TOOL_ACTION zoomOutCenter
Definition actions.h:136
static TOOL_ACTION showDatasheet
Definition actions.h:267
static TOOL_ACTION findAndReplace
Definition actions.h:118
static TOOL_ACTION milsUnits
Definition actions.h:205
static TOOL_ACTION toggleBoundingBoxes
Definition actions.h:157
static TOOL_ACTION undo
Definition actions.h:75
static TOOL_ACTION inchesUnits
Definition actions.h:204
static TOOL_ACTION selectionTool
Definition actions.h:251
static TOOL_ACTION zoomFitScreen
Definition actions.h:142
static TOOL_ACTION redo
Definition actions.h:76
static TOOL_ACTION deleteTool
Definition actions.h:86
static TOOL_ACTION zoomTool
Definition actions.h:146
static TOOL_ACTION cursor45Crosshairs
Definition actions.h:154
static TOOL_ACTION showProperties
Definition actions.h:266
static TOOL_ACTION zoomInCenter
Definition actions.h:135
static TOOL_ACTION toggleGridOverrides
Definition actions.h:199
static TOOL_ACTION cursorFullCrosshairs
Definition actions.h:153
static TOOL_ACTION find
Definition actions.h:117
static ACTION_TOOLBAR_CONTROL unitSelector
static ACTION_TOOLBAR_CONTROL bodyStyleSelector
Define the structure of a toolbar with buttons that invoke ACTIONs.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
virtual void ClearToolbarControl(int aId)
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.
virtual void configureToolbars()
static TOOL_ACTION rotateCCW
static TOOL_ACTION newSymbol
static TOOL_ACTION mirrorV
static TOOL_ACTION checkSymbol
static TOOL_ACTION drawArc
Definition sch_actions.h:97
static TOOL_ACTION pinTable
static TOOL_ACTION drawSymbolLines
static TOOL_ACTION placeSymbolPin
static TOOL_ACTION drawSymbolTextBox
static TOOL_ACTION drawRectangle
Definition sch_actions.h:95
static TOOL_ACTION drawCircle
Definition sch_actions.h:96
static TOOL_ACTION drawBezier
Definition sch_actions.h:98
static TOOL_ACTION rotateCW
static TOOL_ACTION showElectricalTypes
static TOOL_ACTION drawSymbolPolygon
static TOOL_ACTION showHiddenFields
static TOOL_ACTION placeSymbolAnchor
static TOOL_ACTION showHiddenPins
static TOOL_ACTION mirrorH
static TOOL_ACTION symbolProperties
static TOOL_ACTION placeSymbolText
static TOOL_ACTION toggleSyncedPinsMode
static TOOL_ACTION addSymbolToSchematic
wxComboBox * m_unitSelectBox
void ClearToolbarControl(int aId) override
void configureToolbars() override
wxComboBox * m_bodyStyleSelectBox
std::optional< TOOLBAR_CONFIGURATION > DefaultToolbarConfig(TOOLBAR_LOC aToolbar) override
Get the default tools to show on the specified canvas toolbar.
Master controller class:
#define _(s)
@ ID_LIBEDIT_SELECT_UNIT_NUMBER
Definition eeschema_id.h:65
@ ID_LIBEDIT_SELECT_BODY_STYLE
Definition eeschema_id.h:66
@ 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.
#define LISTBOX_WIDTH