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 96 of file class_layer_box_selector.cpp.

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

Implements LAYER_SELECTOR.

Definition at line 72 of file class_gbr_layer_box_selector.cpp.

References GERBER_DRAW_LAYER, and GERBVIEW_FRAME::GetLayerColor().

73 {
74  GERBVIEW_FRAME* frame = (GERBVIEW_FRAME*) GetParent()->GetParent();
75 
76  return frame->GetLayerColor( GERBER_DRAW_LAYER( aLayer ) );
77 }
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 81 of file class_gbr_layer_box_selector.cpp.

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

Referenced by Resync().

82 {
84  wxString name = images.GetDisplayName( aLayer );
85 
86  return name;
87 }
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
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 38 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().

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

References LAYER_SELECTOR::SetBitmapLayer().

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

138 {
139  int elements = GetCount();
140 
141  for( LAYER_NUM i = 0; i < elements; ++i )
142  {
143  wxBitmap layerbmp( 14, 14 );
144  SetBitmapLayer( layerbmp, i );
145  }
146 }
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 50 of file class_layer_box_selector.cpp.

References LAYER_SELECTOR::GetLayerColor().

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

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

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

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