-//-----------------------------------------------------------------------------
-// wxDataViewEditorCtrlEvtHandler
-//-----------------------------------------------------------------------------
-
-class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler
-{
-public:
- wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner );
-
- void AcceptChangesAndFinish();
- void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; }
-
-protected:
- void OnChar( wxKeyEvent &event );
- void OnTextEnter( wxCommandEvent &event );
- void OnKillFocus( wxFocusEvent &event );
- void OnIdle( wxIdleEvent &event );
-
-private:
- wxDataViewRenderer *m_owner;
- wxControl *m_editorCtrl;
- bool m_finished;
- bool m_focusOnIdle;
-
-private:
- DECLARE_EVENT_TABLE()
-};
-
-// ---------------------------------------------------------
-// wxDataViewRendererBase
-// ---------------------------------------------------------
-
-enum wxDataViewCellMode
-{
- wxDATAVIEW_CELL_INERT,
- wxDATAVIEW_CELL_ACTIVATABLE,
- wxDATAVIEW_CELL_EDITABLE
-};
-
-enum wxDataViewCellRenderState
-{
- wxDATAVIEW_CELL_SELECTED = 1,
- wxDATAVIEW_CELL_PRELIT = 2,
- wxDATAVIEW_CELL_INSENSITIVE = 4,
- wxDATAVIEW_CELL_FOCUSED = 8
-};
-
-class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject
-{
-public:
- wxDataViewRendererBase( const wxString &varianttype,
- wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
- int alignment = wxDVR_DEFAULT_ALIGNMENT );
- virtual ~wxDataViewRendererBase();
-
- virtual bool Validate( wxVariant& WXUNUSED(value) )
- { return true; }
-
- void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; }
- wxDataViewColumn* GetOwner() const { return m_owner; }
-
- // renderer properties:
-
- virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0;
- virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0;
-
- wxString GetVariantType() const { return m_variantType; }
-
- virtual void SetMode( wxDataViewCellMode mode ) = 0;
- virtual wxDataViewCellMode GetMode() const = 0;
-
- // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
- // rather an "int"; that's because for rendering cells it's allowed
- // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
- virtual void SetAlignment( int align ) = 0;
- virtual int GetAlignment() const = 0;
-
- // enable or disable (if called with wxELLIPSIZE_NONE) replacing parts of
- // the item text (hence this only makes sense for renderers showing
- // text...) with ellipsis in order to make it fit the column width
- virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE) = 0;
- void DisableEllipsize() { EnableEllipsize(wxELLIPSIZE_NONE); }
-
- virtual wxEllipsizeMode GetEllipsizeMode() const = 0;
-
- // in-place editing
- virtual bool HasEditorCtrl() const
- { return false; }
- virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent),
- wxRect WXUNUSED(labelRect),
- const wxVariant& WXUNUSED(value))
- { return NULL; }
- virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor),
- wxVariant& WXUNUSED(value))
- { return false; }
-
- virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect );
- virtual void CancelEditing();
- virtual bool FinishEditing();
-
- wxControl *GetEditorCtrl() { return m_editorCtrl; }
-
-protected:
- wxString m_variantType;
- wxDataViewColumn *m_owner;
- wxWeakRef<wxControl> m_editorCtrl;
- wxDataViewItem m_item; // for m_editorCtrl
-
- // internal utility:
- const wxDataViewCtrl* GetView() const;
-
-protected:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase)
-};
-
-//-----------------------------------------------------------------------------
-// wxDataViewIconText
-//-----------------------------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewIconText: public wxObject
-{
-public:
- wxDataViewIconText( const wxString &text = wxEmptyString, const wxIcon& icon = wxNullIcon )
- : m_text(text), m_icon(icon)
- { }
- wxDataViewIconText( const wxDataViewIconText &other )
- : wxObject()
- { m_icon = other.m_icon; m_text = other.m_text; }
-
- void SetText( const wxString &text ) { m_text = text; }
- wxString GetText() const { return m_text; }
- void SetIcon( const wxIcon &icon ) { m_icon = icon; }
- const wxIcon &GetIcon() const { return m_icon; }
-
-private:
- wxString m_text;
- wxIcon m_icon;
-
-private:
- DECLARE_DYNAMIC_CLASS(wxDataViewIconText)
-};
-
-inline
-bool operator==(const wxDataViewIconText& left, const wxDataViewIconText& right)
-{
- return left.GetText() == right.GetText() &&
- left.GetIcon().IsSameAs(right.GetIcon());
-}
-
-inline
-bool operator!=(const wxDataViewIconText& left, const wxDataViewIconText& right)
-{
- return !(left == right);
-}