#if defined(__WXGTK20__)
// for testing
- // #define wxUSE_GENERICDATAVIEWCTRL 1
+ #define wxUSE_GENERICDATAVIEWCTRL 1
#elif defined(__WXMAC__)
#define wxUSE_GENERICDATAVIEWCTRL 1
#else
public:
wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer, unsigned int model_column,
int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
+ wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer, unsigned int model_column,
+ int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
virtual ~wxDataViewColumnBase();
virtual void SetTitle( const wxString &title );
virtual wxString GetTitle();
+ virtual void SetBitmap( const wxBitmap &bitmap );
+ virtual const wxBitmap &GetBitmap();
+
wxDataViewRenderer* GetRenderer() { return m_renderer; }
unsigned int GetModelColumn() { return m_model_column; }
int m_model_column;
int m_flags;
wxString m_title;
+ wxBitmap m_bitmap;
wxDataViewCtrl *m_owner;
protected:
virtual bool AssociateModel( wxDataViewListModel *model );
wxDataViewListModel* GetModel();
+ // short cuts
virtual bool AppendTextColumn( const wxString &label, unsigned int model_column );
virtual bool AppendToggleColumn( const wxString &label, unsigned int model_column );
virtual bool AppendProgressColumn( const wxString &label, unsigned int model_column );
virtual bool AppendDateColumn( const wxString &label, unsigned int model_column );
+ virtual bool AppendBitmapColumn( const wxString &label, unsigned int model_column );
+ virtual bool AppendTextColumn( const wxBitmap &label, unsigned int model_column );
+ virtual bool AppendToggleColumn( const wxBitmap &label, unsigned int model_column );
+ virtual bool AppendProgressColumn( const wxBitmap &label, unsigned int model_column );
+ virtual bool AppendDateColumn( const wxBitmap &label, unsigned int model_column );
+ virtual bool AppendBitmapColumn( const wxBitmap &label, unsigned int model_column );
+
virtual bool AppendColumn( wxDataViewColumn *col );
virtual unsigned int GetNumberOfColumns();
virtual bool DeleteColumn( unsigned int pos );
public:
wxDataViewColumn( const wxString &title, wxDataViewRenderer *renderer, unsigned int model_column,
int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
+ wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer, unsigned int model_column,
+ int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
virtual ~wxDataViewColumn();
virtual void SetTitle( const wxString &title );
public:
wxDataViewColumn( const wxString &title, wxDataViewRenderer *renderer, unsigned int model_column,
int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
+ wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer, unsigned int model_column,
+ int width = 80, int flags = wxDATAVIEW_COL_RESIZABLE );
virtual ~wxDataViewColumn();
virtual void SetTitle( const wxString &title );
-
+ virtual void SetBitmap( const wxBitmap &bitmap );
+
virtual int GetWidth();
virtual void SetFixedWidth( int width );
wxDataViewColumn *column = new wxDataViewColumn( wxT("editable"), text_renderer, 0 );
dataview_left->AppendColumn( column );
dataview_left->AppendTextColumn( wxT("second"), 1 );
- dataview_left->AppendColumn( new wxDataViewColumn( wxT("icon"), new wxDataViewBitmapRenderer, 2, 25 ) );
+ dataview_left->AppendColumn( new wxDataViewColumn( wxBitmap(null_xpm), new wxDataViewBitmapRenderer, 2, 25 ) );
dataview_left->AppendColumn( new wxDataViewColumn( wxT("icon"), new wxDataViewBitmapRenderer, 3, 25 ) );
// Right wxDataViewCtrl using the sorting model
m_renderer->SetOwner( (wxDataViewColumn*) this );
}
+wxDataViewColumnBase::wxDataViewColumnBase(const wxBitmap& bitmap,
+ wxDataViewRenderer *renderer,
+ unsigned int model_column,
+ int WXUNUSED(width),
+ int flags )
+{
+ m_renderer = renderer;
+ m_model_column = model_column;
+ m_flags = flags;
+ m_bitmap = bitmap;
+ m_owner = NULL;
+ m_renderer->SetOwner( (wxDataViewColumn*) this );
+}
+
wxDataViewColumnBase::~wxDataViewColumnBase()
{
if (m_renderer)
return m_title;
}
+void wxDataViewColumnBase::SetBitmap( const wxBitmap &bitmap )
+{
+ m_bitmap = bitmap;
+}
+
+const wxBitmap &wxDataViewColumnBase::GetBitmap()
+{
+ return m_bitmap;
+}
+
// ---------------------------------------------------------
// wxDataViewCtrlBase
// ---------------------------------------------------------
return AppendColumn( new wxDataViewColumn( label, new wxDataViewDateRenderer(), model_column ) );
}
+bool wxDataViewCtrlBase::AppendBitmapColumn( const wxString &label, unsigned int model_column )
+{
+ return AppendColumn( new wxDataViewColumn( label, new wxDataViewBitmapRenderer(), model_column ) );
+}
+
+bool wxDataViewCtrlBase::AppendTextColumn( const wxBitmap &label, unsigned int model_column )
+{
+ return AppendColumn( new wxDataViewColumn( label, new wxDataViewTextRenderer(), model_column ) );
+}
+
+bool wxDataViewCtrlBase::AppendToggleColumn( const wxBitmap &label, unsigned int model_column )
+{
+ return AppendColumn( new wxDataViewColumn( label, new wxDataViewToggleRenderer(), model_column, 30 ) );
+}
+
+bool wxDataViewCtrlBase::AppendProgressColumn( const wxBitmap &label, unsigned int model_column )
+{
+ return AppendColumn( new wxDataViewColumn( label, new wxDataViewProgressRenderer(), model_column, 70 ) );
+}
+
+bool wxDataViewCtrlBase::AppendDateColumn( const wxBitmap &label, unsigned int model_column )
+{
+ return AppendColumn( new wxDataViewColumn( label, new wxDataViewDateRenderer(), model_column ) );
+}
+
+bool wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap &label, unsigned int model_column )
+{
+ return AppendColumn( new wxDataViewColumn( label, new wxDataViewBitmapRenderer(), model_column ) );
+}
+
bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
{
m_cols.Append( (wxObject*) col );
m_width = 80;
}
+wxDataViewColumn::wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *cell, unsigned int model_column,
+ int width, int flags ) :
+ wxDataViewColumnBase( bitmap, cell, model_column, width, flags )
+{
+ m_width = width;
+ if (m_width < 0)
+ m_width = 30;
+}
+
wxDataViewColumn::~wxDataViewColumn()
{
}
m_column = (void*) column;
}
+wxDataViewColumn::wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *cell, unsigned int model_column,
+ int width, int flags ) :
+ wxDataViewColumnBase( bitmap, cell, model_column, width, flags )
+{
+ GtkCellRenderer *renderer = (GtkCellRenderer *) cell->GetGtkHandle();
+
+ GtkTreeViewColumn *column = gtk_tree_view_column_new();
+ m_column = (void*) column;
+
+ SetBitmap( bitmap );
+
+ if (flags & wxDATAVIEW_COL_RESIZABLE)
+ gtk_tree_view_column_set_resizable( column, true );
+ if (flags & wxDATAVIEW_COL_HIDDEN)
+ gtk_tree_view_column_set_visible( column, false );
+ if (flags & wxDATAVIEW_COL_SORTABLE)
+ gtk_tree_view_column_set_sort_indicator( column, true );
+
+ if (width > 0)
+ {
+ gtk_tree_view_column_set_fixed_width( column, width );
+ gtk_tree_view_column_set_sizing( column, GTK_TREE_VIEW_COLUMN_FIXED );
+ }
+
+ gtk_tree_view_column_pack_end( column, renderer, FALSE );
+
+ gtk_tree_view_column_set_cell_data_func( column, renderer,
+ wxGtkTreeCellDataFunc, (gpointer) cell, NULL );
+}
+
wxDataViewColumn::~wxDataViewColumn()
{
}
GtkTreeViewColumn *column = (GtkTreeViewColumn *)m_column;
gtk_tree_view_column_set_title( column, wxGTK_CONV(title) );
+
+ gtk_tree_view_column_set_widget( column, NULL );
+}
+
+void wxDataViewColumn::SetBitmap( const wxBitmap &bitmap )
+{
+ wxDataViewColumnBase::SetBitmap( bitmap );
+
+ GtkTreeViewColumn *column = (GtkTreeViewColumn *)m_column;
+ if (bitmap.Ok())
+ {
+ GtkImage *gtk_image = GTK_IMAGE( gtk_image_new() );
+
+ GdkBitmap *mask = (GdkBitmap *) NULL;
+ if (bitmap.GetMask())
+ mask = bitmap.GetMask()->GetBitmap();
+
+ if (bitmap.HasPixbuf())
+ {
+ gtk_image_set_from_pixbuf(GTK_IMAGE(gtk_image),
+ bitmap.GetPixbuf());
+ }
+ else
+ {
+ gtk_image_set_from_pixmap(GTK_IMAGE(gtk_image),
+ bitmap.GetPixmap(), mask);
+ }
+ gtk_widget_show( GTK_WIDGET(gtk_image) );
+
+ gtk_tree_view_column_set_widget( column, GTK_WIDGET(gtk_image) );
+ }
+ else
+ {
+ gtk_tree_view_column_set_widget( column, NULL );
+ }
}
int wxDataViewColumn::GetWidth()