// wxDataViewCtrl globals
// ----------------------------------------------------------------------------
+class WXDLLIMPEXP_CORE wxDataViewCtrl;
+class WXDLLIMPEXP_CORE wxDataViewColumn;
+
extern WXDLLEXPORT_DATA(const wxChar) wxDataViewCtrlNameStr[];
// ---------------------------------------------------------
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewListModel)
};
+// ---------------------------------------------------------
+// wxDataViewColumn
+// ---------------------------------------------------------
+
+enum wxDataViewColumnType
+{
+ wxDATAVIEW_COL_TEXT,
+ wxDATAVIEW_COL_ICON,
+ wxDATAVIEW_COL_ICONTEXT,
+ wxDATAVIEW_COL_CHECK,
+ wxDATAVIEW_COL_DATETIME,
+ wxDATAVIEW_COL_PROGRESS,
+ wxDATAVIEW_COL_CHOICE,
+ wxDATAVIEW_COL_CUSTOM
+};
+
+enum wxDataViewColumnFlags
+{
+ wxDATAVIEW_COL_RESIZABLE = 1,
+ wxDATAVIEW_COL_SORTABLE = 2,
+ wxDATAVIEW_COL_HIDDEN = 4
+};
+
+class wxDataViewColumnBase: public wxObject
+{
+public:
+ wxDataViewColumnBase( const wxString &title, wxDataViewCtrl *ctrl,
+ wxDataViewColumnType kind, int flags = 0 );
+
+ virtual void SetTitle( const wxString &title );
+ virtual wxString GetTitle();
+
+private:
+ wxDataViewCtrl *m_ctrl;
+ wxDataViewColumnType m_kind;
+ int m_flags;
+ wxString m_title;
+
+protected:
+ DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
+};
+
// ---------------------------------------------------------
// wxDataViewCtrlBase
// ---------------------------------------------------------
wxDataViewCtrlBase();
~wxDataViewCtrlBase();
- virtual bool AppendStringColumn( const wxString &label ) = 0;
virtual bool AssociateModel( wxDataViewListModel *model );
wxDataViewListModel* GetModel();
+ virtual bool AppendStringColumn( const wxString &label );
+ virtual bool AppendColumn( wxDataViewColumn *col );
+ virtual size_t GetNumberOfColumns();
+ virtual bool DeleteColumn( size_t pos );
+ virtual bool ClearColumns();
+ virtual wxDataViewColumn* GetColumn( size_t pos );
+
private:
wxDataViewListModel *m_model;
+ wxList m_cols;
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
};
-
-
#if defined(__WXGTK20__)
#include "wx/gtk/dataview.h"
#elif defined(__WXMAC__)
class WXDLLIMPEXP_CORE wxDataViewCtrl;
+// ---------------------------------------------------------
+// wxDataViewColumn
+// ---------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxDataViewColumn: public wxDataViewColumnBase
+{
+public:
+ wxDataViewColumn( const wxString &title, wxDataViewCtrl *ctrl,
+ wxDataViewColumnType kind, int flags = 0 );
+ virtual ~wxDataViewColumn();
+
+ virtual void SetTitle( const wxString &title );
+
+ // implementation
+ void* GetGtkHandle() { return m_column; }
+
+private:
+ void* m_column;
+
+protected:
+ DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
+};
+
// ---------------------------------------------------------
// wxDataViewCtrl
// ---------------------------------------------------------
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator );
- virtual bool AppendStringColumn( const wxString &label );
-
virtual bool AssociateModel( wxDataViewListModel *model );
-
+ virtual bool AppendColumn( wxDataViewColumn *col );
private:
DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
return m_notifier;
}
+// ---------------------------------------------------------
+// wxDataViewColumnBase
+// ---------------------------------------------------------
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject)
+
+wxDataViewColumnBase::wxDataViewColumnBase( const wxString &title, wxDataViewCtrl *ctrl,
+ wxDataViewColumnType kind, int flags)
+{
+ m_ctrl = ctrl;
+ m_kind = kind;
+ m_flags = flags;
+ m_title = title;
+}
+
+void wxDataViewColumnBase::SetTitle( const wxString &title )
+{
+ m_title = title;
+}
+
+wxString wxDataViewColumnBase::GetTitle()
+{
+ return m_title;
+}
+
// ---------------------------------------------------------
// wxDataViewCtrlBase
// ---------------------------------------------------------
wxDataViewCtrlBase::wxDataViewCtrlBase()
{
m_model = NULL;
+ m_cols.DeleteContents( true );
}
wxDataViewCtrlBase::~wxDataViewCtrlBase()
return m_model;
}
+bool wxDataViewCtrlBase::AppendStringColumn( const wxString &label )
+{
+ return AppendColumn( new wxDataViewColumn( label, (wxDataViewCtrl*) this, wxDATAVIEW_COL_TEXT ) );
+}
+
+bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
+{
+ m_cols.Append( (wxObject*) col );
+ return true;
+}
+
+size_t wxDataViewCtrlBase::GetNumberOfColumns()
+{
+ return m_cols.GetCount();
+}
+
+bool wxDataViewCtrlBase::DeleteColumn( size_t pos )
+{
+ return false;
+}
+
+bool wxDataViewCtrlBase::ClearColumns()
+{
+ return false;
+}
+
+wxDataViewColumn* wxDataViewCtrlBase::GetColumn( size_t pos )
+{
+ return (wxDataViewColumn*) m_cols[ pos ];
+}
+
}
+// ---------------------------------------------------------
+// wxDataViewColumn
+// ---------------------------------------------------------
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn, wxDataViewColumnBase)
+
+wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCtrl *ctrl,
+ wxDataViewColumnType kind, int flags ) :
+ wxDataViewColumnBase( title, ctrl, kind, flags )
+{
+ GtkCellRenderer *renderer = NULL;
+
+ 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.
+
+ m_column = (void*) column;
+}
+
+wxDataViewColumn::~wxDataViewColumn()
+{
+}
+
+void wxDataViewColumn::SetTitle( const wxString &title )
+{
+ wxDataViewColumnBase::SetTitle( title );
+
+ GtkTreeViewColumn *column = (GtkTreeViewColumn *)m_column;
+ gtk_tree_view_column_set_title( column, wxGTK_CONV(title) );
+}
+
//-----------------------------------------------------------------------------
// wxDataViewCtrl
//-----------------------------------------------------------------------------
return true;
}
-bool wxDataViewCtrl::AppendStringColumn( const wxString &label )
-{
- GtkCellRenderer *renderer
- = gtk_cell_renderer_text_new();
-
- GtkTreeViewColumn *column
- = gtk_tree_view_column_new_with_attributes( wxGTK_CONV(label), renderer, "text", -1, NULL );
-
- gtk_tree_view_append_column( GTK_TREE_VIEW(m_widget), column );
-
- return true;
-}
-
bool wxDataViewCtrl::AssociateModel( wxDataViewListModel *model )
{
if (!wxDataViewCtrlBase::AssociateModel( model ))
return true;
}
+bool wxDataViewCtrl::AppendColumn( wxDataViewColumn *col )
+{
+ if (!wxDataViewCtrlBase::AppendColumn(col))
+ return false;
+
+ GtkTreeViewColumn *column = (GtkTreeViewColumn *)col->GetGtkHandle();
+
+ gtk_tree_view_append_column( GTK_TREE_VIEW(m_widget), column );
+
+ return true;
+}
+
#endif // wxUSE_DATAVIEWCTRL