added wxDataViewCell
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37675 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxDataViewCtrl;
|
class WXDLLIMPEXP_CORE wxDataViewCtrl;
|
||||||
class WXDLLIMPEXP_CORE wxDataViewColumn;
|
class WXDLLIMPEXP_CORE wxDataViewColumn;
|
||||||
|
class WXDLLIMPEXP_CORE wxDataViewCell;
|
||||||
|
|
||||||
extern WXDLLEXPORT_DATA(const wxChar) wxDataViewCtrlNameStr[];
|
extern WXDLLEXPORT_DATA(const wxChar) wxDataViewCtrlNameStr[];
|
||||||
|
|
||||||
@@ -103,21 +104,52 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// wxDataViewColumn
|
// wxDataViewCellBase
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
enum wxDataViewColumnType
|
enum wxDataViewCellMode
|
||||||
{
|
{
|
||||||
wxDATAVIEW_COL_TEXT,
|
wxDATAVIEW_CELL_INERT,
|
||||||
wxDATAVIEW_COL_ICON,
|
wxDATAVIEW_CELL_ACTIVATABLE,
|
||||||
wxDATAVIEW_COL_ICONTEXT,
|
wxDATAVIEW_CELL_EDITABLE
|
||||||
wxDATAVIEW_COL_CHECK,
|
|
||||||
wxDATAVIEW_COL_DATETIME,
|
|
||||||
wxDATAVIEW_COL_PROGRESS,
|
|
||||||
wxDATAVIEW_COL_CHOICE,
|
|
||||||
wxDATAVIEW_COL_CUSTOM
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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
|
enum wxDataViewColumnFlags
|
||||||
{
|
{
|
||||||
wxDATAVIEW_COL_RESIZABLE = 1,
|
wxDATAVIEW_COL_RESIZABLE = 1,
|
||||||
@@ -128,17 +160,26 @@ enum wxDataViewColumnFlags
|
|||||||
class wxDataViewColumnBase: public wxObject
|
class wxDataViewColumnBase: public wxObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxDataViewColumnBase( const wxString &title, wxDataViewCtrl *ctrl,
|
wxDataViewColumnBase( const wxString &title, wxDataViewCell *cell, size_t model_column, int flags = 0 );
|
||||||
wxDataViewColumnType kind, int flags = 0 );
|
~wxDataViewColumnBase();
|
||||||
|
|
||||||
virtual void SetTitle( const wxString &title );
|
virtual void SetTitle( const wxString &title );
|
||||||
virtual wxString GetTitle();
|
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:
|
private:
|
||||||
wxDataViewCtrl *m_ctrl;
|
wxDataViewCtrl *m_ctrl;
|
||||||
wxDataViewColumnType m_kind;
|
wxDataViewCell *m_cell;
|
||||||
|
int m_model_column;
|
||||||
int m_flags;
|
int m_flags;
|
||||||
wxString m_title;
|
wxString m_title;
|
||||||
|
wxDataViewCtrl *m_owner;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
|
||||||
@@ -154,11 +195,10 @@ public:
|
|||||||
wxDataViewCtrlBase();
|
wxDataViewCtrlBase();
|
||||||
~wxDataViewCtrlBase();
|
~wxDataViewCtrlBase();
|
||||||
|
|
||||||
|
|
||||||
virtual bool AssociateModel( wxDataViewListModel *model );
|
virtual bool AssociateModel( wxDataViewListModel *model );
|
||||||
wxDataViewListModel* GetModel();
|
wxDataViewListModel* GetModel();
|
||||||
|
|
||||||
virtual bool AppendStringColumn( const wxString &label );
|
virtual bool AppendStringColumn( const wxString &label, size_t model_column );
|
||||||
virtual bool AppendColumn( wxDataViewColumn *col );
|
virtual bool AppendColumn( wxDataViewColumn *col );
|
||||||
virtual size_t GetNumberOfColumns();
|
virtual size_t GetNumberOfColumns();
|
||||||
virtual bool DeleteColumn( size_t pos );
|
virtual bool DeleteColumn( size_t pos );
|
||||||
|
@@ -21,6 +21,40 @@
|
|||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxDataViewCtrl;
|
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
|
// wxDataViewColumn
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@@ -28,8 +62,7 @@ class WXDLLIMPEXP_CORE wxDataViewCtrl;
|
|||||||
class WXDLLIMPEXP_CORE wxDataViewColumn: public wxDataViewColumnBase
|
class WXDLLIMPEXP_CORE wxDataViewColumn: public wxDataViewColumnBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxDataViewColumn( const wxString &title, wxDataViewCtrl *ctrl,
|
wxDataViewColumn( const wxString &title, wxDataViewCell *cell, size_t model_column, int flags = 0 );
|
||||||
wxDataViewColumnType kind, int flags = 0 );
|
|
||||||
virtual ~wxDataViewColumn();
|
virtual ~wxDataViewColumn();
|
||||||
|
|
||||||
virtual void SetTitle( const wxString &title );
|
virtual void SetTitle( const wxString &title );
|
||||||
@@ -38,6 +71,7 @@ public:
|
|||||||
void* GetGtkHandle() { return m_column; }
|
void* GetGtkHandle() { return m_column; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// holds the GTK handle
|
||||||
void* m_column;
|
void* m_column;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -112,19 +112,38 @@ wxDataViewListModelNotifier* wxDataViewListModel::GetNotifier()
|
|||||||
return m_notifier;
|
return m_notifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
// wxDataViewCellBase
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
|
IMPLEMENT_ABSTRACT_CLASS(wxDataViewCellBase, wxObject)
|
||||||
|
|
||||||
|
wxDataViewCellBase::wxDataViewCellBase( const wxString &varianttype, wxDataViewCellMode mode )
|
||||||
|
{
|
||||||
|
m_variantType = varianttype;
|
||||||
|
m_mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// wxDataViewColumnBase
|
// wxDataViewColumnBase
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject)
|
IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject)
|
||||||
|
|
||||||
wxDataViewColumnBase::wxDataViewColumnBase( const wxString &title, wxDataViewCtrl *ctrl,
|
wxDataViewColumnBase::wxDataViewColumnBase( const wxString &title, wxDataViewCell *cell, size_t model_column, int flags)
|
||||||
wxDataViewColumnType kind, int flags)
|
|
||||||
{
|
{
|
||||||
m_ctrl = ctrl;
|
m_cell = cell;
|
||||||
m_kind = kind;
|
m_model_column = model_column;
|
||||||
m_flags = flags;
|
m_flags = flags;
|
||||||
m_title = title;
|
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 )
|
void wxDataViewColumnBase::SetTitle( const wxString &title )
|
||||||
@@ -170,14 +189,15 @@ wxDataViewListModel* wxDataViewCtrlBase::GetModel()
|
|||||||
return m_model;
|
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 )
|
bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
|
||||||
{
|
{
|
||||||
m_cols.Append( (wxObject*) col );
|
m_cols.Append( (wxObject*) col );
|
||||||
|
col->SetOwner( (wxDataViewCtrl*) this );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -501,6 +501,29 @@ bool wxGtkDataViewListModelNotifier::Cleared()
|
|||||||
return false;
|
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
|
// wxDataViewColumn
|
||||||
@@ -508,31 +531,20 @@ bool wxGtkDataViewListModelNotifier::Cleared()
|
|||||||
|
|
||||||
IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn, wxDataViewColumnBase)
|
IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn, wxDataViewColumnBase)
|
||||||
|
|
||||||
wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCtrl *ctrl,
|
wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCell *cell,
|
||||||
wxDataViewColumnType kind, int flags ) :
|
size_t model_column, int flags ) :
|
||||||
wxDataViewColumnBase( title, ctrl, kind, flags )
|
wxDataViewColumnBase( title, cell, model_column, flags )
|
||||||
{
|
{
|
||||||
GtkCellRenderer *renderer = NULL;
|
GtkCellRenderer *renderer = (GtkCellRenderer *) cell->GetGtkHandle();
|
||||||
|
|
||||||
if (kind == wxDATAVIEW_COL_TEXT)
|
GtkTreeViewColumn *column = gtk_tree_view_column_new();
|
||||||
{
|
|
||||||
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_set_title( column, wxGTK_CONV(title) );
|
||||||
gtk_tree_view_column_new_with_attributes( wxGTK_CONV(title), renderer, "text", 0, NULL );
|
|
||||||
|
|
||||||
// bind to data here... not above.
|
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;
|
m_column = (void*) column;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user