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)
 

Public Attributes

struct EDA_HOTKEY_CONFIGm_hotkeys
 

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

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

Definition at line 48 of file layer_box_selector.cpp.

References KIGFX::COLOR4D::WithAlpha().

Referenced by GRID_CELL_LAYER_RENDERER::Draw(), 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  if( aBackground != COLOR4D::UNSPECIFIED )
58  {
59  brush.SetColour( aBackground.WithAlpha(1.0).ToColour() );
60  bmpDC.SetBrush( brush );
61  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
62  }
63 
64  brush.SetColour( aColor.ToColour() );
65  bmpDC.SetBrush( brush );
66  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
67 
68  bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
69  bmpDC.SetPen( *wxBLACK_PEN );
70  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
71 }
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:233
int LAYER_BOX_SELECTOR::GetChoice ( )
inherited

Definition at line 114 of file layer_box_selector.cpp.

115 {
116  return GetSelection();
117 }
COLOR4D GBR_LAYER_BOX_SELECTOR::GetLayerColor ( int  aLayer) const
overridevirtual

Implements LAYER_SELECTOR.

Definition at line 68 of file gbr_layer_box_selector.cpp.

References GERBER_DRAW_LAYER, and GERBVIEW_FRAME::GetLayerColor().

Referenced by GBR_LAYER_BOX_SELECTOR(), and Resync().

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)
wxString GBR_LAYER_BOX_SELECTOR::GetLayerName ( int  aLayer) const
overridevirtual

Implements LAYER_SELECTOR.

Definition at line 77 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().

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
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, LAYER_SELECTOR::DrawColorSwatch(), GERBER_FILE_IMAGE_LIST::GetImagesList(), GetLayerColor(), GetLayerName(), GERBER_FILE_IMAGE_LIST::ImagesMaxCount(), IsLayerEnabled(), and LAYER_PCB_BACKGROUND.

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  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
void LAYER_BOX_SELECTOR::ResyncBitmapOnly ( )
inherited

Definition at line 155 of file layer_box_selector.cpp.

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().

156 {
157  int elements = GetCount();
158 
159  for( LAYER_NUM i = 0; i < elements; ++i )
160  {
161  wxBitmap layerbmp( 14, 14 );
163  }
164 }
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:597
int LAYER_BOX_SELECTOR::SetLayerSelection ( LAYER_NUM  layer)
inherited

Definition at line 131 of file layer_box_selector.cpp.

References i.

Referenced by GRID_CELL_LAYER_SELECTOR::BeginEdit(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildFilterLists(), DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), 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().

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

Member Data Documentation

struct EDA_HOTKEY_CONFIG* LAYER_BOX_SELECTOR::m_hotkeys
inherited

Definition at line 76 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: