KiCad PCB EDA Suite
GBR_LAYER_BOX_SELECTOR Class Reference

#include <class_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 SetLayersOrdered (bool value)
 
bool SetLayersHotkeys (bool value)
 

Public Attributes

struct EDA_HOTKEY_CONFIGm_hotkeys
 

Protected Member Functions

void SetBitmapLayer (wxBitmap &aLayerbmp, LAYER_NUM aLayer)
 

Protected Attributes

bool m_layerhotkeys
 

Detailed Description

Definition at line 32 of file class_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 class_gbr_layer_box_selector.h.

References LAYER_SELECTOR::m_layerhotkeys.

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

int LAYER_BOX_SELECTOR::GetChoice ( )
inherited

Definition at line 97 of file class_layer_box_selector.cpp.

98 {
99  return GetSelection();
100 }
COLOR4D GBR_LAYER_BOX_SELECTOR::GetLayerColor ( int  aLayer) const
overridevirtual

Implements LAYER_SELECTOR.

Definition at line 73 of file class_gbr_layer_box_selector.cpp.

References GERBVIEW_FRAME::GetLayerColor().

74 {
75  GERBVIEW_FRAME* frame = (GERBVIEW_FRAME*) GetParent()->GetParent();
76 
77  return frame->GetLayerColor( aLayer );
78 }
COLOR4D GetLayerColor(int aLayer) const
Function GetLayerColor gets a layer color for any valid layer.
wxString GBR_LAYER_BOX_SELECTOR::GetLayerName ( int  aLayer) const
overridevirtual

Implements LAYER_SELECTOR.

Definition at line 82 of file class_gbr_layer_box_selector.cpp.

References GERBER_FILE_IMAGE_LIST::GetDisplayName(), and GERBER_FILE_IMAGE_LIST::GetImagesList().

Referenced by Resync().

83 {
85  wxString name = images.GetDisplayName( aLayer );
86 
87  return name;
88 }
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()
bool GBR_LAYER_BOX_SELECTOR::IsLayerEnabled ( int  aLayer) const
inlineoverridevirtual

Implements LAYER_SELECTOR.

Definition at line 53 of file class_gbr_layer_box_selector.h.

Referenced by Resync().

53 { return true; }
void GBR_LAYER_BOX_SELECTOR::Resync ( )
overridevirtual

Implements LAYER_BOX_SELECTOR.

Definition at line 39 of file class_gbr_layer_box_selector.cpp.

References BM_SIZE, GERBER_FILE_IMAGE_LIST::GetImagesList(), GetLayerName(), GERBER_FILE_IMAGE_LIST::ImagesMaxCount(), IsLayerEnabled(), and LAYER_SELECTOR::SetBitmapLayer().

Referenced by GERBVIEW_FRAME::ReCreateHToolbar(), GERBVIEW_FRAME::ReFillLayerWidget(), and GERBVIEW_FRAME::syncLayerBox().

40 {
41  #define BM_SIZE 14
42  Freeze();
43  Clear();
44 
46 
47  for( unsigned layerid = 0; layerid < images.ImagesMaxCount(); ++layerid )
48  {
49  wxBitmap layerbmp( BM_SIZE, BM_SIZE );
50  wxString layername;
51 
52  if( !IsLayerEnabled( layerid ) )
53  continue;
54 
55  // Prepare Bitmap
56  SetBitmapLayer( layerbmp, layerid );
57 
58  layername = GetLayerName( layerid );
59 
60  Append( layername, layerbmp, (void*)(intptr_t) layerid );
61  }
62 
63  // Ensure the width of the widget is enough to show the text and the icon
64  SetMinSize( wxSize( -1, -1 ) );
65  int minwidth = GetBestSize().x + BM_SIZE + 10;
66  SetMinSize( wxSize( minwidth, -1 ) );
67 
68  Thaw();
69 }
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...
void SetBitmapLayer(wxBitmap &aLayerbmp, LAYER_NUM aLayer)
static GERBER_FILE_IMAGE_LIST & GetImagesList()
#define BM_SIZE
bool IsLayerEnabled(int aLayer) const override
void LAYER_BOX_SELECTOR::ResyncBitmapOnly ( )
inherited

Definition at line 138 of file class_layer_box_selector.cpp.

References LAYER_SELECTOR::SetBitmapLayer().

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

139 {
140  int elements = GetCount();
141 
142  for( LAYER_NUM i = 0; i < elements; ++i )
143  {
144  wxBitmap layerbmp( 14, 14 );
145  SetBitmapLayer( layerbmp, i );
146  }
147 }
void SetBitmapLayer(wxBitmap &aLayerbmp, LAYER_NUM aLayer)
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
void LAYER_SELECTOR::SetBitmapLayer ( wxBitmap &  aLayerbmp,
LAYER_NUM  aLayer 
)
protectedinherited

Definition at line 51 of file class_layer_box_selector.cpp.

References LAYER_SELECTOR::GetLayerColor().

Referenced by Resync(), PCB_LAYER_BOX_SELECTOR::Resync(), and LAYER_BOX_SELECTOR::ResyncBitmapOnly().

52 {
53  wxMemoryDC bmpDC;
54  wxBrush brush;
55 
56  // Prepare Bitmap
57  bmpDC.SelectObject( aLayerbmp );
58  brush.SetColour( GetLayerColor( aLayer ).ToColour() );
59  brush.SetStyle( wxBRUSHSTYLE_SOLID );
60 
61  bmpDC.SetBrush( brush );
62  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
63  bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
64  bmpDC.SetPen( *wxBLACK_PEN );
65  bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
66 }
virtual COLOR4D GetLayerColor(LAYER_NUM aLayer) const =0
int LAYER_BOX_SELECTOR::SetLayerSelection ( LAYER_NUM  layer)
inherited

Definition at line 114 of file class_layer_box_selector.cpp.

Referenced by DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR(), DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), PCB_EDIT_FRAME::OnUpdateLayerSelectBox(), DialogEditModuleText::TransferDataToWindow(), DIALOG_PCB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::TransferDataToWindow(), and DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow().

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

Member Data Documentation

struct EDA_HOTKEY_CONFIG* LAYER_BOX_SELECTOR::m_hotkeys
inherited

Definition at line 78 of file class_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: