2013-07-19 18:27:22 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-05-20 10:23:32 +00:00
|
|
|
* Copyright (C) 2016-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-08-14 08:28:07 +00:00
|
|
|
* Copyright (C) 2013-2019 CERN
|
2013-08-13 17:51:22 +00:00
|
|
|
* @author Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2013-07-19 18:27:22 +00:00
|
|
|
*
|
2018-01-08 04:05:03 +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 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
2013-07-19 18:27:22 +00:00
|
|
|
*
|
2018-01-08 04:05:03 +00:00
|
|
|
* 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.
|
2013-07-19 18:27:22 +00:00
|
|
|
*
|
2018-01-08 04:05:03 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2013-07-19 18:27:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <bitmaps.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <tool/action_toolbar.h>
|
2021-06-03 11:49:49 +00:00
|
|
|
#include <wx/choice.h>
|
2020-10-13 05:04:31 +00:00
|
|
|
|
|
|
|
#include "pl_editor_id.h"
|
|
|
|
#include "pl_editor_frame.h"
|
|
|
|
#include "tools/pl_actions.h"
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
void PL_EDITOR_FRAME::ReCreateHToolbar()
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2018-01-08 04:05:03 +00:00
|
|
|
if( m_mainToolBar )
|
2020-09-26 23:55:59 +00:00
|
|
|
{
|
2020-06-23 10:42:23 +00:00
|
|
|
m_mainToolBar->ClearToolbar();
|
2020-09-26 23:55:59 +00:00
|
|
|
}
|
2018-01-08 04:05:03 +00:00
|
|
|
else
|
2020-09-26 23:55:59 +00:00
|
|
|
{
|
2019-05-14 19:21:10 +00:00
|
|
|
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
2020-11-06 01:56:02 +00:00
|
|
|
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
|
2020-09-26 23:55:59 +00:00
|
|
|
m_mainToolBar->SetAuiManager( &m_auimgr );
|
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2019-05-25 00:34:44 +00:00
|
|
|
m_mainToolBar->Add( ACTIONS::doNew );
|
|
|
|
m_mainToolBar->Add( ACTIONS::open );
|
|
|
|
m_mainToolBar->Add( ACTIONS::save );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-06-17 11:03:25 +00:00
|
|
|
m_mainToolBar->AddScaledSeparator( this );
|
2019-05-25 00:34:44 +00:00
|
|
|
m_mainToolBar->Add( ACTIONS::print );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-06-17 11:03:25 +00:00
|
|
|
m_mainToolBar->AddScaledSeparator( this );
|
2019-05-20 10:23:32 +00:00
|
|
|
m_mainToolBar->Add( ACTIONS::undo );
|
|
|
|
m_mainToolBar->Add( ACTIONS::redo );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-06-17 11:03:25 +00:00
|
|
|
m_mainToolBar->AddScaledSeparator( this );
|
2019-05-20 10:23:32 +00:00
|
|
|
m_mainToolBar->Add( ACTIONS::zoomRedraw );
|
|
|
|
m_mainToolBar->Add( ACTIONS::zoomInCenter );
|
|
|
|
m_mainToolBar->Add( ACTIONS::zoomOutCenter );
|
|
|
|
m_mainToolBar->Add( ACTIONS::zoomFitScreen );
|
2020-09-05 00:48:22 +00:00
|
|
|
m_mainToolBar->Add( ACTIONS::zoomTool, ACTION_TOOLBAR::TOGGLE, ACTION_TOOLBAR::CANCEL );
|
2017-06-06 13:35:20 +00:00
|
|
|
|
2020-06-17 11:03:25 +00:00
|
|
|
m_mainToolBar->AddScaledSeparator( this );
|
2019-06-14 18:14:41 +00:00
|
|
|
m_mainToolBar->Add( PL_ACTIONS::showInspector );
|
2019-07-10 22:15:57 +00:00
|
|
|
m_mainToolBar->Add( PL_ACTIONS::previewSettings );
|
2019-06-14 18:14:41 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
// Display mode switch
|
2020-06-17 11:03:25 +00:00
|
|
|
m_mainToolBar->AddScaledSeparator( this );
|
2020-07-29 23:50:25 +00:00
|
|
|
m_mainToolBar->Add( PL_ACTIONS::layoutNormalMode, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
m_mainToolBar->Add( PL_ACTIONS::layoutEditMode, ACTION_TOOLBAR::TOGGLE );
|
2020-06-17 11:03:25 +00:00
|
|
|
m_mainToolBar->AddScaledSeparator( this );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
wxString choiceList[5] =
|
|
|
|
{
|
|
|
|
_("Left Top paper corner"),
|
|
|
|
_("Right Bottom page corner"),
|
|
|
|
_("Left Bottom page corner"),
|
|
|
|
_("Right Top page corner"),
|
|
|
|
_("Left Top page corner")
|
|
|
|
};
|
|
|
|
|
2020-10-01 18:50:09 +00:00
|
|
|
if( !m_originSelectBox )
|
|
|
|
{
|
|
|
|
m_originSelectBox = new wxChoice( m_mainToolBar, ID_SELECT_COORDINATE_ORIGIN,
|
|
|
|
wxDefaultPosition, wxDefaultSize, 5, choiceList );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
m_mainToolBar->AddControl( m_originSelectBox );
|
2017-06-07 10:56:20 +00:00
|
|
|
m_originSelectBox->SetToolTip( _("Origin of coordinates displayed to the status bar") );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
int minwidth = 0;
|
2020-10-01 18:50:09 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
for( int ii = 0; ii < 5; ii++ )
|
|
|
|
{
|
2020-10-25 16:41:38 +00:00
|
|
|
int width = KIUI::GetTextSize( choiceList[ii], m_originSelectBox ).x;
|
2013-07-19 18:27:22 +00:00
|
|
|
minwidth = std::max( minwidth, width );
|
|
|
|
}
|
2020-10-01 18:50:09 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
m_originSelectBox->SetMinSize( wxSize( minwidth, -1 ) );
|
|
|
|
m_originSelectBox->SetSelection( m_originSelectChoice );
|
|
|
|
|
|
|
|
wxString pageList[5] =
|
|
|
|
{
|
|
|
|
_("Page 1"),
|
|
|
|
_("Other pages")
|
|
|
|
};
|
|
|
|
|
2020-10-01 18:50:09 +00:00
|
|
|
if( !m_pageSelectBox )
|
|
|
|
{
|
|
|
|
m_pageSelectBox = new wxChoice( m_mainToolBar, ID_SELECT_PAGE_NUMBER,
|
|
|
|
wxDefaultPosition, wxDefaultSize, 2, pageList );
|
|
|
|
}
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
m_mainToolBar->AddControl( m_pageSelectBox );
|
|
|
|
m_pageSelectBox->SetToolTip( _("Simulate page 1 or other pages to show how items\n"\
|
|
|
|
"which are not on all page are displayed") );
|
|
|
|
m_pageSelectBox->SetSelection( 0 );
|
|
|
|
|
|
|
|
|
2021-03-27 21:49:38 +00:00
|
|
|
// Go through and ensure the comboboxes are the correct size, since the strings in the
|
|
|
|
// box could have changed widths.
|
|
|
|
m_mainToolBar->UpdateControlWidth( ID_SELECT_COORDINATE_ORIGIN );
|
|
|
|
m_mainToolBar->UpdateControlWidth( ID_SELECT_PAGE_NUMBER );
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
|
2020-11-06 01:56:02 +00:00
|
|
|
m_mainToolBar->KiRealize();
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
void PL_EDITOR_FRAME::ReCreateVToolbar()
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
|
|
|
if( m_drawToolBar )
|
2020-09-26 23:55:59 +00:00
|
|
|
{
|
2020-06-23 10:42:23 +00:00
|
|
|
m_drawToolBar->ClearToolbar();
|
2020-09-26 23:55:59 +00:00
|
|
|
}
|
2018-01-08 04:05:03 +00:00
|
|
|
else
|
2020-09-26 23:55:59 +00:00
|
|
|
{
|
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 );
|
2020-09-26 23:55:59 +00:00
|
|
|
m_drawToolBar->SetAuiManager( &m_auimgr );
|
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2021-05-30 22:56:24 +00:00
|
|
|
m_drawToolBar->Add( ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2020-06-17 11:03:25 +00:00
|
|
|
m_drawToolBar->AddScaledSeparator( this );
|
2021-05-30 22:56:24 +00:00
|
|
|
m_drawToolBar->Add( PL_ACTIONS::drawLine, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
m_drawToolBar->Add( PL_ACTIONS::drawRectangle, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
m_drawToolBar->Add( PL_ACTIONS::placeText, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
m_drawToolBar->Add( PL_ACTIONS::placeImage, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
m_drawToolBar->Add( PL_ACTIONS::appendImportedDrawingSheet, ACTION_TOOLBAR::TOGGLE );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2020-06-17 11:03:25 +00:00
|
|
|
m_drawToolBar->AddScaledSeparator( this );
|
2021-05-30 22:56:24 +00:00
|
|
|
m_drawToolBar->Add( ACTIONS::deleteTool, ACTION_TOOLBAR::TOGGLE );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-11-06 01:56:02 +00:00
|
|
|
m_drawToolBar->KiRealize();
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
void PL_EDITOR_FRAME::ReCreateOptToolbar()
|
|
|
|
{
|
2020-12-09 01:50:03 +00:00
|
|
|
if( m_optionsToolBar )
|
|
|
|
{
|
|
|
|
m_optionsToolBar->ClearToolbar();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR,
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
|
|
|
|
m_optionsToolBar->SetAuiManager( &m_auimgr );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_optionsToolBar->Add( ACTIONS::toggleGrid, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
m_optionsToolBar->Add( ACTIONS::inchesUnits, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
m_optionsToolBar->Add( ACTIONS::milsUnits, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
m_optionsToolBar->Add( ACTIONS::millimetersUnits, ACTION_TOOLBAR::TOGGLE );
|
|
|
|
|
|
|
|
m_optionsToolBar->KiRealize();
|
2019-05-20 10:23:32 +00:00
|
|
|
}
|
2021-03-27 21:49:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
void PL_EDITOR_FRAME::UpdateToolbarControlSizes()
|
|
|
|
{
|
|
|
|
if( m_mainToolBar )
|
|
|
|
{
|
|
|
|
// Update the item widths
|
|
|
|
m_mainToolBar->UpdateControlWidth( ID_SELECT_COORDINATE_ORIGIN );
|
|
|
|
m_mainToolBar->UpdateControlWidth( ID_SELECT_PAGE_NUMBER );
|
|
|
|
}
|
|
|
|
}
|