Commit 047749a8 authored by jean-pierre charras's avatar jean-pierre charras

minor changes and refinement in class pcb layer box

parent 684bfad0
...@@ -50,15 +50,13 @@ void LAYER_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer ) ...@@ -50,15 +50,13 @@ void LAYER_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer )
bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() ); bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
} }
/* class to display a layer list. /* class to display a layer list in a wxBitmapComboBox.
*
*/ */
LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id, LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, const wxPoint& pos, const wxSize& size,
int n, const wxString choices[] ) : int n, const wxString choices[] ) :
LAYER_SELECTOR(), wxBitmapComboBox( parent, id, wxEmptyString, pos, size, n, choices, wxCB_READONLY ),
wxBitmapComboBox( parent, id, wxEmptyString, pos, size, n, choices, wxCB_READONLY ) LAYER_SELECTOR()
{ {
if( choices != NULL ) if( choices != NULL )
ResyncBitmapOnly(); ResyncBitmapOnly();
...@@ -68,8 +66,8 @@ LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id, ...@@ -68,8 +66,8 @@ LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id, LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, const wxPoint& pos, const wxSize& size,
const wxArrayString& choices ) : const wxArrayString& choices ) :
LAYER_SELECTOR(), wxBitmapComboBox( parent, id, wxEmptyString, pos, size, choices, wxCB_READONLY ),
wxBitmapComboBox( parent, id, wxEmptyString, pos, size, choices, wxCB_READONLY ) LAYER_SELECTOR()
{ {
if( !choices.IsEmpty() ) if( !choices.IsEmpty() )
ResyncBitmapOnly(); ResyncBitmapOnly();
......
...@@ -46,7 +46,7 @@ protected: ...@@ -46,7 +46,7 @@ protected:
/* class to display a layer list in a wxBitmapComboBox. /* class to display a layer list in a wxBitmapComboBox.
*/ */
class LAYER_BOX_SELECTOR : public LAYER_SELECTOR, public wxBitmapComboBox class LAYER_BOX_SELECTOR :public wxBitmapComboBox, public LAYER_SELECTOR
{ {
public: public:
// Hotkey Info // Hotkey Info
......
...@@ -40,10 +40,7 @@ ...@@ -40,10 +40,7 @@
#include <class_pcb_layer_box_selector.h> #include <class_pcb_layer_box_selector.h>
/* class to display a layer list. // class to display a layer list in a wxBitmapComboBox.
*
*/
// Reload the Layers // Reload the Layers
void PCB_LAYER_BOX_SELECTOR::Resync() void PCB_LAYER_BOX_SELECTOR::Resync()
...@@ -53,9 +50,16 @@ void PCB_LAYER_BOX_SELECTOR::Resync() ...@@ -53,9 +50,16 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
static DECLARE_LAYERS_ORDER_LIST( layertranscode ); static DECLARE_LAYERS_ORDER_LIST( layertranscode );
static DECLARE_LAYERS_HOTKEY( layerhk ); static DECLARE_LAYERS_HOTKEY( layerhk );
// Tray to fix a minimum width fot the BitmapComboBox
int minwidth, h;
wxClientDC dc( GetParent() ); // The DC for "this" is not always initialized
wxString dummyText( wxT("XXXXXXXXXXXX") );
dc.GetTextExtent ( dummyText, &minwidth, &h );
#define BM_SIZE 14
for( LAYER_NUM i = FIRST_LAYER; i < NB_LAYERS; ++i ) for( LAYER_NUM i = FIRST_LAYER; i < NB_LAYERS; ++i )
{ {
wxBitmap layerbmp( 14, 14 ); wxBitmap layerbmp( BM_SIZE, BM_SIZE );
wxString layername; wxString layername;
LAYER_NUM layerid = i; LAYER_NUM layerid = i;
...@@ -73,10 +77,20 @@ void PCB_LAYER_BOX_SELECTOR::Resync() ...@@ -73,10 +77,20 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
layername = GetLayerName( layerid ); layername = GetLayerName( layerid );
if( m_layerhotkeys && m_hotkeys != NULL ) if( m_layerhotkeys && m_hotkeys != NULL )
layername = AddHotkeyName( layername, m_hotkeys, layerhk[layerid], IS_COMMENT ); layername = AddHotkeyName( layername, m_hotkeys,
layerhk[layerid], IS_COMMENT );
Append( layername, layerbmp, (void*)(intptr_t) layerid ); Append( layername, layerbmp, (void*)(intptr_t) layerid );
int w;
dc.GetTextExtent ( layername, &w, &h );
minwidth = std::max( minwidth, w );
} }
minwidth += BM_SIZE + 12; // Take in account the bitmap size and margins
wxLogMessage( "minw %d min %d", minwidth, GetMinClientSize().x );
// SetMinClientSize( wxSize( minwidth, -1 ) );
Layout();
} }
......
...@@ -21,7 +21,7 @@ public: ...@@ -21,7 +21,7 @@ public:
// If you are thinking the constructor is a bit curious, // If you are thinking the constructor is a bit curious,
// just remember it is used by automaticallty generated by wxFormBuilder files, // just remember it is used by automaticallty generated by wxFormBuilder files,
// and it should mimic the wxBitmapComboBox constructor. // and it should mimic the wxBitmapComboBox constructor.
// Therefore, value, pos, size, n, choices and style are not yet used, // Therefore, value, style are not yet used,
// but they are here for compatibility // but they are here for compatibility
PCB_LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id, PCB_LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxString& value = wxEmptyString, const wxString& value = wxEmptyString,
...@@ -49,6 +49,7 @@ public: ...@@ -49,6 +49,7 @@ public:
// Virtual function // Virtual function
void Resync(); void Resync();
private:
// Returns a color index from the layer id // Returns a color index from the layer id
// Virtual function // Virtual function
EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const; EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const;
......
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