diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 56f3fb3fc1..c71ea854f3 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -20,6 +20,7 @@ set(COMMON_SRCS block_commande.cpp build_version.cpp class_colors_design_settings.cpp + class_layerchoicebox.cpp class_marker_base.cpp class_plotter.cpp class_undoredo_container.cpp diff --git a/pcbnew/class_layerchoicebox.cpp b/common/class_layerchoicebox.cpp similarity index 74% rename from pcbnew/class_layerchoicebox.cpp rename to common/class_layerchoicebox.cpp index 806d008e6c..8679dfc8ad 100644 --- a/pcbnew/class_layerchoicebox.cpp +++ b/common/class_layerchoicebox.cpp @@ -29,6 +29,10 @@ WinEDALayerChoiceBox::WinEDALayerChoiceBox( WinEDA_Toolbar* parent, wxWindowID i { m_layerorder = true; m_layerhotkeys = true; + m_hotkeys = NULL; + + if( choices != NULL ) + ResyncBitmapOnly(); } @@ -40,6 +44,10 @@ WinEDALayerChoiceBox::WinEDALayerChoiceBox( WinEDA_Toolbar* parent, wxWindowID i { m_layerorder = true; m_layerhotkeys = true; + m_hotkeys = NULL; + + if( !choices.IsEmpty() ) + ResyncBitmapOnly(); } @@ -136,10 +144,38 @@ void WinEDALayerChoiceBox::Resync() layername = board->GetLayerName( layerid ); - if( m_layerhotkeys ) - layername = AddHotkeyName( layername, s_Board_Editor_Hokeys_Descr, - layerhk[layerid], false ); + if( m_layerhotkeys && m_hotkeys != NULL ) + layername = AddHotkeyName( layername, m_hotkeys, layerhk[layerid], false ); Append( layername, layerbmp, (void*) layerid ); } } + +void WinEDALayerChoiceBox::ResyncBitmapOnly() +{ + WinEDA_BasePcbFrame* pcbFrame = (WinEDA_BasePcbFrame*) GetParent()->GetParent(); + BOARD* board = pcbFrame->GetBoard(); + + int elements = GetCount(); + for( int i = 0; i < elements; i++ ) + { + wxBitmap layerbmp( 14, 14 ); + wxMemoryDC bmpDC; + wxBrush brush; + wxString layername; + int layerid = i; + + // Prepare Bitmap + bmpDC.SelectObject( layerbmp ); + brush.SetColour( MakeColour( board->GetLayerColor( layerid ) ) ); + brush.SetStyle( wxSOLID ); + + bmpDC.SetBrush( brush ); + bmpDC.DrawRectangle( 0, 0, layerbmp.GetWidth(), layerbmp.GetHeight() ); + bmpDC.SetBrush( *wxTRANSPARENT_BRUSH ); + bmpDC.SetPen( *wxBLACK_PEN ); + bmpDC.DrawRectangle( 0, 0, layerbmp.GetWidth(), layerbmp.GetHeight() ); + + SetItemBitmap(i, layerbmp); + } +} diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index 78a13de1c8..d9bf109b0c 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -13,7 +13,7 @@ #include "gerbview_id.h" #include "hotkeys.h" #include "class_GERBER.h" - +#include "class_layerchoicebox.h" void WinEDA_GerberFrame::ReCreateHToolbar( void ) { @@ -89,7 +89,7 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) choices.Add( msg ); } - m_SelLayerBox = new WinEDAChoiceBox( m_HToolBar, + m_SelLayerBox = new WinEDALayerChoiceBox( m_HToolBar, ID_TOOLBARH_GERBVIEW_SELECT_LAYER, wxDefaultPosition, wxSize( 150, -1 ), choices ); diff --git a/gerbview/wxGerberFrame.h b/gerbview/wxGerberFrame.h index 9ce3f136cc..d51f149d51 100644 --- a/gerbview/wxGerberFrame.h +++ b/gerbview/wxGerberFrame.h @@ -8,7 +8,7 @@ #include "id.h" #include "class_gerbview_layer_widget.h" - +#include "class_layerchoicebox.h" /** * Command IDs for the gerber file viewer. @@ -44,7 +44,7 @@ protected: GERBER_LAYER_WIDGET* m_LayersManager; public: - WinEDAChoiceBox* m_SelLayerBox; + WinEDALayerChoiceBox* m_SelLayerBox; WinEDAChoiceBox* m_SelLayerTool; wxTextCtrl* m_TextInfo; // a wxTextCtrl used to display some info about // gerber data (format..) diff --git a/include/class_layerchoicebox.h b/include/class_layerchoicebox.h index a64fd4d0b6..535cfe5ee4 100644 --- a/include/class_layerchoicebox.h +++ b/include/class_layerchoicebox.h @@ -1,6 +1,7 @@ #ifndef CLASS_LAYERCHOICEBOX_H #define CLASS_LAYERCHOICEBOX_H 1 +#include "hotkeys_basic.h" #include /* class to display a layer list. @@ -33,9 +34,12 @@ public: // Reload the Layers void Resync(); + void ResyncBitmapOnly(); bool SetLayersOrdered(bool value); bool SetLayersHotkeys(bool value); + // Hotkey Info + struct Ki_HotkeyInfoSectionDescriptor* m_hotkeys; }; #define DECLARE_LAYERS_HOTKEY(list) int list[LAYER_COUNT] = \ diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index fa190a9709..265c5719f1 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -32,7 +32,6 @@ set(PCBNEW_SRCS block.cpp block_module_editor.cpp build_BOM_from_board.cpp - class_layerchoicebox.cpp class_pcb_layer_widget.cpp clean.cpp # cleaningoptions_dialog.cpp diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index e95d75bb05..f4d3e3a58b 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -700,6 +700,7 @@ WinEDALayerChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent if( m_SelLayerBox == NULL ) return NULL; + m_SelLayerBox->m_hotkeys = s_Board_Editor_Hokeys_Descr; m_SelLayerBox->Resync(); m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );