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 SetLayersHotkeys (bool value)
 

Static Public Member Functions

static void DrawColorSwatch (wxBitmap &aLayerbmp, COLOR4D aBackground, COLOR4D aColor)
 

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::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.

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)

References LAYER_SELECTOR::m_layerhotkeys.

Member Function Documentation

◆ DrawColorSwatch()

void LAYER_SELECTOR::DrawColorSwatch ( wxBitmap &  aLayerbmp,
COLOR4D  aBackground,
COLOR4D  aColor 
)
staticinherited

Definition at line 47 of file layer_box_selector.cpp.

48 {
49  wxMemoryDC bmpDC;
50  wxBrush brush;
51 
52  // Prepare Bitmap
53  bmpDC.SelectObject( aLayerbmp );
54 
55  brush.SetStyle( wxBRUSHSTYLE_SOLID );
56  if( aBackground != COLOR4D::UNSPECIFIED )
57  {
58  brush.SetColour( aBackground.WithAlpha(1.0).ToColour() );
59  bmpDC.SetBrush( brush );
60  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
61  }
62 
63  brush.SetColour( aColor.ToColour() );
64  bmpDC.SetBrush( brush );
65  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
66 
67  bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
68  bmpDC.SetPen( *wxBLACK_PEN );
69  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
70 }
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:247

References KIGFX::COLOR4D::WithAlpha().

Referenced by PANEL_SETUP_BOARD_STACKUP::createBmComboBox(), GRID_CELL_LAYER_RENDERER::Draw(), PANEL_SETUP_BOARD_STACKUP::onColorSelected(), Resync(), PCB_LAYER_BOX_SELECTOR::Resync(), LAYER_BOX_SELECTOR::ResyncBitmapOnly(), and PANEL_SETUP_BOARD_STACKUP::synchronizeWithBoard().

◆ GetChoice()

int LAYER_BOX_SELECTOR::GetChoice ( )
inherited

Definition at line 109 of file layer_box_selector.cpp.

110 {
111  return GetSelection();
112 }

◆ GetLayerColor()

COLOR4D GBR_LAYER_BOX_SELECTOR::GetLayerColor ( int  aLayer) const
overridevirtual

Implements LAYER_SELECTOR.

Definition at line 68 of file gbr_layer_box_selector.cpp.

69 {
70  GERBVIEW_FRAME* frame = (GERBVIEW_FRAME*) GetParent()->GetParent();
71 
72  return frame->GetLayerColor( GERBER_DRAW_LAYER( aLayer ) );
73 }
COLOR4D GetLayerColor(int aLayer) const
Function GetLayerColor gets a layer color for any valid layer.
#define GERBER_DRAW_LAYER(x)

References GERBER_DRAW_LAYER, and GERBVIEW_FRAME::GetLayerColor().

Referenced by Resync().

◆ GetLayerName()

wxString GBR_LAYER_BOX_SELECTOR::GetLayerName ( int  aLayer) const
overridevirtual

Implements LAYER_SELECTOR.

Definition at line 77 of file gbr_layer_box_selector.cpp.

78 {
80  wxString name = images.GetDisplayName( aLayer );
81 
82  return name;
83 }
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

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

Referenced by Resync().

◆ GetLayerSelection()

◆ IsLayerEnabled()

bool GBR_LAYER_BOX_SELECTOR::IsLayerEnabled ( int  aLayer) const
inlineoverridevirtual

Implements LAYER_SELECTOR.

Definition at line 53 of file gbr_layer_box_selector.h.

53 { return true; }

Referenced by Resync().

◆ Resync()

void GBR_LAYER_BOX_SELECTOR::Resync ( )
overridevirtual

Implements LAYER_BOX_SELECTOR.

Definition at line 38 of file gbr_layer_box_selector.cpp.

39 {
40  #define BM_SIZE 14
41  Freeze();
42  Clear();
43 
45 
46  for( unsigned layerid = 0; layerid < images.ImagesMaxCount(); ++layerid )
47  {
48  if( !IsLayerEnabled( layerid ) )
49  continue;
50 
51  // Prepare Bitmap
52  wxBitmap bmp( BM_SIZE, BM_SIZE );
54 
55  Append( GetLayerName( layerid ), bmp, (void*)(intptr_t) layerid );
56  }
57 
58  // Ensure the width of the widget is enough to show the text and the icon
59  SetMinSize( wxSize( -1, -1 ) );
60  int minwidth = GetBestSize().x + BM_SIZE + 10;
61  SetMinSize( wxSize( minwidth, -1 ) );
62 
63  Thaw();
64 }
COLOR4D GetLayerColor(int aLayer) const override
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...
static GERBER_FILE_IMAGE_LIST & GetImagesList()
static void DrawColorSwatch(wxBitmap &aLayerbmp, COLOR4D aBackground, COLOR4D aColor)
#define BM_SIZE
bool IsLayerEnabled(int aLayer) const override

References BM_SIZE, LAYER_SELECTOR::DrawColorSwatch(), GERBER_FILE_IMAGE_LIST::GetImagesList(), GetLayerColor(), GetLayerName(), GERBER_FILE_IMAGE_LIST::ImagesMaxCount(), IsLayerEnabled(), and LAYER_PCB_BACKGROUND.

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

◆ ResyncBitmapOnly()

void LAYER_BOX_SELECTOR::ResyncBitmapOnly ( )
inherited

Definition at line 150 of file layer_box_selector.cpp.

151 {
152  int elements = GetCount();
153 
154  for( LAYER_NUM i = 0; i < elements; ++i )
155  {
156  wxBitmap layerbmp( 14, 14 );
158  }
159 }
virtual COLOR4D GetLayerColor(LAYER_NUM aLayer) const =0
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
static void DrawColorSwatch(wxBitmap &aLayerbmp, COLOR4D aBackground, COLOR4D aColor)
size_t i
Definition: json11.cpp:649

References LAYER_SELECTOR::DrawColorSwatch(), LAYER_SELECTOR::GetLayerColor(), i, and LAYER_PCB_BACKGROUND.

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

◆ SetLayerSelection()

int LAYER_BOX_SELECTOR::SetLayerSelection ( LAYER_NUM  layer)
inherited

Definition at line 126 of file layer_box_selector.cpp.

127 {
128  int elements = GetCount();
129 
130  for( int i = 0; i < elements; i++ )
131  {
132  if( GetClientData( (unsigned) i ) == (void*)(intptr_t) layer )
133  {
134  if( GetSelection() != i ) // Element (i) is not selected
135  {
136  SetSelection( i );
137  return i;
138  }
139  else
140  return i; //If element already selected; do nothing
141  }
142  }
143 
144  // Not Found
145  SetSelection( -1 );
146  return -1;
147 }
size_t i
Definition: json11.cpp:649

References i.

Referenced by GRID_CELL_LAYER_SELECTOR::BeginEdit(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildFilterLists(), DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), FOOTPRINT_EDIT_FRAME::OnUpdateLayerSelectBox(), PCB_EDIT_FRAME::OnUpdateLayerSelectBox(), DIALOG_TRACK_VIA_PROPERTIES::onViaEdit(), GRID_CELL_LAYER_SELECTOR::Reset(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataToWindow().

◆ SetLayersHotkeys()

Member Data Documentation

◆ m_layerhotkeys

bool LAYER_SELECTOR::m_layerhotkeys
protectedinherited

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