2013-07-19 20:27:22 +02:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2019-08-14 09:28:07 +01:00
|
|
|
* Copyright (C) 2013-2019 CERN
|
2013-08-13 19:51:22 +02:00
|
|
|
* @author Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2013-07-19 20:27:22 +02:00
|
|
|
*
|
2018-01-07 21:05:03 -07: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 20:27:22 +02:00
|
|
|
*
|
2018-01-07 21:05:03 -07: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 20:27:22 +02:00
|
|
|
*
|
2018-01-07 21:05:03 -07: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 20:27:22 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <bitmaps.h>
|
2019-06-09 22:57:23 +01:00
|
|
|
#include <tool/action_toolbar.h>
|
2023-04-29 18:16:34 +01:00
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tools/pl_actions.h>
|
|
|
|
#include <tools/pl_selection_tool.h>
|
2021-06-03 07:49:49 -04:00
|
|
|
#include <wx/choice.h>
|
2020-10-13 01:04:31 -04:00
|
|
|
|
|
|
|
#include "pl_editor_id.h"
|
|
|
|
#include "pl_editor_frame.h"
|
2013-07-19 20:27:22 +02:00
|
|
|
|
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
std::optional<TOOLBAR_CONFIGURATION> PL_EDITOR_FRAME::DefaultLeftToolbarConfig()
|
|
|
|
{
|
|
|
|
TOOLBAR_CONFIGURATION config;
|
2019-06-14 20:14:41 +02:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
// clang-format off
|
|
|
|
config.AppendAction( ACTIONS::toggleGrid )
|
|
|
|
.AppendAction( ACTIONS::inchesUnits )
|
|
|
|
.AppendAction( ACTIONS::milsUnits )
|
|
|
|
.AppendAction( ACTIONS::millimetersUnits );
|
2013-07-19 20:27:22 +02:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
/* TODO: Implement context menus
|
|
|
|
PL_SELECTION_TOOL* selTool = m_toolManager->GetTool<PL_SELECTION_TOOL>();
|
|
|
|
std::unique_ptr<ACTION_MENU> gridMenu = std::make_unique<ACTION_MENU>( false, selTool );
|
|
|
|
gridMenu->Add( ACTIONS::gridProperties );
|
|
|
|
m_tbLeft->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
|
|
|
|
*/
|
2020-10-01 19:50:09 +01:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
// clang-format on
|
|
|
|
return config;
|
|
|
|
}
|
2020-10-01 19:50:09 +01:00
|
|
|
|
2013-07-19 20:27:22 +02:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
std::optional<TOOLBAR_CONFIGURATION> PL_EDITOR_FRAME::DefaultRightToolbarConfig()
|
|
|
|
{
|
|
|
|
TOOLBAR_CONFIGURATION config;
|
2020-10-01 19:50:09 +01:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
// clang-format off
|
|
|
|
config.AppendAction( ACTIONS::selectionTool );
|
2020-10-01 19:50:09 +01:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( PL_ACTIONS::drawLine )
|
|
|
|
.AppendAction( PL_ACTIONS::drawRectangle )
|
|
|
|
.AppendAction( PL_ACTIONS::placeText )
|
|
|
|
.AppendAction( PL_ACTIONS::placeImage )
|
|
|
|
.AppendAction( PL_ACTIONS::appendImportedDrawingSheet );
|
2013-07-19 20:27:22 +02:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::deleteTool );
|
2013-07-19 20:27:22 +02:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
// clang-format on
|
|
|
|
return config;
|
|
|
|
}
|
2020-10-01 19:50:09 +01:00
|
|
|
|
2013-07-19 20:27:22 +02:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
std::optional<TOOLBAR_CONFIGURATION> PL_EDITOR_FRAME::DefaultTopMainToolbarConfig()
|
|
|
|
{
|
|
|
|
TOOLBAR_CONFIGURATION config;
|
2013-07-19 20:27:22 +02:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
// clang-format off
|
|
|
|
config.AppendAction( ACTIONS::doNew )
|
|
|
|
.AppendAction( ACTIONS::open )
|
|
|
|
.AppendAction( ACTIONS::save );
|
2021-03-27 21:49:38 +00:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::print );
|
2013-07-19 20:27:22 +02:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::undo )
|
|
|
|
.AppendAction( ACTIONS::redo );
|
2013-07-19 20:27:22 +02:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( ACTIONS::zoomRedraw )
|
|
|
|
.AppendAction( ACTIONS::zoomInCenter )
|
|
|
|
.AppendAction( ACTIONS::zoomOutCenter )
|
|
|
|
.AppendAction( ACTIONS::zoomFitScreen )
|
|
|
|
.AppendAction( ACTIONS::zoomTool );
|
2013-07-19 20:27:22 +02:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( PL_ACTIONS::showInspector )
|
|
|
|
.AppendAction( PL_ACTIONS::previewSettings );
|
2019-05-20 11:23:32 +01:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
// Display mode switch
|
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendAction( PL_ACTIONS::layoutNormalMode )
|
|
|
|
.AppendAction( PL_ACTIONS::layoutEditMode );
|
2019-05-20 11:23:32 +01:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
config.AppendSeparator()
|
|
|
|
.AppendControl( "control.PLEditorOrigin" )
|
|
|
|
.AppendControl( "control.PLEditorPageSelect" );
|
2013-07-19 20:27:22 +02:00
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
// clang-format on
|
|
|
|
return config;
|
2013-07-19 20:27:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-02-20 02:53:15 +00:00
|
|
|
void PL_EDITOR_FRAME::configureToolbars()
|
2019-05-20 11:23:32 +01:00
|
|
|
{
|
2025-02-20 02:53:15 +00:00
|
|
|
EDA_DRAW_FRAME::configureToolbars();
|
|
|
|
|
2025-02-20 12:42:39 +00:00
|
|
|
auto originSelectorFactory =
|
|
|
|
[this]( ACTION_TOOLBAR* aToolbar )
|
2025-02-20 02:53:15 +00:00
|
|
|
{
|
|
|
|
if( !m_originSelectBox )
|
|
|
|
{
|
|
|
|
m_originSelectBox = new wxChoice( aToolbar, ID_SELECT_COORDINATE_ORIGIN,
|
|
|
|
wxDefaultPosition, wxDefaultSize, 5, m_originChoiceList );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_originSelectBox->SetToolTip( _("Origin of coordinates displayed to the status bar") );
|
|
|
|
m_originSelectBox->SetSelection( m_originSelectChoice );
|
|
|
|
|
|
|
|
aToolbar->Add( m_originSelectBox );
|
|
|
|
};
|
|
|
|
|
|
|
|
RegisterCustomToolbarControlFactory( "control.PLEditorOrigin", _( "Origin Selector" ),
|
|
|
|
_( "Select the origin of the status bar coordinates" ),
|
|
|
|
originSelectorFactory );
|
|
|
|
|
|
|
|
|
2025-02-20 12:42:39 +00:00
|
|
|
auto pageSelectorFactory =
|
|
|
|
[this]( ACTION_TOOLBAR* aToolbar )
|
2025-02-20 02:53:15 +00:00
|
|
|
{
|
|
|
|
wxString pageList[5] =
|
|
|
|
{
|
|
|
|
_("Page 1"),
|
|
|
|
_("Other pages")
|
|
|
|
};
|
|
|
|
|
|
|
|
if( !m_pageSelectBox )
|
|
|
|
{
|
|
|
|
m_pageSelectBox = new wxChoice( aToolbar, ID_SELECT_PAGE_NUMBER,
|
|
|
|
wxDefaultPosition, wxDefaultSize, 2, pageList );
|
|
|
|
}
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
|
|
|
aToolbar->Add( m_pageSelectBox );
|
|
|
|
};
|
|
|
|
|
|
|
|
RegisterCustomToolbarControlFactory( "control.PLEditorPageSelect", _( "Page Selector" ),
|
|
|
|
_( "Select the page to simulate item displays" ),
|
|
|
|
pageSelectorFactory );
|
2019-05-20 11:23:32 +01:00
|
|
|
}
|
2021-03-27 21:49:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
void PL_EDITOR_FRAME::UpdateToolbarControlSizes()
|
|
|
|
{
|
2025-02-20 02:53:15 +00:00
|
|
|
// Ensure the origin selector is a minimum size
|
|
|
|
int minwidth = 0;
|
|
|
|
|
|
|
|
for( int ii = 0; ii < 5; ii++ )
|
2021-03-27 21:49:38 +00:00
|
|
|
{
|
2025-02-20 02:53:15 +00:00
|
|
|
int width = KIUI::GetTextSize( m_originChoiceList[ii], m_originSelectBox ).x;
|
|
|
|
minwidth = std::max( minwidth, width );
|
2021-03-27 21:49:38 +00:00
|
|
|
}
|
2025-02-20 02:53:15 +00:00
|
|
|
|
|
|
|
m_originSelectBox->SetMinSize( wxSize( minwidth, -1 ) );
|
|
|
|
|
|
|
|
// Base class actually will go through and update the sizes of the controls
|
|
|
|
EDA_DRAW_FRAME::UpdateToolbarControlSizes();
|
2021-03-27 21:49:38 +00:00
|
|
|
}
|