Route data from wxDataViewModel in a wxVariant
through wxDataViewCell::SetValue() to the GtkCellRendererText. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37677 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
0313c114f5
commit
7b4fde8255
@ -51,6 +51,8 @@ public:
|
|||||||
wxDataViewTextCell( const wxString &varianttype = wxT("string"),
|
wxDataViewTextCell( const wxString &varianttype = wxT("string"),
|
||||||
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
|
||||||
|
|
||||||
|
bool SetValue( const wxVariant &value );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextCell)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextCell)
|
||||||
};
|
};
|
||||||
|
@ -525,10 +525,53 @@ wxDataViewTextCell::wxDataViewTextCell( const wxString &varianttype, wxDataViewC
|
|||||||
m_renderer = (void*) gtk_cell_renderer_text_new();
|
m_renderer = (void*) gtk_cell_renderer_text_new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxDataViewTextCell::SetValue( const wxVariant &value )
|
||||||
|
{
|
||||||
|
wxString tmp = value;
|
||||||
|
|
||||||
|
GValue gvalue = { 0, };
|
||||||
|
g_value_init( &gvalue, G_TYPE_STRING );
|
||||||
|
g_value_set_string( &gvalue, wxGTK_CONV( tmp ) );
|
||||||
|
g_object_set_property( G_OBJECT(m_renderer), "text", &gvalue );
|
||||||
|
g_value_unset( &gvalue );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// wxDataViewColumn
|
// wxDataViewColumn
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *column,
|
||||||
|
GtkCellRenderer *cell,
|
||||||
|
GtkTreeModel *model,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
gpointer data );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *column,
|
||||||
|
GtkCellRenderer *renderer,
|
||||||
|
GtkTreeModel *model,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
gpointer data )
|
||||||
|
{
|
||||||
|
g_return_if_fail (GTK_IS_WX_LIST_STORE (model));
|
||||||
|
GtkWxListStore *list_store = (GtkWxListStore *) model;
|
||||||
|
|
||||||
|
wxDataViewCell *cell = (wxDataViewCell*) data;
|
||||||
|
|
||||||
|
wxVariant value = list_store->model->GetValue( (size_t) iter->user_data,
|
||||||
|
cell->GetOwner()->GetModelColumn() );
|
||||||
|
|
||||||
|
if (value.GetType() != cell->GetVariantType())
|
||||||
|
wxPrintf( wxT("Wrong type\n") );
|
||||||
|
|
||||||
|
cell->SetValue( value );
|
||||||
|
}
|
||||||
|
|
||||||
IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn, wxDataViewColumnBase)
|
IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn, wxDataViewColumnBase)
|
||||||
|
|
||||||
wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCell *cell,
|
wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCell *cell,
|
||||||
@ -543,8 +586,8 @@ wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCell *cell,
|
|||||||
|
|
||||||
gtk_tree_view_column_pack_start( column, renderer, TRUE );
|
gtk_tree_view_column_pack_start( column, renderer, TRUE );
|
||||||
|
|
||||||
// only correct for wxDataViewTextCell
|
gtk_tree_view_column_set_cell_data_func( column, renderer,
|
||||||
gtk_tree_view_column_set_attributes( column, renderer, "text", model_column, NULL );
|
wxGtkTreeCellDataFunc, (gpointer) cell, NULL );
|
||||||
|
|
||||||
m_column = (void*) column;
|
m_column = (void*) column;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user