class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl;
class WXDLLIMPEXP_FWD_ADV wxDataViewCtrlInternal;
+typedef struct _GtkTreeViewColumn GtkTreeViewColumn;
// ---------------------------------------------------------
// wxDataViewRenderer
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)
};
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)
};
// ---------------------------------------------------------
wxDC *m_dc;
public:
- // Internal, temporay for RenderText.
+ // Internal, temporary for RenderText.
GtkCellRenderer *m_text_renderer;
GdkWindow *window;
GtkWidget *widget;
// wxDataViewIconTextRenderer
// ---------------------------------------------------------
-class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewCustomRenderer
+class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewTextRenderer
{
public:
wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"),
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)
};
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 );
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);
virtual void DoSetExpanderColumn();
virtual void DoSetIndent();
+ virtual void DoApplyWidgetStyle(GtkRcStyle *style);
+
private:
+ void Init();
+
friend class wxDataViewCtrlDCImpl;
friend class wxDataViewColumn;
friend class wxGtkDataViewModelNotifier;
void GtkDisableSelectionEvents();
DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
- DECLARE_NO_COPY_CLASS(wxDataViewCtrl)
+ wxDECLARE_NO_COPY_CLASS(wxDataViewCtrl);
};