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