KiCad PCB EDA Suite
PCB_LAYER_BOX_SELECTOR Class Reference

Class to display a pcb layer list in a wxBitmapComboBox. More...

#include <class_pcb_layer_box_selector.h>

Inheritance diagram for PCB_LAYER_BOX_SELECTOR:
LAYER_BOX_SELECTOR LAYER_SELECTOR

Public Member Functions

 PCB_LAYER_BOX_SELECTOR (wxWindow *parent, wxWindowID id, const wxString &value=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int n=0, const wxString choices[]=NULL, int style=0)
 
void SetBoardFrame (PCB_BASE_FRAME *aFrame)
 
void SetLayerSet (LSET aMask)
 
void Resync () override
 
void ShowNonActivatedLayers (bool aShow)
 
int GetChoice ()
 
LAYER_NUM GetLayerSelection () const
 
int SetLayerSelection (LAYER_NUM layer)
 
void ResyncBitmapOnly ()
 
bool SetLayersOrdered (bool value)
 
bool SetLayersHotkeys (bool value)
 

Public Attributes

EDA_HOTKEY_CONFIGm_hotkeys
 

Protected Member Functions

void SetBitmapLayer (wxBitmap &aLayerbmp, LAYER_NUM aLayer)
 

Protected Attributes

bool m_layerhotkeys
 

Private Member Functions

COLOR4D GetLayerColor (LAYER_NUM aLayer) const override
 
bool IsLayerEnabled (LAYER_NUM aLayer) const override
 
wxString GetLayerName (LAYER_NUM aLayer) const override
 
LSET getEnabledLayers () const
 

Private Attributes

PCB_BASE_FRAMEm_boardFrame
 
LSET m_layerMaskDisable
 
bool m_showNotEnabledBrdlayers
 

Detailed Description

Class to display a pcb layer list in a wxBitmapComboBox.

Definition at line 35 of file class_pcb_layer_box_selector.h.

Constructor & Destructor Documentation

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

Definition at line 54 of file class_pcb_layer_box_selector.h.

58  :
59  LAYER_BOX_SELECTOR( parent, id, pos, size, n, choices )
60  {
61  m_boardFrame = NULL;
62  m_hotkeys = NULL;
64  }
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 }
LSET PCB_LAYER_BOX_SELECTOR::getEnabledLayers ( ) const
private

Definition at line 137 of file class_pcb_layer_box_selector.cpp.

References PCB_BASE_FRAME::GetBoard(), BOARD::GetEnabledLayers(), and m_boardFrame.

Referenced by Resync().

138 {
139  wxASSERT( m_boardFrame != NULL );
140  BOARD* board = m_boardFrame->GetBoard();
141  wxASSERT( board != NULL );
142 
143  return board->GetEnabledLayers();
144 }
BOARD * GetBoard() const
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
COLOR4D PCB_LAYER_BOX_SELECTOR::GetLayerColor ( LAYER_NUM  aLayer) const
overrideprivatevirtual

Implements LAYER_SELECTOR.

Definition at line 148 of file class_pcb_layer_box_selector.cpp.

References PCB_GENERAL_SETTINGS::Colors(), COLORS_DESIGN_SETTINGS::GetLayerColor(), m_boardFrame, PCB_BASE_FRAME::Settings(), and ToLAYER_ID().

149 {
150  wxASSERT( m_boardFrame );
151 
152  return m_boardFrame->Settings().Colors().GetLayerColor( ToLAYER_ID( aLayer ) );
153 }
PCB_GENERAL_SETTINGS & Settings()
COLORS_DESIGN_SETTINGS & Colors()
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
wxString PCB_LAYER_BOX_SELECTOR::GetLayerName ( LAYER_NUM  aLayer) const
overrideprivatevirtual

Implements LAYER_SELECTOR.

Definition at line 157 of file class_pcb_layer_box_selector.cpp.

References PCB_BASE_FRAME::GetBoard(), BOARD::GetLayerName(), m_boardFrame, and ToLAYER_ID().

Referenced by Resync().

158 {
159  wxASSERT( m_boardFrame );
160  BOARD* board = m_boardFrame->GetBoard();
161  wxASSERT( board );
162 
163  return board->GetLayerName( ToLAYER_ID( aLayer ) );
164 }
BOARD * GetBoard() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer given by aLayer.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
bool PCB_LAYER_BOX_SELECTOR::IsLayerEnabled ( LAYER_NUM  aLayer) const
overrideprivatevirtual

Implements LAYER_SELECTOR.

Definition at line 127 of file class_pcb_layer_box_selector.cpp.

References PCB_BASE_FRAME::GetBoard(), BOARD::IsLayerEnabled(), m_boardFrame, and ToLAYER_ID().

128 {
129  wxASSERT( m_boardFrame != NULL );
130  BOARD* board = m_boardFrame->GetBoard();
131  wxASSERT( board != NULL );
132 
133  return board->IsLayerEnabled( ToLAYER_ID( aLayer ) );
134 }
bool IsLayerEnabled(PCB_LAYER_ID aLayer) const
Function IsLayerEnabled is a proxy function that calls the correspondent function in m_BoardSettings ...
Definition: class_board.h:439
BOARD * GetBoard() const
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
void PCB_LAYER_BOX_SELECTOR::Resync ( )
overridevirtual

Implements LAYER_BOX_SELECTOR.

Definition at line 75 of file class_pcb_layer_box_selector.cpp.

References AddHotkeyName(), LSET::AllLayersMask(), BM_SIZE, getEnabledLayers(), GetLayerName(), IS_COMMENT, layer2hotkey_id(), m_hotkeys, LAYER_SELECTOR::m_layerhotkeys, m_layerMaskDisable, m_showNotEnabledBrdlayers, max, LAYER_SELECTOR::SetBitmapLayer(), and LSET::UIOrder().

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::ReCreateLayerBox(), DialogEditModuleText::TransferDataToWindow(), DIALOG_PCB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::TransferDataToWindow(), and DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow().

76 {
77  Clear();
78 
79  // Tray to fix a minimum width fot the BitmapComboBox
80  int minwidth = 80;
81 
82  wxClientDC dc( GetParent() ); // The DC for "this" is not always initialized
83 
84  const int BM_SIZE = 14;
85 
87  LSET activated = getEnabledLayers() & ~m_layerMaskDisable;
88  wxString layerstatus;
89 
90  for( LSEQ seq = show.UIOrder(); seq; ++seq )
91  {
92  PCB_LAYER_ID layerid = *seq;
93 
94  if( !m_showNotEnabledBrdlayers && !activated[layerid] )
95  continue;
96  else if( !activated[layerid] )
97  layerstatus = wxT( " " ) + _( "(not activated)" );
98  else
99  layerstatus.Empty();
100 
101  wxBitmap layerbmp( BM_SIZE, BM_SIZE );
102  SetBitmapLayer( layerbmp, layerid );
103 
104  wxString layername = GetLayerName( layerid ) + layerstatus;
105 
106  if( m_layerhotkeys && m_hotkeys )
107  {
108  int id = layer2hotkey_id( layerid );
109 
110  if( id != -1 )
111  layername = AddHotkeyName( layername, m_hotkeys, id, IS_COMMENT );
112  }
113 
114  Append( layername, layerbmp, (void*)(intptr_t) layerid );
115 
116  int w, h;
117  dc.GetTextExtent ( layername, &w, &h );
118  minwidth = std::max( minwidth, w );
119  }
120 
121  minwidth += BM_SIZE + 35; // Take in account the bitmap size and margins
122  SetMinSize( wxSize( minwidth, -1 ) );
123 }
void SetBitmapLayer(wxBitmap &aLayerbmp, LAYER_NUM aLayer)
static int layer2hotkey_id(PCB_LAYER_ID aLayer)
PCB_LAYER_ID
A quick note on layer IDs:
Class LSET is a set of PCB_LAYER_IDs.
static LSET AllLayersMask()
Definition: lset.cpp:676
Class LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
#define BM_SIZE
wxString AddHotkeyName(const wxString &aText, EDA_HOTKEY **aList, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType)
Function AddHotkeyName Add the key name from the Command id value ( m_Idcommand member value) ...
#define max(a, b)
Definition: auxiliary.h:86
wxString GetLayerName(LAYER_NUM aLayer) const override
LSEQ UIOrder() const
Definition: lset.cpp:752
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 GBR_LAYER_BOX_SELECTOR::Resync(), 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
void PCB_LAYER_BOX_SELECTOR::ShowNonActivatedLayers ( bool  aShow)
inline

Member Data Documentation

PCB_BASE_FRAME* PCB_LAYER_BOX_SELECTOR::m_boardFrame
private
EDA_HOTKEY_CONFIG* PCB_LAYER_BOX_SELECTOR::m_hotkeys

Definition at line 46 of file class_pcb_layer_box_selector.h.

Referenced by PCB_EDIT_FRAME::ReCreateLayerBox(), and Resync().

bool LAYER_SELECTOR::m_layerhotkeys
protectedinherited
LSET PCB_LAYER_BOX_SELECTOR::m_layerMaskDisable
private

Definition at line 39 of file class_pcb_layer_box_selector.h.

Referenced by Resync().

bool PCB_LAYER_BOX_SELECTOR::m_showNotEnabledBrdlayers
private

Definition at line 41 of file class_pcb_layer_box_selector.h.

Referenced by Resync().


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