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-2018 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 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 
27 #include <fctsys.h>
28 
29 #include <common.h>
30 #include <macros.h>
31 #include <bitmaps.h>
32 #include <pl_editor_id.h>
33 #include <pl_editor_frame.h>
34 #include <hotkeys.h>
35 
37 {
38  if( m_mainToolBar )
39  m_mainToolBar->Clear();
40  else
41  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
42  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
43 
44  wxString msg;
45 
46  // Standard file commands
47  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
48  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
49 
50  m_mainToolBar->AddTool( wxID_NEW, wxEmptyString, KiScaledBitmap( new_page_layout_xpm, this ),
51  _( "New page layout design" ) );
52 
53  m_mainToolBar->AddTool( wxID_OPEN, wxEmptyString, KiScaledBitmap( open_page_layout_xpm, this ),
54  _( "Open an existing page layout design file" ) );
55 
56  m_mainToolBar->AddTool( wxID_SAVE, wxEmptyString, KiScaledBitmap( save_xpm, this ),
57  _( "Save page layout design" ) );
58 
60 
61  m_mainToolBar->AddTool( ID_SHEET_SET, wxEmptyString, KiScaledBitmap( sheetset_xpm, this ),
62  _( "Page settings" ) );
63 
64  m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, KiScaledBitmap( print_button_xpm, this ),
65  _( "Print page layout" ) );
66 
68 
69  m_mainToolBar->AddTool( wxID_CUT, wxEmptyString, KiScaledBitmap( delete_xpm, this ),
70  _( "Delete selected item" ) );
71 
73 
74  m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString,
75  KiScaledBitmap( undo_xpm, this ), _( "Undo" ) );
76 
77  m_mainToolBar->AddTool( wxID_REDO, wxEmptyString,
78  KiScaledBitmap( redo_xpm, this ), _( "Redo" ) );
79 
80  // Standard Zoom controls:
81  m_mainToolBar->AddSeparator();
82  msg = AddHotkeyName( _( "Redraw view" ), PlEditorHokeysDescr, HK_ZOOM_REDRAW, IS_COMMENT );
83  m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, KiScaledBitmap( zoom_redraw_xpm, this ), msg );
84 
85  msg = AddHotkeyName( _( "Zoom in" ), PlEditorHokeysDescr, HK_ZOOM_IN, IS_COMMENT );
86  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiScaledBitmap( zoom_in_xpm, this ), msg );
87 
88  msg = AddHotkeyName( _( "Zoom out" ), PlEditorHokeysDescr, HK_ZOOM_OUT, IS_COMMENT );
89  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiScaledBitmap( zoom_out_xpm, this ), msg );
90 
91  msg = AddHotkeyName( _( "Zoom auto" ), PlEditorHokeysDescr, HK_ZOOM_AUTO, IS_COMMENT );
92  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiScaledBitmap( zoom_fit_in_page_xpm, this ), msg );
93 
94  // Zoom-to-selection
95  m_mainToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiScaledBitmap( zoom_area_xpm, this ),
96  _( "Zoom to selection" ), wxITEM_CHECK );
97 
98  // Display mode switch
100  m_mainToolBar->AddTool( ID_SHOW_REAL_MODE, wxEmptyString,
101  KiScaledBitmap( pagelayout_normal_view_mode_xpm, this ),
102  _( "Show title block like it will be displayed in applications\n"
103  "texts with format are replaced by the full text"),
104  wxITEM_CHECK );
106  wxEmptyString, KiScaledBitmap( pagelayout_special_view_mode_xpm, this ),
107  _( "Show title block in edit mode: texts are shown as is:\n"
108  "texts with format are displayed with no change"),
109  wxITEM_CHECK );
110 
112 
113  wxString choiceList[5] =
114  {
115  _("Left Top paper corner"),
116  _("Right Bottom page corner"),
117  _("Left Bottom page corner"),
118  _("Right Top page corner"),
119  _("Left Top page corner")
120  };
121 
123  wxDefaultPosition, wxDefaultSize,
124  5, choiceList );
125  m_mainToolBar->AddControl( m_originSelectBox );
126  m_originSelectBox->SetToolTip( _("Origin of coordinates displayed to the status bar") );
127 
128  int minwidth = 0;
129  for( int ii = 0; ii < 5; ii++ )
130  {
131  int width = GetTextSize( choiceList[ii], m_originSelectBox ).x;
132  minwidth = std::max( minwidth, width );
133  }
134  m_originSelectBox->SetMinSize( wxSize( minwidth, -1 ) );
135  m_originSelectBox->SetSelection( m_originSelectChoice );
136 
137  wxString pageList[5] =
138  {
139  _("Page 1"),
140  _("Other pages")
141  };
142 
144  wxDefaultPosition, wxDefaultSize,
145  2, pageList );
146  m_mainToolBar->AddControl( m_pageSelectBox );
147  m_pageSelectBox->SetToolTip( _("Simulate page 1 or other pages to show how items\n"\
148  "which are not on all page are displayed") );
149  m_pageSelectBox->SetSelection( 0 );
150 
151 
152  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
153  m_mainToolBar->Realize();
154 }
155 
156 
158 {
159  if( m_drawToolBar )
160  m_drawToolBar->Clear();
161  else
162  m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
163  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
164 
165  // Set up toolbar
166  m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiScaledBitmap( cursor_xpm, this ) );
168 
169  m_drawToolBar->Realize();
170 }
171 
172 
174 {
175 }
void ReCreateVToolbar() override
creates or updates the right vertical toolbar.
Definition: id.h:241
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, EDA_BASE_FRAME *aWindow)
Function KiScaledBitmap Constructs a wxBitmap from a memory record, scaling it if device DPI demands ...
Definition: bitmap.cpp:114
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
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:126
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
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 KiScaledSeparator(wxAuiToolBar *aToolbar, EDA_BASE_FRAME *aWindow)
Function KiScaledSeparator Adds a separator to the given toolbar scaled the same way as KiScaledBitma...
Definition: bitmap.cpp:146
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
void ReCreateHToolbar() override
wxChoice * m_originSelectBox