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[]=nullptr)
 
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, const COLOR4D &aBackground, const 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[] = nullptr 
)
inline

Definition at line 35 of file gbr_layer_box_selector.h.

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

References LAYER_SELECTOR::m_layerhotkeys.

Member Function Documentation

◆ DrawColorSwatch()

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

Definition at line 48 of file layer_box_selector.cpp.

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

References KIGFX::COLOR4D::WithAlpha().

Referenced by PANEL_SETUP_BOARD_STACKUP::createColorBox(), 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 111 of file layer_box_selector.cpp.

112 {
113  return GetSelection();
114 }

◆ getLayerColor()

COLOR4D GBR_LAYER_BOX_SELECTOR::getLayerColor ( int  aLayer) const
overridevirtual

Implements LAYER_SELECTOR.

Definition at line 71 of file gbr_layer_box_selector.cpp.

72 {
73  GERBVIEW_FRAME* frame = (GERBVIEW_FRAME*) GetParent()->GetParent();
74 
75  return frame->GetLayerColor( GERBER_DRAW_LAYER( aLayer ) );
76 }
#define GERBER_DRAW_LAYER(x)
Definition: layer_ids.h:396
COLOR4D GetLayerColor(int aLayer) const

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 80 of file gbr_layer_box_selector.cpp.

81 {
83  wxString name = images.GetDisplayName( aLayer );
84 
85  return name;
86 }
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:56
const wxString GetDisplayName(int aIdx, bool aNameOnly=false, bool aFullName=false)
Get the display name for the layer at aIdx.

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 51 of file gbr_layer_box_selector.h.

51 { return true; }

Referenced by Resync().

◆ Resync()

void GBR_LAYER_BOX_SELECTOR::Resync ( )
overridevirtual

Implements LAYER_BOX_SELECTOR.

Definition at line 31 of file gbr_layer_box_selector.cpp.

32 {
33  #define BM_SIZE 14
34  Freeze();
35  Clear();
36 
38 
39  for( unsigned layerid = 0; layerid < images.ImagesMaxCount(); ++layerid )
40  {
41  if( !isLayerEnabled( layerid ) )
42  continue;
43 
44  // Prepare Bitmap
45  wxBitmap bmp( BM_SIZE, BM_SIZE );
47 
48  Append( getLayerName( layerid ), bmp, (void*)(intptr_t) layerid );
49  }
50 
51  // Ensure the size of the widget is enough to show the text and the icon
52  // We have to have a selected item when doing this, because otherwise GTK
53  // will just choose a random size that might not fit the actual data
54  // (such as in cases where the font size is very large). So we select
55  // the first item, get the size of the control and make that the minimum size,
56  // then remove the selection (which was the initial state).
57  SetSelection( 0 );
58 
59  SetMinSize( wxSize( -1, -1 ) );
60  wxSize bestSize = GetBestSize();
61 
62  bestSize.x = GetBestSize().x + BM_SIZE + 10;
63  SetMinSize( bestSize );
64 
65  SetSelection( wxNOT_FOUND );
66  Thaw();
67 }
static void DrawColorSwatch(wxBitmap &aLayerbmp, const COLOR4D &aBackground, const COLOR4D &aColor)
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()
wxString getLayerName(int aLayer) const override
#define BM_SIZE
COLOR4D getLayerColor(int aLayer) const override
PCB background color.
Definition: layer_ids.h:215
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 }
static void DrawColorSwatch(wxBitmap &aLayerbmp, const COLOR4D &aBackground, const COLOR4D &aColor)
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:40
virtual COLOR4D getLayerColor(LAYER_NUM aLayer) const =0
PCB background color.
Definition: layer_ids.h:215

References LAYER_SELECTOR::DrawColorSwatch(), LAYER_SELECTOR::getLayerColor(), 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 }

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_DIMENSION_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), and DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow().

◆ SetLayersHotkeys()

Member Data Documentation

◆ m_layerhotkeys

bool LAYER_SELECTOR::m_layerhotkeys
protectedinherited

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