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