From 597338ba5ff18c9488f08271fb2d7871265e3628 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 9 Jul 2014 11:59:23 +0200 Subject: [PATCH] PCB_LAYER_WIDGET became able to cooperate with PCB_BASE_FRAME. --- include/wxPcbStruct.h | 1 + pcbnew/class_pcb_layer_widget.cpp | 5 ++--- pcbnew/class_pcb_layer_widget.h | 6 ++++-- pcbnew/layer_widget.cpp | 6 ++++++ pcbnew/layer_widget.h | 1 + pcbnew/pcbframe.cpp | 8 ++++++++ 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 33f2e0e6bb..98d95c465d 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -252,6 +252,7 @@ public: void OnUpdateAutoPlaceModulesMode( wxUpdateUIEvent& aEvent ); void OnUpdateAutoPlaceTracksMode( wxUpdateUIEvent& aEvent ); void OnUpdateMuWaveToolbar( wxUpdateUIEvent& aEvent ); + void OnLayerColorChange( wxCommandEvent& aEvent ); /** * Function RecordMacros. diff --git a/pcbnew/class_pcb_layer_widget.cpp b/pcbnew/class_pcb_layer_widget.cpp index 172df49f64..04954b1248 100644 --- a/pcbnew/class_pcb_layer_widget.cpp +++ b/pcbnew/class_pcb_layer_widget.cpp @@ -81,7 +81,7 @@ const LAYER_WIDGET::ROW PCB_LAYER_WIDGET::s_render_rows[] = { }; -PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_EDIT_FRAME* aParent, wxWindow* aFocusOwner, int aPointSize ) : +PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_BASE_FRAME* aParent, wxWindow* aFocusOwner, int aPointSize ) : LAYER_WIDGET( aParent, aFocusOwner, aPointSize ), myframe( aParent ) { @@ -213,7 +213,7 @@ void PCB_LAYER_WIDGET::SetLayersManagerTabsText() void PCB_LAYER_WIDGET::ReFillRender() { - BOARD* board = myframe->GetBoard(); + BOARD* board = myframe->GetBoard(); ClearRenderRows(); // Add "Render" tab rows to LAYER_WIDGET, after setting color and checkbox state. @@ -356,7 +356,6 @@ void PCB_LAYER_WIDGET::ReFill() void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, EDA_COLOR_T aColor ) { myframe->GetBoard()->SetLayerColor( ToLAYER_ID( aLayer ), aColor ); - myframe->ReCreateLayerBox( false ); if( myframe->IsGalCanvasActive() ) { diff --git a/pcbnew/class_pcb_layer_widget.h b/pcbnew/class_pcb_layer_widget.h index 4f7d715367..211e603aa4 100644 --- a/pcbnew/class_pcb_layer_widget.h +++ b/pcbnew/class_pcb_layer_widget.h @@ -31,6 +31,8 @@ #ifndef CLASS_PCB_LAYER_WIDGET_H_ #define CLASS_PCB_LAYER_WIDGET_H_ +#include + /** * Class PCB_LAYER_WIDGET * is here to implement the abtract functions of LAYER_WIDGET so they @@ -49,7 +51,7 @@ public: * effectively sets the overal size of the widget via the row height and bitmap * button sizes. */ - PCB_LAYER_WIDGET( PCB_EDIT_FRAME* aParent, wxWindow* aFocusOwner, int aPointSize = 10 ); + PCB_LAYER_WIDGET( PCB_BASE_FRAME* aParent, wxWindow* aFocusOwner, int aPointSize = 10 ); void ReFill(); @@ -108,7 +110,7 @@ protected: bool m_alwaysShowActiveCopperLayer; // If true: Only shows the current active layer // even if it is changed - PCB_EDIT_FRAME* myframe; + PCB_BASE_FRAME* myframe; // popup menu ids. #define ID_SHOW_ALL_COPPERS wxID_HIGHEST diff --git a/pcbnew/layer_widget.cpp b/pcbnew/layer_widget.cpp index fda117b8e4..df23c188e3 100644 --- a/pcbnew/layer_widget.cpp +++ b/pcbnew/layer_widget.cpp @@ -44,6 +44,8 @@ #define BUTT_SIZE_Y 18 #define BUTT_VOID 4 +const wxEventType LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE = wxNewEventType(); + /* XPM * This bitmap is used for not selected layers */ @@ -294,6 +296,10 @@ void LAYER_WIDGET::OnMiddleDownLayerColor( wxMouseEvent& event ) // tell the client code. OnLayerColorChange( layer, newColor ); + + // notify others + wxCommandEvent event( EVT_LAYER_COLOR_CHANGE ); + wxPostEvent( this, event ); } passOnFocus(); diff --git a/pcbnew/layer_widget.h b/pcbnew/layer_widget.h index 347038919c..cfb6bc384f 100644 --- a/pcbnew/layer_widget.h +++ b/pcbnew/layer_widget.h @@ -98,6 +98,7 @@ public: } }; + static const wxEventType EVT_LAYER_COLOR_CHANGE; protected: diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index c07f28a8c4..6bb044b1b7 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -294,6 +294,8 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) PCB_EDIT_FRAME::OnUpdateZoneDisplayStyle ) EVT_UPDATE_UI_RANGE( ID_PCB_MUWAVE_START_CMD, ID_PCB_MUWAVE_END_CMD, PCB_EDIT_FRAME::OnUpdateMuWaveToolbar ) + + EVT_COMMAND( wxID_ANY, LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE, PCB_EDIT_FRAME::OnLayerColorChange ) END_EVENT_TABLE() @@ -1007,6 +1009,12 @@ void PCB_EDIT_FRAME::OnSelectAutoPlaceMode( wxCommandEvent& aEvent ) } +void PCB_EDIT_FRAME::OnLayerColorChange( wxCommandEvent& aEvent ) +{ + ReCreateLayerBox(); +} + + void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event ) { DIALOG_PLOT dlg( this );