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-2020 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 <eeschema_id.h>
28 #include <general.h>
29 #include <lib_edit_frame.h>
30 #include <sch_painter.h>
31 #include <dialog_helpers.h>
32 #include <bitmaps.h>
33 #include <lib_manager.h>
34 #include <class_libentry.h>
35 #include <tool/action_toolbar.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 )
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
55 
64 
65  m_drawToolBar->AddTool( ID_LIBEDIT_IMPORT_BODY_BUTT, wxEmptyString,
66  KiScaledBitmap( import_xpm, this ),
67  _( "Import existing drawings" ), wxITEM_CHECK );
68 
69  m_drawToolBar->AddTool( ID_LIBEDIT_EXPORT_BODY_BUTT, wxEmptyString,
70  KiScaledBitmap( export_xpm, this ),
71  _( "Export current drawing" ), wxITEM_CHECK );
72 
74 
75  m_drawToolBar->Realize();
76 }
77 
78 
80 {
81  if( m_mainToolBar )
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
90 
94 
101 
105 
109 
113 
115 
116  if( m_unitSelectBox == nullptr )
118  wxEmptyString, wxDefaultPosition, wxSize( LISTBOX_WIDTH, -1 ), 0,
119  nullptr, wxCB_READONLY );
120  m_mainToolBar->AddControl( m_unitSelectBox );
121 
124 
127 
128  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
129  m_mainToolBar->Realize();
130 }
131 
132 
134 {
135  if( m_optionsToolBar )
137  else
139  wxDefaultPosition, wxDefaultSize,
140  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
141 
148 
149  m_optionsToolBar->Realize();
150 }
151 
152 
154 {
157 
158  bool isEditable = m_my_part && m_my_part->IsRoot();
159 
162  GetScreen() && GetScreen()->GetUndoCommandCount() > 0 );
164  GetScreen() && GetScreen()->GetRedoCommandCount() > 0 );
167  m_mainToolBar->Toggle( EE_ACTIONS::runERC, isEditable );
169  GetShowDeMorgan(),
170  m_convert == LIB_ITEM::LIB_CONVERT::BASE );
172  GetShowDeMorgan(),
173  m_convert == LIB_ITEM::LIB_CONVERT::DEMORGAN );
174  m_mainToolBar->Toggle( EE_ACTIONS::pinTable, isEditable );
177  m_SyncPinEdit );
178  m_mainToolBar->Refresh();
179 
188  m_optionsToolBar->Refresh();
189 
190 #define TOGGLE_TOOL( toolbar, enable, tool ) toolbar->Toggle( tool, enable, IsCurrentTool( tool ) )
191 
201  m_drawToolBar->EnableTool( ID_LIBEDIT_IMPORT_BODY_BUTT, isEditable );
202  m_drawToolBar->EnableTool( ID_LIBEDIT_EXPORT_BODY_BUTT, isEditable );
203 
204  m_drawToolBar->Refresh();
205 }
static TOOL_ACTION pinTable
Definition: ee_actions.h:145
#define TOGGLE_TOOL(toolbar, enable, tool)
static TOOL_ACTION showDatasheet
Inspection and Editing.
Definition: ee_actions.h:139
bool IsCurrentTool(const TOOL_ACTION &aAction) const
static TOOL_ACTION placeSymbolText
Definition: ee_actions.h:102
ACTION_TOOLBAR.
static TOOL_ACTION drawSymbolLines
Definition: ee_actions.h:106
static TOOL_ACTION zoomInCenter
Definition: actions.h:90
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
static TOOL_ACTION runERC
Definition: ee_actions.h:140
ACTION_TOOLBAR * m_optionsToolBar
static TOOL_ACTION zoomTool
Definition: actions.h:95
static const bool TOGGLE
void AddScaledSeparator(wxWindow *aWindow)
Add a separator that introduces space on either side to not squash the tools when scaled.
LIB_MANAGER * m_libMgr
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
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:93
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
static TOOL_ACTION showComponentTree
Definition: ee_actions.h:194
ACTION_TOOLBAR * m_mainToolBar
#define LISTBOX_WIDTH
static TOOL_ACTION showDeMorganAlternate
Definition: ee_actions.h:127
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, wxWindow *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:140
LIB_PART * m_my_part
static TOOL_ACTION zoomOutCenter
Definition: actions.h:91
static TOOL_ACTION drawSymbolRectangle
Definition: ee_actions.h:103
static TOOL_ACTION placeSymbolPin
Definition: ee_actions.h:101
void SyncToolbars() override
Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state.
bool GetShowDeMorgan() const
bool IsGridVisible() const
static TOOL_ACTION toggleGrid
Definition: actions.h:136
Class LIB_PIN definition.
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:144
const BITMAP_OPAQUE export_xpm[1]
Definition: export.cpp:75
const BITMAP_OPAQUE import_xpm[1]
Definition: import.cpp:68
static TOOL_ACTION drawSymbolCircle
Definition: ee_actions.h:104
Helper dialog and control classes.
void ReCreateOptToolbar() override
static TOOL_ACTION addSymbolToSchematic
Definition: ee_actions.h:162
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:126
static TOOL_ACTION showElectricalTypes
Definition: ee_actions.h:193
static TOOL_ACTION newSymbol
Definition: ee_actions.h:165
static TOOL_ACTION metricUnits
Definition: actions.h:141
static TOOL_ACTION redo
Definition: actions.h:68
void ReCreateHToolbar() override
bool m_SyncPinEdit
Set to true to synchronize pins at the same position when editing symbols with multiple units or mult...
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION zoomRedraw
Definition: actions.h:87
void Toggle(const TOOL_ACTION &aAction, bool aState)
Applies the default toggle action.
static TOOL_ACTION drawSymbolArc
Definition: ee_actions.h:105
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
bool IsMulti() const
bool HasModifications() const
Definition: lib_manager.cpp:66
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
SCH_RENDER_SETTINGS Stores schematic-specific render settings.
Definition: sch_painter.h:70
static TOOL_ACTION deleteTool
Definition: actions.h:75
static TOOL_ACTION toggleSyncedPinsMode
Definition: ee_actions.h:187
static TOOL_ACTION undo
Definition: actions.h:67
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:98
static TOOL_ACTION saveAll
Definition: actions.h:57
wxComboBox * m_unitSelectBox
bool m_fullscreenCursor
Fullscreen crosshair or small cross
bool UnitsLocked() const
Check whether part units are interchangeable.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
static TOOL_ACTION placeSymbolAnchor
Definition: ee_actions.h:107
static TOOL_ACTION selectionTool
Definition: actions.h:147
void ClearToolbar()
Clear the toolbar and remove all associated menus.
ACTION_TOOLBAR * m_drawToolBar
void ReCreateVToolbar() override