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)
 

Public Attributes

struct EDA_HOTKEY_CONFIGm_hotkeys
 

Protected Attributes

bool m_layerhotkeys
 

Private Member Functions

void onKeyDown (wxKeyEvent &aEvent)
 

Detailed Description

Definition at line 72 of file layer_box_selector.h.

Constructor & Destructor Documentation

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

References m_hotkeys, onKeyDown(), and ResyncBitmapOnly().

79  :
80  wxBitmapComboBox( parent, id, wxEmptyString, pos, size, n, choices, wxCB_READONLY ),
82 {
83  m_hotkeys = NULL;
84 
85  if( choices != NULL )
87 
88  GetParent()->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( LAYER_BOX_SELECTOR::onKeyDown ), NULL, this );
89 }
struct EDA_HOTKEY_CONFIG * m_hotkeys
void onKeyDown(wxKeyEvent &aEvent)
LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR ( wxWindow *  parent,
wxWindowID  id,
const wxPoint pos,
const wxSize &  size,
const wxArrayString &  choices 
)

Definition at line 92 of file layer_box_selector.cpp.

References m_hotkeys, onKeyDown(), and ResyncBitmapOnly().

94  :
95  wxBitmapComboBox( parent, id, wxEmptyString, pos, size, choices, wxCB_READONLY ),
97 {
98  m_hotkeys = NULL;
99 
100  if( !choices.IsEmpty() )
102 
103  GetParent()->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( LAYER_BOX_SELECTOR::onKeyDown ), NULL, this );
104 }
struct EDA_HOTKEY_CONFIG * m_hotkeys
void onKeyDown(wxKeyEvent &aEvent)
LAYER_BOX_SELECTOR::~LAYER_BOX_SELECTOR ( )
override

Definition at line 107 of file layer_box_selector.cpp.

References onKeyDown().

108 {
109  GetParent()->Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( LAYER_BOX_SELECTOR::onKeyDown ), NULL, this );
110 }
void onKeyDown(wxKeyEvent &aEvent)

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

Definition at line 114 of file layer_box_selector.cpp.

115 {
116  return GetSelection();
117 }
virtual COLOR4D LAYER_SELECTOR::GetLayerColor ( LAYER_NUM  aLayer) const
pure virtualinherited
virtual wxString LAYER_SELECTOR::GetLayerName ( LAYER_NUM  aLayer) const
pure virtualinherited
virtual bool LAYER_SELECTOR::IsLayerEnabled ( LAYER_NUM  aLayer) const
pure virtualinherited
void LAYER_BOX_SELECTOR::onKeyDown ( wxKeyEvent &  aEvent)
private

Definition at line 167 of file layer_box_selector.cpp.

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

168 {
169 #ifdef __WXOSX_MAC__
170  if( aEvent.GetKeyCode() == WXK_ESCAPE && IsPopupShown() )
171  {
172  Dismiss();
173  return;
174  }
175 #endif
176 
177  aEvent.Skip();
178 }
virtual void LAYER_BOX_SELECTOR::Resync ( )
pure virtual
void LAYER_BOX_SELECTOR::ResyncBitmapOnly ( )

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

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

Definition at line 76 of file layer_box_selector.h.

Referenced by LAYER_BOX_SELECTOR().

bool LAYER_SELECTOR::m_layerhotkeys
protectedinherited

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