KiCad PCB EDA Suite
GRID_CELL_URL_EDITOR Class Reference

#include <grid_text_button_helpers.h>

Inheritance diagram for GRID_CELL_URL_EDITOR:
GRID_CELL_TEXT_BUTTON

Public Member Functions

 GRID_CELL_URL_EDITOR (DIALOG_SHIM *aParent)
 
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_value
 

Detailed Description

Definition at line 112 of file grid_text_button_helpers.h.

Constructor & Destructor Documentation

◆ GRID_CELL_URL_EDITOR()

GRID_CELL_URL_EDITOR::GRID_CELL_URL_EDITOR ( DIALOG_SHIM aParent)
inline

Definition at line 115 of file grid_text_button_helpers.h.

115  :
116  m_dlg( aParent )
117  { }

Referenced by Clone().

Member Function Documentation

◆ ApplyEdit()

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

Definition at line 144 of file grid_text_button_helpers.cpp.

145 {
146  aGrid->GetTable()->SetValue( aRow, aCol, m_value );
147 }

References GRID_CELL_TEXT_BUTTON::m_value.

◆ BeginEdit()

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

Definition at line 114 of file grid_text_button_helpers.cpp.

115 {
116  auto evtHandler = static_cast< wxGridCellEditorEvtHandler* >( m_control->GetEventHandler() );
117 
118  // Don't immediately end if we get a kill focus event within BeginEdit
119  evtHandler->SetInSetFocus( true );
120 
121  m_value = aGrid->GetTable()->GetValue( aRow, aCol );
122 
123  Combo()->SetValue( m_value );
124  Combo()->SetFocus();
125 }
wxComboCtrl * Combo() const

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

◆ Clone()

wxGridCellEditor* GRID_CELL_URL_EDITOR::Clone ( ) const
inlineoverride

Definition at line 119 of file grid_text_button_helpers.h.

120  {
121  return new GRID_CELL_URL_EDITOR( m_dlg );
122  }
GRID_CELL_URL_EDITOR(DIALOG_SHIM *aParent)

References GRID_CELL_URL_EDITOR(), and m_dlg.

◆ Combo()

◆ Create()

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

Definition at line 296 of file grid_text_button_helpers.cpp.

298 {
299  m_control = new TEXT_BUTTON_URL( aParent, m_dlg );
300 
301 #if wxUSE_VALIDATORS
302  // validate text in textctrl, if validator is set
303  if ( m_validator )
304  {
305  Combo()->SetValidator( *m_validator );
306  }
307 #endif
308 
309  wxGridCellEditor::Create( aParent, aId, aEventHandler );
310 }
wxComboCtrl * Combo() const

References GRID_CELL_TEXT_BUTTON::Combo(), and m_dlg.

◆ EndEdit()

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

Definition at line 128 of file grid_text_button_helpers.cpp.

129 {
130  const wxString value = Combo()->GetValue();
131 
132  if( value == m_value )
133  return false;
134 
135  m_value = value;
136 
137  if( aNewVal )
138  *aNewVal = value;
139 
140  return true;
141 }
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 45 of file grid_text_button_helpers.cpp.

46 {
47  return Combo()->GetValue();
48 }
wxComboCtrl * Combo() const

References GRID_CELL_TEXT_BUTTON::Combo().

◆ Reset()

void GRID_CELL_TEXT_BUTTON::Reset ( )
overrideinherited

Definition at line 150 of file grid_text_button_helpers.cpp.

151 {
152  Combo()->SetValue( m_value );
153 }
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 51 of file grid_text_button_helpers.cpp.

52 {
53  wxRect rect( aRect );
54  rect.Inflate( -1 );
55 
56 #if defined( __WXMAC__ )
57  rect.Inflate( 3 ); // no FOCUS_RING, even on Mac
58 #endif
59 
60  Combo()->SetSize( rect, wxSIZE_ALLOW_MINUS_ONE );
61 }
wxComboCtrl * Combo() const

References GRID_CELL_TEXT_BUTTON::Combo().

◆ StartingKey()

void GRID_CELL_TEXT_BUTTON::StartingKey ( wxKeyEvent &  event)
overrideinherited

Definition at line 64 of file grid_text_button_helpers.cpp.

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

Definition at line 127 of file grid_text_button_helpers.h.

Referenced by Clone(), and Create().

◆ m_value

wxString GRID_CELL_TEXT_BUTTON::m_value
protectedinherited

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