Move PLEditor to common actions for file ops.

This commit is contained in:
Jeff Young 2019-05-25 01:34:44 +01:00
parent a3dfce5adb
commit 8518c373d1
13 changed files with 307 additions and 179 deletions

View File

@ -33,6 +33,7 @@ set( PL_EDITOR_SRCS
tools/pl_selection_tool.cpp tools/pl_selection_tool.cpp
tools/pl_drawing_tools.cpp tools/pl_drawing_tools.cpp
tools/pl_edit_tool.cpp tools/pl_edit_tool.cpp
tools/pl_editor_control.cpp
tools/pl_picker_tool.cpp tools/pl_picker_tool.cpp
tools/pl_point_editor.cpp tools/pl_point_editor.cpp
tools/selection.cpp tools/selection.cpp

View File

@ -44,8 +44,12 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
wxMenuBar* oldMenuBar = GetMenuBar(); wxMenuBar* oldMenuBar = GetMenuBar();
wxMenuBar* menuBar = new wxMenuBar(); wxMenuBar* menuBar = new wxMenuBar();
auto modifiedDocumentCondition = [ this ] ( const SELECTION& sel ) {
return GetScreen() && GetScreen()->IsModify();
};
wxString msg; wxString msg;
static wxMenu* openRecentMenu; // Open Recent submenu, static ACTION_MENU* openRecentMenu; // Open Recent submenu,
// static to remember this menu // static to remember this menu
// Before deleting, remove the menus managed by m_fileHistory // Before deleting, remove the menus managed by m_fileHistory
@ -55,53 +59,37 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
// Recreate all menus: // Recreate all menus:
//
// File Menu: // File Menu:
wxMenu* fileMenu = new wxMenu; //
CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool );
msg = AddHotkeyName( _( "&New" ), PlEditorHotkeysDescr, HK_NEW ); openRecentMenu = new ACTION_MENU();
AddMenuItem( fileMenu, wxID_NEW, msg, openRecentMenu->SetTool( selTool );
_( "Create new page layout design" ), openRecentMenu->SetTitle( _( "Open Recent" ) );
KiBitmap( new_page_layout_xpm ) ); openRecentMenu->SetIcon( recent_xpm );
msg = AddHotkeyName( _( "&Open..." ), PlEditorHotkeysDescr, HK_OPEN );
AddMenuItem( fileMenu, wxID_OPEN, msg,
_( "Open an existing page layout design file" ),
KiBitmap( open_page_layout_xpm ) );
openRecentMenu = new wxMenu();
Kiface().GetFileHistory().UseMenu( openRecentMenu ); Kiface().GetFileHistory().UseMenu( openRecentMenu );
Kiface().GetFileHistory().AddFilesToMenu(); Kiface().GetFileHistory().AddFilesToMenu();
AddMenuItem( fileMenu, openRecentMenu, wxID_ANY, _( "Open &Recent" ),
_( "Open recent page layout design file" ), fileMenu->AddItem( ACTIONS::doNew, SELECTION_CONDITIONS::ShowAlways );
KiBitmap( recent_xpm ) ); fileMenu->AddItem( ACTIONS::open, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddMenu( openRecentMenu, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddSeparator();
fileMenu->AddItem( ACTIONS::save, modifiedDocumentCondition );
fileMenu->AddItem( ACTIONS::saveAs, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddSeparator();
fileMenu->AddItem( ACTIONS::pageSetup, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddItem( ACTIONS::print, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AppendSeparator(); fileMenu->AppendSeparator();
fileMenu->AddItem( ACTIONS::quit, SELECTION_CONDITIONS::ShowAlways );
msg = AddHotkeyName( _( "&Save" ), PlEditorHotkeysDescr, HK_SAVE ); //
AddMenuItem( fileMenu, wxID_SAVE, msg,
_( "Save current page layout design file" ),
KiBitmap( save_xpm ) );
msg = AddHotkeyName( _( "Save &As..." ), PlEditorHotkeysDescr, HK_SAVEAS );
AddMenuItem( fileMenu, wxID_SAVEAS, msg,
_( "Save current page layout design file with a different name" ),
KiBitmap( save_as_xpm ) );
fileMenu->AppendSeparator();
msg = AddHotkeyName( _( "&Print..." ), PlEditorHotkeysDescr, HK_PRINT );
AddMenuItem( fileMenu, wxID_PRINT, msg, KiBitmap( print_button_xpm ) );
AddMenuItem( fileMenu, wxID_PREVIEW, _( "Print Pre&view..." ), KiBitmap( print_button_xpm ) );
fileMenu->AppendSeparator();
AddMenuItem( fileMenu, wxID_EXIT, _( "&Close" ),
_( "Close Page Layout Editor" ),
KiBitmap( exit_xpm ) );
// Edit Menu: // Edit Menu:
//
CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, selTool ); CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, selTool );
auto enableUndoCondition = [ this ] ( const SELECTION& sel ) { auto enableUndoCondition = [ this ] ( const SELECTION& sel ) {
@ -115,10 +103,11 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
editMenu->AddItem( ACTIONS::redo, enableRedoCondition ); editMenu->AddItem( ACTIONS::redo, enableRedoCondition );
editMenu->AddSeparator(); editMenu->AddSeparator();
editMenu->AddItem( PL_ACTIONS::doDelete, SELECTION_CONDITIONS::MoreThan( 0 ) ); editMenu->AddItem( ACTIONS::doDelete, SELECTION_CONDITIONS::MoreThan( 0 ) );
//
// View Menu: // View Menu:
//
CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool ); CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool );
auto whiteBackgroundCondition = [ this ] ( const SELECTION& aSel ) { auto whiteBackgroundCondition = [ this ] ( const SELECTION& aSel ) {
@ -143,7 +132,9 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
viewMenu->AddCheckItem( ACTIONS::toggleGrid, gridShownCondition ); viewMenu->AddCheckItem( ACTIONS::toggleGrid, gridShownCondition );
viewMenu->AddCheckItem( ACTIONS::toggleCursorStyle, fullCrosshairCondition ); viewMenu->AddCheckItem( ACTIONS::toggleCursorStyle, fullCrosshairCondition );
//
// Place Menu: // Place Menu:
//
CONDITIONAL_MENU* placeMenu = new CONDITIONAL_MENU( false, selTool ); CONDITIONAL_MENU* placeMenu = new CONDITIONAL_MENU( false, selTool );
placeMenu->AddItem( PL_ACTIONS::drawLine, SELECTION_CONDITIONS::ShowAlways ); placeMenu->AddItem( PL_ACTIONS::drawLine, SELECTION_CONDITIONS::ShowAlways );
@ -154,7 +145,9 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
placeMenu->AddSeparator(); placeMenu->AddSeparator();
placeMenu->AddItem( PL_ACTIONS::appendImportedWorksheet, SELECTION_CONDITIONS::ShowAlways ); placeMenu->AddItem( PL_ACTIONS::appendImportedWorksheet, SELECTION_CONDITIONS::ShowAlways );
//
// Menu for preferences // Menu for preferences
//
wxMenu* preferencesMenu = new wxMenu; wxMenu* preferencesMenu = new wxMenu;
msg = AddHotkeyName( _( "&Preferences..." ), PlEditorHotkeysDescr, HK_PREFERENCES ); msg = AddHotkeyName( _( "&Preferences..." ), PlEditorHotkeysDescr, HK_PREFERENCES );

View File

@ -52,28 +52,18 @@
#include <tools/pl_picker_tool.h> #include <tools/pl_picker_tool.h>
#include <dialog_page_settings.h> #include <dialog_page_settings.h>
#include <invoke_pl_editor_dialog.h> #include <invoke_pl_editor_dialog.h>
#include <tools/pl_editor_control.h>
BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME ) BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME )
EVT_CLOSE( PL_EDITOR_FRAME::OnCloseWindow ) EVT_CLOSE( PL_EDITOR_FRAME::OnCloseWindow )
// Menu Files:
EVT_MENU( wxID_NEW, PL_EDITOR_FRAME::Files_io )
EVT_MENU( wxID_OPEN, PL_EDITOR_FRAME::Files_io )
EVT_MENU( wxID_SAVE, PL_EDITOR_FRAME::Files_io )
EVT_MENU( wxID_SAVEAS, PL_EDITOR_FRAME::Files_io )
EVT_MENU( wxID_FILE, PL_EDITOR_FRAME::Files_io ) EVT_MENU( wxID_FILE, PL_EDITOR_FRAME::Files_io )
EVT_MENU( ID_GEN_PLOT, PL_EDITOR_FRAME::ToPlotter )
EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, PL_EDITOR_FRAME::OnFileHistory ) EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, PL_EDITOR_FRAME::OnFileHistory )
EVT_MENU( wxID_EXIT, PL_EDITOR_FRAME::OnQuit )
// menu Preferences // menu Preferences
EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, PL_EDITOR_FRAME::Process_Special_Functions ) EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, PL_EDITOR_FRAME::Process_Special_Functions )
EVT_MENU( wxID_PREFERENCES, PL_EDITOR_FRAME::Process_Special_Functions ) EVT_MENU( wxID_PREFERENCES, PL_EDITOR_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_PRINT, PL_EDITOR_FRAME::ToPrinter )
EVT_TOOL( wxID_PREVIEW, PL_EDITOR_FRAME::ToPrinter )
EVT_TOOL( ID_SHEET_SET, PL_EDITOR_FRAME::Process_Special_Functions ) EVT_TOOL( ID_SHEET_SET, PL_EDITOR_FRAME::Process_Special_Functions )
EVT_TOOL( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode ) EVT_TOOL( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode )
EVT_TOOL( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode ) EVT_TOOL( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode )
@ -218,6 +208,7 @@ void PL_EDITOR_FRAME::setupTools()
m_toolManager->RegisterTool( new COMMON_TOOLS ); m_toolManager->RegisterTool( new COMMON_TOOLS );
m_toolManager->RegisterTool( new ZOOM_TOOL ); m_toolManager->RegisterTool( new ZOOM_TOOL );
m_toolManager->RegisterTool( new PL_SELECTION_TOOL ); m_toolManager->RegisterTool( new PL_SELECTION_TOOL );
m_toolManager->RegisterTool( new PL_EDITOR_CONTROL );
m_toolManager->RegisterTool( new PL_DRAWING_TOOLS ); m_toolManager->RegisterTool( new PL_DRAWING_TOOLS );
m_toolManager->RegisterTool( new PL_EDIT_TOOL ); m_toolManager->RegisterTool( new PL_EDIT_TOOL );
m_toolManager->RegisterTool( new PL_POINT_EDITOR ); m_toolManager->RegisterTool( new PL_POINT_EDITOR );
@ -304,10 +295,9 @@ void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event )
MAX_PAGE_SIZE_EDITORS_MILS ) ); MAX_PAGE_SIZE_EDITORS_MILS ) );
dlg.SetWksFileName( GetCurrFileName() ); dlg.SetWksFileName( GetCurrFileName() );
dlg.EnableWksFileNamePicker( false ); dlg.EnableWksFileNamePicker( false );
dlg.ShowModal();
cmd.SetId( ID_ZOOM_PAGE ); if( dlg.ShowModal() == wxID_OK )
wxPostEvent( this, cmd ); m_toolManager->RunAction( ACTIONS::zoomFitScreen );
} }
break; break;
@ -336,19 +326,7 @@ void PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode( wxCommandEvent& event )
} }
void PL_EDITOR_FRAME::OnQuit( wxCommandEvent& event ) void PL_EDITOR_FRAME::ToPrinter( bool doPreview )
{
Close( true );
}
void PL_EDITOR_FRAME::ToPlotter(wxCommandEvent& event)
{
wxMessageBox( wxT( "Not yet available" ) );
}
void PL_EDITOR_FRAME::ToPrinter(wxCommandEvent& event)
{ {
// static print data and page setup data, to remember settings during the session // static print data and page setup data, to remember settings during the session
static wxPrintData* s_PrintData; static wxPrintData* s_PrintData;
@ -386,7 +364,7 @@ void PL_EDITOR_FRAME::ToPrinter(wxCommandEvent& event)
*s_PrintData = s_pageSetupData->GetPrintData(); *s_PrintData = s_pageSetupData->GetPrintData();
if( event.GetId() == wxID_PREVIEW ) if( doPreview )
InvokeDialogPrintPreview( this, s_PrintData ); InvokeDialogPrintPreview( this, s_PrintData );
else else
InvokeDialogPrint( this, s_PrintData, s_pageSetupData ); InvokeDialogPrint( this, s_PrintData, s_pageSetupData );

View File

@ -223,12 +223,6 @@ public:
void OnUpdateTitleBlockDisplayNormalMode( wxUpdateUIEvent& event ); void OnUpdateTitleBlockDisplayNormalMode( wxUpdateUIEvent& event );
void OnUpdateTitleBlockDisplaySpecialMode( wxUpdateUIEvent& event ); void OnUpdateTitleBlockDisplaySpecialMode( wxUpdateUIEvent& event );
/**
* Function OnQuit
* called on request of application quit
*/
void OnQuit( wxCommandEvent& event );
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override; EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override;
@ -244,18 +238,11 @@ public:
bool OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition, bool OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition,
EDA_ITEM* aItem = NULL ) override; EDA_ITEM* aItem = NULL ) override;
/**
* Function ToPlotter
* Open a dialog frame to create plot and drill files
* relative to the current board
*/
void ToPlotter( wxCommandEvent& event );
/** /**
* Function ToPrinter * Function ToPrinter
* Open a dialog frame to print layers * Open a dialog frame to print layers
*/ */
void ToPrinter( wxCommandEvent& event ); void ToPrinter( bool doPreview );
void Files_io( wxCommandEvent& event ); void Files_io( wxCommandEvent& event );

View File

@ -1,7 +1,3 @@
/**
* @file pl_editor_id.h
*/
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
@ -32,11 +28,7 @@
#include <id.h> #include <id.h>
/** /**
* Command IDs for the printed circuit board editor. * Page layout editor IDs.
*
* Please add IDs that are unique to the page layout editor (pl_editor) here and not in
* the global id.h file. This will prevent the entire project from being rebuilt when
* adding new commands to the page layout editor.
*/ */
enum pl_editor_ids enum pl_editor_ids

View File

@ -39,22 +39,13 @@ void PL_EDITOR_FRAME::ReCreateHToolbar()
wxString msg; wxString msg;
m_mainToolBar->AddTool( wxID_NEW, wxEmptyString, KiScaledBitmap( new_page_layout_xpm, this ), m_mainToolBar->Add( ACTIONS::doNew );
_( "New page layout design" ) ); m_mainToolBar->Add( ACTIONS::open );
m_mainToolBar->Add( ACTIONS::save );
m_mainToolBar->AddTool( wxID_OPEN, wxEmptyString, KiScaledBitmap( open_page_layout_xpm, this ),
_( "Open an existing page layout design file" ) );
m_mainToolBar->AddTool( wxID_SAVE, wxEmptyString, KiScaledBitmap( save_xpm, this ),
_( "Save page layout design" ) );
KiScaledSeparator( m_mainToolBar, this ); KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->Add( ACTIONS::pageSetup );
m_mainToolBar->AddTool( ID_SHEET_SET, wxEmptyString, KiScaledBitmap( sheetset_xpm, this ), m_mainToolBar->Add( ACTIONS::print );
_( "Page settings" ) );
m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, KiScaledBitmap( print_button_xpm, this ),
_( "Print page layout" ) );
KiScaledSeparator( m_mainToolBar, this ); KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->Add( ACTIONS::undo ); m_mainToolBar->Add( ACTIONS::undo );
@ -155,6 +146,7 @@ void PL_EDITOR_FRAME::ReCreateOptToolbar()
void PL_EDITOR_FRAME::SyncMenusAndToolbars() void PL_EDITOR_FRAME::SyncMenusAndToolbars()
{ {
m_mainToolBar->Toggle( ACTIONS::save, GetScreen() && GetScreen()->IsModify() );
m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION ); m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION );

View File

@ -28,15 +28,6 @@
#include "pl_actions.h" #include "pl_actions.h"
TOOL_ACTION PL_ACTIONS::refreshPreview( "plEditor.EditorControl.refreshPreview",
AS_GLOBAL, 0, "", "" );
TOOL_ACTION PL_ACTIONS::toggleBackground( "plEditor.EditorControl.ToggleBackground",
AS_GLOBAL, 0,
_( "Background White" ), _( "Switch between white and black background" ),
palette_xpm );
OPT<TOOL_EVENT> PL_ACTIONS::TranslateLegacyId( int aId ) OPT<TOOL_EVENT> PL_ACTIONS::TranslateLegacyId( int aId )
{ {
switch( aId ) switch( aId )

View File

@ -73,7 +73,6 @@ public:
// Editing // Editing
static TOOL_ACTION move; static TOOL_ACTION move;
static TOOL_ACTION doDelete; // <<<<<<<< move to actions.h
// Miscellaneous // Miscellaneous
static TOOL_ACTION deleteItemCursor; static TOOL_ACTION deleteItemCursor;

View File

@ -55,11 +55,6 @@ TOOL_ACTION PL_ACTIONS::deleteItemCursor( "plEditor.InteractiveEdit.deleteTool",
_( "Delete Items" ), _( "Delete clicked items" ), _( "Delete Items" ), _( "Delete clicked items" ),
delete_xpm, AF_ACTIVATE ); delete_xpm, AF_ACTIVATE );
TOOL_ACTION PL_ACTIONS::doDelete( "plEditor.InteractiveEdit.delete",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DELETE ),
_( "Delete" ), _( "Deletes selected item(s)" ),
delete_xpm );
PL_EDIT_TOOL::PL_EDIT_TOOL() : PL_EDIT_TOOL::PL_EDIT_TOOL() :
TOOL_INTERACTIVE( "plEditor.InteractiveEdit" ), TOOL_INTERACTIVE( "plEditor.InteractiveEdit" ),
@ -408,7 +403,7 @@ void PL_EDIT_TOOL::setTransitions()
Go( &PL_EDIT_TOOL::Main, PL_ACTIONS::move.MakeEvent() ); Go( &PL_EDIT_TOOL::Main, PL_ACTIONS::move.MakeEvent() );
Go( &PL_EDIT_TOOL::ImportWorksheetContent, PL_ACTIONS::appendImportedWorksheet.MakeEvent() ); Go( &PL_EDIT_TOOL::ImportWorksheetContent, PL_ACTIONS::appendImportedWorksheet.MakeEvent() );
Go( &PL_EDIT_TOOL::DoDelete, PL_ACTIONS::doDelete.MakeEvent() ); Go( &PL_EDIT_TOOL::DoDelete, ACTIONS::doDelete.MakeEvent() );
Go( &PL_EDIT_TOOL::DeleteItemCursor, PL_ACTIONS::deleteItemCursor.MakeEvent() ); Go( &PL_EDIT_TOOL::DeleteItemCursor, PL_ACTIONS::deleteItemCursor.MakeEvent() );
Go( &PL_EDIT_TOOL::Undo, ACTIONS::undo.MakeEvent() ); Go( &PL_EDIT_TOOL::Undo, ACTIONS::undo.MakeEvent() );

View File

@ -0,0 +1,178 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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
*/
#include <fctsys.h>
#include <kiway.h>
#include <view/view.h>
#include <tool/tool_manager.h>
#include <tools/pl_actions.h>
#include <tools/pl_editor_control.h>
#include <tools/pl_selection_tool.h>
#include <pl_editor_frame.h>
#include <worksheet_painter.h>
#include <confirm.h>
#include <bitmaps.h>
#include <properties_frame.h>
TOOL_ACTION PL_ACTIONS::refreshPreview( "plEditor.EditorControl.refreshPreview",
AS_GLOBAL, 0, "", "" );
TOOL_ACTION PL_ACTIONS::toggleBackground( "plEditor.EditorControl.ToggleBackground",
AS_GLOBAL, 0,
_( "Background White" ), _( "Switch between white and black background" ),
palette_xpm );
bool PL_EDITOR_CONTROL::Init()
{
m_frame = getEditFrame<PL_EDITOR_FRAME>();
return true;
}
void PL_EDITOR_CONTROL::Reset( RESET_REASON aReason )
{
if( aReason == MODEL_RELOAD )
m_frame = getEditFrame<PL_EDITOR_FRAME>();
}
int PL_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )
{
wxCommandEvent evt( wxEVT_NULL, wxID_NEW );
m_frame->Files_io( evt );
return 0;
}
int PL_EDITOR_CONTROL::Open( const TOOL_EVENT& aEvent )
{
wxCommandEvent evt( wxEVT_NULL, wxID_OPEN );
m_frame->Files_io( evt );
return 0;
}
int PL_EDITOR_CONTROL::Save( const TOOL_EVENT& aEvent )
{
wxCommandEvent evt( wxEVT_NULL, wxID_SAVE );
m_frame->Files_io( evt );
return 0;
}
int PL_EDITOR_CONTROL::SaveAs( const TOOL_EVENT& aEvent )
{
wxCommandEvent evt( wxEVT_NULL, wxID_SAVEAS );
m_frame->Files_io( evt );
return 0;
}
int PL_EDITOR_CONTROL::PageSetup( const TOOL_EVENT& aEvent )
{
wxCommandEvent evt( wxEVT_NULL, ID_SHEET_SET );
m_frame->Process_Special_Functions( evt );
return 0;
}
int PL_EDITOR_CONTROL::Print( const TOOL_EVENT& aEvent )
{
m_frame->ToPrinter( false );
return 0;
}
int PL_EDITOR_CONTROL::Plot( const TOOL_EVENT& aEvent )
{
wxMessageBox( wxT( "Not yet available" ) );
return 0;
}
int PL_EDITOR_CONTROL::Quit( const TOOL_EVENT& aEvent )
{
m_frame->Close( false );
return 0;
}
int PL_EDITOR_CONTROL::ToggleBackgroundColor( const TOOL_EVENT& aEvent )
{
m_frame->SetDrawBgColor( m_frame->GetDrawBgColor() == WHITE ? BLACK : WHITE );
getView()->GetPainter()->GetSettings()->SetBackgroundColor( m_frame->GetDrawBgColor() );
m_frame->GetGalCanvas()->GetView()->UpdateAllLayersColor();
m_frame->GetCanvas()->Refresh();
return 0;
}
int PL_EDITOR_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
{
PL_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PL_SELECTION_TOOL>();
SELECTION& selection = selTool->GetSelection();
if( selection.GetSize() == 1 )
{
EDA_ITEM* item = (EDA_ITEM*) selection.Front();
MSG_PANEL_ITEMS msgItems;
item->GetMsgPanelInfo( m_frame->GetUserUnits(), msgItems );
m_frame->SetMsgPanel( msgItems );
WORKSHEET_DATAITEM* dataItem = static_cast<WS_DRAW_ITEM_BASE*>( item )->GetPeer();
m_frame->GetPropertiesFrame()->CopyPrmsFromItemToPanel( dataItem );
}
else
{
m_frame->ClearMsgPanel();
m_frame->GetPropertiesFrame()->CopyPrmsFromItemToPanel( nullptr );
}
m_frame->GetPropertiesFrame()->CopyPrmsFromGeneralToPanel();
return 0;
}
void PL_EDITOR_CONTROL::setTransitions()
{
Go( &PL_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
Go( &PL_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
Go( &PL_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
Go( &PL_EDITOR_CONTROL::SaveAs, ACTIONS::saveAs.MakeEvent() );
Go( &PL_EDITOR_CONTROL::PageSetup, ACTIONS::pageSetup.MakeEvent() );
Go( &PL_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
Go( &PL_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
Go( &PL_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
Go( &PL_EDITOR_CONTROL::ToggleBackgroundColor, PL_ACTIONS::toggleBackground.MakeEvent() );
Go( &PL_EDITOR_CONTROL::UpdateMessagePanel, EVENTS::SelectedEvent );
Go( &PL_EDITOR_CONTROL::UpdateMessagePanel, EVENTS::UnselectedEvent );
Go( &PL_EDITOR_CONTROL::UpdateMessagePanel, EVENTS::ClearedEvent );
Go( &PL_EDITOR_CONTROL::UpdateMessagePanel, EVENTS::SelectedItemsModified );
}

View File

@ -0,0 +1,77 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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
*/
#ifndef PL_EDITOR_CONTROL_H
#define PL_EDITOR_CONTROL_H
#include <tool/tool_interactive.h>
class PL_EDITOR_FRAME;
/**
* Class PL_EDITOR_CONTROL
*
* Handles actions specific to the schematic editor in eeschema.
*/
class PL_EDITOR_CONTROL : public wxEvtHandler, public TOOL_INTERACTIVE
{
public:
PL_EDITOR_CONTROL() :
TOOL_INTERACTIVE( "plEditor.EditorControl" ),
m_frame( nullptr )
{ }
~PL_EDITOR_CONTROL() { }
/// @copydoc TOOL_INTERACTIVE::Init()
bool Init() override;
/// @copydoc TOOL_INTERACTIVE::Reset()
void Reset( RESET_REASON aReason ) override;
int New( const TOOL_EVENT& aEvent );
int Open( const TOOL_EVENT& aEvent );
int Save( const TOOL_EVENT& aEvent );
int SaveAs( const TOOL_EVENT& aEvent );
int PageSetup( const TOOL_EVENT& aEvent );
int Print( const TOOL_EVENT& aEvent );
int Plot( const TOOL_EVENT& aEvent );
int Quit( const TOOL_EVENT& aEvent );
int ToggleBackgroundColor( const TOOL_EVENT& aEvent );
int UpdateMessagePanel( const TOOL_EVENT& aEvent );
private:
///> Sets up handlers for various events.
void setTransitions() override;
private:
PL_EDITOR_FRAME* m_frame;
};
#endif // PL_EDITOR_CONTROL_H

View File

@ -22,11 +22,9 @@
*/ */
#include <menus_helpers.h> #include <bitmaps.h>
#include <hotkeys.h>
#include <view/view.h> #include <view/view.h>
#include <view/view_controls.h> #include <view/view_controls.h>
#include <view/view_group.h>
#include <preview_items/selection_area.h> #include <preview_items/selection_area.h>
#include <pl_editor_frame.h> #include <pl_editor_frame.h>
#include <tool/tool_event.h> #include <tool/tool_event.h>
@ -37,7 +35,6 @@
#include <worksheet_painter.h> #include <worksheet_painter.h>
#include <ws_draw_item.h> #include <ws_draw_item.h>
#include <collector.h> #include <collector.h>
#include <properties_frame.h>
#include "pl_selection_tool.h" #include "pl_selection_tool.h"
/** /**
@ -712,46 +709,6 @@ bool PL_SELECTION_TOOL::selectionContains( const VECTOR2I& aPoint ) const
} }
int PL_SELECTION_TOOL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
{
PL_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PL_SELECTION_TOOL>();
SELECTION& selection = selTool->GetSelection();
if( selection.GetSize() == 1 )
{
EDA_ITEM* item = (EDA_ITEM*) selection.Front();
MSG_PANEL_ITEMS msgItems;
item->GetMsgPanelInfo( m_frame->GetUserUnits(), msgItems );
m_frame->SetMsgPanel( msgItems );
WORKSHEET_DATAITEM* dataItem = static_cast<WS_DRAW_ITEM_BASE*>( item )->GetPeer();
m_frame->GetPropertiesFrame()->CopyPrmsFromItemToPanel( dataItem );
}
else
{
m_frame->ClearMsgPanel();
m_frame->GetPropertiesFrame()->CopyPrmsFromItemToPanel( nullptr );
}
m_frame->GetPropertiesFrame()->CopyPrmsFromGeneralToPanel();
return 0;
}
int PL_SELECTION_TOOL::ToggleBackgroundColor( const TOOL_EVENT& aEvent )
{
m_frame->SetDrawBgColor( m_frame->GetDrawBgColor() == WHITE ? BLACK : WHITE );
getView()->GetPainter()->GetSettings()->SetBackgroundColor( m_frame->GetDrawBgColor() );
m_frame->GetGalCanvas()->GetView()->UpdateAllLayersColor();
m_frame->GetCanvas()->Refresh();
return 0;
}
void PL_SELECTION_TOOL::setTransitions() void PL_SELECTION_TOOL::setTransitions()
{ {
Go( &PL_SELECTION_TOOL::UpdateMenu, ACTIONS::updateMenu.MakeEvent() ); Go( &PL_SELECTION_TOOL::UpdateMenu, ACTIONS::updateMenu.MakeEvent() );
@ -764,13 +721,6 @@ void PL_SELECTION_TOOL::setTransitions()
Go( &PL_SELECTION_TOOL::RemoveItemFromSel, PL_ACTIONS::removeItemFromSel.MakeEvent() ); Go( &PL_SELECTION_TOOL::RemoveItemFromSel, PL_ACTIONS::removeItemFromSel.MakeEvent() );
Go( &PL_SELECTION_TOOL::RemoveItemsFromSel, PL_ACTIONS::removeItemsFromSel.MakeEvent() ); Go( &PL_SELECTION_TOOL::RemoveItemsFromSel, PL_ACTIONS::removeItemsFromSel.MakeEvent() );
Go( &PL_SELECTION_TOOL::SelectionMenu, PL_ACTIONS::selectionMenu.MakeEvent() ); Go( &PL_SELECTION_TOOL::SelectionMenu, PL_ACTIONS::selectionMenu.MakeEvent() );
Go( &PL_SELECTION_TOOL::UpdateMessagePanel, EVENTS::SelectedEvent );
Go( &PL_SELECTION_TOOL::UpdateMessagePanel, EVENTS::UnselectedEvent );
Go( &PL_SELECTION_TOOL::UpdateMessagePanel, EVENTS::ClearedEvent );
Go( &PL_SELECTION_TOOL::UpdateMessagePanel, EVENTS::SelectedItemsModified );
Go( &PL_SELECTION_TOOL::ToggleBackgroundColor, PL_ACTIONS::toggleBackground.MakeEvent() );
} }

View File

@ -125,11 +125,6 @@ public:
*/ */
int SelectionMenu( const TOOL_EVENT& aEvent ); int SelectionMenu( const TOOL_EVENT& aEvent );
int UpdateMessagePanel( const TOOL_EVENT& aEvent );
// Move to PL_EDITOR_CONTROL when there are enough control actions to make it worthwhile
int ToggleBackgroundColor( const TOOL_EVENT& aEvent );
private: private:
/** /**
* Function selectMultiple() * Function selectMultiple()