From 47ce871043d27356128fa1bae5971f695ec72298 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 9 Jul 2014 11:22:43 +0200 Subject: [PATCH] FOOTPRINT_VIEWER_FRAME handles events from toolbar buttons and hot keys. --- pcbnew/modview_frame.cpp | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index 13134fe54f..0a50ed6eb9 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -55,6 +55,11 @@ #include #include +#include +#include +#include "tools/pcbnew_control.h" +#include "tools/common_actions.h" + #include @@ -144,14 +149,6 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent m_footprintList = new wxListBox( this, ID_MODVIEW_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL ); - // Create GAL canvas - EDA_DRAW_FRAME* drawFrame = static_cast( aParent ); - PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, - drawFrame->GetGalCanvas()->GetBackend() ); - SetGalCanvas( drawPanel ); - - SetBoard( new BOARD() ); - // Ensure all layers and items are visible: GetBoard()->SetVisibleAlls(); SetScreen( new PCB_SCREEN( GetPageSizeIU() ) ); @@ -169,6 +166,23 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent ReCreateLibraryList(); UpdateTitle(); + EDA_DRAW_FRAME* drawFrame = static_cast( aParent ); + + // Create GAL canvas + PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, + drawFrame->GetGalCanvas()->GetBackend() ); + SetGalCanvas( drawPanel ); + + // Create the manager and dispatcher & route draw panel events to the dispatcher + m_toolManager = new TOOL_MANAGER; + m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(), + drawPanel->GetViewControls(), this ); + m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager ); + drawPanel->SetEventDispatcher( m_toolDispatcher ); + + m_toolManager->RegisterTool( new PCBNEW_CONTROL ); + m_toolManager->ResetTools( TOOL_BASE::RUN ); + // If a footprint was previously loaded, reload it if( getCurNickname().size() && getCurFootprintName().size() ) { @@ -277,6 +291,10 @@ const wxChar* FOOTPRINT_VIEWER_FRAME::GetFootprintViewerFrameName() void FOOTPRINT_VIEWER_FRAME::OnCloseWindow( wxCloseEvent& Event ) { DBG(printf( "%s:\n", __func__ );) + + if( IsGalCanvasActive() ) + GetGalCanvas()->StopDrawing(); + if( IsModal() ) { // Only dismiss a modal frame once, so that the return values set by