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 )
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,
const wxPoint& pos, const wxSize& size,
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 )
ResyncBitmapOnly();
......@@ -68,8 +66,8 @@ 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 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() )
ResyncBitmapOnly();
......
......@@ -46,7 +46,7 @@ protected:
/* 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:
// Hotkey Info
......
......@@ -40,10 +40,7 @@
#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
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_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 )
{
wxBitmap layerbmp( 14, 14 );
wxBitmap layerbmp( BM_SIZE, BM_SIZE );
wxString layername;
LAYER_NUM layerid = i;
......@@ -73,10 +77,20 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
layername = GetLayerName( layerid );
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 );
}
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();
}
......
......@@ -19,9 +19,9 @@ public:
public:
// 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.
// 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
PCB_LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxString& value = wxEmptyString,
......@@ -49,6 +49,7 @@ public:
// Virtual function
void Resync();
private:
// Returns a color index from the layer id
// Virtual function
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