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,
84  KiScaledBitmap( zoom_redraw_xpm, this ), msg );
85 
86  msg = AddHotkeyName( _( "Zoom in" ), PlEditorHokeysDescr, HK_ZOOM_IN, IS_COMMENT );
87  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiScaledBitmap( zoom_in_xpm, this ), msg );
88 
89  msg = AddHotkeyName( _( "Zoom out" ), PlEditorHokeysDescr, HK_ZOOM_OUT, IS_COMMENT );
90  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiScaledBitmap( zoom_out_xpm, this ), msg );
91 
92  msg = AddHotkeyName( _( "Zoom to fit page" ), PlEditorHokeysDescr, HK_ZOOM_AUTO, IS_COMMENT );
93  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
94  KiScaledBitmap( zoom_fit_in_page_xpm, this ), msg );
95 
96  // Zoom-to-selection
97  m_mainToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiScaledBitmap( zoom_area_xpm, this ),
98  _( "Zoom to selection" ), wxITEM_CHECK );
99 
100  // Display mode switch
102  m_mainToolBar->AddTool( ID_SHOW_REAL_MODE, wxEmptyString,
103  KiScaledBitmap( pagelayout_normal_view_mode_xpm, this ),
104  _( "Show title block like it will be displayed in applications\n"
105  "texts with format are replaced by the full text"),
106  wxITEM_CHECK );
108  wxEmptyString, KiScaledBitmap( pagelayout_special_view_mode_xpm, this ),
109  _( "Show title block in edit mode: texts are shown as is:\n"
110  "texts with format are displayed with no change"),
111  wxITEM_CHECK );
112 
114 
115  wxString choiceList[5] =
116  {
117  _("Left Top paper corner"),
118  _("Right Bottom page corner"),
119  _("Left Bottom page corner"),
120  _("Right Top page corner"),
121  _("Left Top page corner")
122  };
123 
125  wxDefaultPosition, wxDefaultSize,
126  5, choiceList );
127  m_mainToolBar->AddControl( m_originSelectBox );
128  m_originSelectBox->SetToolTip( _("Origin of coordinates displayed to the status bar") );
129 
130  int minwidth = 0;
131  for( int ii = 0; ii < 5; ii++ )
132  {
133  int width = GetTextSize( choiceList[ii], m_originSelectBox ).x;
134  minwidth = std::max( minwidth, width );
135  }
136  m_originSelectBox->SetMinSize( wxSize( minwidth, -1 ) );
137  m_originSelectBox->SetSelection( m_originSelectChoice );
138 
139  wxString pageList[5] =
140  {
141  _("Page 1"),
142  _("Other pages")
143  };
144 
146  wxDefaultPosition, wxDefaultSize,
147  2, pageList );
148  m_mainToolBar->AddControl( m_pageSelectBox );
149  m_pageSelectBox->SetToolTip( _("Simulate page 1 or other pages to show how items\n"\
150  "which are not on all page are displayed") );
151  m_pageSelectBox->SetSelection( 0 );
152 
153 
154  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
155  m_mainToolBar->Realize();
156 }
157 
158 
160 {
161  if( m_drawToolBar )
162  m_drawToolBar->Clear();
163  else
164  m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
165  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
166 
167  // Set up toolbar
168  m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString,
169  KiScaledBitmap( cursor_xpm, this ) );
171 
172  m_drawToolBar->Realize();
173 }
174 
175 
177 {
178 }
void ReCreateVToolbar() override
creates or updates the right vertical toolbar.
Definition: id.h:242
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:94
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:135
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