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 <eeschema_id.h>
28 #include <general.h>
29 #include <lib_edit_frame.h>
30 #include <dialog_helpers.h>
31 #include <bitmaps.h>
32 #include <lib_manager.h>
33 #include <class_libentry.h>
34 #include <tool/action_toolbar.h>
35 #include <tools/ee_actions.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 ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
50  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
51 
52  // Set up toolbar
54 
63 
64  m_drawToolBar->AddTool( ID_LIBEDIT_IMPORT_BODY_BUTT, wxEmptyString,
65  KiScaledBitmap( import_xpm, this ),
66  _( "Import existing drawings" ), wxITEM_CHECK );
67 
68  m_drawToolBar->AddTool( ID_LIBEDIT_EXPORT_BODY_BUTT, wxEmptyString,
69  KiScaledBitmap( export_xpm, this ),
70  _( "Export current drawing" ), wxITEM_CHECK );
71 
73 
74  m_drawToolBar->Realize();
75 }
76 
77 
79 {
80  if( m_mainToolBar )
81  m_mainToolBar->Clear();
82  else
83  m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
84  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
85 
86  // Set up toolbar
89 
90  m_mainToolBar->AddSeparator();
93 
94  m_mainToolBar->AddSeparator();
100 
101  m_mainToolBar->AddSeparator();
104 
108 
112 
114  m_unitSelectBox = new wxComboBox( m_mainToolBar, ID_LIBEDIT_SELECT_PART_NUMBER, wxEmptyString,
115  wxDefaultPosition, wxSize( LISTBOX_WIDTH, -1 ), 0, nullptr,
116  wxCB_READONLY );
117  m_mainToolBar->AddControl( m_unitSelectBox );
118 
121 
124 
125  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
126  m_mainToolBar->Realize();
127 }
128 
129 
131 {
132  if( m_optionsToolBar )
133  m_optionsToolBar->Clear();
134  else
136  wxDefaultPosition, wxDefaultSize,
137  KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
138 
139  ACTION_TOOLBAR* optToolbar = static_cast<ACTION_TOOLBAR*>( m_optionsToolBar );
140 
147 
148  m_optionsToolBar->Realize();
149 }
150 
151 
153 {
155 
156  bool isEditable = m_my_part && m_my_part->IsRoot();
157 
159  m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 );
160  m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 );
164  GetShowDeMorgan(),
165  m_convert == LIB_ITEM::LIB_CONVERT::BASE );
167  GetShowDeMorgan(),
168  m_convert == LIB_ITEM::LIB_CONVERT::DEMORGAN );
169  m_mainToolBar->Toggle( EE_ACTIONS::pinTable, isEditable );
172  m_SyncPinEdit );
173  m_mainToolBar->Refresh();
174 
181  m_optionsToolBar->Refresh();
182 
183 #define TOGGLE_TOOL( toolbar, enable, tool ) toolbar->Toggle( tool, enable, IsCurrentTool( tool ) )
184 
194  m_drawToolBar->EnableTool( ID_LIBEDIT_IMPORT_BODY_BUTT, isEditable );
195  m_drawToolBar->EnableTool( ID_LIBEDIT_EXPORT_BODY_BUTT, isEditable );
196 
197  m_drawToolBar->Refresh();
198 }
static TOOL_ACTION pinTable
Definition: ee_actions.h:150
#define TOGGLE_TOOL(toolbar, enable, tool)
static TOOL_ACTION showDatasheet
Inspection and Editing.
Definition: ee_actions.h:143
static TOOL_ACTION placeSymbolText
Definition: ee_actions.h:105
ACTION_TOOLBAR.
static TOOL_ACTION drawSymbolLines
Definition: ee_actions.h:109
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:144
ACTION_TOOLBAR * m_optionsToolBar
static TOOL_ACTION zoomTool
Definition: actions.h:95
static const bool TOGGLE
virtual bool IsGridVisible() const
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
static TOOL_ACTION showComponentTree
Definition: ee_actions.h:191
ACTION_TOOLBAR * m_mainToolBar
#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 showDeMorganAlternate
Definition: ee_actions.h:129
static TOOL_ACTION imperialUnits
Definition: actions.h:136
LIB_PART * m_my_part
static TOOL_ACTION zoomOutCenter
Definition: actions.h:91
static TOOL_ACTION drawSymbolRectangle
Definition: ee_actions.h:106
static TOOL_ACTION placeSymbolPin
Definition: ee_actions.h:104
void SyncToolbars() override
Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state.
bool GetShowDeMorgan() const
static TOOL_ACTION toggleGrid
Definition: actions.h:132
Class LIB_PIN definition.
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:149
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:107
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:128
static TOOL_ACTION showElectricalTypes
Definition: ee_actions.h:190
bool IsContentModified() override
Get if any parts or libraries have been modified but not saved.
static TOOL_ACTION newSymbol
Definition: ee_actions.h:165
static TOOL_ACTION metricUnits
Definition: actions.h:137
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:31
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:108
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
bool IsMulti() const
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 deleteTool
Definition: actions.h:75
static TOOL_ACTION toggleSyncedPinsMode
Definition: ee_actions.h:184
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 IsCurrentTool(const TOOL_ACTION &aAction) const
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:110
static TOOL_ACTION selectionTool
Definition: actions.h:143
bool GetShowElectricalType()
Allow some frames to show/hide pin electrical type names.
ACTION_TOOLBAR * m_drawToolBar
void ReCreateVToolbar() override