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 
43  wxString msg;
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 
82  if( !m_originSelectBox )
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 ) );
101  m_originSelectBox->SetSelection( m_originSelectChoice );
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 
178 
180 }
181 
182 
184 {
185  if( m_mainToolBar )
186  {
187  // Update the item widths
190  }
191 }
Define the structure of a toolbar with buttons that invoke ACTIONs.
static TOOL_ACTION showInspector
Definition: pl_actions.h:72
static TOOL_ACTION zoomInCenter
Definition: actions.h:93
static TOOL_ACTION layoutEditMode
Definition: pl_actions.h:68
ACTION_TOOLBAR * m_optionsToolBar
static TOOL_ACTION drawLine
Definition: pl_actions.h:61
static constexpr bool TOGGLE
static TOOL_ACTION zoomTool
Definition: actions.h:99
void ReCreateVToolbar() override
Create or update the right vertical toolbar.
static TOOL_ACTION placeImage
Definition: pl_actions.h:59
void AddScaledSeparator(wxWindow *aWindow)
Add a separator that introduces space on either side to not squash the tools when scaled.
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false, bool aIsCancellable=false)
Add a TOOL_ACTION-based button to the toolbar.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
static TOOL_ACTION millimetersUnits
Definition: actions.h:146
void SetAuiManager(wxAuiManager *aManager)
Set the AUI manager that this toolbar belongs to.
void UpdateToolbarControlSizes() override
Update the sizes of any controls in the toolbars of the frame.
static TOOL_ACTION placeText
Definition: pl_actions.h:58
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_mainToolBar
static TOOL_ACTION print
Definition: actions.h:57
bool KiRealize()
Use this over Realize() to avoid a rendering glitch with fixed orientation toolbars.
static TOOL_ACTION zoomOutCenter
Definition: actions.h:94
static constexpr bool CANCEL
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:67
static TOOL_ACTION toggleGrid
Definition: actions.h:140
static TOOL_ACTION open
Definition: actions.h:50
static TOOL_ACTION inchesUnits
Definition: actions.h:144
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION doNew
Definition: actions.h:44
void UpdateControlWidth(int aID)
Update the toolbar item width of a control using its best size.
static TOOL_ACTION previewSettings
Definition: pl_actions.h:73
#define _(s)
static TOOL_ACTION drawRectangle
Definition: pl_actions.h:60
static TOOL_ACTION milsUnits
Definition: actions.h:145
wxChoice * m_pageSelectBox
static TOOL_ACTION redo
Definition: actions.h:65
void ReCreateOptToolbar() override
Create or update the left vertical toolbar.
static TOOL_ACTION appendImportedDrawingSheet
Definition: pl_actions.h:62
static TOOL_ACTION zoomRedraw
Definition: actions.h:90
static constexpr int KICAD_AUI_TB_STYLE
< Default style flags used for wxAUI toolbars.
static TOOL_ACTION deleteTool
Definition: actions.h:73
static TOOL_ACTION undo
Definition: actions.h:64
static TOOL_ACTION layoutNormalMode
Definition: pl_actions.h:67
void ReCreateHToolbar() override
wxChoice * m_originSelectBox
static TOOL_ACTION selectionTool
Definition: actions.h:153
void ClearToolbar()
Clear the toolbar and remove all associated menus.
ACTION_TOOLBAR * m_drawToolBar