Commit 2f7706e8 authored by Maciej Suminski's avatar Maciej Suminski

Reduced number of switched events, allowing to use VIEW_CONTROLS, even if...

Reduced number of switched events, allowing to use VIEW_CONTROLS, even if there is no extra event dispatcher.
parent 0fc93666
......@@ -73,6 +73,20 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this );
const wxEventType events[] =
{
wxEVT_LEFT_UP, wxEVT_LEFT_DOWN, wxEVT_LEFT_DCLICK,
wxEVT_RIGHT_UP, wxEVT_RIGHT_DOWN, wxEVT_RIGHT_DCLICK,
wxEVT_MIDDLE_UP, wxEVT_MIDDLE_DOWN, wxEVT_MIDDLE_DCLICK,
wxEVT_MOTION, wxEVT_MOUSEWHEEL, wxEVT_CHAR, KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE
};
BOOST_FOREACH( wxEventType eventType, events )
{
Connect( eventType, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ),
NULL, m_eventDispatcher );
}
// Set up timer that prevents too frequent redraw commands
m_refreshTimer.SetOwner( this );
m_pendingRefresh = false;
......@@ -171,46 +185,43 @@ void EDA_DRAW_PANEL_GAL::SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher )
{
m_eventDispatcher = aEventDispatcher;
const wxEventType events[] =
#if wxCHECK_VERSION( 3, 0, 0 )
if( m_eventDispatcher )
{
wxEVT_LEFT_UP, wxEVT_LEFT_DOWN, wxEVT_LEFT_DCLICK,
wxEVT_RIGHT_UP, wxEVT_RIGHT_DOWN, wxEVT_RIGHT_DCLICK,
wxEVT_MIDDLE_UP, wxEVT_MIDDLE_DOWN, wxEVT_MIDDLE_DCLICK,
wxEVT_MOTION, wxEVT_MOUSEWHEEL, wxEVT_CHAR, KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE
};
const wxEventType commands[] =
m_parent->Connect( wxEVT_TOOL,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher );
}
else
{
#if wxCHECK_VERSION( 3, 0, 0 )
wxEVT_TOOL
// While loops are used to be sure, that we are removing all event handlers
while( m_parent->Disconnect( wxEVT_TOOL,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher ) );
}
#else
wxEVT_COMMAND_MENU_SELECTED, wxEVT_COMMAND_TOOL_CLICKED
#endif
};
if( m_eventDispatcher )
{
BOOST_FOREACH( wxEventType eventType, events )
Connect( eventType, wxEventHandler( TOOL_DISPATCHER::DispatchWxEvent ),
NULL, m_eventDispatcher );
BOOST_FOREACH( wxEventType eventType, commands )
m_parent->Connect( eventType,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher );
m_parent->Connect( wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher );
m_parent->Connect( wxEVT_COMMAND_TOOL_CLICKED,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher );
}
else
{
// While loops are used to be sure, that we are removing all event handlers
BOOST_FOREACH( wxEventType eventType, events )
while( Disconnect( eventType, wxEventHandler( TOOL_DISPATCHER::DispatchWxEvent ),
NULL, m_eventDispatcher ) );
BOOST_FOREACH( wxEventType eventType, commands )
while( m_parent->Disconnect( eventType,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher ) );
while( m_parent->Disconnect( wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher ) );
while( m_parent->Disconnect( wxEVT_COMMAND_TOOL_CLICKED,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher ) );
}
#endif
}
......@@ -292,6 +303,17 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType )
}
void EDA_DRAW_PANEL_GAL::onEvent( wxEvent& aEvent )
{
if( !m_eventDispatcher )
aEvent.Skip();
else
m_eventDispatcher->DispatchWxEvent( aEvent );
Refresh();
}
void EDA_DRAW_PANEL_GAL::onEnter( wxEvent& aEvent )
{
// Getting focus is necessary in order to receive key events properly
......
......@@ -281,8 +281,6 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
if( evt )
m_toolMgr->ProcessEvent( *evt );
static_cast<PCB_BASE_FRAME*>( m_toolMgr->GetEditFrame() )->GetGalCanvas()->Refresh();
// pass the event to the GUI, it might still be interested in it
aEvent.Skip();
}
......
......@@ -147,6 +147,7 @@ public:
protected:
void onPaint( wxPaintEvent& WXUNUSED( aEvent ) );
void onSize( wxSizeEvent& aEvent );
void onEvent( wxEvent& aEvent );
void onEnter( wxEvent& aEvent );
void onRefreshTimer( wxTimerEvent& aEvent );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment