KiCad PCB EDA Suite
toolbars_libedit.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 <ee_hotkeys.h>
28 #include <eeschema_id.h>
29 #include <tool/action_toolbar.h>
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 #include <tools/ee_actions.h>
37 
38 #ifdef __UNIX__
39 #define LISTBOX_WIDTH 140
40 #else
41 #define LISTBOX_WIDTH 120
42 #endif
43 
44 
46 {
47  if( m_drawToolBar )
48  m_drawToolBar->Clear();
49  else
50  m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
51  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
52 
53  // Set up toolbar
62 
63  m_drawToolBar->AddTool( ID_LIBEDIT_IMPORT_BODY_BUTT, wxEmptyString,
64  KiScaledBitmap( import_xpm, this ),
65  _( "Import existing drawings" ), wxITEM_CHECK );
66 
67  m_drawToolBar->AddTool( ID_LIBEDIT_EXPORT_BODY_BUTT, wxEmptyString,
68  KiScaledBitmap( export_xpm, this ),
69  _( "Export current drawing" ), wxITEM_CHECK );
70 
72 
73  m_drawToolBar->Realize();
74 }
75 
76 
78 {
79  wxString msg;
80 
81  if( m_mainToolBar )
82  m_mainToolBar->Clear();
83  else
84  m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
85  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
86 
87  // Set up toolbar
88  m_mainToolBar->AddTool( ID_LIBEDIT_NEW_PART, wxEmptyString,
89  KiScaledBitmap( new_component_xpm, this ),
90  _( "Create new symbol" ) );
91 
92  m_mainToolBar->AddTool( ID_LIBEDIT_SAVE_ALL, wxEmptyString,
93  KiScaledBitmap( save_xpm, this ),
94  _( "Save all changes" ) );
95 
96  m_mainToolBar->AddSeparator();
99 
100  m_mainToolBar->AddSeparator();
106 
107  m_mainToolBar->AddSeparator();
110 
112 
113  m_mainToolBar->AddTool( ID_LIBEDIT_VIEW_DOC, wxEmptyString,
114  KiScaledBitmap( datasheet_xpm, this ),
115  _( "Show associated datasheet or document" ) );
116 
117  m_mainToolBar->AddTool( ID_LIBEDIT_CHECK_PART, wxEmptyString, KiScaledBitmap( erc_xpm, this ),
118  _( "Check duplicate and off grid pins" ) );
119 
121 
122  m_mainToolBar->AddTool( ID_DE_MORGAN_NORMAL_BUTT, wxEmptyString,
123  KiScaledBitmap( morgan1_xpm, this ),
124  _( "Show as \"De Morgan\" normal symbol" ), wxITEM_CHECK );
125  m_mainToolBar->AddTool( ID_DE_MORGAN_CONVERT_BUTT, wxEmptyString,
126  KiScaledBitmap( morgan2_xpm, this ),
127  _( "Show as \"De Morgan\" convert symbol" ), wxITEM_CHECK );
128 
130 
131  m_partSelectBox = new wxComboBox( m_mainToolBar,
133  wxEmptyString,
134  wxDefaultPosition,
135  wxSize( LISTBOX_WIDTH, -1 ),
136  0, nullptr, wxCB_READONLY );
137  m_mainToolBar->AddControl( m_partSelectBox );
138 
140 
141  msg = _( "Synchronized pin edit mode\n"
142  "Synchronized pin edit mode propagates to other units all pin changes except pin number modification.\n"
143  "Enabled by default for multiunit parts with interchangeable units." );
144  m_mainToolBar->AddTool( ID_LIBEDIT_SYNC_PIN_EDIT, wxEmptyString,
145  KiScaledBitmap( pin2pin_xpm, this ), msg, wxITEM_CHECK );
146 
148 
149  m_mainToolBar->AddTool( ID_ADD_PART_TO_SCHEMATIC, wxEmptyString,
150  KiScaledBitmap( export_xpm, this ),
151  _( "Add symbol to schematic" ) );
152 
153  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
154  m_mainToolBar->Realize();
155 }
156 
157 
159 {
160  if( m_optionsToolBar )
161  m_optionsToolBar->Clear();
162  else
164  wxDefaultPosition, wxDefaultSize,
165  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
166 
167  ACTION_TOOLBAR* optToolbar = static_cast<ACTION_TOOLBAR*>( m_optionsToolBar );
168 
175 
176  m_optionsToolBar->Realize();
177 }
178 
179 
181 {
183  m_mainToolBar->Refresh();
184 
188 
191 
194 
195  m_optionsToolBar->Refresh();
196 
205 
206  m_drawToolBar->Refresh();
207 }
static TOOL_ACTION pinTable
Definition: ee_actions.h:166
static TOOL_ACTION placeSymbolText
Definition: ee_actions.h:107
Class ACTION_TOOLBAR.
static TOOL_ACTION drawSymbolLines
Definition: ee_actions.h:111
static TOOL_ACTION deleteItemCursor
Definition: ee_actions.h:167
static TOOL_ACTION zoomInCenter
Definition: actions.h:60
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
Definition: draw_frame.h:949
ACTION_TOOLBAR * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:166
static TOOL_ACTION zoomTool
Definition: actions.h:65
static const bool TOGGLE
virtual bool IsGridVisible() const
Definition: draw_frame.h:533
void Add(const TOOL_ACTION &aAction, bool aIsToggleEntry=false)
Function Add() Adds a TOOL_ACTION-based button to the toolbar.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:63
static TOOL_ACTION showComponentTree
Definition: ee_actions.h:174
ACTION_TOOLBAR * m_mainToolBar
Definition: draw_frame.h:156
#define LISTBOX_WIDTH
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
static TOOL_ACTION imperialUnits
Definition: actions.h:102
static TOOL_ACTION zoomOutCenter
Definition: actions.h:61
static TOOL_ACTION drawSymbolRectangle
Definition: ee_actions.h:108
static TOOL_ACTION placeSymbolPin
Definition: ee_actions.h:106
static TOOL_ACTION toggleGrid
Definition: actions.h:98
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:289
Definition: common.h:158
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:165
void SyncMenusAndToolbars() override
Update the toolbars and menus (mostly settings/check buttons/checkboxes) with the current controller ...
wxComboBox * m_partSelectBox
a Box to select a part to edit (if any)
static TOOL_ACTION drawSymbolCircle
Definition: ee_actions.h:109
Helper dialog and control classes.
static TOOL_ACTION showElectricalTypes
Definition: ee_actions.h:173
static TOOL_ACTION metricUnits
Definition: actions.h:103
static TOOL_ACTION redo
Definition: actions.h:51
void ReCreateHToolbar() override
static TOOL_ACTION zoomRedraw
Definition: actions.h:57
void Toggle(const TOOL_ACTION &aAction, bool aState)
static TOOL_ACTION drawSymbolArc
Definition: ee_actions.h:110
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 TOOL_ACTION undo
Definition: actions.h:50
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:68
static TOOL_ACTION selectionTool
Definition: ee_actions.h:76
strings common to toolbars and menubar
bool m_fullscreenCursor
Fullscreen crosshair or small cross
static TOOL_ACTION placeSymbolAnchor
Definition: ee_actions.h:112
int GetToolId() const
Definition: draw_frame.h:524
bool GetShowElectricalType()
Allow some frames to show/hide pin electrical type names.
ACTION_TOOLBAR * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:163
void ReCreateVToolbar() override