2011-10-28 13:43:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2017-12-26 14:38:45 +00:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2019-04-11 01:23:34 +00:00
|
|
|
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-28 13:43:37 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <eeschema_id.h>
|
|
|
|
#include <general.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <lib_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_helpers.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2019-06-01 22:23:53 +00:00
|
|
|
#include <lib_manager.h>
|
2019-11-06 19:15:42 +00:00
|
|
|
#include <class_libentry.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <tool/action_toolbar.h>
|
2019-05-14 19:21:10 +00:00
|
|
|
#include <tools/ee_actions.h>
|
2010-06-30 11:15:34 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#ifdef __UNIX__
|
|
|
|
#define LISTBOX_WIDTH 140
|
|
|
|
#else
|
|
|
|
#define LISTBOX_WIDTH 120
|
|
|
|
#endif
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::ReCreateVToolbar()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2018-01-08 04:05:03 +00:00
|
|
|
if( m_drawToolBar )
|
|
|
|
m_drawToolBar->Clear();
|
|
|
|
else
|
2019-05-14 19:21:10 +00:00
|
|
|
m_drawToolBar = new ACTION_TOOLBAR( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
|
|
|
KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
// Set up toolbar
|
2019-06-24 15:27:05 +00:00
|
|
|
m_drawToolBar->Add( ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE );
|
2019-05-15 22:49:48 +00:00
|
|
|
|
|
|
|
KiScaledSeparator( m_drawToolBar, this );
|
2019-05-14 19:21:10 +00:00
|
|
|
m_drawToolBar->Add( EE_ACTIONS::placeSymbolPin, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
m_drawToolBar->Add( EE_ACTIONS::placeSymbolText, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
m_drawToolBar->Add( EE_ACTIONS::drawSymbolRectangle, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
m_drawToolBar->Add( EE_ACTIONS::drawSymbolCircle, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
m_drawToolBar->Add( EE_ACTIONS::drawSymbolArc, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
m_drawToolBar->Add( EE_ACTIONS::drawSymbolLines, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
m_drawToolBar->Add( EE_ACTIONS::placeSymbolAnchor, ACTION_TOOLBAR::TOGGLE );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2018-03-16 12:38:36 +00:00
|
|
|
m_drawToolBar->AddTool( ID_LIBEDIT_IMPORT_BODY_BUTT, wxEmptyString,
|
|
|
|
KiScaledBitmap( import_xpm, this ),
|
2011-12-14 20:03:15 +00:00
|
|
|
_( "Import existing drawings" ), wxITEM_CHECK );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2018-03-16 12:38:36 +00:00
|
|
|
m_drawToolBar->AddTool( ID_LIBEDIT_EXPORT_BODY_BUTT, wxEmptyString,
|
|
|
|
KiScaledBitmap( export_xpm, this ),
|
2011-12-14 20:03:15 +00:00
|
|
|
_( "Export current drawing" ), wxITEM_CHECK );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2019-07-31 12:10:13 +00:00
|
|
|
m_drawToolBar->Add( ACTIONS::deleteTool, ACTION_TOOLBAR::TOGGLE );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2011-12-14 20:03:15 +00:00
|
|
|
m_drawToolBar->Realize();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::ReCreateHToolbar()
|
2007-08-30 08:15:05 +00:00
|
|
|
{
|
2018-01-08 04:05:03 +00:00
|
|
|
if( m_mainToolBar )
|
|
|
|
m_mainToolBar->Clear();
|
|
|
|
else
|
2019-05-14 19:21:10 +00:00
|
|
|
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
|
|
|
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
// Set up toolbar
|
2019-06-02 18:58:09 +00:00
|
|
|
m_mainToolBar->Add( EE_ACTIONS::newSymbol );
|
2019-05-26 23:00:27 +00:00
|
|
|
m_mainToolBar->Add( ACTIONS::saveAll );
|
2017-11-20 14:38:38 +00:00
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
m_mainToolBar->AddSeparator();
|
|
|
|
m_mainToolBar->Add( ACTIONS::undo );
|
|
|
|
m_mainToolBar->Add( ACTIONS::redo );
|
2017-11-20 14:38:38 +00:00
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
m_mainToolBar->AddSeparator();
|
|
|
|
m_mainToolBar->Add( ACTIONS::zoomRedraw );
|
|
|
|
m_mainToolBar->Add( ACTIONS::zoomInCenter );
|
|
|
|
m_mainToolBar->Add( ACTIONS::zoomOutCenter );
|
|
|
|
m_mainToolBar->Add( ACTIONS::zoomFitScreen );
|
|
|
|
m_mainToolBar->Add( ACTIONS::zoomTool, ACTION_TOOLBAR::TOGGLE );
|
2017-11-20 14:38:38 +00:00
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
m_mainToolBar->AddSeparator();
|
|
|
|
m_mainToolBar->Add( EE_ACTIONS::symbolProperties );
|
|
|
|
m_mainToolBar->Add( EE_ACTIONS::pinTable );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2018-01-08 04:05:03 +00:00
|
|
|
KiScaledSeparator( m_mainToolBar, this );
|
2019-06-01 18:36:49 +00:00
|
|
|
m_mainToolBar->Add( EE_ACTIONS::showDatasheet );
|
2019-06-02 18:58:09 +00:00
|
|
|
m_mainToolBar->Add( EE_ACTIONS::runERC );
|
2018-07-24 21:16:59 +00:00
|
|
|
|
|
|
|
KiScaledSeparator( m_mainToolBar, this );
|
2019-06-01 19:48:01 +00:00
|
|
|
m_mainToolBar->Add( EE_ACTIONS::showDeMorganStandard, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
m_mainToolBar->Add( EE_ACTIONS::showDeMorganAlternate, ACTION_TOOLBAR::TOGGLE );
|
2018-07-24 21:16:59 +00:00
|
|
|
|
2018-01-08 04:05:03 +00:00
|
|
|
KiScaledSeparator( m_mainToolBar, this );
|
2019-06-16 18:51:47 +00:00
|
|
|
m_unitSelectBox = new wxComboBox( m_mainToolBar, ID_LIBEDIT_SELECT_PART_NUMBER, wxEmptyString,
|
2019-06-01 18:36:49 +00:00
|
|
|
wxDefaultPosition, wxSize( LISTBOX_WIDTH, -1 ), 0, nullptr,
|
|
|
|
wxCB_READONLY );
|
2019-06-16 18:51:47 +00:00
|
|
|
m_mainToolBar->AddControl( m_unitSelectBox );
|
2011-12-09 16:37:11 +00:00
|
|
|
|
2018-01-08 04:05:03 +00:00
|
|
|
KiScaledSeparator( m_mainToolBar, this );
|
2019-06-16 18:51:47 +00:00
|
|
|
m_mainToolBar->Add( EE_ACTIONS::toggleSyncedPinsMode, ACTION_TOOLBAR::TOGGLE );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2019-04-15 21:09:14 +00:00
|
|
|
KiScaledSeparator( m_mainToolBar, this );
|
2019-06-16 18:51:47 +00:00
|
|
|
m_mainToolBar->Add( EE_ACTIONS::addSymbolToSchematic );
|
2019-04-15 21:09:14 +00:00
|
|
|
|
2011-02-23 14:20:01 +00:00
|
|
|
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
|
2011-12-16 13:32:23 +00:00
|
|
|
m_mainToolBar->Realize();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2011-02-23 14:20:01 +00:00
|
|
|
|
|
|
|
|
2018-01-08 04:05:03 +00:00
|
|
|
void LIB_EDIT_FRAME::ReCreateOptToolbar()
|
2011-02-23 14:20:01 +00:00
|
|
|
{
|
2011-12-14 20:03:15 +00:00
|
|
|
if( m_optionsToolBar )
|
2018-01-08 04:05:03 +00:00
|
|
|
m_optionsToolBar->Clear();
|
|
|
|
else
|
2019-05-14 19:21:10 +00:00
|
|
|
m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR,
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
|
2011-02-23 14:20:01 +00:00
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
ACTION_TOOLBAR* optToolbar = static_cast<ACTION_TOOLBAR*>( m_optionsToolBar );
|
2011-02-23 14:20:01 +00:00
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
optToolbar->Add( ACTIONS::toggleGrid, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
optToolbar->Add( ACTIONS::imperialUnits, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
optToolbar->Add( ACTIONS::metricUnits, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
optToolbar->Add( ACTIONS::toggleCursorStyle, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
optToolbar->Add( EE_ACTIONS::showElectricalTypes, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
optToolbar->Add( EE_ACTIONS::showComponentTree, ACTION_TOOLBAR::TOGGLE );
|
2017-10-31 11:13:20 +00:00
|
|
|
|
2011-12-14 20:03:15 +00:00
|
|
|
m_optionsToolBar->Realize();
|
2011-02-23 14:20:01 +00:00
|
|
|
}
|
2019-05-13 20:42:40 +00:00
|
|
|
|
|
|
|
|
2019-06-10 14:35:01 +00:00
|
|
|
void LIB_EDIT_FRAME::SyncToolbars()
|
2019-05-13 20:42:40 +00:00
|
|
|
{
|
2019-05-15 22:49:48 +00:00
|
|
|
KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions();
|
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
bool isEditable = m_my_part && m_my_part->IsRoot();
|
2019-12-02 20:24:16 +00:00
|
|
|
|
2019-12-19 15:34:01 +00:00
|
|
|
m_mainToolBar->Toggle( ACTIONS::saveAll, IsContentModified() );
|
|
|
|
m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 );
|
|
|
|
m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 );
|
2019-06-24 15:27:05 +00:00
|
|
|
m_mainToolBar->Toggle( ACTIONS::zoomTool, IsCurrentTool( ACTIONS::zoomTool ) );
|
2019-11-06 19:15:42 +00:00
|
|
|
m_mainToolBar->Toggle( EE_ACTIONS::showDatasheet, (bool) m_my_part );
|
2019-06-16 18:51:47 +00:00
|
|
|
m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganStandard,
|
|
|
|
GetShowDeMorgan(),
|
2019-06-01 19:48:01 +00:00
|
|
|
m_convert == LIB_ITEM::LIB_CONVERT::BASE );
|
2019-06-16 18:51:47 +00:00
|
|
|
m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganAlternate,
|
|
|
|
GetShowDeMorgan(),
|
2019-06-01 19:48:01 +00:00
|
|
|
m_convert == LIB_ITEM::LIB_CONVERT::DEMORGAN );
|
2019-11-06 19:15:42 +00:00
|
|
|
m_mainToolBar->Toggle( EE_ACTIONS::pinTable, isEditable );
|
2019-06-16 18:51:47 +00:00
|
|
|
m_mainToolBar->Toggle( EE_ACTIONS::toggleSyncedPinsMode,
|
2019-11-06 19:15:42 +00:00
|
|
|
m_my_part && m_my_part->IsMulti() && !m_my_part->UnitsLocked(),
|
2019-06-16 18:51:47 +00:00
|
|
|
m_SyncPinEdit );
|
2019-05-14 19:21:10 +00:00
|
|
|
m_mainToolBar->Refresh();
|
|
|
|
|
2019-05-15 22:49:48 +00:00
|
|
|
m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() );
|
2019-12-20 14:11:39 +00:00
|
|
|
m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != EDA_UNITS::INCHES );
|
|
|
|
m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == EDA_UNITS::INCHES );
|
2019-05-15 22:49:48 +00:00
|
|
|
m_optionsToolBar->Toggle( ACTIONS::toggleCursorStyle, galOpts.m_fullscreenCursor );
|
2019-05-14 19:21:10 +00:00
|
|
|
m_optionsToolBar->Toggle( EE_ACTIONS::showElectricalTypes, GetShowElectricalType() );
|
2019-05-15 22:49:48 +00:00
|
|
|
m_optionsToolBar->Toggle( EE_ACTIONS::showComponentTree, IsSearchTreeShown() );
|
2019-05-13 21:49:05 +00:00
|
|
|
m_optionsToolBar->Refresh();
|
2019-05-14 19:21:10 +00:00
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
#define TOGGLE_TOOL( toolbar, enable, tool ) toolbar->Toggle( tool, enable, IsCurrentTool( tool ) )
|
|
|
|
|
|
|
|
TOGGLE_TOOL( m_drawToolBar, isEditable, ACTIONS::selectionTool );
|
|
|
|
TOGGLE_TOOL( m_drawToolBar, isEditable, EE_ACTIONS::placeSymbolPin );
|
|
|
|
TOGGLE_TOOL( m_drawToolBar, isEditable, EE_ACTIONS::placeSymbolText );
|
|
|
|
TOGGLE_TOOL( m_drawToolBar, isEditable, EE_ACTIONS::drawSymbolRectangle );
|
|
|
|
TOGGLE_TOOL( m_drawToolBar, isEditable, EE_ACTIONS::drawSymbolCircle );
|
|
|
|
TOGGLE_TOOL( m_drawToolBar, isEditable, EE_ACTIONS::drawSymbolArc );
|
|
|
|
TOGGLE_TOOL( m_drawToolBar, isEditable, EE_ACTIONS::drawSymbolLines );
|
|
|
|
TOGGLE_TOOL( m_drawToolBar, isEditable, EE_ACTIONS::placeSymbolAnchor );
|
|
|
|
TOGGLE_TOOL( m_drawToolBar, isEditable, ACTIONS::deleteTool );
|
|
|
|
m_drawToolBar->EnableTool( ID_LIBEDIT_IMPORT_BODY_BUTT, isEditable );
|
|
|
|
m_drawToolBar->EnableTool( ID_LIBEDIT_EXPORT_BODY_BUTT, isEditable );
|
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
m_drawToolBar->Refresh();
|
2019-05-13 20:42:40 +00:00
|
|
|
}
|