KiCad PCB EDA Suite
GRID_CELL_LAYER_SELECTOR Class Reference

#include <grid_layer_box_helpers.h>

Inheritance diagram for GRID_CELL_LAYER_SELECTOR:

Public Member Functions

 GRID_CELL_LAYER_SELECTOR (PCB_BASE_FRAME *aFrame, LSET forbiddenLayers)
 
wxGridCellEditor * Clone () const override
 
void Create (wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
 
wxString GetValue () const override
 
void SetSize (const wxRect &aRect) override
 
void BeginEdit (int aRow, int aCol, wxGrid *aGrid) override
 
bool EndEdit (int, int, const wxGrid *, const wxString &, wxString *newval) override
 
void ApplyEdit (int aRow, int aCol, wxGrid *aGrid) override
 
void Reset () override
 

Protected Member Functions

PCB_LAYER_BOX_SELECTORLayerBox () const
 
 wxDECLARE_NO_COPY_CLASS (GRID_CELL_LAYER_SELECTOR)
 

Protected Attributes

PCB_BASE_FRAMEm_frame
 
LSET m_mask
 
LAYER_NUM m_value
 

Detailed Description

Definition at line 55 of file grid_layer_box_helpers.h.

Constructor & Destructor Documentation

GRID_CELL_LAYER_SELECTOR::GRID_CELL_LAYER_SELECTOR ( PCB_BASE_FRAME aFrame,
LSET  forbiddenLayers 
)

Definition at line 80 of file grid_layer_box_helpers.cpp.

Referenced by Clone().

80  :
81  m_frame( aFrame ),
82  m_mask( aMask )
83 {
84 }

Member Function Documentation

void GRID_CELL_LAYER_SELECTOR::ApplyEdit ( int  aRow,
int  aCol,
wxGrid *  aGrid 
)
override

Definition at line 183 of file grid_layer_box_helpers.cpp.

References m_value.

184 {
185  aGrid->GetTable()->SetValueAsLong( aRow, aCol, (long) m_value );
186 }
void GRID_CELL_LAYER_SELECTOR::BeginEdit ( int  aRow,
int  aCol,
wxGrid *  aGrid 
)
override

Definition at line 131 of file grid_layer_box_helpers.cpp.

References PCB_BASE_FRAME::GetBoard(), BOARD::IsLayerEnabled(), LayerBox(), m_frame, m_value, PCB_LAYER_BOX_SELECTOR::Resync(), LAYER_BOX_SELECTOR::SetLayerSelection(), PCB_LAYER_BOX_SELECTOR::ShowNonActivatedLayers(), and ToLAYER_ID().

132 {
133  auto* evtHandler = static_cast<wxGridCellEditorEvtHandler*>( m_control->GetEventHandler() );
134 
135  // Don't immediately end if we get a kill focus event within BeginEdit
136  evtHandler->SetInSetFocus( true );
137 
138  m_value = (LAYER_NUM) aGrid->GetTable()->GetValueAsLong( aRow, aCol );
139 
140  // Footprints are defined in a global context and may contain layers not enabled
141  // on the current board. Check and display all layers if so.
142  bool currentLayerEnabled = m_frame->GetBoard()->IsLayerEnabled( ToLAYER_ID( m_value ) );
143  LayerBox()->ShowNonActivatedLayers( !currentLayerEnabled );
144  LayerBox()->Resync();
145 
147  LayerBox()->SetFocus();
148 
149 #ifdef __WXOSX_COCOA__
150  // This is a work around for the combobox being simply dismissed when a
151  // choice is made in it under OS X. The bug is almost certainly due to a
152  // problem in focus events generation logic but it's not obvious to fix and
153  // for now this at least allows to use wxGrid.
154  if( !LayerBox()->IsPopupShown() )
155  LayerBox()->Popup();
156 #endif
157 
158  // When dropping down the menu, a kill focus event
159  // happens after this point, so we can't reset the flag yet.
160 #if !defined(__WXGTK20__)
161  evtHandler->SetInSetFocus( false );
162 #endif
163 }
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:445
BOARD * GetBoard() const
PCB_LAYER_BOX_SELECTOR * LayerBox() const
void ShowNonActivatedLayers(bool aShow)
int SetLayerSelection(LAYER_NUM layer)
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:810
wxGridCellEditor * GRID_CELL_LAYER_SELECTOR::Clone ( ) const
override

Definition at line 87 of file grid_layer_box_helpers.cpp.

References GRID_CELL_LAYER_SELECTOR(), m_frame, and m_mask.

88 {
90 }
GRID_CELL_LAYER_SELECTOR(PCB_BASE_FRAME *aFrame, LSET forbiddenLayers)
void GRID_CELL_LAYER_SELECTOR::Create ( wxWindow *  aParent,
wxWindowID  aId,
wxEvtHandler *  aEventHandler 
)
override

Definition at line 93 of file grid_layer_box_helpers.cpp.

References LayerBox(), m_frame, m_mask, PCB_LAYER_BOX_SELECTOR::SetBoardFrame(), and PCB_LAYER_BOX_SELECTOR::SetNotAllowedLayerSet().

95 {
96  m_control = new PCB_LAYER_BOX_SELECTOR( aParent, aId, wxEmptyString,
97  wxDefaultPosition, wxDefaultSize, 0, nullptr,
98  wxCB_READONLY | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB | wxBORDER_NONE );
99 
102 
103  wxGridCellEditor::Create(aParent, aId, aEventHandler);
104 }
void SetNotAllowedLayerSet(LSET aMask)
Class to display a pcb layer list in a wxBitmapComboBox.
void SetBoardFrame(PCB_BASE_FRAME *aFrame)
PCB_LAYER_BOX_SELECTOR * LayerBox() const
bool GRID_CELL_LAYER_SELECTOR::EndEdit ( int  ,
int  ,
const wxGrid *  ,
const wxString &  ,
wxString *  newval 
)
override

Definition at line 166 of file grid_layer_box_helpers.cpp.

References LAYER_BOX_SELECTOR::GetLayerSelection(), GetValue(), LayerBox(), and m_value.

168 {
169  const LAYER_NUM value = LayerBox()->GetLayerSelection();
170 
171  if ( value == m_value )
172  return false;
173 
174  m_value = value;
175 
176  if ( newval )
177  *newval = GetValue();
178 
179  return true;
180 }
wxString GetValue() const override
PCB_LAYER_BOX_SELECTOR * LayerBox() const
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
LAYER_NUM GetLayerSelection() const
wxString GRID_CELL_LAYER_SELECTOR::GetValue ( ) const
override

Definition at line 107 of file grid_layer_box_helpers.cpp.

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

Referenced by EndEdit().

108 {
109  return m_frame->GetBoard()->GetLayerName( ToLAYER_ID( LayerBox()->GetLayerSelection() ) );
110 }
BOARD * GetBoard() const
PCB_LAYER_BOX_SELECTOR * LayerBox() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer given by aLayer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:810
PCB_LAYER_BOX_SELECTOR* GRID_CELL_LAYER_SELECTOR::LayerBox ( ) const
inlineprotected

Definition at line 73 of file grid_layer_box_helpers.h.

Referenced by BeginEdit(), Create(), EndEdit(), GetValue(), Reset(), and SetSize().

74  {
75  return static_cast<PCB_LAYER_BOX_SELECTOR*>( m_control );
76  }
Class to display a pcb layer list in a wxBitmapComboBox.
void GRID_CELL_LAYER_SELECTOR::Reset ( )
override

Definition at line 189 of file grid_layer_box_helpers.cpp.

References LayerBox(), m_value, and LAYER_BOX_SELECTOR::SetLayerSelection().

190 {
192 }
PCB_LAYER_BOX_SELECTOR * LayerBox() const
int SetLayerSelection(LAYER_NUM layer)
void GRID_CELL_LAYER_SELECTOR::SetSize ( const wxRect &  aRect)
override

Definition at line 113 of file grid_layer_box_helpers.cpp.

References LayerBox().

114 {
115  wxRect rect( aRect );
116  rect.Inflate( -1 );
117 
118 #if !defined( __WXMSW__ ) && !defined( __WXGTK20__ )
119  // Only implemented in generic wxBitmapComboBox; MSW and GTK use native controls
120  LayerBox()->SetButtonPosition( 0, 0, wxRIGHT, 0 );
121 #endif
122 
123 #if defined( __WXMAC__ )
124  rect.Inflate( 3 ); // no FOCUS_RING, even on Mac
125 #endif
126 
127  LayerBox()->SetSize( rect, wxSIZE_ALLOW_MINUS_ONE );
128 }
PCB_LAYER_BOX_SELECTOR * LayerBox() const
GRID_CELL_LAYER_SELECTOR::wxDECLARE_NO_COPY_CLASS ( GRID_CELL_LAYER_SELECTOR  )
protected

Member Data Documentation

PCB_BASE_FRAME* GRID_CELL_LAYER_SELECTOR::m_frame
protected

Definition at line 78 of file grid_layer_box_helpers.h.

Referenced by BeginEdit(), Clone(), Create(), and GetValue().

LSET GRID_CELL_LAYER_SELECTOR::m_mask
protected

Definition at line 79 of file grid_layer_box_helpers.h.

Referenced by Clone(), and Create().

LAYER_NUM GRID_CELL_LAYER_SELECTOR::m_value
protected

Definition at line 80 of file grid_layer_box_helpers.h.

Referenced by ApplyEdit(), BeginEdit(), EndEdit(), and Reset().


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