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, SEARCH_STACK *aSearchStack=nullptr)
 
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
 
SEARCH_STACKm_searchStack
 
wxString m_value
 

Detailed Description

Definition at line 114 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,
SEARCH_STACK aSearchStack = nullptr 
)
inline

Definition at line 117 of file grid_text_button_helpers.h.

117  :
118  m_dlg( aParent ), m_searchStack( aSearchStack )
119  { }

Referenced by Clone().

Member Function Documentation

◆ ApplyEdit()

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

Definition at line 159 of file grid_text_button_helpers.cpp.

160 {
161  aGrid->GetTable()->SetValue( aRow, aCol, m_value );
162 }

References GRID_CELL_TEXT_BUTTON::m_value.

◆ BeginEdit()

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

Definition at line 129 of file grid_text_button_helpers.cpp.

130 {
131  auto evtHandler = static_cast< wxGridCellEditorEvtHandler* >( m_control->GetEventHandler() );
132 
133  // Don't immediately end if we get a kill focus event within BeginEdit
134  evtHandler->SetInSetFocus( true );
135 
136  m_value = aGrid->GetTable()->GetValue( aRow, aCol );
137 
138  Combo()->SetValue( m_value );
139  Combo()->SetFocus();
140 }
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 121 of file grid_text_button_helpers.h.

122  {
123  return new GRID_CELL_URL_EDITOR( m_dlg );
124  }
GRID_CELL_URL_EDITOR(DIALOG_SHIM *aParent, SEARCH_STACK *aSearchStack=nullptr)

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

334 {
335  m_control = new TEXT_BUTTON_URL( aParent, m_dlg, m_searchStack );
336 
337 #if wxUSE_VALIDATORS
338  // validate text in textctrl, if validator is set
339  if ( m_validator )
340  {
341  Combo()->SetValidator( *m_validator );
342  }
343 #endif
344 
345  wxGridCellEditor::Create( aParent, aId, aEventHandler );
346 }
wxComboCtrl * Combo() const

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

◆ EndEdit()

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

Definition at line 143 of file grid_text_button_helpers.cpp.

144 {
145  const wxString value = Combo()->GetValue();
146 
147  if( value == m_value )
148  return false;
149 
150  m_value = value;
151 
152  if( aNewVal )
153  *aNewVal = value;
154 
155  return true;
156 }
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 165 of file grid_text_button_helpers.cpp.

166 {
167  Combo()->SetValue( m_value );
168 }
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 
63 #if defined( __WXMAC__ )
64  rect.Inflate( 2 ); // ignore FOCUS_RING
65 #elif defined( __WXGTK__ )
66  rect.Inflate( -3 ); // The -3 is a very sad hack here. Some GTK themes overrun the
67  // default -1, preventing display. Unfortunately, we don't appear to
68  // have a good method of finding the current margin needed.
69  // Some GTK resize events seem to update the cell size but not all and
70  // not consistently.
71 #else
72  rect.Inflate( -1 );
73 #endif
74 
75  Combo()->SetSize( rect, wxSIZE_ALLOW_MINUS_ONE );
76 }
wxComboCtrl * Combo() const

References GRID_CELL_TEXT_BUTTON::Combo().

◆ StartingKey()

void GRID_CELL_TEXT_BUTTON::StartingKey ( wxKeyEvent &  event)
overrideinherited

Definition at line 79 of file grid_text_button_helpers.cpp.

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

Referenced by Clone(), and Create().

◆ m_searchStack

SEARCH_STACK* GRID_CELL_URL_EDITOR::m_searchStack
protected

Definition at line 130 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: