KiCad PCB EDA Suite
GRID_CELL_FOOTPRINT_ID_EDITOR Class Reference

#include <grid_text_button_helpers.h>

Inheritance diagram for GRID_CELL_FOOTPRINT_ID_EDITOR:
GRID_CELL_TEXT_BUTTON

Public Member Functions

 GRID_CELL_FOOTPRINT_ID_EDITOR (DIALOG_SHIM *aParent, const wxString &aPreselect=wxEmptyString)
 
wxGridCellEditor * Clone () const override
 
void Create (wxWindow *aParent, wxWindowID aId, wxEvtHandler *aEventHandler) override
 
wxString GetValue () const override
 
void SetSize (const wxRect &aRect) override
 
void StartingKey (wxKeyEvent &event) override
 
void BeginEdit (int aRow, int aCol, wxGrid *aGrid) override
 
bool EndEdit (int, int, const wxGrid *, const wxString &, wxString *aNewVal) override
 
void ApplyEdit (int aRow, int aCol, wxGrid *aGrid) override
 
void Reset () override
 

Protected Member Functions

wxComboCtrl * Combo () const
 
 wxDECLARE_NO_COPY_CLASS (GRID_CELL_TEXT_BUTTON)
 

Protected Attributes

DIALOG_SHIMm_dlg
 
wxString m_preselect
 
wxString m_value
 

Detailed Description

Definition at line 92 of file grid_text_button_helpers.h.

Constructor & Destructor Documentation

◆ GRID_CELL_FOOTPRINT_ID_EDITOR()

GRID_CELL_FOOTPRINT_ID_EDITOR::GRID_CELL_FOOTPRINT_ID_EDITOR ( DIALOG_SHIM aParent,
const wxString &  aPreselect = wxEmptyString 
)
inline

Definition at line 95 of file grid_text_button_helpers.h.

96  :
97  m_dlg( aParent ),
98  m_preselect( aPreselect )
99  { }

Referenced by Clone().

Member Function Documentation

◆ ApplyEdit()

void GRID_CELL_TEXT_BUTTON::ApplyEdit ( int  aRow,
int  aCol,
wxGrid *  aGrid 
)
overrideinherited

Definition at line 152 of file grid_text_button_helpers.cpp.

153 {
154  aGrid->GetTable()->SetValue( aRow, aCol, m_value );
155 }

References GRID_CELL_TEXT_BUTTON::m_value.

◆ BeginEdit()

void GRID_CELL_TEXT_BUTTON::BeginEdit ( int  aRow,
int  aCol,
wxGrid *  aGrid 
)
overrideinherited

Definition at line 122 of file grid_text_button_helpers.cpp.

123 {
124  auto evtHandler = static_cast< wxGridCellEditorEvtHandler* >( m_control->GetEventHandler() );
125 
126  // Don't immediately end if we get a kill focus event within BeginEdit
127  evtHandler->SetInSetFocus( true );
128 
129  m_value = aGrid->GetTable()->GetValue( aRow, aCol );
130 
131  Combo()->SetValue( m_value );
132  Combo()->SetFocus();
133 }
wxComboCtrl * Combo() const

References GRID_CELL_TEXT_BUTTON::Combo(), and GRID_CELL_TEXT_BUTTON::m_value.

◆ Clone()

wxGridCellEditor* GRID_CELL_FOOTPRINT_ID_EDITOR::Clone ( ) const
inlineoverride

Definition at line 101 of file grid_text_button_helpers.h.

102  {
103  return new GRID_CELL_FOOTPRINT_ID_EDITOR( m_dlg );
104  }
GRID_CELL_FOOTPRINT_ID_EDITOR(DIALOG_SHIM *aParent, const wxString &aPreselect=wxEmptyString)

References GRID_CELL_FOOTPRINT_ID_EDITOR(), and m_dlg.

◆ Combo()

wxComboCtrl* GRID_CELL_TEXT_BUTTON::Combo ( ) const
inlineprotectedinherited

◆ Create()

void GRID_CELL_FOOTPRINT_ID_EDITOR::Create ( wxWindow *  aParent,
wxWindowID  aId,
wxEvtHandler *  aEventHandler 
)
override

Definition at line 274 of file grid_text_button_helpers.cpp.

276 {
277  m_control = new TEXT_BUTTON_FP_CHOOSER( aParent, m_dlg, m_preselect );
278 
279 #if wxUSE_VALIDATORS
280  // validate text in textctrl, if validator is set
281  if ( m_validator )
282  {
283  Combo()->SetValidator( *m_validator );
284  }
285 #endif
286 
287  wxGridCellEditor::Create( aParent, aId, aEventHandler );
288 }
wxComboCtrl * Combo() const

References GRID_CELL_TEXT_BUTTON::Combo(), m_dlg, and m_preselect.

◆ EndEdit()

bool GRID_CELL_TEXT_BUTTON::EndEdit ( int  ,
int  ,
const wxGrid *  ,
const wxString &  ,
wxString *  aNewVal 
)
overrideinherited

Definition at line 136 of file grid_text_button_helpers.cpp.

137 {
138  const wxString value = Combo()->GetValue();
139 
140  if( value == m_value )
141  return false;
142 
143  m_value = value;
144 
145  if( aNewVal )
146  *aNewVal = value;
147 
148  return true;
149 }
wxComboCtrl * Combo() const

References GRID_CELL_TEXT_BUTTON::Combo(), and GRID_CELL_TEXT_BUTTON::m_value.

◆ GetValue()

wxString GRID_CELL_TEXT_BUTTON::GetValue ( ) const
overrideinherited

Definition at line 53 of file grid_text_button_helpers.cpp.

54 {
55  return Combo()->GetValue();
56 }
wxComboCtrl * Combo() const

References GRID_CELL_TEXT_BUTTON::Combo().

◆ Reset()

void GRID_CELL_TEXT_BUTTON::Reset ( )
overrideinherited

Definition at line 158 of file grid_text_button_helpers.cpp.

159 {
160  Combo()->SetValue( m_value );
161 }
wxComboCtrl * Combo() const

References GRID_CELL_TEXT_BUTTON::Combo(), and GRID_CELL_TEXT_BUTTON::m_value.

◆ SetSize()

void GRID_CELL_TEXT_BUTTON::SetSize ( const wxRect &  aRect)
overrideinherited

Definition at line 59 of file grid_text_button_helpers.cpp.

60 {
61  wxRect rect( aRect );
62  rect.Inflate( -1 );
63 
64 #if defined( __WXMAC__ )
65  rect.Inflate( 3 ); // no FOCUS_RING, even on Mac
66 #endif
67 
68  Combo()->SetSize( rect, wxSIZE_ALLOW_MINUS_ONE );
69 }
wxComboCtrl * Combo() const

References GRID_CELL_TEXT_BUTTON::Combo().

◆ StartingKey()

void GRID_CELL_TEXT_BUTTON::StartingKey ( wxKeyEvent &  event)
overrideinherited

Definition at line 72 of file grid_text_button_helpers.cpp.

73 {
74  // Note: this is a copy of wxGridCellTextEditor's StartingKey()
75 
76  // Since this is now happening in the EVT_CHAR event EmulateKeyPress is no
77  // longer an appropriate way to get the character into the text control.
78  // Do it ourselves instead. We know that if we get this far that we have
79  // a valid character, so not a whole lot of testing needs to be done.
80 
81  // wxComboCtrl inherits from wxTextEntry, so can statically cast
82  wxTextEntry* textEntry = static_cast<wxTextEntry*>( Combo() );
83  int ch;
84 
85  bool isPrintable;
86 
87 #if wxUSE_UNICODE
88  ch = event.GetUnicodeKey();
89 
90  if( ch != WXK_NONE )
91  isPrintable = true;
92  else
93 #endif // wxUSE_UNICODE
94  {
95  ch = event.GetKeyCode();
96  isPrintable = ch >= WXK_SPACE && ch < WXK_START;
97  }
98 
99  switch( ch )
100  {
101  case WXK_DELETE:
102  // Delete the initial character when starting to edit with DELETE.
103  textEntry->Remove( 0, 1 );
104  break;
105 
106  case WXK_BACK:
107  // Delete the last character when starting to edit with BACKSPACE.
108  {
109  const long pos = textEntry->GetLastPosition();
110  textEntry->Remove( pos - 1, pos );
111  }
112  break;
113 
114  default:
115  if( isPrintable )
116  textEntry->WriteText( static_cast<wxChar>( ch ) );
117  break;
118  }
119 }
wxComboCtrl * Combo() const

References GRID_CELL_TEXT_BUTTON::Combo().

◆ wxDECLARE_NO_COPY_CLASS()

GRID_CELL_TEXT_BUTTON::wxDECLARE_NO_COPY_CLASS ( GRID_CELL_TEXT_BUTTON  )
protectedinherited

Member Data Documentation

◆ m_dlg

DIALOG_SHIM* GRID_CELL_FOOTPRINT_ID_EDITOR::m_dlg
protected

Definition at line 109 of file grid_text_button_helpers.h.

Referenced by Clone(), and Create().

◆ m_preselect

wxString GRID_CELL_FOOTPRINT_ID_EDITOR::m_preselect
protected

Definition at line 110 of file grid_text_button_helpers.h.

Referenced by Create().

◆ m_value

wxString GRID_CELL_TEXT_BUTTON::m_value
protectedinherited

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