#include "wx/dataview.h"
#include "wx/spinctrl.h"
+#include "wx/ptr_shrd.h"
+#include "wx/vector.h"
+
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
};
-
#define DEFAULT_ALIGN wxALIGN_LEFT
#define DATAVIEW_DEFAULT_STYLE (wxDV_MULTIPLE|wxDV_HORIZ_RULES|wxDV_VERT_RULES)
-
// -------------------------------------
// MyMusicModel
// -------------------------------------
wxBoxSizer *bottom_sizer = new wxBoxSizer( wxHORIZONTAL );
- m_log = new wxTextCtrl( this, -1,wxString(), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
+ m_log = new wxTextCtrl( this, -1, wxString(), wxDefaultPosition, wxSize(100,200), wxTE_MULTILINE );
m_logOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_log));
wxLogMessage(_("This is the log window"));
// wxDataViewTreeStore
wxDataViewCtrl *treectrl = new wxDataViewCtrl( this, -1,
- wxDefaultPosition, wxSize(300,200), wxDV_NO_HEADER );
+ wxDefaultPosition, wxSize(100,200), wxDV_NO_HEADER );
wxDataViewTreeStore *store = new wxDataViewTreeStore;
wxDataViewItem parent = store->AppendContainer( wxDataViewItem(0),wxT("Root 1"), wxIcon(small1_xpm) );
wxDataViewItem child = store->AppendItem( parent,wxT("Child 1"), wxIcon(small1_xpm) );
child = store->AppendItem( parent,wxT("Child 2"), wxIcon(small1_xpm) );
- child = store->AppendItem( parent,wxT("Child 3"), wxIcon(small1_xpm) );
+ child = store->AppendItem( parent,wxT("Child 3, very long, long, long, long"), wxIcon(small1_xpm) );
treectrl->AssociateModel( store );
store->DecRef();
- treectrl->AppendIconTextColumn(wxT("no label"), 0, wxDATAVIEW_CELL_INERT, 200 );
+ treectrl->AppendIconTextColumn(wxT("no label"), 0, wxDATAVIEW_CELL_INERT, -1 );
- bottom_sizer->Add( treectrl );
+ bottom_sizer->Add( treectrl, 1 );
// wxDataViewTreeCtrl
- wxDataViewTreeCtrl *treectrl2 = new wxDataViewTreeCtrl( this, -1, wxDefaultPosition, wxSize(300,200) );
+ wxDataViewTreeCtrl *treectrl2 = new wxDataViewTreeCtrl( this, -1, wxDefaultPosition, wxSize(100,200) );
wxImageList *ilist = new wxImageList( 16, 16 );
ilist->Add( wxIcon(small1_xpm) );
parent = treectrl2->AppendContainer( wxDataViewItem(0),wxT("Root 1"), 0 );
child = treectrl2->AppendItem( parent,wxT("Child 1"), 0 );
child = treectrl2->AppendItem( parent,wxT("Child 2"), 0 );
- child = treectrl2->AppendItem( parent,wxT("Child 3"), 0 );
+ child = treectrl2->AppendItem( parent,wxT("Child 3, very long, long, long, long"), 0 );
- bottom_sizer->Add( treectrl2 );
+ bottom_sizer->Add( treectrl2, 1 );
// main sizer
return true;
}
-bool wxDataViewIconTextRenderer::GetValue( wxVariant &value ) const
+bool wxDataViewIconTextRenderer::GetValue( wxVariant &WXUNUSED(value) ) const
{
return false;
}
return size;
}
-wxControl* wxDataViewIconTextRenderer::CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value )
+wxControl* wxDataViewIconTextRenderer::CreateEditorCtrl(
+ wxWindow *WXUNUSED(parent), wxRect WXUNUSED(labelRect), const wxVariant &WXUNUSED(value) )
{
return NULL;
}
-bool wxDataViewIconTextRenderer::GetValueFromEditorCtrl( wxControl* editor, wxVariant &value )
+bool wxDataViewIconTextRenderer::GetValueFromEditorCtrl(
+ wxControl* WXUNUSED(editor), wxVariant &WXUNUSED(value) )
{
return false;
}
static gboolean
-gtk_dataview_header_button_press_callback( GtkWidget *widget,
+gtk_dataview_header_button_press_callback( GtkWidget *WXUNUSED(widget),
GdkEventButton *gdk_event,
wxDataViewColumn *column )
{
}
-static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *column,
+static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *WXUNUSED(column),
GtkCellRenderer *renderer,
GtkTreeModel *model,
GtkTreeIter *iter,
SetFlags( flags );
SetAlignment( align );
- // NOTE: we prefer not to call SetMinWidth(wxDVC_DEFAULT_MINWIDTH);
- // as GTK+ is smart and unless explicitely told, will set the minimal
- // width to the title's lenght, which is a better default
-
- // the GTK_TREE_VIEW_COLUMN_FIXED is required by the "fixed height" mode
- // that we use for the wxDataViewCtrl
- gtk_tree_view_column_set_fixed_width( column, width < 0 ? wxDVC_DEFAULT_WIDTH : width );
- gtk_tree_view_column_set_sizing( column, GTK_TREE_VIEW_COLUMN_FIXED );
+ SetWidth( width );
gtk_tree_view_column_pack_end( column, renderer, TRUE );
void wxDataViewColumn::SetWidth( int width )
{
- gtk_tree_view_column_set_fixed_width( GTK_TREE_VIEW_COLUMN(m_column), width );
+ if (width < 0)
+ {
+ gtk_tree_view_column_set_sizing( GTK_TREE_VIEW_COLUMN(m_column), GTK_TREE_VIEW_COLUMN_AUTOSIZE );
+ }
+ else
+ {
+ gtk_tree_view_column_set_sizing( GTK_TREE_VIEW_COLUMN(m_column), GTK_TREE_VIEW_COLUMN_FIXED );
+
+ gtk_tree_view_column_set_fixed_width( GTK_TREE_VIEW_COLUMN(m_column), width );
+ }
}
void wxDataViewColumn::SetReorderable( bool reorderable )
//-----------------------------------------------------------------------------
static void
-wxdataview_selection_changed_callback( GtkTreeSelection* selection, wxDataViewCtrl *dv )
+wxdataview_selection_changed_callback( GtkTreeSelection* WXUNUSED(selection), wxDataViewCtrl *dv )
{
if (!GTK_WIDGET_REALIZED(dv->m_widget))
return;
}
static void
-wxdataview_row_activated_callback( GtkTreeView* treeview, GtkTreePath *path,
- GtkTreeViewColumn *column, wxDataViewCtrl *dv )
+wxdataview_row_activated_callback( GtkTreeView* WXUNUSED(treeview), GtkTreePath *path,
+ GtkTreeViewColumn *WXUNUSED(column), wxDataViewCtrl *dv )
{
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, dv->GetId() );
}
static gboolean
-wxdataview_test_expand_row_callback( GtkTreeView* treeview, GtkTreeIter* iter,
- GtkTreePath *path, wxDataViewCtrl *dv )
+wxdataview_test_expand_row_callback( GtkTreeView* WXUNUSED(treeview), GtkTreeIter* iter,
+ GtkTreePath *WXUNUSED(path), wxDataViewCtrl *dv )
{
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, dv->GetId() );
}
static void
-wxdataview_row_expanded_callback( GtkTreeView* treeview, GtkTreeIter* iter,
- GtkTreePath *path, wxDataViewCtrl *dv )
+wxdataview_row_expanded_callback( GtkTreeView* WXUNUSED(treeview), GtkTreeIter* iter,
+ GtkTreePath *WXUNUSED(path), wxDataViewCtrl *dv )
{
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, dv->GetId() );
}
static gboolean
-wxdataview_test_collapse_row_callback( GtkTreeView* treeview, GtkTreeIter* iter,
- GtkTreePath *path, wxDataViewCtrl *dv )
+wxdataview_test_collapse_row_callback( GtkTreeView* WXUNUSED(treeview), GtkTreeIter* iter,
+ GtkTreePath *WXUNUSED(path), wxDataViewCtrl *dv )
{
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, dv->GetId() );
}
static void
-wxdataview_row_collapsed_callback( GtkTreeView* treeview, GtkTreeIter* iter,
- GtkTreePath *path, wxDataViewCtrl *dv )
+wxdataview_row_collapsed_callback( GtkTreeView* WXUNUSED(treeview), GtkTreeIter* iter,
+ GtkTreePath *WXUNUSED(path), wxDataViewCtrl *dv )
{
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, dv->GetId() );
static
void gtk_dataviewctrl_size_callback( GtkWidget *WXUNUSED(widget),
- GtkAllocation *alloc,
+ GtkAllocation *WXUNUSED(gtk_alloc),
wxDataViewCtrl *win )
{
wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst();
//-----------------------------------------------------------------------------
static gboolean
-gtk_dataview_motion_notify_callback( GtkWidget *widget,
+gtk_dataview_motion_notify_callback( GtkWidget *WXUNUSED(widget),
GdkEventMotion *gdk_event,
wxDataViewCtrl *dv )
{
gtk_tree_view_enable_model_drag_source( GTK_TREE_VIEW(m_treeview),
GDK_BUTTON1_MASK, &gs_target, 1, (GdkDragAction) GDK_ACTION_COPY );
-
#ifdef __WXGTK26__
if (!gtk_check_version(2,6,0))
gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), TRUE );
m_cols.Append( col );
+#ifdef __WXGTK26__
+ if (!gtk_check_version(2,6,0))
+ {
+ if (gtk_tree_view_column_get_sizing( GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) ) !=
+ GTK_TREE_VIEW_COLUMN_FIXED)
+ gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), FALSE );
+ }
+#endif
+
gtk_tree_view_append_column( GTK_TREE_VIEW(m_treeview),
GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) );
m_cols.Insert( col );
+#ifdef __WXGTK26__
+ if (!gtk_check_version(2,6,0))
+ {
+ if (gtk_tree_view_column_get_sizing( GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()) ) !=
+ GTK_TREE_VIEW_COLUMN_FIXED)
+ gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), FALSE );
+ }
+#endif
+
gtk_tree_view_insert_column( GTK_TREE_VIEW(m_treeview),
GTK_TREE_VIEW_COLUMN(col->GetGtkHandle()), 0 );