Added wxDataViewColumn
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37665 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -29,6 +29,9 @@
|
|||||||
// wxDataViewCtrl globals
|
// wxDataViewCtrl globals
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLIMPEXP_CORE wxDataViewCtrl;
|
||||||
|
class WXDLLIMPEXP_CORE wxDataViewColumn;
|
||||||
|
|
||||||
extern WXDLLEXPORT_DATA(const wxChar) wxDataViewCtrlNameStr[];
|
extern WXDLLEXPORT_DATA(const wxChar) wxDataViewCtrlNameStr[];
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@@ -99,6 +102,48 @@ protected:
|
|||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewListModel)
|
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
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@@ -109,20 +154,25 @@ public:
|
|||||||
wxDataViewCtrlBase();
|
wxDataViewCtrlBase();
|
||||||
~wxDataViewCtrlBase();
|
~wxDataViewCtrlBase();
|
||||||
|
|
||||||
virtual bool AppendStringColumn( const wxString &label ) = 0;
|
|
||||||
|
|
||||||
virtual bool AssociateModel( wxDataViewListModel *model );
|
virtual bool AssociateModel( wxDataViewListModel *model );
|
||||||
wxDataViewListModel* GetModel();
|
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:
|
private:
|
||||||
wxDataViewListModel *m_model;
|
wxDataViewListModel *m_model;
|
||||||
|
wxList m_cols;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__WXGTK20__)
|
#if defined(__WXGTK20__)
|
||||||
#include "wx/gtk/dataview.h"
|
#include "wx/gtk/dataview.h"
|
||||||
#elif defined(__WXMAC__)
|
#elif defined(__WXMAC__)
|
||||||
|
@@ -21,6 +21,29 @@
|
|||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxDataViewCtrl;
|
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
|
// wxDataViewCtrl
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@@ -50,10 +73,8 @@ public:
|
|||||||
const wxSize& size = wxDefaultSize, long style = 0,
|
const wxSize& size = wxDefaultSize, long style = 0,
|
||||||
const wxValidator& validator = wxDefaultValidator );
|
const wxValidator& validator = wxDefaultValidator );
|
||||||
|
|
||||||
virtual bool AppendStringColumn( const wxString &label );
|
|
||||||
|
|
||||||
virtual bool AssociateModel( wxDataViewListModel *model );
|
virtual bool AssociateModel( wxDataViewListModel *model );
|
||||||
|
virtual bool AppendColumn( wxDataViewColumn *col );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
|
DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
|
||||||
|
@@ -112,6 +112,31 @@ wxDataViewListModelNotifier* wxDataViewListModel::GetNotifier()
|
|||||||
return m_notifier;
|
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
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@@ -121,6 +146,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase, wxControl)
|
|||||||
wxDataViewCtrlBase::wxDataViewCtrlBase()
|
wxDataViewCtrlBase::wxDataViewCtrlBase()
|
||||||
{
|
{
|
||||||
m_model = NULL;
|
m_model = NULL;
|
||||||
|
m_cols.DeleteContents( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataViewCtrlBase::~wxDataViewCtrlBase()
|
wxDataViewCtrlBase::~wxDataViewCtrlBase()
|
||||||
@@ -144,3 +170,34 @@ wxDataViewListModel* wxDataViewCtrlBase::GetModel()
|
|||||||
return m_model;
|
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 ];
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -502,6 +502,53 @@ bool wxGtkDataViewListModelNotifier::Cleared()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
// 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
|
// wxDataViewCtrl
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -541,19 +588,6 @@ bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
return true;
|
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 )
|
bool wxDataViewCtrl::AssociateModel( wxDataViewListModel *model )
|
||||||
{
|
{
|
||||||
if (!wxDataViewCtrlBase::AssociateModel( model ))
|
if (!wxDataViewCtrlBase::AssociateModel( model ))
|
||||||
@@ -572,6 +606,18 @@ bool wxDataViewCtrl::AssociateModel( wxDataViewListModel *model )
|
|||||||
return true;
|
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
|
#endif // wxUSE_DATAVIEWCTRL
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user