class WXDLLIMPEXP_CORE wxDataViewCtrl;
class WXDLLIMPEXP_CORE wxDataViewColumn;
+class WXDLLIMPEXP_CORE wxDataViewCell;
extern WXDLLEXPORT_DATA(const wxChar) wxDataViewCtrlNameStr[];
};
// ---------------------------------------------------------
-// wxDataViewColumn
+// wxDataViewCellBase
// ---------------------------------------------------------
-enum wxDataViewColumnType
+enum wxDataViewCellMode
{
- wxDATAVIEW_COL_TEXT,
- wxDATAVIEW_COL_ICON,
- wxDATAVIEW_COL_ICONTEXT,
- wxDATAVIEW_COL_CHECK,
- wxDATAVIEW_COL_DATETIME,
- wxDATAVIEW_COL_PROGRESS,
- wxDATAVIEW_COL_CHOICE,
- wxDATAVIEW_COL_CUSTOM
+ 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 wxDataViewCellBase: public wxObject
+{
+public:
+ wxDataViewCellBase( const wxString &varianttype, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
+
+ virtual bool SetValue( const wxVariant &value ) { return true; }
+ virtual bool GetValue( wxVariant &value ) { return true; }
+ virtual bool BeginEdit() { return true; }
+ virtual bool EndEdit() { return true; }
+
+ virtual bool Render( wxRect cell, wxRect exposed, wxDC *dc, int state ) { return true; }
+
+ void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; }
+ wxDataViewColumn* GetOwner() { return m_owner; }
+
+private:
+ wxDataViewCellMode m_mode;
+ wxString m_variantType;
+ wxDataViewColumn *m_owner;
+
+protected:
+ DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCellBase)
+};
+
+// ---------------------------------------------------------
+// wxDataViewColumnBase
+// ---------------------------------------------------------
+
enum wxDataViewColumnFlags
{
wxDATAVIEW_COL_RESIZABLE = 1,
class wxDataViewColumnBase: public wxObject
{
public:
- wxDataViewColumnBase( const wxString &title, wxDataViewCtrl *ctrl,
- wxDataViewColumnType kind, int flags = 0 );
+ wxDataViewColumnBase( const wxString &title, wxDataViewCell *cell, size_t model_column, int flags = 0 );
+ ~wxDataViewColumnBase();
virtual void SetTitle( const wxString &title );
virtual wxString GetTitle();
+
+ wxDataViewCell* GetCell() { return m_cell; }
+
+ size_t GetModelColumn() { return m_model_column; }
+
+ void SetOwner( wxDataViewCtrl *owner ) { m_owner = owner; }
+ wxDataViewCtrl *GetOwner() { return m_owner; }
private:
wxDataViewCtrl *m_ctrl;
- wxDataViewColumnType m_kind;
+ wxDataViewCell *m_cell;
+ int m_model_column;
int m_flags;
wxString m_title;
+ wxDataViewCtrl *m_owner;
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
public:
wxDataViewCtrlBase();
~wxDataViewCtrlBase();
-
virtual bool AssociateModel( wxDataViewListModel *model );
wxDataViewListModel* GetModel();
- virtual bool AppendStringColumn( const wxString &label );
+ virtual bool AppendStringColumn( const wxString &label, size_t model_column );
virtual bool AppendColumn( wxDataViewColumn *col );
virtual size_t GetNumberOfColumns();
virtual bool DeleteColumn( size_t pos );
class WXDLLIMPEXP_CORE wxDataViewCtrl;
+// ---------------------------------------------------------
+// wxDataViewCell
+// ---------------------------------------------------------
+
+class wxDataViewCell: public wxDataViewCellBase
+{
+public:
+ wxDataViewCell( const wxString &varianttype, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
+
+ // implementation
+ void* GetGtkHandle() { return m_renderer; }
+
+protected:
+ // holds the GTK handle
+ void* m_renderer;
+
+protected:
+ DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCell)
+};
+
+// ---------------------------------------------------------
+// wxDataViewTextCell
+// ---------------------------------------------------------
+
+class wxDataViewTextCell: public wxDataViewCell
+{
+public:
+ wxDataViewTextCell( const wxString &varianttype = wxT("string"),
+ wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
+
+protected:
+ DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextCell)
+};
+
// ---------------------------------------------------------
// wxDataViewColumn
// ---------------------------------------------------------
class WXDLLIMPEXP_CORE wxDataViewColumn: public wxDataViewColumnBase
{
public:
- wxDataViewColumn( const wxString &title, wxDataViewCtrl *ctrl,
- wxDataViewColumnType kind, int flags = 0 );
+ wxDataViewColumn( const wxString &title, wxDataViewCell *cell, size_t model_column, int flags = 0 );
virtual ~wxDataViewColumn();
virtual void SetTitle( const wxString &title );
void* GetGtkHandle() { return m_column; }
private:
+ // holds the GTK handle
void* m_column;
protected:
return m_notifier;
}
+// ---------------------------------------------------------
+// wxDataViewCellBase
+// ---------------------------------------------------------
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewCellBase, wxObject)
+
+wxDataViewCellBase::wxDataViewCellBase( const wxString &varianttype, wxDataViewCellMode mode )
+{
+ m_variantType = varianttype;
+ m_mode = mode;
+}
+
// ---------------------------------------------------------
// wxDataViewColumnBase
// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject)
-wxDataViewColumnBase::wxDataViewColumnBase( const wxString &title, wxDataViewCtrl *ctrl,
- wxDataViewColumnType kind, int flags)
+wxDataViewColumnBase::wxDataViewColumnBase( const wxString &title, wxDataViewCell *cell, size_t model_column, int flags)
{
- m_ctrl = ctrl;
- m_kind = kind;
+ m_cell = cell;
+ m_model_column = model_column;
m_flags = flags;
m_title = title;
+ m_owner = NULL;
+ m_cell->SetOwner( (wxDataViewColumn*) this );
+}
+
+wxDataViewColumnBase::~wxDataViewColumnBase()
+{
+ if (m_cell)
+ delete m_cell;
}
void wxDataViewColumnBase::SetTitle( const wxString &title )
return m_model;
}
-bool wxDataViewCtrlBase::AppendStringColumn( const wxString &label )
+bool wxDataViewCtrlBase::AppendStringColumn( const wxString &label, size_t model_column )
{
- return AppendColumn( new wxDataViewColumn( label, (wxDataViewCtrl*) this, wxDATAVIEW_COL_TEXT ) );
+ return AppendColumn( new wxDataViewColumn( label, new wxDataViewTextCell(), model_column ) );
}
bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
{
m_cols.Append( (wxObject*) col );
+ col->SetOwner( (wxDataViewCtrl*) this );
return true;
}
return false;
}
+// ---------------------------------------------------------
+// wxDataViewCell
+// ---------------------------------------------------------
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewCell, wxDataViewCellBase)
+
+wxDataViewCell::wxDataViewCell( const wxString &varianttype, wxDataViewCellMode mode ) :
+ wxDataViewCellBase( varianttype, mode )
+{
+ m_renderer = NULL;
+}
+
+// ---------------------------------------------------------
+// wxDataViewTextCell
+// ---------------------------------------------------------
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewTextCell, wxDataViewCell)
+
+wxDataViewTextCell::wxDataViewTextCell( const wxString &varianttype, wxDataViewCellMode mode ) :
+ wxDataViewCell( varianttype, mode )
+{
+ m_renderer = (void*) gtk_cell_renderer_text_new();
+}
// ---------------------------------------------------------
// wxDataViewColumn
IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn, wxDataViewColumnBase)
-wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCtrl *ctrl,
- wxDataViewColumnType kind, int flags ) :
- wxDataViewColumnBase( title, ctrl, kind, flags )
+wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCell *cell,
+ size_t model_column, int flags ) :
+ wxDataViewColumnBase( title, cell, model_column, flags )
{
- GtkCellRenderer *renderer = NULL;
+ GtkCellRenderer *renderer = (GtkCellRenderer *) cell->GetGtkHandle();
- if (kind == wxDATAVIEW_COL_TEXT)
- {
- renderer = gtk_cell_renderer_text_new();
- } else
- if (kind == wxDATAVIEW_COL_CHECK)
- {
- renderer = gtk_cell_renderer_toggle_new();
- } else
- if (kind == wxDATAVIEW_COL_ICON)
- {
- renderer = gtk_cell_renderer_pixbuf_new();
- }
- else
- return;
-
- GtkTreeViewColumn *column =
- gtk_tree_view_column_new_with_attributes( wxGTK_CONV(title), renderer, "text", 0, NULL );
-
- // bind to data here... not above.
+ GtkTreeViewColumn *column = gtk_tree_view_column_new();
+
+ gtk_tree_view_column_set_title( column, wxGTK_CONV(title) );
+ gtk_tree_view_column_pack_start( column, renderer, TRUE );
+
+ // only correct for wxDataViewTextCell
+ gtk_tree_view_column_set_attributes( column, renderer, "text", model_column, NULL );
+
m_column = (void*) column;
}