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 
25 #include "pl_editor_id.h"
26 #include "pl_editor_frame.h"
27 #include "tools/pl_actions.h"
28 
30 {
31  if( m_mainToolBar )
32  {
34  }
35  else
36  {
37  m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
38  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
40  }
41 
42  wxString msg;
43 
47 
50 
54 
61 
65 
66  // Display mode switch
71 
72  wxString choiceList[5] =
73  {
74  _("Left Top paper corner"),
75  _("Right Bottom page corner"),
76  _("Left Bottom page corner"),
77  _("Right Top page corner"),
78  _("Left Top page corner")
79  };
80 
81  if( !m_originSelectBox )
82  {
84  wxDefaultPosition, wxDefaultSize, 5, choiceList );
85  }
86 
87 
88  m_mainToolBar->AddControl( m_originSelectBox );
89  m_originSelectBox->SetToolTip( _("Origin of coordinates displayed to the status bar") );
90 
91  int minwidth = 0;
92 
93  for( int ii = 0; ii < 5; ii++ )
94  {
95  int width = KIUI::GetTextSize( choiceList[ii], m_originSelectBox ).x;
96  minwidth = std::max( minwidth, width );
97  }
98 
99  m_originSelectBox->SetMinSize( wxSize( minwidth, -1 ) );
100  m_originSelectBox->SetSelection( m_originSelectChoice );
101 
102  wxString pageList[5] =
103  {
104  _("Page 1"),
105  _("Other pages")
106  };
107 
108  if( !m_pageSelectBox )
109  {
111  wxDefaultPosition, wxDefaultSize, 2, pageList );
112  }
113 
114  m_mainToolBar->AddControl( m_pageSelectBox );
115  m_pageSelectBox->SetToolTip( _("Simulate page 1 or other pages to show how items\n"\
116  "which are not on all page are displayed") );
117  m_pageSelectBox->SetSelection( 0 );
118 
119 
120  // Go through and ensure the comboboxes are the correct size, since the strings in the
121  // box could have changed widths.
124 
125  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
127 }
128 
129 
131 {
132  if( m_drawToolBar )
133  {
135  }
136  else
137  {
138  m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
139  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
141  }
142 
144 
151 
154 
156 }
157 
158 
160 {
161  if( m_optionsToolBar )
162  {
164  }
165  else
166  {
168  wxDefaultPosition, wxDefaultSize,
169  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
171  }
172 
177 
179 }
180 
181 
183 {
184  if( m_mainToolBar )
185  {
186  // Update the item widths
189  }
190 }
Define the structure of a toolbar with buttons that invoke ACTIONs.
static TOOL_ACTION showInspector
Definition: pl_actions.h:76
static TOOL_ACTION zoomInCenter
Definition: actions.h:96
static TOOL_ACTION layoutEditMode
Definition: pl_actions.h:72
ACTION_TOOLBAR * m_optionsToolBar
static TOOL_ACTION drawLine
Definition: pl_actions.h:65
static constexpr bool TOGGLE
static TOOL_ACTION zoomTool
Definition: actions.h:102
void ReCreateVToolbar() override
creates or updates the right vertical toolbar.
static TOOL_ACTION placeImage
Definition: pl_actions.h:63
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:99
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
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:62
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_mainToolBar
static TOOL_ACTION print
Definition: actions.h:60
bool KiRealize()
Use this over Realize() to avoid a rendering glitch with fixed orientation toolbars.
static TOOL_ACTION zoomOutCenter
Definition: actions.h:97
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:58
static TOOL_ACTION toggleGrid
Definition: actions.h:143
static TOOL_ACTION open
Definition: actions.h:53
static TOOL_ACTION inchesUnits
Definition: actions.h:147
static TOOL_ACTION save
Definition: actions.h:54
static TOOL_ACTION doNew
Definition: actions.h:47
void UpdateControlWidth(int aID)
Update the toolbar item width of a control using its best size.
static TOOL_ACTION previewSettings
Definition: pl_actions.h:77
static TOOL_ACTION drawRectangle
Definition: pl_actions.h:64
static TOOL_ACTION milsUnits
Definition: actions.h:148
wxChoice * m_pageSelectBox
static TOOL_ACTION redo
Definition: actions.h:68
void ReCreateOptToolbar() override
Create or update the left vertical toolbar (option toolbar.
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION zoomRedraw
Definition: actions.h:93
static TOOL_ACTION appendImportedWorksheet
Definition: pl_actions.h:66
static constexpr int KICAD_AUI_TB_STYLE
< Default style flags used for wxAUI toolbars.
static TOOL_ACTION deleteTool
Definition: actions.h:76
static TOOL_ACTION undo
Definition: actions.h:67
static TOOL_ACTION layoutNormalMode
Definition: pl_actions.h:71
void ReCreateHToolbar() override
wxChoice * m_originSelectBox
static TOOL_ACTION selectionTool
Definition: actions.h:156
void ClearToolbar()
Clear the toolbar and remove all associated menus.
ACTION_TOOLBAR * m_drawToolBar