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 KiCad Developers, see AUTHORS.txt for contributors.
5  * Copyright (C) 2013 CERN
6  * @author Jean-Pierre Charras, jp.charras at wanadoo.fr
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 
31 #include <fctsys.h>
32 
33 #include <common.h>
34 #include <macros.h>
35 #include <bitmaps.h>
36 #include <pl_editor_id.h>
37 #include <pl_editor_frame.h>
38 #include <hotkeys.h>
39 
41 {
42  if( m_mainToolBar != NULL )
43  return;
44 
45  wxString msg;
46 
47  // Standard file commands
48  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
49  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
50 
51  m_mainToolBar->AddTool( wxID_NEW, wxEmptyString, KiBitmap( pagelayout_new_xpm ),
52  _( "New page layout design" ) );
53 
54  m_mainToolBar->AddTool( wxID_OPEN, wxEmptyString, KiBitmap( pagelayout_load_xpm ),
55  _( "Load a page layout file. Previous data will be deleted" ) );
56 
57  m_mainToolBar->AddTool( wxID_SAVE, wxEmptyString, KiBitmap( save_project_xpm ),
58  _( "Save page layout design" ) );
59 
60  m_mainToolBar->AddSeparator();
61  m_mainToolBar->AddTool( ID_SHEET_SET, wxEmptyString, KiBitmap( sheetset_xpm ),
62  _( "Page settings" ) );
63 
64  m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, KiBitmap( print_button_xpm ),
65  _( "Print page layout" ) );
66 
67  m_mainToolBar->AddSeparator();
68  m_mainToolBar->AddTool( wxID_CUT, wxEmptyString, KiBitmap( delete_xpm ),
69  _( "Delete selected item" ) );
70 
71  m_mainToolBar->AddSeparator();
72  m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString,
73  KiBitmap( undo_xpm ), wxEmptyString );
74  m_mainToolBar->AddTool( wxID_REDO, wxEmptyString,
75  KiBitmap( redo_xpm ), wxEmptyString );
76 
77  // Standard Zoom controls:
78  m_mainToolBar->AddSeparator();
79  msg = AddHotkeyName( _( "Zoom in" ), PlEditorHokeysDescr, HK_ZOOM_IN, IS_COMMENT );
80  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiBitmap( zoom_in_xpm ), msg );
81 
82  msg = AddHotkeyName( _( "Zoom out" ), PlEditorHokeysDescr, HK_ZOOM_OUT, IS_COMMENT );
83  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiBitmap( zoom_out_xpm ), msg );
84 
85  msg = AddHotkeyName( _( "Redraw view" ), PlEditorHokeysDescr, HK_ZOOM_REDRAW, IS_COMMENT );
86  m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, KiBitmap( zoom_redraw_xpm ), msg );
87 
88  msg = AddHotkeyName( _( "Zoom auto" ), PlEditorHokeysDescr, HK_ZOOM_AUTO, IS_COMMENT );
89  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiBitmap( zoom_fit_in_page_xpm ), msg );
90 
91  // Zoom-to-selection
92  m_mainToolBar->AddSeparator();
93  m_mainToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiBitmap( cursor_xpm ),
94  wxEmptyString, wxITEM_CHECK );
95 
96  m_mainToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiBitmap( zoom_area_xpm ),
97  _( "Zoom to selection" ), wxITEM_CHECK );
98 
99  // Display mode switch
100  m_mainToolBar->AddSeparator();
101  m_mainToolBar->AddTool( ID_SHOW_REAL_MODE, wxEmptyString,
102  KiBitmap( pagelayout_normal_view_mode_xpm ),
103  _( "Show title block like it will be displayed in applications\n"
104  "texts with format are replaced by the full text"),
105  wxITEM_CHECK );
107  wxEmptyString, KiBitmap( pagelayout_special_view_mode_xpm ),
108  _( "Show title block in edit mode: texts are shown as is:\n"
109  "texts with format are displayed with no change"),
110  wxITEM_CHECK );
111 
112  m_mainToolBar->AddSeparator();
113 
114  wxString choiceList[5] =
115  {
116  _("Left Top paper corner"),
117  _("Right Bottom page corner"),
118  _("Left Bottom page corner"),
119  _("Right Top page corner"),
120  _("Left Top page corner")
121  };
122 
124  wxDefaultPosition, wxDefaultSize,
125  5, choiceList );
126  m_mainToolBar->AddControl( m_originSelectBox );
127  m_originSelectBox->SetToolTip( _(" Origin of coordinates displayed to the status bar") );
128 
129  int minwidth = 0;
130  for( int ii = 0; ii < 5; ii++ )
131  {
132  int width = GetTextSize( choiceList[ii], m_originSelectBox ).x;
133  minwidth = std::max( minwidth, width );
134  }
135  m_originSelectBox->SetMinSize( wxSize( minwidth, -1 ) );
136  m_originSelectBox->SetSelection( m_originSelectChoice );
137 
138  wxString pageList[5] =
139  {
140  _("Page 1"),
141  _("Other pages")
142  };
143 
145  wxDefaultPosition, wxDefaultSize,
146  2, pageList );
147  m_mainToolBar->AddControl( m_pageSelectBox );
148  m_pageSelectBox->SetToolTip( _("Simulate page 1 or other pages to show how items\n"\
149  "which are not on all page are displayed") );
150  m_pageSelectBox->SetSelection( 0 );
151 
152 
153  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
154  m_mainToolBar->Realize();
155 }
156 
157 
159 {
160  if( m_drawToolBar )
161  return;
162 
163  m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
164  wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
165 
166  // Set up toolbar
167  m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiBitmap( cursor_xpm ) );
168  m_drawToolBar->AddSeparator();
169 
170  m_drawToolBar->Realize();
171 }
172 
173 
175 {
176 }
void ReCreateVToolbar() override
creates or updates the right vertical toolbar.
Definition: id.h:232
This file contains miscellaneous commonly used macros and functions.
wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Function GetTextSize returns the size of aSingleLine of text when it is rendered in aWindow using wha...
Definition: common.cpp:93
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:122
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:135
wxChoice * m_pageSelectBox
wxString AddHotkeyName(const wxString &aText, EDA_HOTKEY **aList, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType)
Function AddHotkeyName Add the key name from the Command id value ( m_Idcommand member value) ...
#define max(a, b)
Definition: auxiliary.h:86
void ReCreateOptToolbar()
Create or update the left vertical toolbar (option toolbar.
struct EDA_HOTKEY_CONFIG PlEditorHokeysDescr[]
The common library.
void ReCreateHToolbar() override
wxChoice * m_originSelectBox