KiCad PCB EDA Suite
GBR_LAYER_BOX_SELECTOR Class Reference

#include <gbr_layer_box_selector.h>

Inheritance diagram for GBR_LAYER_BOX_SELECTOR:
LAYER_BOX_SELECTOR LAYER_SELECTOR

Public Member Functions

 GBR_LAYER_BOX_SELECTOR (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int n=0, const wxString choices[]=NULL)
 
void Resync () override
 
COLOR4D GetLayerColor (int aLayer) const override
 
bool IsLayerEnabled (int aLayer) const override
 
wxString GetLayerName (int aLayer) const override
 
int GetChoice ()
 
LAYER_NUM GetLayerSelection () const
 
int SetLayerSelection (LAYER_NUM layer)
 
void ResyncBitmapOnly ()
 
bool SetLayersOrdered (bool value)
 
bool SetLayersHotkeys (bool value)
 

Public Attributes

struct EDA_HOTKEY_CONFIGm_hotkeys
 

Protected Member Functions

void SetBitmapLayer (wxBitmap &aLayerbmp, LAYER_NUM aLayer)
 

Protected Attributes

bool m_layerhotkeys
 

Detailed Description

Definition at line 32 of file gbr_layer_box_selector.h.

Constructor & Destructor Documentation

GBR_LAYER_BOX_SELECTOR::GBR_LAYER_BOX_SELECTOR ( wxWindow *  parent,
wxWindowID  id,
const wxPoint pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
int  n = 0,
const wxString  choices[] = NULL 
)
inline

Definition at line 35 of file gbr_layer_box_selector.h.

References GetLayerColor(), LAYER_SELECTOR::m_layerhotkeys, and Resync().

37  :
38  LAYER_BOX_SELECTOR( parent, id, pos, size, n, choices )
39  {
40  m_layerhotkeys = false;
41  }
LAYER_BOX_SELECTOR(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int n=0, const wxString choices[]=NULL)

Member Function Documentation

int LAYER_BOX_SELECTOR::GetChoice ( )
inherited

Definition at line 105 of file layer_box_selector.cpp.

106 {
107  return GetSelection();
108 }
COLOR4D GBR_LAYER_BOX_SELECTOR::GetLayerColor ( int  aLayer) const
overridevirtual

Implements LAYER_SELECTOR.

Definition at line 72 of file gbr_layer_box_selector.cpp.

References GERBER_DRAW_LAYER, and GERBVIEW_FRAME::GetLayerColor().

Referenced by GBR_LAYER_BOX_SELECTOR().

73 {
74  GERBVIEW_FRAME* frame = (GERBVIEW_FRAME*) GetParent()->GetParent();
75 
76  return frame->GetLayerColor( GERBER_DRAW_LAYER( aLayer ) );
77 }
COLOR4D GetLayerColor(int aLayer) const
Function GetLayerColor gets a layer color for any valid layer.
#define GERBER_DRAW_LAYER(x)
wxString GBR_LAYER_BOX_SELECTOR::GetLayerName ( int  aLayer) const
overridevirtual

Implements LAYER_SELECTOR.

Definition at line 81 of file gbr_layer_box_selector.cpp.

References GERBER_FILE_IMAGE_LIST::GetDisplayName(), GERBER_FILE_IMAGE_LIST::GetImagesList(), and name.

Referenced by IsLayerEnabled(), and Resync().

82 {
84  wxString name = images.GetDisplayName( aLayer );
85 
86  return name;
87 }
const wxString GetDisplayName(int aIdx, bool aNameOnly=false)
GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files which are loaded...
static GERBER_FILE_IMAGE_LIST & GetImagesList()
const char * name
Definition: DXF_plotter.cpp:61
bool GBR_LAYER_BOX_SELECTOR::IsLayerEnabled ( int  aLayer) const
inlineoverridevirtual

Implements LAYER_SELECTOR.

Definition at line 53 of file gbr_layer_box_selector.h.

References GetLayerName().

Referenced by Resync().

53 { return true; }
void GBR_LAYER_BOX_SELECTOR::Resync ( )
overridevirtual

Implements LAYER_BOX_SELECTOR.

Definition at line 38 of file gbr_layer_box_selector.cpp.

References BM_SIZE, GERBER_FILE_IMAGE_LIST::GetImagesList(), GetLayerName(), GERBER_FILE_IMAGE_LIST::ImagesMaxCount(), IsLayerEnabled(), and LAYER_SELECTOR::SetBitmapLayer().

Referenced by GBR_LAYER_BOX_SELECTOR(), GERBVIEW_FRAME::ReCreateHToolbar(), GERBVIEW_FRAME::ReFillLayerWidget(), and GERBVIEW_FRAME::syncLayerBox().

39 {
40  #define BM_SIZE 14
41  Freeze();
42  Clear();
43 
45 
46  for( unsigned layerid = 0; layerid < images.ImagesMaxCount(); ++layerid )
47  {
48  wxBitmap layerbmp( BM_SIZE, BM_SIZE );
49  wxString layername;
50 
51  if( !IsLayerEnabled( layerid ) )
52  continue;
53 
54  // Prepare Bitmap
55  SetBitmapLayer( layerbmp, layerid );
56 
57  layername = GetLayerName( layerid );
58 
59  Append( layername, layerbmp, (void*)(intptr_t) layerid );
60  }
61 
62  // Ensure the width of the widget is enough to show the text and the icon
63  SetMinSize( wxSize( -1, -1 ) );
64  int minwidth = GetBestSize().x + BM_SIZE + 10;
65  SetMinSize( wxSize( minwidth, -1 ) );
66 
67  Thaw();
68 }
wxString GetLayerName(int aLayer) const override
GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files which are loaded...
void SetBitmapLayer(wxBitmap &aLayerbmp, LAYER_NUM aLayer)
static GERBER_FILE_IMAGE_LIST & GetImagesList()
#define BM_SIZE
bool IsLayerEnabled(int aLayer) const override
void LAYER_BOX_SELECTOR::ResyncBitmapOnly ( )
inherited

Definition at line 146 of file layer_box_selector.cpp.

References LAYER_SELECTOR::SetBitmapLayer().

Referenced by LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR(), and GERBER_LAYER_WIDGET::OnLayerColorChange().

147 {
148  int elements = GetCount();
149 
150  for( LAYER_NUM i = 0; i < elements; ++i )
151  {
152  wxBitmap layerbmp( 14, 14 );
153  SetBitmapLayer( layerbmp, i );
154  }
155 }
void SetBitmapLayer(wxBitmap &aLayerbmp, LAYER_NUM aLayer)
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
void LAYER_SELECTOR::SetBitmapLayer ( wxBitmap &  aLayerbmp,
LAYER_NUM  aLayer 
)
protectedinherited

Definition at line 48 of file layer_box_selector.cpp.

References LAYER_SELECTOR::GetLayerColor(), LAYER_PCB_BACKGROUND, and KIGFX::COLOR4D::WithAlpha().

Referenced by Resync(), PCB_LAYER_BOX_SELECTOR::Resync(), and LAYER_BOX_SELECTOR::ResyncBitmapOnly().

49 {
50  wxMemoryDC bmpDC;
51  wxBrush brush;
52 
53  // Prepare Bitmap
54  bmpDC.SelectObject( aLayerbmp );
55 
56  brush.SetStyle( wxBRUSHSTYLE_SOLID );
57  COLOR4D backgroundColor = GetLayerColor( LAYER_PCB_BACKGROUND );
58  if( backgroundColor != COLOR4D::UNSPECIFIED )
59  {
60  brush.SetColour( backgroundColor.WithAlpha(1.0).ToColour() );
61  bmpDC.SetBrush( brush );
62  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
63  }
64 
65  brush.SetColour( GetLayerColor( aLayer ).ToColour() );
66  bmpDC.SetBrush( brush );
67  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
68 
69  bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
70  bmpDC.SetPen( *wxBLACK_PEN );
71  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
72 }
virtual COLOR4D GetLayerColor(LAYER_NUM aLayer) const =0
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:237
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
int LAYER_BOX_SELECTOR::SetLayerSelection ( LAYER_NUM  layer)
inherited

Definition at line 122 of file layer_box_selector.cpp.

Referenced by DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR(), DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), PCB_EDIT_FRAME::OnUpdateLayerSelectBox(), DIALOG_TRACK_VIA_PROPERTIES::onViaEdit(), DIALOG_EDIT_FPTEXT::TransferDataToWindow(), DIALOG_PCB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::TransferDataToWindow(), and DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow().

123 {
124  int elements = GetCount();
125 
126  for( int i = 0; i < elements; i++ )
127  {
128  if( GetClientData( i ) == (void*)(intptr_t) layer )
129  {
130  if( GetSelection() != i ) // Element (i) is not selected
131  {
132  SetSelection( i );
133  return i;
134  }
135  else
136  return i; //If element already selected; do nothing
137  }
138  }
139 
140  // Not Found
141  SetSelection( -1 );
142  return -1;
143 }
bool LAYER_SELECTOR::SetLayersOrdered ( bool  value)
inherited

Member Data Documentation

struct EDA_HOTKEY_CONFIG* LAYER_BOX_SELECTOR::m_hotkeys
inherited

Definition at line 78 of file layer_box_selector.h.

Referenced by LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR().

bool LAYER_SELECTOR::m_layerhotkeys
protectedinherited

The documentation for this class was generated from the following files: