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[]=nullptr)
 
 LAYER_BOX_SELECTOR (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayString &choices)
 
 ~LAYER_BOX_SELECTOR () override
 
int GetLayerSelection () const
 
int SetLayerSelection (int layer)
 
virtual void Resync ()=0
 
void ResyncBitmapOnly ()
 
bool SetLayersHotkeys (bool value)
 

Static Public Member Functions

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

Protected Member Functions

virtual COLOR4D getLayerColor (int aLayer) const =0
 
virtual wxString getLayerName (int aLayer) const =0
 
virtual bool isLayerEnabled (int aLayer) const =0
 

Protected Attributes

bool m_layerhotkeys
 

Private Member Functions

void onKeyDown (wxKeyEvent &aEvent)
 

Detailed Description

Definition at line 69 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[] = nullptr 
)

Definition at line 75 of file layer_box_selector.cpp.

76 :
77 wxBitmapComboBox( parent, id, wxEmptyString, pos, size, n, choices, wxCB_READONLY ),
79{
80 if( choices != nullptr )
82
83 GetParent()->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( LAYER_BOX_SELECTOR::onKeyDown ),
84 nullptr, this );
85}
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 88 of file layer_box_selector.cpp.

89 :
90 wxBitmapComboBox( parent, id, wxEmptyString, pos, size, choices, wxCB_READONLY ),
92{
93 if( !choices.IsEmpty() )
95
96 GetParent()->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( LAYER_BOX_SELECTOR::onKeyDown ),
97 nullptr, this );
98}

References onKeyDown(), and ResyncBitmapOnly().

◆ ~LAYER_BOX_SELECTOR()

LAYER_BOX_SELECTOR::~LAYER_BOX_SELECTOR ( )
override

Definition at line 101 of file layer_box_selector.cpp.

102{
103 GetParent()->Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( LAYER_BOX_SELECTOR::onKeyDown ),
104 nullptr, this );
105}

References onKeyDown().

Member Function Documentation

◆ DrawColorSwatch()

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

Definition at line 47 of file layer_box_selector.cpp.

49{
50 wxMemoryDC bmpDC;
51 wxBrush brush;
52
53 // Prepare Bitmap
54 bmpDC.SelectObject( aLayerbmp );
55
56 brush.SetStyle( wxBRUSHSTYLE_SOLID );
57
58 if( aBackground != COLOR4D::UNSPECIFIED )
59 {
60 brush.SetColour( aBackground.WithAlpha( 1.0 ).ToColour() );
61 bmpDC.SetBrush( brush );
62 bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
63 }
64
65 brush.SetColour( aColor.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}
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
Definition: color4d.h:321

References KIGFX::COLOR4D::WithAlpha().

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

◆ getLayerColor()

virtual COLOR4D LAYER_SELECTOR::getLayerColor ( int  aLayer) const
protectedpure virtualinherited

◆ getLayerName()

virtual wxString LAYER_SELECTOR::getLayerName ( int  aLayer) const
protectedpure virtualinherited

◆ GetLayerSelection()

◆ isLayerEnabled()

virtual bool LAYER_SELECTOR::isLayerEnabled ( int  aLayer) const
protectedpure virtualinherited

◆ onKeyDown()

void LAYER_BOX_SELECTOR::onKeyDown ( wxKeyEvent &  aEvent)
private

Definition at line 151 of file layer_box_selector.cpp.

152{
153#ifdef __WXOSX_MAC__
154 if( aEvent.GetKeyCode() == WXK_ESCAPE && IsPopupShown() )
155 {
156 Dismiss();
157 return;
158 }
159#endif
160
161 aEvent.Skip();
162}

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 141 of file layer_box_selector.cpp.

142{
143 for( int i = 0; i < (int) GetCount(); ++i )
144 {
145 wxBitmap layerbmp( 14, 14 );
147 }
148}
virtual COLOR4D getLayerColor(int aLayer) const =0
static void DrawColorSwatch(wxBitmap &aLayerbmp, const COLOR4D &aBackground, const COLOR4D &aColor)
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition: layer_ids.h:220

References LAYER_SELECTOR::DrawColorSwatch(), LAYER_SELECTOR::getLayerColor(), and LAYER_PCB_BACKGROUND.

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

◆ SetLayerSelection()

int LAYER_BOX_SELECTOR::SetLayerSelection ( int  layer)

Definition at line 117 of file layer_box_selector.cpp.

118{
119 for( int i = 0; i < (int) GetCount(); i++ )
120 {
121 if( GetClientData( (unsigned) i ) == (void*)(intptr_t) layer )
122 {
123 if( GetSelection() != i ) // Element (i) is not selected
124 {
125 SetSelection( i );
126 return i;
127 }
128 else
129 {
130 return i; // If element already selected; do nothing
131 }
132 }
133 }
134
135 // Not Found
136 SetSelection( -1 );
137 return -1;
138}

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_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow(), and PCB_EDIT_FRAME::UpdateUserInterface().

◆ SetLayersHotkeys()

Member Data Documentation

◆ m_layerhotkeys

bool LAYER_SELECTOR::m_layerhotkeys
protectedinherited

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