X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/15cac64f7564d48c274c6490774a77bd8c09f808..2feacb6eb30247634085f45c0a69014ef89772e9:/include/wx/gtk/dataview.h diff --git a/include/wx/gtk/dataview.h b/include/wx/gtk/dataview.h index 1418915ef3..589da74a9a 100644 --- a/include/wx/gtk/dataview.h +++ b/include/wx/gtk/dataview.h @@ -19,6 +19,7 @@ class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl; class WXDLLIMPEXP_FWD_ADV wxDataViewCtrlInternal; +typedef struct _GtkTreeViewColumn GtkTreeViewColumn; // --------------------------------------------------------- // wxDataViewRenderer @@ -37,16 +38,44 @@ public: virtual void SetAlignment( int align ); virtual int GetAlignment() const; - // implementation + virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE); + virtual wxEllipsizeMode GetEllipsizeMode() const; + + // GTK-specific implementation + // --------------------------- + + // pack the GTK cell renderers used by this renderer to the given column + // + // by default only a single m_renderer is used but some renderers use more + // than one GTK cell renderer + virtual void GtkPackIntoColumn(GtkTreeViewColumn *column); + + // called when the cell value was edited by user with the new value + // + // it validates the new value and notifies the model about the change by + // calling GtkOnCellChanged() if it was accepted + void GtkOnTextEdited(const gchar *itempath, const wxString& value); + GtkCellRenderer* GetGtkHandle() { return m_renderer; } void GtkInitHandlers(); - virtual bool GtkHasAttributes() { return false; } void GtkUpdateAlignment(); + bool GtkIsUsingDefaultAttrs() const { return m_usingDefaultAttrs; } + void GtkSetUsingDefaultAttrs(bool def) { m_usingDefaultAttrs = def; } + protected: + virtual void GtkOnCellChanged(const wxVariant& value, + const wxDataViewItem& item, + unsigned col); + + GtkCellRenderer *m_renderer; int m_alignment; + // true if we hadn't changed any visual attributes or restored them since + // doing this + bool m_usingDefaultAttrs; + protected: DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer) }; @@ -62,31 +91,31 @@ public: wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int align = wxDVR_DEFAULT_ALIGNMENT ); - bool SetValue( const wxVariant &value ); - bool GetValue( wxVariant &value ) const; - - void SetAlignment( int align ); + virtual bool SetValue( const wxVariant &value ) + { + return SetTextValue(value); + } -protected: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer) -}; + virtual bool GetValue( wxVariant &value ) const + { + wxString str; + if ( !GetTextValue(str) ) + return false; -// --------------------------------------------------------- -// wxDataViewTextRendererAttr -// --------------------------------------------------------- + value = str; -class WXDLLIMPEXP_ADV wxDataViewTextRendererAttr: public wxDataViewTextRenderer -{ -public: - wxDataViewTextRendererAttr( const wxString &varianttype = wxT("string"), - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, - int align = wxDVR_DEFAULT_ALIGNMENT ); + return true; + } - // implementation - bool GtkHasAttributes() { return true; } + virtual void SetAlignment( int align ); protected: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRendererAttr) + // implementation of Set/GetValue() + bool SetTextValue(const wxString& str); + bool GetTextValue(wxString& str) const; + + + DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer) }; // --------------------------------------------------------- @@ -168,7 +197,7 @@ private: wxDC *m_dc; public: - // Internal, temporay for RenderText. + // Internal, temporary for RenderText. GtkCellRenderer *m_text_renderer; GdkWindow *window; GtkWidget *widget; @@ -212,7 +241,7 @@ protected: // wxDataViewIconTextRenderer // --------------------------------------------------------- -class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewCustomRenderer +class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewTextRenderer { public: wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"), @@ -223,17 +252,19 @@ public: bool SetValue( const wxVariant &value ); bool GetValue( wxVariant &value ) const; - virtual bool Render( wxRect cell, wxDC *dc, int state ); - virtual wxSize GetSize() const; + virtual void GtkPackIntoColumn(GtkTreeViewColumn *column); - virtual bool HasEditorCtrl() { return true; } - virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ); - virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ); +protected: + virtual void GtkOnCellChanged(const wxVariant& value, + const wxDataViewItem& item, + unsigned col); private: wxDataViewIconText m_value; -protected: + // we use the base class m_renderer for the text and this one for the icon + GtkCellRenderer *m_rendererIcon; + DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer) }; @@ -383,18 +414,18 @@ public: const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator ) { + Init(); + Create(parent, id, pos, size, style, validator ); } - virtual ~wxDataViewCtrl(); - - void Init(); - bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator ); + virtual ~wxDataViewCtrl(); + virtual bool AssociateModel( wxDataViewModel *model ); virtual bool PrependColumn( wxDataViewColumn *col ); @@ -431,6 +462,7 @@ public: virtual bool IsExpanded( const wxDataViewItem & item ) const; virtual bool EnableDragSource( const wxDataFormat &format ); + virtual bool EnableDropTarget( const wxDataFormat &format ); static wxVisualAttributes GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); @@ -446,7 +478,11 @@ protected: virtual void DoSetExpanderColumn(); virtual void DoSetIndent(); + virtual void DoApplyWidgetStyle(GtkRcStyle *style); + private: + void Init(); + friend class wxDataViewCtrlDCImpl; friend class wxDataViewColumn; friend class wxGtkDataViewModelNotifier; @@ -462,7 +498,7 @@ private: void GtkDisableSelectionEvents(); DECLARE_DYNAMIC_CLASS(wxDataViewCtrl) - DECLARE_NO_COPY_CLASS(wxDataViewCtrl) + wxDECLARE_NO_COPY_CLASS(wxDataViewCtrl); };