#include </home/zeitlin/src/wx/github/interface/wx/dataview.h>
You need to derive a new class from wxDataViewCustomRenderer in order to write a new renderer.
You need to override at least wxDataViewRenderer::SetValue, wxDataViewRenderer::GetValue, wxDataViewCustomRenderer::GetSize and wxDataViewCustomRenderer::Render.
If you want your renderer to support in-place editing then you also need to override wxDataViewCustomRenderer::HasEditorCtrl, wxDataViewCustomRenderer::CreateEditorCtrl and wxDataViewCustomRenderer::GetValueFromEditorCtrl.
Note that a special event handler will be pushed onto that editor control which handles <ENTER> and focus out events in order to end the editing.
Public Member Functions | |
wxDataViewCustomRenderer (const wxString &varianttype="string", wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=-1, bool no_init=false) | |
Constructor. | |
virtual | ~wxDataViewCustomRenderer () |
Destructor. | |
virtual bool | ActivateCell (const wxRect &cell, wxDataViewModel *model, const wxDataViewItem &item, unsigned int col, const wxMouseEvent *mouseEvent) |
Override this to react to cell activation. | |
virtual wxWindow * | CreateEditorCtrl (wxWindow *parent, wxRect labelRect, const wxVariant &value) |
Override this to create the actual editor control once editing is about to start. | |
const wxDataViewItemAttr & | GetAttr () const |
Return the attribute to be used for rendering. | |
virtual wxSize | GetSize () const =0 |
Return size required to show content. | |
virtual bool | GetValueFromEditorCtrl (wxWindow *editor, wxVariant &value) |
Override this so that the renderer can get the value from the editor control (pointed to by editor): | |
virtual bool | HasEditorCtrl () const |
Override this and make it return true in order to indicate that this renderer supports in-place editing. | |
virtual bool | LeftClick (const wxPoint &cursor, const wxRect &cell, wxDataViewModel *model, const wxDataViewItem &item, unsigned int col) |
左クリックに反応するにはこの関数をオーバーライドしてください。 | |
virtual bool | Render (wxRect cell, wxDC *dc, int state)=0 |
Override this to render the cell. | |
void | RenderText (const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state) |
This method should be called from within Render() whenever you need to render simple text. | |
virtual bool | StartDrag (const wxPoint &cursor, const wxRect &cell, wxDataViewModel *model, const wxDataViewItem &item, unsigned int col) |
ドラッグ操作を開始するにはこの関数をオーバーライドしてください。 |
wxDataViewCustomRenderer::wxDataViewCustomRenderer | ( | const wxString & | varianttype = "string" , |
wxDataViewCellMode | mode = wxDATAVIEW_CELL_INERT , |
||
int | align = -1 , |
||
bool | no_init = false |
||
) |
Constructor.
virtual wxDataViewCustomRenderer::~wxDataViewCustomRenderer | ( | ) | [virtual] |
Destructor.
virtual bool wxDataViewCustomRenderer::ActivateCell | ( | const wxRect & | cell, |
wxDataViewModel * | model, | ||
const wxDataViewItem & | item, | ||
unsigned int | col, | ||
const wxMouseEvent * | mouseEvent | ||
) | [virtual] |
Override this to react to cell activation.
Activating a cell is an alternative to showing inline editor when the value can be edited in a simple way that doesn't warrant full editor control. The most typical use of cell activation is toggling the checkbox in wxDataViewToggleRenderer; others would be e.g. an embedded volume slider or a five-star rating column.
The exact means of activating a cell are platform-dependent, but they are usually similar to those used for inline editing of values. Typically, a cell would be activated by Space or Enter keys or by left mouse click.
This method will only be called if the cell has the wxDATAVIEW_CELL_ACTIVATABLE mode.
cell | Coordinates of the activated cell's area. |
model | The model to manipulate in response. |
item | Activated item. |
col | Activated column of item. |
mouseEvent | If the activation was triggered by mouse click, contains the corresponding event. Is NULL otherwise (for keyboard activation). Mouse coordinates are adjusted to be relative to the cell. |
virtual wxWindow* wxDataViewCustomRenderer::CreateEditorCtrl | ( | wxWindow * | parent, |
wxRect | labelRect, | ||
const wxVariant & | value | ||
) | [virtual] |
Override this to create the actual editor control once editing is about to start.
This method will only be called if the cell has the wxDATAVIEW_CELL_EDITABLE mode. Editing is typically triggered by slowly double-clicking the cell or by a platform-dependent keyboard shortcut (F2 is typical on Windows, Space and/or Enter is common elsewhere and supported on Windows too).
parent | The parent of the editor control. |
labelRect | Indicates the position and size of the editor control. The control should be created in place of the cell and labelRect should be respected as much as possible. |
value | Initial value of the editor. |
An example:
{ long l = value; return new wxSpinCtrl( parent, wxID_ANY, wxEmptyString, labelRect.GetTopLeft(), labelRect.GetSize(), 0, 0, 100, l ); }
const wxDataViewItemAttr& wxDataViewCustomRenderer::GetAttr | ( | ) | const |
Return the attribute to be used for rendering.
This function may be called from Render() implementation to use the attributes defined for the item if the renderer supports them.
Notice that when Render() is called, the wxDC object passed to it is already set up to use the correct attributes (e.g. its font is set to bold or italic version if wxDataViewItemAttr::GetBold() or GetItalic() returns true) so it may not be necessary to call it explicitly if you only want to render text using the items attributes.
virtual wxSize wxDataViewCustomRenderer::GetSize | ( | ) | const [pure virtual] |
Return size required to show content.
virtual bool wxDataViewCustomRenderer::GetValueFromEditorCtrl | ( | wxWindow * | editor, |
wxVariant & | value | ||
) | [virtual] |
Override this so that the renderer can get the value from the editor control (pointed to by editor):
{ wxSpinCtrl *sc = (wxSpinCtrl*) editor; long l = sc->GetValue(); value = l; return true; }
virtual bool wxDataViewCustomRenderer::HasEditorCtrl | ( | ) | const [virtual] |
Override this and make it return true in order to indicate that this renderer supports in-place editing.
virtual bool wxDataViewCustomRenderer::LeftClick | ( | const wxPoint & | cursor, |
const wxRect & | cell, | ||
wxDataViewModel * | model, | ||
const wxDataViewItem & | item, | ||
unsigned int | col | ||
) | [virtual] |
左クリックに反応するにはこの関数をオーバーライドしてください。
This method will only be called in wxDATAVIEW_CELL_ACTIVATABLE
mode.
Override this to render the cell.
Before this is called, wxDataViewRenderer::SetValue was called so that this instance knows what to render.
void wxDataViewCustomRenderer::RenderText | ( | const wxString & | text, |
int | xoffset, | ||
wxRect | cell, | ||
wxDC * | dc, | ||
int | state | ||
) |
This method should be called from within Render() whenever you need to render simple text.
This will ensure that the correct colour, font and vertical alignment will be chosen so the text will look the same as text drawn by native renderers.
virtual bool wxDataViewCustomRenderer::StartDrag | ( | const wxPoint & | cursor, |
const wxRect & | cell, | ||
wxDataViewModel * | model, | ||
const wxDataViewItem & | item, | ||
unsigned int | col | ||
) | [virtual] |
ドラッグ操作を開始するにはこの関数をオーバーライドしてください。
Not yet supported.