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 145 of file grid_text_button_helpers.cpp.

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

References GRID_CELL_TEXT_BUTTON::m_value.

◆ BeginEdit()

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

Definition at line 115 of file grid_text_button_helpers.cpp.

116 {
117  auto evtHandler = static_cast< wxGridCellEditorEvtHandler* >( m_control->GetEventHandler() );
118 
119  // Don't immediately end if we get a kill focus event within BeginEdit
120  evtHandler->SetInSetFocus( true );
121 
122  m_value = aGrid->GetTable()->GetValue( aRow, aCol );
123 
124  Combo()->SetValue( m_value );
125  Combo()->SetFocus();
126 }
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 297 of file grid_text_button_helpers.cpp.

299 {
300  m_control = new TEXT_BUTTON_URL( aParent, m_dlg );
301 
302 #if wxUSE_VALIDATORS
303  // validate text in textctrl, if validator is set
304  if ( m_validator )
305  {
306  Combo()->SetValidator( *m_validator );
307  }
308 #endif
309 
310  wxGridCellEditor::Create( aParent, aId, aEventHandler );
311 }
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 129 of file grid_text_button_helpers.cpp.

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

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

References GRID_CELL_TEXT_BUTTON::Combo().

◆ Reset()

void GRID_CELL_TEXT_BUTTON::Reset ( )
overrideinherited

Definition at line 151 of file grid_text_button_helpers.cpp.

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

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

References GRID_CELL_TEXT_BUTTON::Combo().

◆ StartingKey()

void GRID_CELL_TEXT_BUTTON::StartingKey ( wxKeyEvent &  event)
overrideinherited

Definition at line 65 of file grid_text_button_helpers.cpp.

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