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, KiScaledBitmap( text_xpm, this ),
64  HELP_ADD_BODYTEXT, wxITEM_CHECK );
65 
66  m_drawToolBar->AddTool( ID_LIBEDIT_BODY_RECT_BUTT, wxEmptyString, KiScaledBitmap( add_rectangle_xpm, this ),
67  HELP_ADD_BODYRECT, wxITEM_CHECK );
68 
69  m_drawToolBar->AddTool( ID_LIBEDIT_BODY_CIRCLE_BUTT, wxEmptyString, KiScaledBitmap( add_circle_xpm, this ),
70  HELP_ADD_BODYCIRCLE, wxITEM_CHECK );
71 
72  m_drawToolBar->AddTool( ID_LIBEDIT_BODY_ARC_BUTT, wxEmptyString, KiScaledBitmap( add_arc_xpm, this ),
73  HELP_ADD_BODYARC, wxITEM_CHECK );
74 
75  m_drawToolBar->AddTool( ID_LIBEDIT_BODY_LINE_BUTT, wxEmptyString, KiScaledBitmap( add_polygon_xpm, this ),
76  HELP_ADD_BODYPOLYGON, wxITEM_CHECK );
77 
78  m_drawToolBar->AddTool( ID_LIBEDIT_ANCHOR_ITEM_BUTT, wxEmptyString, KiScaledBitmap( anchor_xpm, this ),
79  _( "Move symbol anchor" ), wxITEM_CHECK );
80 
81  m_drawToolBar->AddTool( ID_LIBEDIT_IMPORT_BODY_BUTT, wxEmptyString, KiScaledBitmap( import_xpm, this ),
82  _( "Import existing drawings" ), wxITEM_CHECK );
83 
84  m_drawToolBar->AddTool( ID_LIBEDIT_EXPORT_BODY_BUTT, wxEmptyString, KiScaledBitmap( export_xpm, this ),
85  _( "Export current drawing" ), wxITEM_CHECK );
86 
87  m_drawToolBar->AddTool( ID_LIBEDIT_DELETE_ITEM_BUTT, wxEmptyString, KiScaledBitmap( delete_xpm, this ),
88  HELP_DELETE_ITEMS, wxITEM_CHECK );
89 
90  m_drawToolBar->Realize();
91 }
92 
93 
95 {
96  wxString msg;
97 
98  if( m_mainToolBar )
99  m_mainToolBar->Clear();
100  else
101  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
102  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
103 
104  // Set up toolbar
105  m_mainToolBar->AddTool( ID_LIBEDIT_NEW_LIBRARY, wxEmptyString,
106  KiScaledBitmap( new_library_xpm, this ),
107  _( "Create a new library" ) );
108 
109  m_mainToolBar->AddTool( ID_LIBEDIT_ADD_LIBRARY, wxEmptyString,
110  KiScaledBitmap( add_library_xpm, this ),
111  _( "Add an existing library" ) );
112 
113  m_mainToolBar->AddTool( ID_LIBEDIT_SAVE_LIBRARY, wxEmptyString,
114  KiScaledBitmap( save_library_xpm, this ),
115  _( "Save current library" ) );
116 
118 
119  m_mainToolBar->AddTool( ID_LIBEDIT_NEW_PART, wxEmptyString, KiScaledBitmap( new_component_xpm, this ),
120  _( "Create new symbol" ) );
121 
122  m_mainToolBar->AddTool( ID_LIBEDIT_SAVE_PART, wxEmptyString,
123  KiScaledBitmap( save_part_xpm, this ),
124  _( "Save current symbol" ) );
125 
126  m_mainToolBar->AddTool( ID_LIBEDIT_IMPORT_PART, wxEmptyString, KiScaledBitmap( import_part_xpm, this ),
127  _( "Import symbol" ) );
128 
129  m_mainToolBar->AddTool( ID_LIBEDIT_EXPORT_PART, wxEmptyString, KiScaledBitmap( export_part_xpm, this ),
130  _( "Export symbol" ) );
131 
133 
134  m_mainToolBar->AddTool( wxID_PASTE, wxEmptyString, KiScaledBitmap( paste_xpm, this ),
135  _( "Paste" ) );
136 
138 
140  m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString, KiScaledBitmap( undo_xpm, this ), msg );
141 
143  m_mainToolBar->AddTool( wxID_REDO, wxEmptyString, KiScaledBitmap( redo_xpm, this ), msg );
144 
146 
147  m_mainToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_PART, wxEmptyString,
148  KiScaledBitmap( part_properties_xpm, this ), _( "Edit symbol properties" ) );
149 
150  m_mainToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, wxEmptyString,
151  KiScaledBitmap( text_xpm, this ),
152  _( "Edit field properties" ) );
153 
155 
156  m_mainToolBar->AddTool( ID_LIBEDIT_CHECK_PART, wxEmptyString, KiScaledBitmap( erc_xpm, this ),
157  _( "Check duplicate and off grid pins" ) );
158 
160 
162  m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, KiScaledBitmap( zoom_redraw_xpm, this ), msg );
163 
165  m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiScaledBitmap( zoom_in_xpm, this ), msg );
166 
168  m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiScaledBitmap( zoom_out_xpm, this ), msg );
169 
171  m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiScaledBitmap( zoom_fit_in_page_xpm, this ), msg );
172 
173  m_mainToolBar->AddTool( ID_ZOOM_SELECTION, wxEmptyString, KiScaledBitmap( zoom_area_xpm, this ),
174  _( "Zoom to selection" ), wxITEM_CHECK );
175 
177 
178  m_mainToolBar->AddTool( ID_DE_MORGAN_NORMAL_BUTT, wxEmptyString, KiScaledBitmap( morgan1_xpm, this ),
179  _( "Show as \"De Morgan\" normal symbol" ), wxITEM_CHECK );
180  m_mainToolBar->AddTool( ID_DE_MORGAN_CONVERT_BUTT, wxEmptyString, KiScaledBitmap( morgan2_xpm, this ),
181  _( "Show as \"De Morgan\" convert symbol" ), wxITEM_CHECK );
182 
184 
185  m_mainToolBar->AddTool( ID_LIBEDIT_VIEW_DOC, wxEmptyString, KiScaledBitmap( datasheet_xpm, this ),
186  _( "Show associated datasheet or document" ) );
187 
189 
190  m_partSelectBox = new wxComboBox( m_mainToolBar,
192  wxEmptyString,
193  wxDefaultPosition,
194  wxSize( LISTBOX_WIDTH, -1 ),
195  0, nullptr, wxCB_READONLY );
196  m_mainToolBar->AddControl( m_partSelectBox );
197 
198  m_aliasSelectBox = new wxComboBox( m_mainToolBar,
200  wxEmptyString,
201  wxDefaultPosition,
202  wxSize( LISTBOX_WIDTH, -1 ),
203  0, nullptr, wxCB_READONLY );
204  m_mainToolBar->AddControl( m_aliasSelectBox );
205 
206  m_mainToolBar->AddSeparator();
208  msg = _( "Synchronized pin edit mode\n"
209  "Synchronized pin edit mode propagates to other units all pin changes except pin number modification.\n"
210  "Enabled by default for multiunit parts with interchangeable units." );
211  m_mainToolBar->AddTool( ID_LIBEDIT_SYNC_PIN_EDIT, wxEmptyString, KiScaledBitmap( pin2pin_xpm, this ),
212  msg, wxITEM_CHECK );
213  m_mainToolBar->AddTool( ID_LIBEDIT_EDIT_PIN_BY_TABLE, wxEmptyString, KiScaledBitmap( pin_table_xpm, this ),
214  _( "Show pin table" ) );
215 
216  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
217  m_mainToolBar->Realize();
218 }
219 
220 
222 {
223  if( m_optionsToolBar )
224  m_optionsToolBar->Clear();
225  else
226  m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
227  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
228 
229  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, KiScaledBitmap( grid_xpm, this ),
230  _( "Turn grid off" ), wxITEM_CHECK );
231 
232  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
233  KiScaledBitmap( unit_inch_xpm, this ), _( "Set units to inches" ),
234  wxITEM_CHECK );
235 
236  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
237  KiScaledBitmap( unit_mm_xpm, this ),
238  _( "Set units to millimeters" ), wxITEM_CHECK );
239 
240 #ifndef __APPLE__
241  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
242  KiScaledBitmap( cursor_shape_xpm, this ),
243  _( "Change cursor shape" ), wxITEM_CHECK );
244 #else
245  m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
246  KiScaledBitmap( cursor_shape_xpm, this ),
247  _( "Change cursor shape (not supported in Legacy Toolset)" ),
248  wxITEM_CHECK );
249 #endif
250 
251  m_optionsToolBar->AddTool( ID_LIBEDIT_SHOW_ELECTRICAL_TYPE, wxEmptyString,
252  KiScaledBitmap( pin_show_etype_xpm, this ),
253  _( "Show pins electrical type" ), wxITEM_CHECK );
254 
255  m_optionsToolBar->AddTool( ID_LIBEDIT_SHOW_HIDE_SEARCH_TREE, wxEmptyString,
256  KiScaledBitmap( search_tree_xpm, this ),
257  _( "Toggles the search tree" ), wxITEM_CHECK );
258 
259  m_optionsToolBar->Realize();
260 }
void ReCreateOptToolbar()
Definition: tool_lib.cpp:221
#define HELP_ADD_BODYRECT
#define HELP_ADD_BODYCIRCLE
#define HELP_ZOOM_FIT
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)
Function KiScaledBitmap Constructs a wxBitmap from a memory record, scaling it if device DPI demands ...
Definition: bitmap.cpp:114
#define HELP_ZOOM_OUT
EDA_DRAW_FRAME::OnSelectGrid ID_TB_OPTIONS_SELECT_UNIT_INCH
Definition: draw_frame.cpp:122
#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:129
strings common to toolbars and menubar
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:126
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:94
#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)
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
Definition of class LIB_EDIT_FRAME.
static const char * text_xpm[]
#define HELP_DELETE_ITEMS
wxComboBox * m_aliasSelectBox
a box to select the alias to edit (if any)
void ReCreateVToolbar() override
Definition: tool_lib.cpp:48