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 (C) 2016-2019 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
33{
34 if( m_mainToolBar )
35 {
37 }
38 else
39 {
40 m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
41 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
43 }
44
48
51
55
62
66
67 // Display mode switch
72
73 wxString choiceList[5] =
74 {
75 _("Left Top paper corner"),
76 _("Right Bottom page corner"),
77 _("Left Bottom page corner"),
78 _("Right Top page corner"),
79 _("Left Top page corner")
80 };
81
83 {
85 wxDefaultPosition, wxDefaultSize, 5, choiceList );
86 }
87
88
89 m_mainToolBar->AddControl( m_originSelectBox );
90 m_originSelectBox->SetToolTip( _("Origin of coordinates displayed to the status bar") );
91
92 int minwidth = 0;
93
94 for( int ii = 0; ii < 5; ii++ )
95 {
96 int width = KIUI::GetTextSize( choiceList[ii], m_originSelectBox ).x;
97 minwidth = std::max( minwidth, width );
98 }
99
100 m_originSelectBox->SetMinSize( wxSize( minwidth, -1 ) );
102
103 wxString pageList[5] =
104 {
105 _("Page 1"),
106 _("Other pages")
107 };
108
109 if( !m_pageSelectBox )
110 {
112 wxDefaultPosition, wxDefaultSize, 2, pageList );
113 }
114
115 m_mainToolBar->AddControl( m_pageSelectBox );
116 m_pageSelectBox->SetToolTip( _("Simulate page 1 or other pages to show how items\n"\
117 "which are not on all page are displayed") );
118 m_pageSelectBox->SetSelection( 0 );
119
120
121 // Go through and ensure the comboboxes are the correct size, since the strings in the
122 // box could have changed widths.
125
126 // after adding the buttons to the toolbar, must call Realize() to reflect the changes
128}
129
130
132{
133 if( m_drawToolBar )
134 {
136 }
137 else
138 {
139 m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
140 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
142 }
143
145
152
155
157}
158
159
161{
162 if( m_optionsToolBar )
163 {
165 }
166 else
167 {
169 wxDefaultPosition, wxDefaultSize,
170 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
172 }
173
175 std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
176 gridMenu->Add( ACTIONS::gridProperties );
178
183
185}
186
187
189{
190 if( m_mainToolBar )
191 {
192 // Update the item widths
195 }
196}
static TOOL_ACTION gridProperties
Definition: actions.h:174
static TOOL_ACTION toggleGrid
Definition: actions.h:172
static TOOL_ACTION zoomRedraw
Definition: actions.h:114
static TOOL_ACTION millimetersUnits
Definition: actions.h:180
static TOOL_ACTION zoomOutCenter
Definition: actions.h:118
static TOOL_ACTION milsUnits
Definition: actions.h:179
static TOOL_ACTION open
Definition: actions.h:50
static TOOL_ACTION undo
Definition: actions.h:66
static TOOL_ACTION inchesUnits
Definition: actions.h:178
static TOOL_ACTION selectionTool
Definition: actions.h:187
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:124
static TOOL_ACTION redo
Definition: actions.h:67
static TOOL_ACTION deleteTool
Definition: actions.h:76
static TOOL_ACTION zoomTool
Definition: actions.h:127
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION doNew
Definition: actions.h:47
static TOOL_ACTION zoomInCenter
Definition: actions.h:117
Define the structure of a toolbar with buttons that invoke ACTIONs.
static constexpr bool TOGGLE
static constexpr bool CANCEL
void SetAuiManager(wxAuiManager *aManager)
Set the AUI manager that this toolbar belongs to.
void UpdateControlWidth(int aID)
Update the toolbar item width of a control using its best size.
void AddToolContextMenu(const TOOL_ACTION &aAction, std::unique_ptr< ACTION_MENU > aMenu)
Add a context menu to a specific tool item on the toolbar.
void AddScaledSeparator(wxWindow *aWindow)
Add a separator that introduces space on either side to not squash the tools when scaled.
bool KiRealize()
Use this over Realize() to avoid a rendering glitch with fixed orientation toolbars.
void ClearToolbar()
Clear the toolbar and remove all associated menus.
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false, bool aIsCancellable=false)
Add a TOOL_ACTION-based button to the toolbar.
static constexpr int KICAD_AUI_TB_STYLE
< Default style flags used for wxAUI toolbars.
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_optionsToolBar
ACTION_TOOLBAR * m_mainToolBar
ACTION_TOOLBAR * m_drawToolBar
static TOOL_ACTION placeImage
Definition: pl_actions.h:59
static TOOL_ACTION drawRectangle
Definition: pl_actions.h:60
static TOOL_ACTION showInspector
Definition: pl_actions.h:72
static TOOL_ACTION previewSettings
Definition: pl_actions.h:73
static TOOL_ACTION layoutNormalMode
Definition: pl_actions.h:67
static TOOL_ACTION placeText
Definition: pl_actions.h:58
static TOOL_ACTION layoutEditMode
Definition: pl_actions.h:68
static TOOL_ACTION appendImportedDrawingSheet
Definition: pl_actions.h:62
static TOOL_ACTION drawLine
Definition: pl_actions.h:61
void ReCreateOptToolbar() override
Create or update the left vertical toolbar.
void ReCreateHToolbar() override
void UpdateToolbarControlSizes() override
Update the sizes of any controls in the toolbars of the frame.
wxChoice * m_originSelectBox
wxChoice * m_pageSelectBox
void ReCreateVToolbar() override
Create or update the right vertical toolbar.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:167
#define _(s)
@ ID_OPT_TOOLBAR
Definition: id.h:102
@ ID_V_TOOLBAR
Definition: id.h:101
@ ID_H_TOOLBAR
Definition: id.h:100
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:74
@ ID_SELECT_PAGE_NUMBER
Definition: pl_editor_id.h:39
@ ID_SELECT_COORDINATE_ORIGIN
Definition: pl_editor_id.h:38