#include <wx/grid.h>
This class is responsible for providing and manipulating the in-place edit controls for the grid.
Instances of wxGridCellEditor (actually, instances of derived classes since it is an abstract class) can be associated with the cell attributes for individual cells, rows, columns, or even for the entire grid.
Normally wxGridCellEditor shows some UI control allowing the user to edit the cell, but starting with wxWidgets 3.1.4 it's also possible to define "activatable" cell editors, that change the value of the cell directly when it's activated (typically by pressing Space key or clicking on it), see TryActivate() method. Note that when implementing an editor which is always activatable, i.e. never shows any in-place editor, it is more convenient to derive its class from wxGridCellActivatableEditor than from wxGridCellEditor itself.
<>< =''>:</>&;&;< =''>\ </></>
Public Member Functions | |
wxGridCellEditor () | |
Default constructor. More... | |
virtual void | BeginEdit (int row, int col, wxGrid *grid)=0 |
Fetch the value from the table and prepare the edit control to begin editing. More... | |
virtual wxGridCellEditor * | Clone () const =0 |
Create a new object which is the copy of this one. More... | |
virtual void | Create (wxWindow *parent, wxWindowID id, wxEvtHandler *evtHandler)=0 |
Creates the actual edit control. More... | |
virtual void | Destroy () |
Final cleanup. More... | |
virtual bool | EndEdit (int row, int col, const wxGrid *grid, const wxString &oldval, wxString *newval)=0 |
End editing the cell. More... | |
virtual void | ApplyEdit (int row, int col, wxGrid *grid)=0 |
Effectively save the changes in the grid. More... | |
virtual void | HandleReturn (wxKeyEvent &event) |
Some types of controls on some platforms may need some help with the Return key. More... | |
bool | IsCreated () |
Returns true if the edit control has been created. More... | |
virtual void | PaintBackground (wxDC &dc, const wxRect &rectCell, const wxGridCellAttr &attr) |
Draws the part of the cell not occupied by the control: the base class version just fills it with background colour from the attribute. More... | |
virtual void | Reset ()=0 |
Reset the value in the control back to its starting value. More... | |
virtual void | SetSize (const wxRect &rect) |
Size and position the edit control. More... | |
virtual void | Show (bool show, wxGridCellAttr *attr=NULL) |
Show or hide the edit control, use the specified attributes to set colours/fonts for it. More... | |
virtual void | StartingClick () |
If the editor is enabled by clicking on the cell, this method will be called. More... | |
virtual void | StartingKey (wxKeyEvent &event) |
If the editor is enabled by pressing keys on the grid, this will be called to let the editor do something about that first key if desired. More... | |
virtual bool | IsAcceptedKey (wxKeyEvent &event) |
Return true to allow the given key to start editing: the base class version only checks that the event has no modifiers. More... | |
virtual wxString | GetValue () const =0 |
Returns the value currently in the editor control. More... | |
wxWindow * | GetWindow () const |
Get the edit window used by this editor. More... | |
void | SetWindow (wxWindow *window) |
Set the wxWindow that will be used by this cell editor for editing the value. More... | |
wxControl * | GetControl () |
Get the wxControl used by this editor. More... | |
void | SetControl (wxControl *control) |
Set the wxControl that will be used by this cell editor for editing the value. More... | |
virtual wxGridActivationResult | TryActivate (int row, int col, wxGrid *grid, const wxGridActivationSource &actSource) |
Function allowing to create an "activatable" editor. More... | |
virtual void | DoActivate (int row, int col, wxGrid *grid) |
Function which must be overridden for "activatable" editors. More... | |
![]() | |
wxClientDataContainer () | |
Default constructor. More... | |
virtual | ~wxClientDataContainer () |
Destructor. More... | |
void * | GetClientData () const |
Get the untyped client data. More... | |
wxClientData * | GetClientObject () const |
Get a pointer to the client data object. More... | |
void | SetClientData (void *data) |
Set the untyped client data. More... | |
void | SetClientObject (wxClientData *data) |
Set the client data object. More... | |
![]() | |
wxRefCounter () | |
Default constructor. More... | |
void | DecRef () |
Decrements the reference count associated with this shared data and, if it reaches zero, destroys this instance of wxRefCounter releasing its memory. More... | |
int | GetRefCount () const |
Returns the reference count associated with this shared data. More... | |
void | IncRef () |
Increments the reference count associated with this shared data. More... | |
Protected Member Functions | |
virtual | ~wxGridCellEditor () |
The destructor is private because only DecRef() can delete us. More... | |
![]() | |
virtual | ~wxRefCounter () |
Destructor. More... | |
wxGridCellEditor::wxGridCellEditor | ( | ) |
Default constructor.
|
protectedvirtual |
The destructor is private because only DecRef() can delete us.
|
pure virtual |
Effectively save the changes in the grid.
This function should save the value of the control in the grid. It is called only after EndEdit() returns true.
|
pure virtual |
Fetch the value from the table and prepare the edit control to begin editing.
This function should save the original value of the grid cell at the given row and col and show the control allowing the user to change it.
|
pure virtual |
Create a new object which is the copy of this one.
|
pure virtual |
Creates the actual edit control.
|
virtual |
Final cleanup.
|
virtual |
Function which must be overridden for "activatable" editors.
If TryActivate() is overridden to return "change" action, this function will be called to actually apply this change. Note that it is not passed the value to apply, as it is assumed that the editor class stores this value as a member variable anyhow.
Reimplemented in wxGridCellActivatableEditor.
|
pure virtual |
End editing the cell.
This function must check if the current value of the editing control is valid and different from the original value (available as oldval in its string form and possibly saved internally using its real type by BeginEdit()). If it isn't, it just returns false, otherwise it must do the following:
Notice that it must not modify the grid as the change could still be vetoed.
If the user-defined wxEVT_GRID_CELL_CHANGING event handler doesn't veto this change, ApplyEdit() will be called next.
wxControl* wxGridCellEditor::GetControl | ( | ) |
Get the wxControl used by this editor.
This function is preserved for compatibility, but GetWindow() should be preferred in the new code as the associated window doesn't need to be of a wxControl-derived class.
Note that if SetWindow() had been called with an object not deriving from wxControl, this method will return NULL.
|
pure virtual |
Returns the value currently in the editor control.
wxWindow* wxGridCellEditor::GetWindow | ( | ) | const |
Get the edit window used by this editor.
|
virtual |
Some types of controls on some platforms may need some help with the Return key.
|
virtual |
Return true to allow the given key to start editing: the base class version only checks that the event has no modifiers.
If the key is F2 (special), editing will always start and this method will not be called at all (but StartingKey() will)
bool wxGridCellEditor::IsCreated | ( | ) |
Returns true if the edit control has been created.
|
virtual |
Draws the part of the cell not occupied by the control: the base class version just fills it with background colour from the attribute.
|
pure virtual |
Reset the value in the control back to its starting value.
void wxGridCellEditor::SetControl | ( | wxControl * | control | ) |
Set the wxControl that will be used by this cell editor for editing the value.
This function is preserved for compatibility, but SetWindow() should be preferred in the new code, see GetControl().
|
virtual |
Size and position the edit control.
void wxGridCellEditor::SetWindow | ( | wxWindow * | window | ) |
Set the wxWindow that will be used by this cell editor for editing the value.
|
virtual |
Show or hide the edit control, use the specified attributes to set colours/fonts for it.
|
virtual |
If the editor is enabled by clicking on the cell, this method will be called.
|
virtual |
If the editor is enabled by pressing keys on the grid, this will be called to let the editor do something about that first key if desired.
|
virtual |
Function allowing to create an "activatable" editor.
As explained in this class description, activatable editors don't show any edit control but change the cell value directly, when it is activated (by any way described by wxGridActivationSource).
To create such editor, this method must be overridden to return wxGridActivationResult::DoChange() passing it the new value of the cell. If the change is not vetoed by wxEVT_GRID_CELL_CHANGING handler, DoActivate() will be called to actually change the value, so it must be overridden as well if TryActivate() is overridden.
By default, wxGridActivationResult::DoEdit() is returned, meaning that this is a normal editor, using an edit control for changing the cell value.
Reimplemented in wxGridCellActivatableEditor.