KiCad PCB EDA Suite
LAYER_BOX_SELECTOR Class Referenceabstract

#include <layer_box_selector.h>

Inheritance diagram for LAYER_BOX_SELECTOR:
LAYER_SELECTOR GBR_LAYER_BOX_SELECTOR PCB_LAYER_BOX_SELECTOR

Public Member Functions

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

Static Public Member Functions

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

Protected Attributes

bool m_layerhotkeys
 

Private Member Functions

void onKeyDown (wxKeyEvent &aEvent)
 

Detailed Description

Definition at line 67 of file layer_box_selector.h.

Constructor & Destructor Documentation

◆ LAYER_BOX_SELECTOR() [1/2]

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

Definition at line 76 of file layer_box_selector.cpp.

78  :
79  wxBitmapComboBox( parent, id, wxEmptyString, pos, size, n, choices, wxCB_READONLY ),
81 {
82  if( choices != NULL )
84 
85  GetParent()->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( LAYER_BOX_SELECTOR::onKeyDown ), NULL, this );
86 }
void onKeyDown(wxKeyEvent &aEvent)

References onKeyDown(), and ResyncBitmapOnly().

◆ LAYER_BOX_SELECTOR() [2/2]

LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR ( wxWindow *  parent,
wxWindowID  id,
const wxPoint &  pos,
const wxSize &  size,
const wxArrayString &  choices 
)

Definition at line 89 of file layer_box_selector.cpp.

91  :
92  wxBitmapComboBox( parent, id, wxEmptyString, pos, size, choices, wxCB_READONLY ),
94 {
95  if( !choices.IsEmpty() )
97 
98  GetParent()->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( LAYER_BOX_SELECTOR::onKeyDown ), NULL, this );
99 }
void onKeyDown(wxKeyEvent &aEvent)

References onKeyDown(), and ResyncBitmapOnly().

◆ ~LAYER_BOX_SELECTOR()

LAYER_BOX_SELECTOR::~LAYER_BOX_SELECTOR ( )
override

Definition at line 102 of file layer_box_selector.cpp.

103 {
104  GetParent()->Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( LAYER_BOX_SELECTOR::onKeyDown ), NULL, this );
105 }
void onKeyDown(wxKeyEvent &aEvent)

References onKeyDown().

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 GRID_CELL_LAYER_RENDERER::Draw(), GBR_LAYER_BOX_SELECTOR::Resync(), PCB_LAYER_BOX_SELECTOR::Resync(), and ResyncBitmapOnly().

◆ GetChoice()

int LAYER_BOX_SELECTOR::GetChoice ( )

Definition at line 109 of file layer_box_selector.cpp.

110 {
111  return GetSelection();
112 }

◆ GetLayerColor()

virtual COLOR4D LAYER_SELECTOR::GetLayerColor ( LAYER_NUM  aLayer) const
pure virtualinherited

◆ GetLayerName()

virtual wxString LAYER_SELECTOR::GetLayerName ( LAYER_NUM  aLayer) const
pure virtualinherited

◆ GetLayerSelection()

◆ IsLayerEnabled()

virtual bool LAYER_SELECTOR::IsLayerEnabled ( LAYER_NUM  aLayer) const
pure virtualinherited

◆ onKeyDown()

void LAYER_BOX_SELECTOR::onKeyDown ( wxKeyEvent &  aEvent)
private

Definition at line 162 of file layer_box_selector.cpp.

163 {
164 #ifdef __WXOSX_MAC__
165  if( aEvent.GetKeyCode() == WXK_ESCAPE && IsPopupShown() )
166  {
167  Dismiss();
168  return;
169  }
170 #endif
171 
172  aEvent.Skip();
173 }

Referenced by LAYER_BOX_SELECTOR(), and ~LAYER_BOX_SELECTOR().

◆ Resync()

virtual void LAYER_BOX_SELECTOR::Resync ( )
pure virtual

◆ ResyncBitmapOnly()

void LAYER_BOX_SELECTOR::ResyncBitmapOnly ( )

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

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

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

◆ SetLayerSelection()

int LAYER_BOX_SELECTOR::SetLayerSelection ( LAYER_NUM  layer)

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

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(), 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: