KiCad PCB EDA Suite
tool_lib.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) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
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 
30 #include <fctsys.h>
31 #include <hotkeys.h>
32 #include <eeschema_id.h>
33 
34 #include <general.h>
35 #include <lib_edit_frame.h>
36 #include <dialog_helpers.h>
37 #include <bitmaps.h>
38 
39 #include <help_common_strings.h>
40 
41 #ifdef __UNIX__
42 #define LISTBOX_WIDTH 140
43 #else
44 #define LISTBOX_WIDTH 120
45 #endif
46 
47 
49 {
50  if( m_drawToolBar )
51  m_drawToolBar->Clear();
52  else
53  m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
54  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
55 
56  // Set up toolbar
57  m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiScaledBitmap( cursor_xpm, this ),
58  _( "Deselect current tool" ), wxITEM_CHECK );
59 
60  m_drawToolBar->AddTool( ID_LIBEDIT_PIN_BUTT, wxEmptyString, KiScaledBitmap( pin_xpm, this ),
61  HELP_ADD_PIN, wxITEM_CHECK );
62 
63  m_drawToolBar->AddTool( ID_LIBEDIT_BODY_TEXT_BUTT, wxEmptyString,
64  KiScaledBitmap( text_xpm, this ),
65  HELP_ADD_BODYTEXT, wxITEM_CHECK );
66 
67  m_drawToolBar->AddTool( ID_LIBEDIT_BODY_RECT_BUTT, wxEmptyString,
68  KiScaledBitmap( add_rectangle_xpm, this ),
69  HELP_ADD_BODYRECT, wxITEM_CHECK );
70 
71  m_drawToolBar->AddTool( ID_LIBEDIT_BODY_CIRCLE_BUTT, wxEmptyString,
72  KiScaledBitmap( add_circle_xpm, this ),
73  HELP_ADD_BODYCIRCLE, wxITEM_CHECK );
74 
75  m_drawToolBar->AddTool( ID_LIBEDIT_BODY_ARC_BUTT, wxEmptyString,
76  KiScaledBitmap( add_arc_xpm, this ),
77  HELP_ADD_BODYARC, wxITEM_CHECK );
78 
79  m_drawToolBar->AddTool( ID_LIBEDIT_BODY_LINE_BUTT, wxEmptyString,
80  KiScaledBitmap( add_polygon_xpm, this ),
81  HELP_ADD_BODYPOLYGON, wxITEM_CHECK );
82 
83  m_drawToolBar->AddTool( ID_LIBEDIT_ANCHOR_ITEM_BUTT, wxEmptyString,
84  KiScaledBitmap( anchor_xpm, this ),
85  _( "Move symbol anchor" ), wxITEM_CHECK );
86 
87  m_drawToolBar->AddTool( ID_LIBEDIT_IMPORT_BODY_BUTT, wxEmptyString,
88  KiScaledBitmap( import_xpm, this ),
89  _( "Import existing drawings" ), wxITEM_CHECK );
90 
91  m_drawToolBar->AddTool( ID_LIBEDIT_EXPORT_BODY_BUTT, wxEmptyString,
92  KiScaledBitmap( export_xpm, this ),
93  _( "Export current drawing" ), wxITEM_CHECK );
94 
95  m_drawToolBar->AddTool( ID_LIBEDIT_DELETE_ITEM_BUTT, wxEmptyString,
96  KiScaledBitmap( delete_xpm, this ),
97  HELP_DELETE_ITEMS, wxITEM_CHECK );
98 
99  m_drawToolBar->Realize();
100 }
101 
102 
104 {
105  wxString msg;
106 
107  if( m_mainToolBar )
108  m_mainToolBar->Clear();
109  else
110  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
111  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
112 
113  // Set up toolbar
114  m_mainToolBar->AddTool( ID_LIBEDIT_NEW_PART, wxEmptyString,
115  KiScaledBitmap( new_component_xpm, this ),
116  _( "Create new symbol" ) );
117 
118  m_mainToolBar->AddTool( ID_LIBEDIT_SAVE_ALL, wxEmptyString,
119  KiScaledBitmap( save_xpm, this ),
120  _( "Save all changes" ) );
121 
123 
125  m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString, KiScaledBitmap( undo_xpm, this ), msg );
126 
128  m_mainToolBar->AddTool( wxID_REDO, wxEmptyString, KiScaledBitmap( redo_xpm, this ), msg );
129 
131 
133  m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString,
134  KiScaledBitmap( zoom_redraw_xpm, this ), msg );
135 
137  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiScaledBitmap( zoom_in_xpm, this ), msg );
138 
140  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiScaledBitmap( zoom_out_xpm, this ), msg );
141 
142  msg = AddHotkeyName( _( "Zoom to fit symbol" ), g_Libedit_Hokeys_Descr,
144  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
145  KiScaledBitmap( zoom_fit_in_page_xpm, this ), msg );
146 
147  m_mainToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiScaledBitmap( zoom_area_xpm, this ),
148  _( "Zoom to selection" ), wxITEM_CHECK );
149 
151 
152  m_mainToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_PART, wxEmptyString,
153  KiScaledBitmap( part_properties_xpm, this ),
154  _( "Edit symbol properties" ) );
155 
156  m_mainToolBar->AddTool( ID_LIBEDIT_EDIT_PIN_BY_TABLE, wxEmptyString,
157  KiScaledBitmap( pin_table_xpm, this ),
158  _( "Show pin table" ) );
159 
161 
162  m_mainToolBar->AddTool( ID_LIBEDIT_VIEW_DOC, wxEmptyString,
163  KiScaledBitmap( datasheet_xpm, this ),
164  _( "Show associated datasheet or document" ) );
165 
166  m_mainToolBar->AddTool( ID_LIBEDIT_CHECK_PART, wxEmptyString, KiScaledBitmap( erc_xpm, this ),
167  _( "Check duplicate and off grid pins" ) );
168 
170 
171  m_mainToolBar->AddTool( ID_DE_MORGAN_NORMAL_BUTT, wxEmptyString,
172  KiScaledBitmap( morgan1_xpm, this ),
173  _( "Show as \"De Morgan\" normal symbol" ), wxITEM_CHECK );
174  m_mainToolBar->AddTool( ID_DE_MORGAN_CONVERT_BUTT, wxEmptyString,
175  KiScaledBitmap( morgan2_xpm, this ),
176  _( "Show as \"De Morgan\" convert symbol" ), wxITEM_CHECK );
177 
179 
180  m_partSelectBox = new wxComboBox( m_mainToolBar,
182  wxEmptyString,
183  wxDefaultPosition,
184  wxSize( LISTBOX_WIDTH, -1 ),
185  0, nullptr, wxCB_READONLY );
186  m_mainToolBar->AddControl( m_partSelectBox );
187 
189 
190  msg = _( "Synchronized pin edit mode\n"
191  "Synchronized pin edit mode propagates to other units all pin changes except pin number modification.\n"
192  "Enabled by default for multiunit parts with interchangeable units." );
193  m_mainToolBar->AddTool( ID_LIBEDIT_SYNC_PIN_EDIT, wxEmptyString,
194  KiScaledBitmap( pin2pin_xpm, this ), msg, wxITEM_CHECK );
195 
196  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
197  m_mainToolBar->Realize();
198 }
199 
200 
202 {
203  if( m_optionsToolBar )
204  m_optionsToolBar->Clear();
205  else
206  m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
207  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
208 
209  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString,
210  KiScaledBitmap( grid_xpm, this ),
211  _( "Turn grid off" ), wxITEM_CHECK );
212 
213  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
214  KiScaledBitmap( unit_inch_xpm, this ), _( "Set units to inches" ),
215  wxITEM_CHECK );
216 
217  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
218  KiScaledBitmap( unit_mm_xpm, this ),
219  _( "Set units to millimeters" ), wxITEM_CHECK );
220 
221 #ifndef __APPLE__
222  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
223  KiScaledBitmap( cursor_shape_xpm, this ),
224  _( "Change cursor shape" ), wxITEM_CHECK );
225 #else
226  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
227  KiScaledBitmap( cursor_shape_xpm, this ),
228  _( "Change cursor shape (not supported in Legacy Toolset)" ),
229  wxITEM_CHECK );
230 #endif
231 
232  m_optionsToolBar->AddTool( ID_LIBEDIT_SHOW_ELECTRICAL_TYPE, wxEmptyString,
233  KiScaledBitmap( pin_show_etype_xpm, this ),
234  _( "Show pins electrical type" ), wxITEM_CHECK );
235 
236  m_optionsToolBar->AddTool( ID_LIBEDIT_SHOW_HIDE_SEARCH_TREE, wxEmptyString,
237  KiScaledBitmap( search_tree_xpm, this ),
238  _( "Toggles the search tree" ), wxITEM_CHECK );
239 
240  m_optionsToolBar->Realize();
241 }
void ReCreateOptToolbar()
Definition: tool_lib.cpp:201
#define HELP_ADD_BODYRECT
#define HELP_ADD_BODYCIRCLE
Definition: id.h:241
struct EDA_HOTKEY_CONFIG g_Libedit_Hokeys_Descr[]
#define LISTBOX_WIDTH
Definition: tool_lib.cpp:44
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
#define HELP_ZOOM_OUT
Pcbnew hotkeys.
#define HELP_ZOOM_REDRAW
#define HELP_ADD_BODYPOLYGON
wxAuiToolBar * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:160
EDA_DRAW_FRAME::OnSelectGrid ID_TB_OPTIONS_SELECT_UNIT_INCH
wxComboBox * m_partSelectBox
a Box to select a part to edit (if any)
#define HELP_ADD_BODYTEXT
Helper dialog and control classes.
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:157
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
#define HELP_REDO
#define HELP_ADD_BODYARC
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) ...
void ReCreateHToolbar() override
Definition: tool_lib.cpp:103
#define HELP_ADD_PIN
#define HELP_ZOOM_IN
#define HELP_UNDO
These strings are used in menus and tools, that do the same command But they are internationalized, and therefore must be created at run time, on the fly.
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
Definition of class LIB_EDIT_FRAME.
static const char * text_xpm[]
strings common to toolbars and menubar
#define HELP_DELETE_ITEMS
void ReCreateVToolbar() override
Definition: tool_lib.cpp:48