KiCad PCB EDA Suite
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 <wx/choice.h>
25
26#include "pl_editor_id.h"
27#include "pl_editor_frame.h"
28#include "tools/pl_actions.h"
29
31{
32 if( m_mainToolBar )
33 {
35 }
36 else
37 {
38 m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
39 KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
41 }
42
46
49
53
60
64
65 // Display mode switch
70
71 wxString choiceList[5] =
72 {
73 _("Left Top paper corner"),
74 _("Right Bottom page corner"),
75 _("Left Bottom page corner"),
76 _("Right Top page corner"),
77 _("Left Top page corner")
78 };
79
81 {
83 wxDefaultPosition, wxDefaultSize, 5, choiceList );
84 }
85
86
87 m_mainToolBar->AddControl( m_originSelectBox );
88 m_originSelectBox->SetToolTip( _("Origin of coordinates displayed to the status bar") );
89
90 int minwidth = 0;
91
92 for( int ii = 0; ii < 5; ii++ )
93 {
94 int width = KIUI::GetTextSize( choiceList[ii], m_originSelectBox ).x;
95 minwidth = std::max( minwidth, width );
96 }
97
98 m_originSelectBox->SetMinSize( wxSize( minwidth, -1 ) );
100
101 wxString pageList[5] =
102 {
103 _("Page 1"),
104 _("Other pages")
105 };
106
107 if( !m_pageSelectBox )
108 {
110 wxDefaultPosition, wxDefaultSize, 2, pageList );
111 }
112
113 m_mainToolBar->AddControl( m_pageSelectBox );
114 m_pageSelectBox->SetToolTip( _("Simulate page 1 or other pages to show how items\n"\
115 "which are not on all page are displayed") );
116 m_pageSelectBox->SetSelection( 0 );
117
118
119 // Go through and ensure the comboboxes are the correct size, since the strings in the
120 // box could have changed widths.
123
124 // after adding the buttons to the toolbar, must call Realize() to reflect the changes
126}
127
128
130{
131 if( m_drawToolBar )
132 {
134 }
135 else
136 {
137 m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
138 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
140 }
141
143
150
153
155}
156
157
159{
160 if( m_optionsToolBar )
161 {
163 }
164 else
165 {
167 wxDefaultPosition, wxDefaultSize,
168 KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
170 }
171
176
178}
179
180
182{
183 if( m_mainToolBar )
184 {
185 // Update the item widths
188 }
189}
static TOOL_ACTION toggleGrid
Definition: actions.h:143
static TOOL_ACTION zoomRedraw
Definition: actions.h:92
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
static TOOL_ACTION zoomOutCenter
Definition: actions.h:96
static TOOL_ACTION milsUnits
Definition: actions.h:148
static TOOL_ACTION open
Definition: actions.h:50
static TOOL_ACTION undo
Definition: actions.h:65
static TOOL_ACTION inchesUnits
Definition: actions.h:147
static TOOL_ACTION selectionTool
Definition: actions.h:156
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION zoomFitScreen
Definition: actions.h:98
static TOOL_ACTION redo
Definition: actions.h:66
static TOOL_ACTION deleteTool
Definition: actions.h:74
static TOOL_ACTION zoomTool
Definition: actions.h:101
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION doNew
Definition: actions.h:47
static TOOL_ACTION zoomInCenter
Definition: actions.h:95
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 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.
#define _(s)
@ ID_OPT_TOOLBAR
Definition: id.h:102
@ ID_V_TOOLBAR
Definition: id.h:101
@ ID_H_TOOLBAR
Definition: id.h:100
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:70
@ ID_SELECT_PAGE_NUMBER
Definition: pl_editor_id.h:39
@ ID_SELECT_COORDINATE_ORIGIN
Definition: pl_editor_id.h:38