1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/dataview.cpp
3 // Purpose: wxDataViewCtrl GTK+2 implementation
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
13 #if wxUSE_DATAVIEWCTRL
15 #include "wx/dataview.h"
17 #ifndef wxUSE_GENERICDATAVIEWCTRL
21 #include "wx/dcclient.h"
25 #include "wx/settings.h"
29 #include "wx/stockitem.h"
30 #include "wx/calctrl.h"
31 #include "wx/popupwin.h"
32 #include "wx/listimpl.cpp"
34 #include "wx/gtk/private.h"
35 #include "wx/gtk/dc.h"
36 #include "wx/gtk/dcclient.h"
38 //-----------------------------------------------------------------------------
39 //-----------------------------------------------------------------------------
41 class wxDataViewCtrlInternal
;
43 wxDataViewCtrlInternal
*g_internal
= NULL
;
45 class wxGtkTreeModelNode
;
48 typedef struct _GtkWxTreeModel GtkWxTreeModel
;
51 //-----------------------------------------------------------------------------
52 // wxDataViewCtrlInternal
53 //-----------------------------------------------------------------------------
55 WX_DECLARE_LIST(wxDataViewItem
, ItemList
);
56 WX_DEFINE_LIST(ItemList
)
58 class wxDataViewCtrlInternal
61 wxDataViewCtrlInternal( wxDataViewCtrl
*owner
, wxDataViewModel
*wx_model
, GtkWxTreeModel
*owner
);
62 ~wxDataViewCtrlInternal();
64 GtkTreeModelFlags
get_flags();
65 gboolean
get_iter( GtkTreeIter
*iter
, GtkTreePath
*path
);
66 GtkTreePath
*get_path( GtkTreeIter
*iter
);
67 gboolean
iter_next( GtkTreeIter
*iter
);
68 gboolean
iter_children( GtkTreeIter
*iter
, GtkTreeIter
*parent
);
69 gboolean
iter_has_child( GtkTreeIter
*iter
);
70 gint
iter_n_children( GtkTreeIter
*iter
);
71 gboolean
iter_nth_child( GtkTreeIter
*iter
, GtkTreeIter
*parent
, gint n
);
72 gboolean
iter_parent( GtkTreeIter
*iter
, GtkTreeIter
*child
);
74 wxDataViewModel
* GetDataViewModel() { return m_wx_model
; }
75 wxDataViewCtrl
* GetOwner() { return m_owner
; }
76 GtkWxTreeModel
* GetGtkModel() { return m_gtk_model
; }
78 bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
79 bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
80 bool ItemChanged( const wxDataViewItem
&item
);
81 bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
85 void SetSortOrder( GtkSortType sort_order
) { m_sort_order
= sort_order
; }
86 GtkSortType
GetSortOrder() { return m_sort_order
; }
88 void SetSortColumn( int column
) { m_sort_column
= column
; }
89 int GetSortColumn() { return m_sort_column
; }
91 void SetDataViewSortColumn( wxDataViewColumn
*column
) { m_dataview_sort_column
= column
; }
92 wxDataViewColumn
*GetDataViewSortColumn() { return m_dataview_sort_column
; }
94 bool IsSorted() { return (m_sort_column
>= 0); }
99 wxGtkTreeModelNode
*FindNode( const wxDataViewItem
&item
);
100 wxGtkTreeModelNode
*FindNode( GtkTreeIter
*iter
);
101 wxGtkTreeModelNode
*FindParentNode( const wxDataViewItem
&item
);
102 wxGtkTreeModelNode
*FindParentNode( GtkTreeIter
*iter
);
103 void BuildBranch( wxGtkTreeModelNode
*branch
);
106 wxGtkTreeModelNode
*m_root
;
107 wxDataViewModel
*m_wx_model
;
108 GtkWxTreeModel
*m_gtk_model
;
109 wxDataViewCtrl
*m_owner
;
110 GtkSortType m_sort_order
;
111 wxDataViewColumn
*m_dataview_sort_column
;
116 //-----------------------------------------------------------------------------
117 // wxGtkTreeModelNode
118 //-----------------------------------------------------------------------------
120 int LINKAGEMODE
wxGtkTreeModelChildCmp( void** id1
, void** id2
)
122 int ret
= g_internal
->GetDataViewModel()->Compare( *id1
, *id2
,
123 g_internal
->GetSortColumn(), (g_internal
->GetSortOrder() == GTK_SORT_ASCENDING
) );
128 WX_DEFINE_ARRAY_PTR( wxGtkTreeModelNode
*, wxGtkTreeModelNodes
);
129 WX_DEFINE_ARRAY_PTR( void*, wxGtkTreeModelChildren
);
131 class wxGtkTreeModelNode
134 wxGtkTreeModelNode( wxGtkTreeModelNode
* parent
, const wxDataViewItem
&item
,
135 wxDataViewCtrlInternal
*internal
)
139 m_internal
= internal
;
142 ~wxGtkTreeModelNode()
144 size_t count
= m_children
.GetCount();
146 for (i
= 0; i
< count
; i
++)
148 wxGtkTreeModelNode
*child
= m_nodes
.Item( i
);
153 unsigned int AddNode( wxGtkTreeModelNode
* child
)
155 m_nodes
.Add( child
);
157 void *id
= child
->GetItem().GetID();
159 m_children
.Add( id
);
161 if (m_internal
->IsSorted() || m_internal
->GetDataViewModel()->HasDefaultCompare())
163 g_internal
= m_internal
;
164 m_children
.Sort( &wxGtkTreeModelChildCmp
);
165 return m_children
.Index( id
);
168 return m_children
.GetCount()-1;
171 unsigned int AddLeave( void* id
)
173 m_children
.Add( id
);
175 if (m_internal
->IsSorted() || m_internal
->GetDataViewModel()->HasDefaultCompare())
177 g_internal
= m_internal
;
178 m_children
.Sort( &wxGtkTreeModelChildCmp
);
179 return m_children
.Index( id
);
182 return m_children
.GetCount()-1;
185 void DeleteChild( void* id
)
187 m_children
.Remove( id
);
189 unsigned int count
= m_nodes
.GetCount();
191 for (pos
= 0; pos
< count
; pos
++)
193 wxGtkTreeModelNode
*node
= m_nodes
.Item( pos
);
194 if (node
->GetItem().GetID() == id
)
196 m_nodes
.RemoveAt( pos
);
204 wxGtkTreeModelNode
* GetParent()
206 wxGtkTreeModelNodes
&GetNodes()
208 wxGtkTreeModelChildren
&GetChildren()
209 { return m_children
; }
211 unsigned int GetChildCount() { return m_children
.GetCount(); }
212 unsigned int GetNodesCount() { return m_nodes
.GetCount(); }
214 wxDataViewItem
&GetItem() { return m_item
; }
215 wxDataViewCtrlInternal
*GetInternal() { return m_internal
; }
220 wxGtkTreeModelNode
*m_parent
;
221 wxGtkTreeModelNodes m_nodes
;
222 wxGtkTreeModelChildren m_children
;
223 wxDataViewItem m_item
;
224 wxDataViewCtrlInternal
*m_internal
;
228 //-----------------------------------------------------------------------------
230 //-----------------------------------------------------------------------------
232 extern bool g_blockEventsOnDrag
;
234 //-----------------------------------------------------------------------------
235 // define new GTK+ class wxGtkTreeModel
236 //-----------------------------------------------------------------------------
240 #define GTK_TYPE_WX_TREE_MODEL (gtk_wx_tree_model_get_type ())
241 #define GTK_WX_TREE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_WX_TREE_MODEL, GtkWxTreeModel))
242 #define GTK_WX_TREE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WX_TREE_MODEL, GtkWxTreeModelClass))
243 #define GTK_IS_WX_TREE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_WX_TREE_MODEL))
244 #define GTK_IS_WX_TREE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WX_TREE_MODEL))
245 #define GTK_WX_TREE_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WX_TREE_MODEL, GtkWxTreeModelClass))
247 GType
gtk_wx_tree_model_get_type (void);
249 typedef struct _GtkWxTreeModelClass GtkWxTreeModelClass
;
251 struct _GtkWxTreeModel
257 wxDataViewCtrlInternal
*internal
;
260 struct _GtkWxTreeModelClass
262 GObjectClass list_parent_class
;
265 static GtkWxTreeModel
*wxgtk_tree_model_new (void);
266 static void wxgtk_tree_model_init (GtkWxTreeModel
*tree_model
);
267 static void wxgtk_tree_model_class_init (GtkWxTreeModelClass
*klass
);
268 static void wxgtk_tree_model_tree_model_init (GtkTreeModelIface
*iface
);
269 static void wxgtk_tree_model_sortable_init (GtkTreeSortableIface
*iface
);
270 static void wxgtk_tree_model_finalize (GObject
*object
);
271 static GtkTreeModelFlags
wxgtk_tree_model_get_flags (GtkTreeModel
*tree_model
);
272 static gint
wxgtk_tree_model_get_n_columns (GtkTreeModel
*tree_model
);
273 static GType
wxgtk_tree_model_get_column_type (GtkTreeModel
*tree_model
,
275 static gboolean
wxgtk_tree_model_get_iter (GtkTreeModel
*tree_model
,
278 static GtkTreePath
*wxgtk_tree_model_get_path (GtkTreeModel
*tree_model
,
280 static void wxgtk_tree_model_get_value (GtkTreeModel
*tree_model
,
284 static gboolean
wxgtk_tree_model_iter_next (GtkTreeModel
*tree_model
,
286 static gboolean
wxgtk_tree_model_iter_children (GtkTreeModel
*tree_model
,
288 GtkTreeIter
*parent
);
289 static gboolean
wxgtk_tree_model_iter_has_child (GtkTreeModel
*tree_model
,
291 static gint
wxgtk_tree_model_iter_n_children (GtkTreeModel
*tree_model
,
293 static gboolean
wxgtk_tree_model_iter_nth_child (GtkTreeModel
*tree_model
,
297 static gboolean
wxgtk_tree_model_iter_parent (GtkTreeModel
*tree_model
,
302 static gboolean
wxgtk_tree_model_get_sort_column_id (GtkTreeSortable
*sortable
,
303 gint
*sort_column_id
,
305 static void wxgtk_tree_model_set_sort_column_id (GtkTreeSortable
*sortable
,
308 static void wxgtk_tree_model_set_sort_func (GtkTreeSortable
*sortable
,
310 GtkTreeIterCompareFunc func
,
312 GtkDestroyNotify destroy
);
313 static void wxgtk_tree_model_set_default_sort_func (GtkTreeSortable
*sortable
,
314 GtkTreeIterCompareFunc func
,
316 GtkDestroyNotify destroy
);
317 static gboolean
wxgtk_tree_model_has_default_sort_func (GtkTreeSortable
*sortable
);
321 static GObjectClass
*list_parent_class
= NULL
;
324 gtk_wx_tree_model_get_type (void)
326 static GType tree_model_type
= 0;
328 if (!tree_model_type
)
330 const GTypeInfo tree_model_info
=
332 sizeof (GtkWxTreeModelClass
),
333 NULL
, /* base_init */
334 NULL
, /* base_finalize */
335 (GClassInitFunc
) wxgtk_tree_model_class_init
,
336 NULL
, /* class_finalize */
337 NULL
, /* class_data */
338 sizeof (GtkWxTreeModel
),
340 (GInstanceInitFunc
) wxgtk_tree_model_init
,
343 static const GInterfaceInfo tree_model_iface_info
=
345 (GInterfaceInitFunc
) wxgtk_tree_model_tree_model_init
,
350 static const GInterfaceInfo sortable_iface_info
=
352 (GInterfaceInitFunc
) wxgtk_tree_model_sortable_init
,
357 tree_model_type
= g_type_register_static (G_TYPE_OBJECT
, "GtkWxTreeModel",
358 &tree_model_info
, (GTypeFlags
)0 );
360 g_type_add_interface_static (tree_model_type
,
362 &tree_model_iface_info
);
363 g_type_add_interface_static (tree_model_type
,
364 GTK_TYPE_TREE_SORTABLE
,
365 &sortable_iface_info
);
368 return tree_model_type
;
371 static GtkWxTreeModel
*
372 wxgtk_tree_model_new(void)
374 GtkWxTreeModel
*retval
= (GtkWxTreeModel
*) g_object_new (GTK_TYPE_WX_TREE_MODEL
, NULL
);
379 wxgtk_tree_model_class_init (GtkWxTreeModelClass
*klass
)
381 list_parent_class
= (GObjectClass
*) g_type_class_peek_parent (klass
);
382 GObjectClass
*object_class
= (GObjectClass
*) klass
;
383 object_class
->finalize
= wxgtk_tree_model_finalize
;
387 wxgtk_tree_model_tree_model_init (GtkTreeModelIface
*iface
)
389 iface
->get_flags
= wxgtk_tree_model_get_flags
;
390 iface
->get_n_columns
= wxgtk_tree_model_get_n_columns
;
391 iface
->get_column_type
= wxgtk_tree_model_get_column_type
;
392 iface
->get_iter
= wxgtk_tree_model_get_iter
;
393 iface
->get_path
= wxgtk_tree_model_get_path
;
394 iface
->get_value
= wxgtk_tree_model_get_value
;
395 iface
->iter_next
= wxgtk_tree_model_iter_next
;
396 iface
->iter_children
= wxgtk_tree_model_iter_children
;
397 iface
->iter_has_child
= wxgtk_tree_model_iter_has_child
;
398 iface
->iter_n_children
= wxgtk_tree_model_iter_n_children
;
399 iface
->iter_nth_child
= wxgtk_tree_model_iter_nth_child
;
400 iface
->iter_parent
= wxgtk_tree_model_iter_parent
;
404 wxgtk_tree_model_sortable_init (GtkTreeSortableIface
*iface
)
406 iface
->get_sort_column_id
= wxgtk_tree_model_get_sort_column_id
;
407 iface
->set_sort_column_id
= wxgtk_tree_model_set_sort_column_id
;
408 iface
->set_sort_func
= wxgtk_tree_model_set_sort_func
;
409 iface
->set_default_sort_func
= wxgtk_tree_model_set_default_sort_func
;
410 iface
->has_default_sort_func
= wxgtk_tree_model_has_default_sort_func
;
414 wxgtk_tree_model_init (GtkWxTreeModel
*tree_model
)
416 tree_model
->internal
= NULL
;
417 tree_model
->stamp
= g_random_int();
421 wxgtk_tree_model_finalize (GObject
*object
)
424 (* list_parent_class
->finalize
) (object
);
429 //-----------------------------------------------------------------------------
430 // implement callbacks from wxGtkTreeModel class by letting
431 // them call the methods of wxWidgets' wxDataViewModel
432 //-----------------------------------------------------------------------------
434 static GtkTreeModelFlags
435 wxgtk_tree_model_get_flags (GtkTreeModel
*tree_model
)
437 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
438 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), (GtkTreeModelFlags
)0 );
440 return wxtree_model
->internal
->get_flags();
444 wxgtk_tree_model_get_n_columns (GtkTreeModel
*tree_model
)
446 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
447 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), 0);
449 return wxtree_model
->internal
->GetDataViewModel()->GetColumnCount();
453 wxgtk_tree_model_get_column_type (GtkTreeModel
*tree_model
,
456 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
457 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), G_TYPE_INVALID
);
459 GType gtype
= G_TYPE_INVALID
;
461 wxString wxtype
= wxtree_model
->internal
->GetDataViewModel()->GetColumnType( (unsigned int) index
);
463 if (wxtype
== wxT("string"))
464 gtype
= G_TYPE_STRING
;
467 gtype
= G_TYPE_STRING
;
468 // wxFAIL_MSG( _T("non-string columns not supported yet") );
475 wxgtk_tree_model_get_iter (GtkTreeModel
*tree_model
,
479 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
480 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), FALSE
);
481 g_return_val_if_fail (gtk_tree_path_get_depth (path
) > 0, FALSE
);
483 return wxtree_model
->internal
->get_iter( iter
, path
);
487 wxgtk_tree_model_get_path (GtkTreeModel
*tree_model
,
490 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
491 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), NULL
);
492 g_return_val_if_fail (iter
->stamp
== GTK_WX_TREE_MODEL (wxtree_model
)->stamp
, NULL
);
494 return wxtree_model
->internal
->get_path( iter
);
498 wxgtk_tree_model_get_value (GtkTreeModel
*tree_model
,
503 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
504 g_return_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
) );
506 wxDataViewModel
*model
= wxtree_model
->internal
->GetDataViewModel();
507 wxString mtype
= model
->GetColumnType( (unsigned int) column
);
508 if (mtype
== wxT("string"))
511 g_value_init( value
, G_TYPE_STRING
);
512 wxDataViewItem
item( (void*) iter
->user_data
);
513 model
->GetValue( variant
, item
, (unsigned int) column
);
515 g_value_set_string( value
, variant
.GetString().utf8_str() );
519 wxFAIL_MSG( _T("non-string columns not supported yet") );
524 wxgtk_tree_model_iter_next (GtkTreeModel
*tree_model
,
527 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
528 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), FALSE
);
529 g_return_val_if_fail (wxtree_model
->stamp
== iter
->stamp
, FALSE
);
531 return wxtree_model
->internal
->iter_next( iter
);
535 wxgtk_tree_model_iter_children (GtkTreeModel
*tree_model
,
539 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
540 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), FALSE
);
541 g_return_val_if_fail (wxtree_model
->stamp
== parent
->stamp
, FALSE
);
543 return wxtree_model
->internal
->iter_children( iter
, parent
);
547 wxgtk_tree_model_iter_has_child (GtkTreeModel
*tree_model
,
550 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
551 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), FALSE
);
552 g_return_val_if_fail (wxtree_model
->stamp
== iter
->stamp
, FALSE
);
554 return wxtree_model
->internal
->iter_has_child( iter
);
558 wxgtk_tree_model_iter_n_children (GtkTreeModel
*tree_model
,
561 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
562 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), FALSE
);
563 g_return_val_if_fail (wxtree_model
->stamp
== iter
->stamp
, 0);
565 return wxtree_model
->internal
->iter_n_children( iter
);
569 wxgtk_tree_model_iter_nth_child (GtkTreeModel
*tree_model
,
574 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
575 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), FALSE
);
577 return wxtree_model
->internal
->iter_nth_child( iter
, parent
, n
);
581 wxgtk_tree_model_iter_parent (GtkTreeModel
*tree_model
,
585 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
586 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), FALSE
);
587 g_return_val_if_fail (wxtree_model
->stamp
== child
->stamp
, FALSE
);
589 return wxtree_model
->internal
->iter_parent( iter
, child
);
593 gboolean
wxgtk_tree_model_get_sort_column_id (GtkTreeSortable
*sortable
,
594 gint
*sort_column_id
,
597 GtkWxTreeModel
*tree_model
= (GtkWxTreeModel
*) sortable
;
599 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (sortable
), FALSE
);
601 if (!tree_model
->internal
->IsSorted())
604 *sort_column_id
= -1;
611 *sort_column_id
= tree_model
->internal
->GetSortColumn();
614 *order
= tree_model
->internal
->GetSortOrder();
619 wxDataViewColumn
*gs_lastLeftClickHeader
= NULL
;
621 void wxgtk_tree_model_set_sort_column_id (GtkTreeSortable
*sortable
,
625 GtkWxTreeModel
*tree_model
= (GtkWxTreeModel
*) sortable
;
626 g_return_if_fail (GTK_IS_WX_TREE_MODEL (sortable
) );
628 tree_model
->internal
->SetDataViewSortColumn( gs_lastLeftClickHeader
);
630 if ((sort_column_id
!= (gint
) tree_model
->internal
->GetSortColumn()) ||
631 (order
!= tree_model
->internal
->GetSortOrder()))
633 tree_model
->internal
->SetSortColumn( sort_column_id
);
634 tree_model
->internal
->SetSortOrder( order
);
636 gtk_tree_sortable_sort_column_changed (sortable
);
638 tree_model
->internal
->GetDataViewModel()->Resort();
641 if (gs_lastLeftClickHeader
)
643 wxDataViewCtrl
*dv
= tree_model
->internal
->GetOwner();
644 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
, dv
->GetId() );
645 event
.SetDataViewColumn( gs_lastLeftClickHeader
);
646 event
.SetModel( dv
->GetModel() );
647 dv
->HandleWindowEvent( event
);
650 gs_lastLeftClickHeader
= NULL
;
653 void wxgtk_tree_model_set_sort_func (GtkTreeSortable
*sortable
,
654 gint
WXUNUSED(sort_column_id
),
655 GtkTreeIterCompareFunc func
,
656 gpointer
WXUNUSED(data
),
657 GtkDestroyNotify
WXUNUSED(destroy
) )
659 g_return_if_fail (GTK_IS_WX_TREE_MODEL (sortable
) );
660 g_return_if_fail (func
!= NULL
);
663 void wxgtk_tree_model_set_default_sort_func (GtkTreeSortable
*sortable
,
664 GtkTreeIterCompareFunc func
,
665 gpointer
WXUNUSED(data
),
666 GtkDestroyNotify
WXUNUSED(destroy
) )
668 g_return_if_fail (GTK_IS_WX_TREE_MODEL (sortable
) );
669 g_return_if_fail (func
!= NULL
);
671 wxPrintf( "wxgtk_tree_model_set_default_sort_func\n" );
674 gboolean
wxgtk_tree_model_has_default_sort_func (GtkTreeSortable
*sortable
)
676 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (sortable
), FALSE
);
681 //-----------------------------------------------------------------------------
682 // define new GTK+ class wxGtkRendererRenderer
683 //-----------------------------------------------------------------------------
687 #define GTK_TYPE_WX_CELL_RENDERER (gtk_wx_cell_renderer_get_type ())
688 #define GTK_WX_CELL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_WX_CELL_RENDERER, GtkWxCellRenderer))
689 #define GTK_WX_CELL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WX_CELL_RENDERER, GtkWxCellRendererClass))
690 #define GTK_IS_WX_CELL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_WX_CELL_RENDERER))
691 #define GTK_IS_WX_CELL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WX_CELL_RENDERER))
692 #define GTK_WX_CELL_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WX_CELL_RENDERER, GtkWxCellRendererClass))
694 GType
gtk_wx_cell_renderer_get_type (void);
696 typedef struct _GtkWxCellRenderer GtkWxCellRenderer
;
697 typedef struct _GtkWxCellRendererClass GtkWxCellRendererClass
;
699 struct _GtkWxCellRenderer
701 GtkCellRenderer parent
;
704 wxDataViewCustomRenderer
*cell
;
708 struct _GtkWxCellRendererClass
710 GtkCellRendererClass cell_parent_class
;
714 static GtkCellRenderer
*gtk_wx_cell_renderer_new (void);
715 static void gtk_wx_cell_renderer_init (
716 GtkWxCellRenderer
*cell
);
717 static void gtk_wx_cell_renderer_class_init(
718 GtkWxCellRendererClass
*klass
);
719 static void gtk_wx_cell_renderer_finalize (
721 static void gtk_wx_cell_renderer_get_size (
722 GtkCellRenderer
*cell
,
724 GdkRectangle
*rectangle
,
729 static void gtk_wx_cell_renderer_render (
730 GtkCellRenderer
*cell
,
733 GdkRectangle
*background_area
,
734 GdkRectangle
*cell_area
,
735 GdkRectangle
*expose_area
,
736 GtkCellRendererState flags
);
737 static gboolean
gtk_wx_cell_renderer_activate(
738 GtkCellRenderer
*cell
,
742 GdkRectangle
*background_area
,
743 GdkRectangle
*cell_area
,
744 GtkCellRendererState flags
);
745 static GtkCellEditable
*gtk_wx_cell_renderer_start_editing(
746 GtkCellRenderer
*cell
,
750 GdkRectangle
*background_area
,
751 GdkRectangle
*cell_area
,
752 GtkCellRendererState flags
);
755 static GObjectClass
*cell_parent_class
= NULL
;
760 gtk_wx_cell_renderer_get_type (void)
762 static GType cell_wx_type
= 0;
766 const GTypeInfo cell_wx_info
=
768 sizeof (GtkWxCellRendererClass
),
769 NULL
, /* base_init */
770 NULL
, /* base_finalize */
771 (GClassInitFunc
) gtk_wx_cell_renderer_class_init
,
772 NULL
, /* class_finalize */
773 NULL
, /* class_data */
774 sizeof (GtkWxCellRenderer
),
776 (GInstanceInitFunc
) gtk_wx_cell_renderer_init
,
779 cell_wx_type
= g_type_register_static( GTK_TYPE_CELL_RENDERER
,
780 "GtkWxCellRenderer", &cell_wx_info
, (GTypeFlags
)0 );
787 gtk_wx_cell_renderer_init (GtkWxCellRenderer
*cell
)
790 cell
->last_click
= 0;
794 gtk_wx_cell_renderer_class_init (GtkWxCellRendererClass
*klass
)
796 GObjectClass
*object_class
= G_OBJECT_CLASS (klass
);
797 GtkCellRendererClass
*cell_class
= GTK_CELL_RENDERER_CLASS (klass
);
799 cell_parent_class
= (GObjectClass
*) g_type_class_peek_parent (klass
);
801 object_class
->finalize
= gtk_wx_cell_renderer_finalize
;
803 cell_class
->get_size
= gtk_wx_cell_renderer_get_size
;
804 cell_class
->render
= gtk_wx_cell_renderer_render
;
805 cell_class
->activate
= gtk_wx_cell_renderer_activate
;
806 cell_class
->start_editing
= gtk_wx_cell_renderer_start_editing
;
810 gtk_wx_cell_renderer_finalize (GObject
*object
)
813 (* G_OBJECT_CLASS (cell_parent_class
)->finalize
) (object
);
817 gtk_wx_cell_renderer_new (void)
819 return (GtkCellRenderer
*) g_object_new (GTK_TYPE_WX_CELL_RENDERER
, NULL
);
824 static GtkCellEditable
*gtk_wx_cell_renderer_start_editing(
825 GtkCellRenderer
*renderer
,
826 GdkEvent
*WXUNUSED(event
),
829 GdkRectangle
*WXUNUSED(background_area
),
830 GdkRectangle
*cell_area
,
831 GtkCellRendererState
WXUNUSED(flags
) )
833 GtkWxCellRenderer
*wxrenderer
= (GtkWxCellRenderer
*) renderer
;
834 wxDataViewCustomRenderer
*cell
= wxrenderer
->cell
;
835 if (!cell
->HasEditorCtrl())
839 gtk_wx_cell_renderer_get_size (renderer
, widget
, cell_area
,
845 rect
.x
+= cell_area
->x
;
846 rect
.y
+= cell_area
->y
;
847 // rect.width -= renderer->xpad * 2;
848 // rect.height -= renderer->ypad * 2;
850 // wxRect renderrect( rect.x, rect.y, rect.width, rect.height );
851 wxRect
renderrect( cell_area
->x
, cell_area
->y
, cell_area
->width
, cell_area
->height
);
853 GtkTreePath
*treepath
= gtk_tree_path_new_from_string( path
);
855 cell
->GetOwner()->GetOwner()->GtkGetInternal()->get_iter( &iter
, treepath
);
856 wxDataViewItem
item( (void*) iter
.user_data
);
857 gtk_tree_path_free( treepath
);
859 cell
->StartEditing( item
, renderrect
);
865 gtk_wx_cell_renderer_get_size (GtkCellRenderer
*renderer
,
866 GtkWidget
*WXUNUSED(widget
),
867 GdkRectangle
*cell_area
,
873 GtkWxCellRenderer
*wxrenderer
= (GtkWxCellRenderer
*) renderer
;
874 wxDataViewCustomRenderer
*cell
= wxrenderer
->cell
;
876 wxSize size
= cell
->GetSize();
878 gint calc_width
= (gint
) renderer
->xpad
* 2 + size
.x
;
879 gint calc_height
= (gint
) renderer
->ypad
* 2 + size
.y
;
886 if (cell_area
&& size
.x
> 0 && size
.y
> 0)
890 *x_offset
= (gint
)((renderer
->xalign
*
891 (cell_area
->width
- calc_width
- 2 * renderer
->xpad
)));
892 *x_offset
= MAX (*x_offset
, 0) + renderer
->xpad
;
896 *y_offset
= (gint
)((renderer
->yalign
*
897 (cell_area
->height
- calc_height
- 2 * renderer
->ypad
)));
898 *y_offset
= MAX (*y_offset
, 0) + renderer
->ypad
;
906 *height
= calc_height
;
910 gtk_wx_cell_renderer_render (GtkCellRenderer
*renderer
,
913 GdkRectangle
*background_area
,
914 GdkRectangle
*cell_area
,
915 GdkRectangle
*expose_area
,
916 GtkCellRendererState flags
)
919 GtkWxCellRenderer
*wxrenderer
= (GtkWxCellRenderer
*) renderer
;
920 wxDataViewCustomRenderer
*cell
= wxrenderer
->cell
;
922 cell
->window
= window
;
923 cell
->widget
= widget
;
924 cell
->background_area
= (void*) background_area
;
925 cell
->cell_area
= (void*) cell_area
;
926 cell
->expose_area
= (void*) expose_area
;
927 cell
->flags
= (int) flags
;
930 gtk_wx_cell_renderer_get_size (renderer
, widget
, cell_area
,
936 rect
.x
+= cell_area
->x
;
937 rect
.y
+= cell_area
->y
;
938 rect
.width
-= renderer
->xpad
* 2;
939 rect
.height
-= renderer
->ypad
* 2;
942 if (gdk_rectangle_intersect (expose_area
, &rect
, &dummy
))
944 wxRect
renderrect( rect
.x
, rect
.y
, rect
.width
, rect
.height
);
945 wxWindowDC
* dc
= (wxWindowDC
*) cell
->GetDC();
946 wxWindowDCImpl
*impl
= (wxWindowDCImpl
*) dc
->GetImpl();
947 if (impl
->m_gdkwindow
== NULL
)
949 impl
->m_gdkwindow
= window
;
954 if (flags
& GTK_CELL_RENDERER_SELECTED
)
955 state
|= wxDATAVIEW_CELL_SELECTED
;
956 if (flags
& GTK_CELL_RENDERER_PRELIT
)
957 state
|= wxDATAVIEW_CELL_PRELIT
;
958 if (flags
& GTK_CELL_RENDERER_INSENSITIVE
)
959 state
|= wxDATAVIEW_CELL_INSENSITIVE
;
960 if (flags
& GTK_CELL_RENDERER_INSENSITIVE
)
961 state
|= wxDATAVIEW_CELL_INSENSITIVE
;
962 if (flags
& GTK_CELL_RENDERER_FOCUSED
)
963 state
|= wxDATAVIEW_CELL_FOCUSED
;
964 cell
->Render( renderrect
, dc
, state
);
969 gtk_wx_cell_renderer_activate(
970 GtkCellRenderer
*renderer
,
974 GdkRectangle
*WXUNUSED(background_area
),
975 GdkRectangle
*cell_area
,
976 GtkCellRendererState
WXUNUSED(flags
) )
978 GtkWxCellRenderer
*wxrenderer
= (GtkWxCellRenderer
*) renderer
;
979 wxDataViewCustomRenderer
*cell
= wxrenderer
->cell
;
982 gtk_wx_cell_renderer_get_size (renderer
, widget
, cell_area
,
988 rect
.x
+= cell_area
->x
;
989 rect
.y
+= cell_area
->y
;
990 rect
.width
-= renderer
->xpad
* 2;
991 rect
.height
-= renderer
->ypad
* 2;
993 wxRect
renderrect( rect
.x
, rect
.y
, rect
.width
, rect
.height
);
995 wxDataViewModel
*model
= cell
->GetOwner()->GetOwner()->GetModel();
997 GtkTreePath
*treepath
= gtk_tree_path_new_from_string( path
);
1000 cell
->GetOwner()->GetOwner()->GtkGetInternal()->get_iter( &iter
, treepath
);
1001 wxDataViewItem
item( iter
.user_data
);
1002 gtk_tree_path_free( treepath
);
1004 unsigned int model_col
= cell
->GetOwner()->GetModelColumn();
1010 // activated by <ENTER>
1011 if (cell
->Activate( renderrect
, model
, item
, model_col
))
1016 else if (event
->type
== GDK_BUTTON_PRESS
)
1018 GdkEventButton
*button_event
= (GdkEventButton
*) event
;
1019 wxPoint
pt( ((int) button_event
->x
) - renderrect
.x
,
1020 ((int) button_event
->y
) - renderrect
.y
);
1023 if (button_event
->button
== 1)
1025 if (cell
->LeftClick( pt
, renderrect
, model
, item
, model_col
))
1027 // TODO: query system double-click time
1028 if (button_event
->time
- wxrenderer
->last_click
< 400)
1029 if (cell
->Activate( renderrect
, model
, item
, model_col
))
1032 if (button_event
->button
== 3)
1034 if (cell
->RightClick( pt
, renderrect
, model
, item
, model_col
))
1038 wxrenderer
->last_click
= button_event
->time
;
1046 // ---------------------------------------------------------
1047 // wxGtkDataViewModelNotifier
1048 // ---------------------------------------------------------
1050 class wxGtkDataViewModelNotifier
: public wxDataViewModelNotifier
1053 wxGtkDataViewModelNotifier( GtkWxTreeModel
*wxgtk_model
,
1054 wxDataViewModel
*wx_model
,
1055 wxDataViewCtrl
*ctrl
);
1056 ~wxGtkDataViewModelNotifier();
1058 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
1059 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
1060 virtual bool ItemChanged( const wxDataViewItem
&item
);
1061 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
1062 virtual bool Cleared();
1063 virtual void Resort();
1065 GtkWxTreeModel
*m_wxgtk_model
;
1066 wxDataViewModel
*m_wx_model
;
1067 wxDataViewCtrl
*m_owner
;
1070 // ---------------------------------------------------------
1071 // wxGtkDataViewListModelNotifier
1072 // ---------------------------------------------------------
1074 wxGtkDataViewModelNotifier::wxGtkDataViewModelNotifier(
1075 GtkWxTreeModel
* wxgtk_model
, wxDataViewModel
*wx_model
,
1076 wxDataViewCtrl
*ctrl
)
1078 m_wxgtk_model
= wxgtk_model
;
1079 m_wx_model
= wx_model
;
1083 wxGtkDataViewModelNotifier::~wxGtkDataViewModelNotifier()
1086 m_wxgtk_model
= NULL
;
1089 bool wxGtkDataViewModelNotifier::ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
)
1091 m_owner
->GtkGetInternal()->ItemAdded( parent
, item
);
1094 iter
.stamp
= m_wxgtk_model
->stamp
;
1095 iter
.user_data
= (gpointer
) item
.GetID();
1097 GtkTreePath
*path
= wxgtk_tree_model_get_path(
1098 GTK_TREE_MODEL(m_wxgtk_model
), &iter
);
1099 gtk_tree_model_row_inserted(
1100 GTK_TREE_MODEL(m_wxgtk_model
), path
, &iter
);
1101 gtk_tree_path_free (path
);
1106 bool wxGtkDataViewModelNotifier::ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
)
1109 iter
.stamp
= m_wxgtk_model
->stamp
;
1110 iter
.user_data
= (gpointer
) item
.GetID();
1112 GtkTreePath
*path
= wxgtk_tree_model_get_path(
1113 GTK_TREE_MODEL(m_wxgtk_model
), &iter
);
1114 gtk_tree_model_row_deleted(
1115 GTK_TREE_MODEL(m_wxgtk_model
), path
);
1116 gtk_tree_path_free (path
);
1118 m_owner
->GtkGetInternal()->ItemDeleted( parent
, item
);
1123 void wxGtkDataViewModelNotifier::Resort()
1125 m_owner
->GtkGetInternal()->Resort();
1128 bool wxGtkDataViewModelNotifier::ItemChanged( const wxDataViewItem
&item
)
1131 iter
.stamp
= m_wxgtk_model
->stamp
;
1132 iter
.user_data
= (gpointer
) item
.GetID();
1134 GtkTreePath
*path
= wxgtk_tree_model_get_path(
1135 GTK_TREE_MODEL(m_wxgtk_model
), &iter
);
1136 gtk_tree_model_row_changed(
1137 GTK_TREE_MODEL(m_wxgtk_model
), path
, &iter
);
1138 gtk_tree_path_free (path
);
1140 m_owner
->GtkGetInternal()->ItemChanged( item
);
1145 bool wxGtkDataViewModelNotifier::ValueChanged( const wxDataViewItem
&item
, unsigned int model_col
)
1147 // This adds GTK+'s missing MVC logic for ValueChanged
1149 for (index
= 0; index
< m_owner
->GetColumnCount(); index
++)
1151 wxDataViewColumn
*column
= m_owner
->GetColumn( index
);
1152 if (column
->GetModelColumn() == model_col
)
1154 GtkTreeView
*widget
= GTK_TREE_VIEW(m_owner
->m_treeview
);
1155 GtkTreeViewColumn
*gcolumn
= GTK_TREE_VIEW_COLUMN(column
->GetGtkHandle());
1159 iter
.stamp
= m_wxgtk_model
->stamp
;
1160 iter
.user_data
= (gpointer
) item
.GetID();
1161 GtkTreePath
*path
= wxgtk_tree_model_get_path(
1162 GTK_TREE_MODEL(m_wxgtk_model
), &iter
);
1163 GdkRectangle cell_area
;
1164 gtk_tree_view_get_cell_area( widget
, path
, gcolumn
, &cell_area
);
1165 gtk_tree_path_free( path
);
1167 GtkAdjustment
* hadjust
= gtk_tree_view_get_hadjustment( widget
);
1168 double d
= gtk_adjustment_get_value( hadjust
);
1169 int xdiff
= (int) d
;
1171 int ydiff
= gcolumn
->button
->allocation
.height
;
1173 gtk_widget_queue_draw_area( GTK_WIDGET(widget
),
1174 cell_area
.x
- xdiff
, ydiff
+ cell_area
.y
, cell_area
.width
, cell_area
.height
);
1176 m_owner
->GtkGetInternal()->ValueChanged( item
, model_col
);
1185 bool wxGtkDataViewModelNotifier::Cleared()
1187 // TODO: delete everything
1189 m_owner
->GtkGetInternal()->Cleared();
1194 // ---------------------------------------------------------
1195 // wxDataViewRenderer
1196 // ---------------------------------------------------------
1198 static gpointer s_user_data
= NULL
;
1201 wxgtk_cell_editable_editing_done( GtkCellEditable
*WXUNUSED(editable
),
1202 wxDataViewRenderer
*wxrenderer
)
1204 wxDataViewColumn
*column
= wxrenderer
->GetOwner();
1205 wxDataViewCtrl
*dv
= column
->GetOwner();
1206 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
, dv
->GetId() );
1207 event
.SetDataViewColumn( column
);
1208 event
.SetModel( dv
->GetModel() );
1209 wxDataViewItem
item( s_user_data
);
1210 event
.SetItem( item
);
1211 dv
->HandleWindowEvent( event
);
1215 wxgtk_renderer_editing_started( GtkCellRenderer
*WXUNUSED(cell
), GtkCellEditable
*editable
,
1216 gchar
*path
, wxDataViewRenderer
*wxrenderer
)
1218 wxDataViewColumn
*column
= wxrenderer
->GetOwner();
1219 wxDataViewCtrl
*dv
= column
->GetOwner();
1220 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
, dv
->GetId() );
1221 event
.SetDataViewColumn( column
);
1222 event
.SetModel( dv
->GetModel() );
1223 GtkTreePath
*tree_path
= gtk_tree_path_new_from_string( path
);
1225 dv
->GtkGetInternal()->get_iter( &iter
, tree_path
);
1226 gtk_tree_path_free( tree_path
);
1227 wxDataViewItem
item( iter
.user_data
);
1228 event
.SetItem( item
);
1229 dv
->HandleWindowEvent( event
);
1231 if (GTK_IS_CELL_EDITABLE(editable
))
1233 s_user_data
= iter
.user_data
;
1235 g_signal_connect (GTK_CELL_EDITABLE (editable
), "editing_done",
1236 G_CALLBACK (wxgtk_cell_editable_editing_done
),
1237 (gpointer
) wxrenderer
);
1243 IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer
, wxDataViewRendererBase
)
1245 wxDataViewRenderer::wxDataViewRenderer( const wxString
&varianttype
, wxDataViewCellMode mode
,
1247 wxDataViewRendererBase( varianttype
, mode
, align
)
1251 // NOTE: SetMode() and SetAlignment() needs to be called in the renderer's ctor,
1252 // after the m_renderer pointer has been initialized
1255 void wxDataViewRenderer::GtkInitHandlers()
1257 if (!gtk_check_version(2,6,0))
1259 g_signal_connect (GTK_CELL_RENDERER(m_renderer
), "editing_started",
1260 G_CALLBACK (wxgtk_renderer_editing_started
),
1265 void wxDataViewRenderer::SetMode( wxDataViewCellMode mode
)
1267 GtkCellRendererMode gtkMode
;
1270 case wxDATAVIEW_CELL_INERT
:
1271 gtkMode
= GTK_CELL_RENDERER_MODE_INERT
;
1273 case wxDATAVIEW_CELL_ACTIVATABLE
:
1274 gtkMode
= GTK_CELL_RENDERER_MODE_ACTIVATABLE
;
1276 case wxDATAVIEW_CELL_EDITABLE
:
1277 gtkMode
= GTK_CELL_RENDERER_MODE_EDITABLE
;
1281 // This value is most often ignored in GtkTreeView
1282 GValue gvalue
= { 0, };
1283 g_value_init( &gvalue
, gtk_cell_renderer_mode_get_type() );
1284 g_value_set_enum( &gvalue
, gtkMode
);
1285 g_object_set_property( G_OBJECT(m_renderer
), "mode", &gvalue
);
1286 g_value_unset( &gvalue
);
1289 wxDataViewCellMode
wxDataViewRenderer::GetMode() const
1291 wxDataViewCellMode ret
;
1294 g_object_get( G_OBJECT(m_renderer
), "mode", &gvalue
, NULL
);
1296 switch (g_value_get_enum(&gvalue
))
1298 case GTK_CELL_RENDERER_MODE_INERT
:
1299 ret
= wxDATAVIEW_CELL_INERT
;
1301 case GTK_CELL_RENDERER_MODE_ACTIVATABLE
:
1302 ret
= wxDATAVIEW_CELL_ACTIVATABLE
;
1304 case GTK_CELL_RENDERER_MODE_EDITABLE
:
1305 ret
= wxDATAVIEW_CELL_EDITABLE
;
1309 g_value_unset( &gvalue
);
1314 void wxDataViewRenderer::SetAlignment( int align
)
1316 // horizontal alignment:
1318 gfloat xalign
= 0.0;
1319 if (align
& wxALIGN_RIGHT
)
1321 else if (align
& wxALIGN_CENTER_HORIZONTAL
)
1324 GValue gvalue
= { 0, };
1325 g_value_init( &gvalue
, G_TYPE_FLOAT
);
1326 g_value_set_float( &gvalue
, xalign
);
1327 g_object_set_property( G_OBJECT(m_renderer
), "xalign", &gvalue
);
1328 g_value_unset( &gvalue
);
1330 // vertical alignment:
1332 gfloat yalign
= 0.0;
1333 if (align
& wxALIGN_BOTTOM
)
1335 else if (align
& wxALIGN_CENTER_VERTICAL
)
1338 GValue gvalue2
= { 0, };
1339 g_value_init( &gvalue2
, G_TYPE_FLOAT
);
1340 g_value_set_float( &gvalue2
, yalign
);
1341 g_object_set_property( G_OBJECT(m_renderer
), "yalign", &gvalue2
);
1342 g_value_unset( &gvalue2
);
1345 int wxDataViewRenderer::GetAlignment() const
1350 // horizontal alignment:
1352 g_object_get( G_OBJECT(m_renderer
), "xalign", &gvalue
, NULL
);
1353 float xalign
= g_value_get_float( &gvalue
);
1355 ret
|= wxALIGN_LEFT
;
1356 else if (xalign
== 0.5)
1357 ret
|= wxALIGN_CENTER_HORIZONTAL
;
1359 ret
|= wxALIGN_RIGHT
;
1360 g_value_unset( &gvalue
);
1363 // vertical alignment:
1365 g_object_get( G_OBJECT(m_renderer
), "yalign", &gvalue
, NULL
);
1366 float yalign
= g_value_get_float( &gvalue
);
1369 else if (yalign
== 0.5)
1370 ret
|= wxALIGN_CENTER_VERTICAL
;
1372 ret
|= wxALIGN_BOTTOM
;
1373 g_value_unset( &gvalue
);
1380 // ---------------------------------------------------------
1381 // wxDataViewTextRenderer
1382 // ---------------------------------------------------------
1385 static void wxGtkTextRendererEditedCallback( GtkCellRendererText
*renderer
,
1386 gchar
*arg1
, gchar
*arg2
, gpointer user_data
);
1389 static void wxGtkTextRendererEditedCallback( GtkCellRendererText
*WXUNUSED(renderer
),
1390 gchar
*arg1
, gchar
*arg2
, gpointer user_data
)
1392 wxDataViewTextRenderer
*cell
= (wxDataViewTextRenderer
*) user_data
;
1394 wxString tmp
= wxGTK_CONV_BACK_FONT(arg2
, cell
->GetOwner()->GetOwner()->GetFont());
1395 wxVariant value
= tmp
;
1396 if (!cell
->Validate( value
))
1399 wxDataViewModel
*model
= cell
->GetOwner()->GetOwner()->GetModel();
1401 GtkTreePath
*path
= gtk_tree_path_new_from_string( arg1
);
1403 cell
->GetOwner()->GetOwner()->GtkGetInternal()->get_iter( &iter
, path
);
1404 wxDataViewItem
item( (void*) iter
.user_data
);;
1405 gtk_tree_path_free( path
);
1407 unsigned int model_col
= cell
->GetOwner()->GetModelColumn();
1409 model
->SetValue( value
, item
, model_col
);
1410 model
->ValueChanged( item
, model_col
);
1413 IMPLEMENT_CLASS(wxDataViewTextRenderer
, wxDataViewRenderer
)
1415 wxDataViewTextRenderer::wxDataViewTextRenderer( const wxString
&varianttype
, wxDataViewCellMode mode
,
1417 wxDataViewRenderer( varianttype
, mode
, align
)
1419 m_renderer
= (GtkCellRenderer
*) gtk_cell_renderer_text_new();
1421 if (mode
& wxDATAVIEW_CELL_EDITABLE
)
1423 GValue gvalue
= { 0, };
1424 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
1425 g_value_set_boolean( &gvalue
, true );
1426 g_object_set_property( G_OBJECT(m_renderer
), "editable", &gvalue
);
1427 g_value_unset( &gvalue
);
1429 g_signal_connect_after( m_renderer
, "edited", G_CALLBACK(wxGtkTextRendererEditedCallback
), this );
1435 SetAlignment(align
);
1438 bool wxDataViewTextRenderer::SetValue( const wxVariant
&value
)
1440 wxString tmp
= value
;
1442 GValue gvalue
= { 0, };
1443 g_value_init( &gvalue
, G_TYPE_STRING
);
1444 g_value_set_string( &gvalue
, wxGTK_CONV( tmp
) );
1445 g_object_set_property( G_OBJECT(m_renderer
), "text", &gvalue
);
1446 g_value_unset( &gvalue
);
1451 bool wxDataViewTextRenderer::GetValue( wxVariant
&value
) const
1453 GValue gvalue
= { 0, };
1454 g_value_init( &gvalue
, G_TYPE_STRING
);
1455 g_object_get_property( G_OBJECT(m_renderer
), "text", &gvalue
);
1456 wxString tmp
= wxGTK_CONV_BACK( g_value_get_string( &gvalue
) );
1457 g_value_unset( &gvalue
);
1464 void wxDataViewTextRenderer::SetAlignment( int align
)
1466 wxDataViewRenderer::SetAlignment(align
);
1468 if (gtk_check_version(2,10,0))
1471 // horizontal alignment:
1472 PangoAlignment pangoAlign
= PANGO_ALIGN_LEFT
;
1473 if (align
& wxALIGN_RIGHT
)
1474 pangoAlign
= PANGO_ALIGN_RIGHT
;
1475 else if (align
& wxALIGN_CENTER_HORIZONTAL
)
1476 pangoAlign
= PANGO_ALIGN_CENTER
;
1478 GValue gvalue
= { 0, };
1479 g_value_init( &gvalue
, gtk_cell_renderer_mode_get_type() );
1480 g_value_set_enum( &gvalue
, pangoAlign
);
1481 g_object_set_property( G_OBJECT(m_renderer
), "alignment", &gvalue
);
1482 g_value_unset( &gvalue
);
1485 // ---------------------------------------------------------
1486 // wxDataViewTextRendererAttr
1487 // ---------------------------------------------------------
1489 IMPLEMENT_CLASS(wxDataViewTextRendererAttr
,wxDataViewTextRenderer
)
1491 wxDataViewTextRendererAttr::wxDataViewTextRendererAttr( const wxString
&varianttype
,
1492 wxDataViewCellMode mode
, int align
) :
1493 wxDataViewTextRenderer( varianttype
, mode
, align
)
1497 // ---------------------------------------------------------
1498 // wxDataViewBitmapRenderer
1499 // ---------------------------------------------------------
1501 IMPLEMENT_CLASS(wxDataViewBitmapRenderer
, wxDataViewRenderer
)
1503 wxDataViewBitmapRenderer::wxDataViewBitmapRenderer( const wxString
&varianttype
, wxDataViewCellMode mode
,
1505 wxDataViewRenderer( varianttype
, mode
, align
)
1507 m_renderer
= (GtkCellRenderer
*) gtk_cell_renderer_pixbuf_new();
1510 SetAlignment(align
);
1513 bool wxDataViewBitmapRenderer::SetValue( const wxVariant
&value
)
1515 if (value
.GetType() == wxT("wxBitmap"))
1520 // This may create a Pixbuf representation in the
1521 // wxBitmap object (and it will stay there)
1522 GdkPixbuf
*pixbuf
= bitmap
.GetPixbuf();
1524 GValue gvalue
= { 0, };
1525 g_value_init( &gvalue
, G_TYPE_OBJECT
);
1526 g_value_set_object( &gvalue
, pixbuf
);
1527 g_object_set_property( G_OBJECT(m_renderer
), "pixbuf", &gvalue
);
1528 g_value_unset( &gvalue
);
1533 if (value
.GetType() == wxT("wxIcon"))
1538 // This may create a Pixbuf representation in the
1539 // wxBitmap object (and it will stay there)
1540 GdkPixbuf
*pixbuf
= bitmap
.GetPixbuf();
1542 GValue gvalue
= { 0, };
1543 g_value_init( &gvalue
, G_TYPE_OBJECT
);
1544 g_value_set_object( &gvalue
, pixbuf
);
1545 g_object_set_property( G_OBJECT(m_renderer
), "pixbuf", &gvalue
);
1546 g_value_unset( &gvalue
);
1554 bool wxDataViewBitmapRenderer::GetValue( wxVariant
&WXUNUSED(value
) ) const
1559 // ---------------------------------------------------------
1560 // wxDataViewToggleRenderer
1561 // ---------------------------------------------------------
1564 static void wxGtkToggleRendererToggledCallback( GtkCellRendererToggle
*renderer
,
1565 gchar
*path
, gpointer user_data
);
1568 static void wxGtkToggleRendererToggledCallback( GtkCellRendererToggle
*renderer
,
1569 gchar
*path
, gpointer user_data
)
1571 wxDataViewToggleRenderer
*cell
= (wxDataViewToggleRenderer
*) user_data
;
1574 GValue gvalue
= { 0, };
1575 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
1576 g_object_get_property( G_OBJECT(renderer
), "active", &gvalue
);
1577 bool tmp
= g_value_get_boolean( &gvalue
);
1578 g_value_unset( &gvalue
);
1582 wxVariant value
= tmp
;
1583 if (!cell
->Validate( value
))
1586 wxDataViewModel
*model
= cell
->GetOwner()->GetOwner()->GetModel();
1588 GtkTreePath
*gtk_path
= gtk_tree_path_new_from_string( path
);
1590 cell
->GetOwner()->GetOwner()->GtkGetInternal()->get_iter( &iter
, gtk_path
);
1591 wxDataViewItem
item( (void*) iter
.user_data
);;
1592 gtk_tree_path_free( gtk_path
);
1594 unsigned int model_col
= cell
->GetOwner()->GetModelColumn();
1596 model
->SetValue( value
, item
, model_col
);
1597 model
->ValueChanged( item
, model_col
);
1600 IMPLEMENT_CLASS(wxDataViewToggleRenderer
, wxDataViewRenderer
)
1602 wxDataViewToggleRenderer::wxDataViewToggleRenderer( const wxString
&varianttype
,
1603 wxDataViewCellMode mode
, int align
) :
1604 wxDataViewRenderer( varianttype
, mode
, align
)
1606 m_renderer
= (GtkCellRenderer
*) gtk_cell_renderer_toggle_new();
1608 if (mode
& wxDATAVIEW_CELL_ACTIVATABLE
)
1610 g_signal_connect_after( m_renderer
, "toggled",
1611 G_CALLBACK(wxGtkToggleRendererToggledCallback
), this );
1615 GValue gvalue
= { 0, };
1616 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
1617 g_value_set_boolean( &gvalue
, false );
1618 g_object_set_property( G_OBJECT(m_renderer
), "activatable", &gvalue
);
1619 g_value_unset( &gvalue
);
1623 SetAlignment(align
);
1626 bool wxDataViewToggleRenderer::SetValue( const wxVariant
&value
)
1630 GValue gvalue
= { 0, };
1631 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
1632 g_value_set_boolean( &gvalue
, tmp
);
1633 g_object_set_property( G_OBJECT(m_renderer
), "active", &gvalue
);
1634 g_value_unset( &gvalue
);
1639 bool wxDataViewToggleRenderer::GetValue( wxVariant
&value
) const
1641 GValue gvalue
= { 0, };
1642 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
1643 g_object_get_property( G_OBJECT(m_renderer
), "active", &gvalue
);
1644 bool tmp
= g_value_get_boolean( &gvalue
);
1645 g_value_unset( &gvalue
);
1652 // ---------------------------------------------------------
1653 // wxDataViewCustomRenderer
1654 // ---------------------------------------------------------
1656 class wxDataViewCtrlDCImpl
: public wxWindowDCImpl
1659 wxDataViewCtrlDCImpl( wxDC
*owner
, wxDataViewCtrl
*window
) :
1660 wxWindowDCImpl( owner
)
1662 GtkWidget
*widget
= window
->m_treeview
;
1668 m_context
= window
->GtkGetPangoDefaultContext();
1669 m_layout
= pango_layout_new( m_context
);
1670 m_fontdesc
= pango_font_description_copy( widget
->style
->font_desc
);
1672 m_cmap
= gtk_widget_get_colormap( widget
? widget
: window
->m_widget
);
1674 // Set m_gdkwindow later
1679 class wxDataViewCtrlDC
: public wxWindowDC
1682 wxDataViewCtrlDC( wxDataViewCtrl
*window
) :
1683 wxWindowDC( new wxDataViewCtrlDCImpl( this, window
) )
1688 // ---------------------------------------------------------
1689 // wxDataViewCustomRenderer
1690 // ---------------------------------------------------------
1692 IMPLEMENT_CLASS(wxDataViewCustomRenderer
, wxDataViewRenderer
)
1694 wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString
&varianttype
,
1695 wxDataViewCellMode mode
, int align
,
1697 wxDataViewRenderer( varianttype
, mode
, align
)
1700 m_text_renderer
= NULL
;
1708 void wxDataViewCustomRenderer::RenderText( const wxString
&text
, int xoffset
, wxRect cell
, wxDC
*dc
, int state
)
1711 wxDataViewCtrl
*view
= GetOwner()->GetOwner();
1712 wxColour col
= (state
& wxDATAVIEW_CELL_SELECTED
) ?
1713 wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT
) :
1714 view
->GetForegroundColour();
1715 dc
->SetTextForeground(col
);
1716 dc
->DrawText( text
, cell
.x
+ xoffset
, cell
.y
+ ((cell
.height
- dc
->GetCharHeight()) / 2));
1718 if (!m_text_renderer
)
1719 m_text_renderer
= gtk_cell_renderer_text_new();
1721 GValue gvalue
= { 0, };
1722 g_value_init( &gvalue
, G_TYPE_STRING
);
1723 g_value_set_string( &gvalue
, wxGTK_CONV( text
) );
1724 g_object_set_property( G_OBJECT(m_text_renderer
), "text", &gvalue
);
1725 g_value_unset( &gvalue
);
1727 ((GdkRectangle
*) cell_area
)->x
+= xoffset
;
1728 ((GdkRectangle
*) cell_area
)->width
-= xoffset
;
1730 gtk_cell_renderer_render( m_text_renderer
,
1733 (GdkRectangle
*) background_area
,
1734 (GdkRectangle
*) cell_area
,
1735 (GdkRectangle
*) expose_area
,
1736 (GtkCellRendererState
) flags
);
1738 ((GdkRectangle
*) cell_area
)->x
-= xoffset
;
1739 ((GdkRectangle
*) cell_area
)->width
+= xoffset
;
1743 bool wxDataViewCustomRenderer::Init(wxDataViewCellMode mode
, int align
)
1745 GtkWxCellRenderer
*renderer
= (GtkWxCellRenderer
*) gtk_wx_cell_renderer_new();
1746 renderer
->cell
= this;
1748 m_renderer
= (GtkCellRenderer
*) renderer
;
1751 SetAlignment(align
);
1758 wxDataViewCustomRenderer::~wxDataViewCustomRenderer()
1763 if (m_text_renderer
)
1764 gtk_object_sink( GTK_OBJECT(m_text_renderer
) );
1767 wxDC
*wxDataViewCustomRenderer::GetDC()
1771 if (GetOwner() == NULL
)
1773 if (GetOwner()->GetOwner() == NULL
)
1775 m_dc
= new wxDataViewCtrlDC( GetOwner()->GetOwner() );
1781 // ---------------------------------------------------------
1782 // wxDataViewProgressRenderer
1783 // ---------------------------------------------------------
1785 IMPLEMENT_CLASS(wxDataViewProgressRenderer
, wxDataViewCustomRenderer
)
1787 wxDataViewProgressRenderer::wxDataViewProgressRenderer( const wxString
&label
,
1788 const wxString
&varianttype
, wxDataViewCellMode mode
, int align
) :
1789 wxDataViewCustomRenderer( varianttype
, mode
, align
, true )
1795 if (!gtk_check_version(2,6,0))
1797 m_renderer
= (GtkCellRenderer
*) gtk_cell_renderer_progress_new();
1799 GValue gvalue
= { 0, };
1800 g_value_init( &gvalue
, G_TYPE_STRING
);
1802 g_value_set_string( &gvalue
, wxGTK_CONV(m_label
) );
1803 g_object_set_property( G_OBJECT(m_renderer
), "text", &gvalue
);
1804 g_value_unset( &gvalue
);
1807 SetAlignment(align
);
1812 // Use custom cell code
1813 wxDataViewCustomRenderer::Init(mode
, align
);
1817 wxDataViewProgressRenderer::~wxDataViewProgressRenderer()
1821 bool wxDataViewProgressRenderer::SetValue( const wxVariant
&value
)
1824 if (!gtk_check_version(2,6,0))
1826 gint tmp
= (long) value
;
1827 GValue gvalue
= { 0, };
1828 g_value_init( &gvalue
, G_TYPE_INT
);
1829 g_value_set_int( &gvalue
, tmp
);
1830 g_object_set_property( G_OBJECT(m_renderer
), "value", &gvalue
);
1831 g_value_unset( &gvalue
);
1836 m_value
= (long) value
;
1838 if (m_value
< 0) m_value
= 0;
1839 if (m_value
> 100) m_value
= 100;
1845 bool wxDataViewProgressRenderer::GetValue( wxVariant
&value
) const
1850 bool wxDataViewProgressRenderer::Render( wxRect cell
, wxDC
*dc
, int state
)
1852 double pct
= (double)m_value
/ 100.0;
1854 bar
.width
= (int)(cell
.width
* pct
);
1855 dc
->SetPen( *wxTRANSPARENT_PEN
);
1856 dc
->SetBrush( *wxBLUE_BRUSH
);
1857 dc
->DrawRectangle( bar
);
1859 dc
->SetBrush( *wxTRANSPARENT_BRUSH
);
1860 dc
->SetPen( *wxBLACK_PEN
);
1861 dc
->DrawRectangle( cell
);
1866 wxSize
wxDataViewProgressRenderer::GetSize() const
1868 return wxSize(40,12);
1871 // ---------------------------------------------------------
1872 // wxDataViewDateRenderer
1873 // ---------------------------------------------------------
1875 class wxDataViewDateRendererPopupTransient
: public wxPopupTransientWindow
1878 wxDataViewDateRendererPopupTransient( wxWindow
* parent
, wxDateTime
*value
,
1879 wxDataViewModel
*model
, const wxDataViewItem
&item
, unsigned int col
) :
1880 wxPopupTransientWindow( parent
, wxBORDER_SIMPLE
)
1885 m_cal
= new wxCalendarCtrl( this, -1, *value
);
1886 wxBoxSizer
*sizer
= new wxBoxSizer( wxHORIZONTAL
);
1887 sizer
->Add( m_cal
, 1, wxGROW
);
1892 virtual void OnDismiss()
1896 void OnCalendar( wxCalendarEvent
&event
);
1898 wxCalendarCtrl
*m_cal
;
1899 wxDataViewModel
*m_model
;
1900 wxDataViewItem m_item
;
1904 DECLARE_EVENT_TABLE()
1907 BEGIN_EVENT_TABLE(wxDataViewDateRendererPopupTransient
,wxPopupTransientWindow
)
1908 EVT_CALENDAR( -1, wxDataViewDateRendererPopupTransient::OnCalendar
)
1911 void wxDataViewDateRendererPopupTransient::OnCalendar( wxCalendarEvent
&event
)
1913 wxDateTime date
= event
.GetDate();
1914 wxVariant value
= date
;
1915 m_model
->SetValue( value
, m_item
, m_col
);
1916 m_model
->ValueChanged( m_item
, m_col
);
1920 IMPLEMENT_CLASS(wxDataViewDateRenderer
, wxDataViewCustomRenderer
)
1922 wxDataViewDateRenderer::wxDataViewDateRenderer( const wxString
&varianttype
,
1923 wxDataViewCellMode mode
, int align
) :
1924 wxDataViewCustomRenderer( varianttype
, mode
, align
)
1927 SetAlignment(align
);
1930 bool wxDataViewDateRenderer::SetValue( const wxVariant
&value
)
1932 m_date
= value
.GetDateTime();
1937 bool wxDataViewDateRenderer::GetValue( wxVariant
&value
) const
1942 bool wxDataViewDateRenderer::Render( wxRect cell
, wxDC
*dc
, int state
)
1944 dc
->SetFont( GetOwner()->GetOwner()->GetFont() );
1945 wxString tmp
= m_date
.FormatDate();
1946 RenderText( tmp
, 0, cell
, dc
, state
);
1950 wxSize
wxDataViewDateRenderer::GetSize() const
1952 wxString tmp
= m_date
.FormatDate();
1954 GetView()->GetTextExtent( tmp
, &x
, &y
, &d
);
1955 return wxSize(x
,y
+d
);
1958 bool wxDataViewDateRenderer::Activate( wxRect cell
, wxDataViewModel
*model
,
1959 const wxDataViewItem
&item
, unsigned int col
)
1962 model
->GetValue( variant
, item
, col
);
1963 wxDateTime value
= variant
.GetDateTime();
1965 wxDataViewDateRendererPopupTransient
*popup
= new wxDataViewDateRendererPopupTransient(
1966 GetOwner()->GetOwner()->GetParent(), &value
, model
, item
, col
);
1967 wxPoint pos
= wxGetMousePosition();
1970 popup
->Popup( popup
->m_cal
);
1976 // ---------------------------------------------------------
1977 // wxDataViewIconTextRenderer
1978 // ---------------------------------------------------------
1980 IMPLEMENT_CLASS(wxDataViewIconTextRenderer
, wxDataViewCustomRenderer
)
1982 wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(
1983 const wxString
&varianttype
, wxDataViewCellMode mode
, int align
) :
1984 wxDataViewCustomRenderer( varianttype
, mode
, align
)
1987 SetAlignment(align
);
1990 wxDataViewIconTextRenderer::~wxDataViewIconTextRenderer()
1994 bool wxDataViewIconTextRenderer::SetValue( const wxVariant
&value
)
2000 bool wxDataViewIconTextRenderer::GetValue( wxVariant
&value
) const
2005 bool wxDataViewIconTextRenderer::Render( wxRect cell
, wxDC
*dc
, int state
)
2007 const wxIcon
&icon
= m_value
.GetIcon();
2011 int yoffset
= wxMax( 0, (cell
.height
- icon
.GetHeight()) / 2 );
2012 dc
->DrawIcon( icon
, cell
.x
, cell
.y
+ yoffset
);
2013 offset
= icon
.GetWidth() + 4;
2016 RenderText( m_value
.GetText(), offset
, cell
, dc
, state
);
2021 wxSize
wxDataViewIconTextRenderer::GetSize() const
2024 if (m_value
.GetIcon().IsOk())
2025 size
.x
= 4 + m_value
.GetIcon().GetWidth();
2027 GetView()->GetTextExtent( m_value
.GetText(), &x
, &y
, &d
);
2033 wxControl
* wxDataViewIconTextRenderer::CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
)
2038 bool wxDataViewIconTextRenderer::GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
)
2043 // ---------------------------------------------------------
2045 // ---------------------------------------------------------
2049 gtk_dataview_header_button_press_callback( GtkWidget
*widget
,
2050 GdkEventButton
*gdk_event
,
2051 wxDataViewColumn
*column
)
2053 if (gdk_event
->type
!= GDK_BUTTON_PRESS
)
2056 if (gdk_event
->button
== 1)
2058 gs_lastLeftClickHeader
= column
;
2060 wxDataViewCtrl
*dv
= column
->GetOwner();
2061 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
, dv
->GetId() );
2062 event
.SetDataViewColumn( column
);
2063 event
.SetModel( dv
->GetModel() );
2064 if (dv
->HandleWindowEvent( event
))
2068 if (gdk_event
->button
== 3)
2070 wxDataViewCtrl
*dv
= column
->GetOwner();
2071 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
, dv
->GetId() );
2072 event
.SetDataViewColumn( column
);
2073 event
.SetModel( dv
->GetModel() );
2074 if (dv
->HandleWindowEvent( event
))
2082 static void wxGtkTreeCellDataFunc( GtkTreeViewColumn
*column
,
2083 GtkCellRenderer
*cell
,
2084 GtkTreeModel
*model
,
2090 static void wxGtkTreeCellDataFunc( GtkTreeViewColumn
*column
,
2091 GtkCellRenderer
*renderer
,
2092 GtkTreeModel
*model
,
2096 g_return_if_fail (GTK_IS_WX_TREE_MODEL (model
));
2097 GtkWxTreeModel
*tree_model
= (GtkWxTreeModel
*) model
;
2099 wxDataViewRenderer
*cell
= (wxDataViewRenderer
*) data
;
2101 wxDataViewItem
item( (void*) iter
->user_data
);
2103 wxDataViewModel
*wx_model
= tree_model
->internal
->GetDataViewModel();
2105 if (!wx_model
->IsIndexListModel())
2108 if (wx_model
->IsContainer( item
))
2110 if (wx_model
->HasContainerColumns( item
) || (cell
->GetOwner()->GetModelColumn() == 0))
2112 GValue gvalue
= { 0, };
2113 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
2114 g_value_set_boolean( &gvalue
, TRUE
);
2115 g_object_set_property( G_OBJECT(renderer
), "visible", &gvalue
);
2116 g_value_unset( &gvalue
);
2120 GValue gvalue
= { 0, };
2121 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
2122 g_value_set_boolean( &gvalue
, FALSE
);
2123 g_object_set_property( G_OBJECT(renderer
), "visible", &gvalue
);
2124 g_value_unset( &gvalue
);
2131 GValue gvalue
= { 0, };
2132 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
2133 g_value_set_boolean( &gvalue
, TRUE
);
2134 g_object_set_property( G_OBJECT(renderer
), "visible", &gvalue
);
2135 g_value_unset( &gvalue
);
2141 wx_model
->GetValue( value
, item
, cell
->GetOwner()->GetModelColumn() );
2143 if (value
.GetType() != cell
->GetVariantType())
2144 wxLogError( wxT("Wrong type, required: %s but: %s"),
2145 value
.GetType().c_str(),
2146 cell
->GetVariantType().c_str() );
2148 cell
->SetValue( value
);
2150 if (cell
->GtkHasAttributes())
2152 wxDataViewItemAttr attr
;
2153 bool colour_set
= false;
2154 bool style_set
= false;
2155 bool weight_set
= false;
2157 if (wx_model
->GetAttr( item
, cell
->GetOwner()->GetModelColumn(), attr
))
2159 // this must be a GtkCellRendererText
2160 wxColour colour
= attr
.GetColour();
2163 const GdkColor
* const gcol
= colour
.GetColor();
2165 GValue gvalue
= { 0, };
2166 g_value_init( &gvalue
, GDK_TYPE_COLOR
);
2167 g_value_set_boxed( &gvalue
, gcol
);
2168 g_object_set_property( G_OBJECT(renderer
), "foreground_gdk", &gvalue
);
2169 g_value_unset( &gvalue
);
2174 if (attr
.GetItalic())
2176 GValue gvalue
= { 0, };
2177 g_value_init( &gvalue
, PANGO_TYPE_STYLE
);
2178 g_value_set_enum( &gvalue
, PANGO_STYLE_ITALIC
);
2179 g_object_set_property( G_OBJECT(renderer
), "style", &gvalue
);
2180 g_value_unset( &gvalue
);
2187 GValue gvalue
= { 0, };
2188 g_value_init( &gvalue
, PANGO_TYPE_WEIGHT
);
2189 g_value_set_enum( &gvalue
, PANGO_WEIGHT_BOLD
);
2190 g_object_set_property( G_OBJECT(renderer
), "weight", &gvalue
);
2191 g_value_unset( &gvalue
);
2199 GValue gvalue
= { 0, };
2200 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
2201 g_value_set_boolean( &gvalue
, FALSE
);
2202 g_object_set_property( G_OBJECT(renderer
), "style-set", &gvalue
);
2203 g_value_unset( &gvalue
);
2208 GValue gvalue
= { 0, };
2209 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
2210 g_value_set_boolean( &gvalue
, FALSE
);
2211 g_object_set_property( G_OBJECT(renderer
), "weight-set", &gvalue
);
2212 g_value_unset( &gvalue
);
2217 GValue gvalue
= { 0, };
2218 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
2219 g_value_set_boolean( &gvalue
, FALSE
);
2220 g_object_set_property( G_OBJECT(renderer
), "foreground-set", &gvalue
);
2221 g_value_unset( &gvalue
);
2226 if (attr
.HasBackgroundColour())
2228 wxColour colour
= attr
.GetBackgroundColour();
2229 const GdkColor
* const gcol
= colour
.GetColor();
2231 GValue gvalue
= { 0, };
2232 g_value_init( &gvalue
, GDK_TYPE_COLOR
);
2233 g_value_set_boxed( &gvalue
, gcol
);
2234 g_object_set_property( G_OBJECT(renderer
), "cell-background_gdk", &gvalue
);
2235 g_value_unset( &gvalue
);
2239 GValue gvalue
= { 0, };
2240 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
2241 g_value_set_boolean( &gvalue
, FALSE
);
2242 g_object_set_property( G_OBJECT(renderer
), "cell-background-set", &gvalue
);
2243 g_value_unset( &gvalue
);
2249 IMPLEMENT_CLASS(wxDataViewColumn
, wxDataViewColumnBase
)
2251 #include <wx/listimpl.cpp>
2252 WX_DEFINE_LIST(wxDataViewColumnList
)
2254 wxDataViewColumn::wxDataViewColumn( const wxString
&title
, wxDataViewRenderer
*cell
,
2255 unsigned int model_column
, int width
,
2256 wxAlignment align
, int flags
) :
2257 wxDataViewColumnBase( title
, cell
, model_column
, width
, align
, flags
)
2259 Init( align
, flags
, width
);
2261 gtk_tree_view_column_set_clickable( GTK_TREE_VIEW_COLUMN(m_column
), TRUE
);
2265 wxDataViewColumn::wxDataViewColumn( const wxBitmap
&bitmap
, wxDataViewRenderer
*cell
,
2266 unsigned int model_column
, int width
,
2267 wxAlignment align
, int flags
) :
2268 wxDataViewColumnBase( bitmap
, cell
, model_column
, width
, align
, flags
)
2270 Init( align
, flags
, width
);
2272 SetBitmap( bitmap
);
2275 void wxDataViewColumn::Init(wxAlignment align
, int flags
, int width
)
2277 m_isConnected
= false;
2279 GtkCellRenderer
*renderer
= (GtkCellRenderer
*) GetRenderer()->GetGtkHandle();
2280 GtkTreeViewColumn
*column
= gtk_tree_view_column_new();
2281 m_column
= (GtkWidget
*) column
;
2284 SetAlignment( align
);
2286 // NOTE: we prefer not to call SetMinWidth(wxDVC_DEFAULT_MINWIDTH);
2287 // as GTK+ is smart and unless explicitely told, will set the minimal
2288 // width to the title's lenght, which is a better default
2290 // the GTK_TREE_VIEW_COLUMN_FIXED is required by the "fixed height" mode
2291 // that we use for the wxDataViewCtrl
2292 gtk_tree_view_column_set_fixed_width( column
, width
< 0 ? wxDVC_DEFAULT_WIDTH
: width
);
2293 gtk_tree_view_column_set_sizing( column
, GTK_TREE_VIEW_COLUMN_FIXED
);
2295 gtk_tree_view_column_pack_end( column
, renderer
, TRUE
);
2297 gtk_tree_view_column_set_cell_data_func( column
, renderer
,
2298 wxGtkTreeCellDataFunc
, (gpointer
) GetRenderer(), NULL
);
2301 wxDataViewColumn::~wxDataViewColumn()
2305 void wxDataViewColumn::OnInternalIdle()
2310 if (GTK_WIDGET_REALIZED(GetOwner()->m_treeview
))
2312 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2315 g_signal_connect(column
->button
, "button_press_event",
2316 G_CALLBACK (gtk_dataview_header_button_press_callback
), this);
2318 m_isConnected
= true;
2323 void wxDataViewColumn::SetOwner( wxDataViewCtrl
*owner
)
2325 wxDataViewColumnBase::SetOwner( owner
);
2327 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2329 gtk_tree_view_column_set_title( column
, wxGTK_CONV_FONT(GetTitle(), GetOwner()->GetFont() ) );
2332 void wxDataViewColumn::SetTitle( const wxString
&title
)
2334 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2338 // disconnect before column->button gets recreated
2339 g_signal_handlers_disconnect_by_func( column
->button
,
2340 (GtkWidget
*) gtk_dataview_header_button_press_callback
, this);
2342 m_isConnected
= false;
2345 // FIXME: can it really happen that we don't have the owner here??
2346 wxDataViewCtrl
*ctrl
= GetOwner();
2347 gtk_tree_view_column_set_title( column
, ctrl
? wxGTK_CONV_FONT(title
, ctrl
->GetFont())
2348 : wxGTK_CONV_SYS(title
) );
2350 gtk_tree_view_column_set_widget( column
, NULL
);
2353 wxString
wxDataViewColumn::GetTitle() const
2355 const gchar
*str
= gtk_tree_view_column_get_title( GTK_TREE_VIEW_COLUMN(m_column
) );
2356 return wxConvFileName
->cMB2WX(str
);
2359 void wxDataViewColumn::SetBitmap( const wxBitmap
&bitmap
)
2361 wxDataViewColumnBase::SetBitmap( bitmap
);
2363 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2366 GtkImage
*gtk_image
= GTK_IMAGE( gtk_image_new() );
2368 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
2369 if (bitmap
.GetMask())
2370 mask
= bitmap
.GetMask()->GetBitmap();
2372 if (bitmap
.HasPixbuf())
2374 gtk_image_set_from_pixbuf(GTK_IMAGE(gtk_image
),
2375 bitmap
.GetPixbuf());
2379 gtk_image_set_from_pixmap(GTK_IMAGE(gtk_image
),
2380 bitmap
.GetPixmap(), mask
);
2382 gtk_widget_show( GTK_WIDGET(gtk_image
) );
2384 gtk_tree_view_column_set_widget( column
, GTK_WIDGET(gtk_image
) );
2388 gtk_tree_view_column_set_widget( column
, NULL
);
2392 void wxDataViewColumn::SetHidden( bool hidden
)
2394 gtk_tree_view_column_set_visible( GTK_TREE_VIEW_COLUMN(m_column
), !hidden
);
2397 void wxDataViewColumn::SetResizeable( bool resizeable
)
2399 gtk_tree_view_column_set_resizable( GTK_TREE_VIEW_COLUMN(m_column
), resizeable
);
2402 void wxDataViewColumn::SetAlignment( wxAlignment align
)
2404 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2406 gfloat xalign
= 0.0;
2407 if (align
== wxALIGN_RIGHT
)
2409 if (align
== wxALIGN_CENTER_HORIZONTAL
||
2410 align
== wxALIGN_CENTER
)
2413 gtk_tree_view_column_set_alignment( column
, xalign
);
2416 wxAlignment
wxDataViewColumn::GetAlignment() const
2418 gfloat xalign
= gtk_tree_view_column_get_alignment( GTK_TREE_VIEW_COLUMN(m_column
) );
2421 return wxALIGN_RIGHT
;
2423 return wxALIGN_CENTER_HORIZONTAL
;
2425 return wxALIGN_LEFT
;
2428 void wxDataViewColumn::SetSortable( bool sortable
)
2430 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2434 gtk_tree_view_column_set_sort_column_id( column
, GetModelColumn() );
2438 gtk_tree_view_column_set_sort_column_id( column
, -1 );
2439 gtk_tree_view_column_set_sort_indicator( column
, FALSE
);
2443 bool wxDataViewColumn::IsSortable() const
2445 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2446 return (gtk_tree_view_column_get_sort_column_id( column
) != -1);
2449 bool wxDataViewColumn::IsResizeable() const
2451 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2452 return gtk_tree_view_column_get_resizable( column
);
2455 bool wxDataViewColumn::IsHidden() const
2457 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2458 return !gtk_tree_view_column_get_visible( column
);
2461 void wxDataViewColumn::SetSortOrder( bool ascending
)
2463 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2466 gtk_tree_view_column_set_sort_order( column
, GTK_SORT_ASCENDING
);
2468 gtk_tree_view_column_set_sort_order( column
, GTK_SORT_DESCENDING
);
2470 gtk_tree_view_column_set_sort_indicator( column
, TRUE
);
2473 bool wxDataViewColumn::IsSortOrderAscending() const
2475 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2477 return (gtk_tree_view_column_get_sort_order( column
) != GTK_SORT_DESCENDING
);
2480 void wxDataViewColumn::SetMinWidth( int width
)
2482 gtk_tree_view_column_set_min_width( GTK_TREE_VIEW_COLUMN(m_column
), width
);
2485 int wxDataViewColumn::GetMinWidth() const
2487 return gtk_tree_view_column_get_min_width( GTK_TREE_VIEW_COLUMN(m_column
) );
2490 int wxDataViewColumn::GetWidth() const
2492 return gtk_tree_view_column_get_width( GTK_TREE_VIEW_COLUMN(m_column
) );
2495 void wxDataViewColumn::SetWidth( int width
)
2497 gtk_tree_view_column_set_fixed_width( GTK_TREE_VIEW_COLUMN(m_column
), width
);
2501 //-----------------------------------------------------------------------------
2502 // wxGtkTreeModelNode
2503 //-----------------------------------------------------------------------------
2505 void wxGtkTreeModelNode::Resort()
2507 size_t child_count
= GetChildCount();
2508 if (child_count
== 0)
2511 size_t node_count
= GetNodesCount();
2513 if (child_count
== 1)
2515 if (node_count
== 1)
2517 wxGtkTreeModelNode
*node
= m_nodes
.Item( 0 );
2523 wxGtkTreeModelChildren temp
;
2524 WX_APPEND_ARRAY( temp
, m_children
);
2526 g_internal
= m_internal
;
2527 m_children
.Sort( &wxGtkTreeModelChildCmp
);
2529 gint
*new_order
= new gint
[child_count
];
2532 for (pos
= 0; pos
< child_count
; pos
++)
2534 void *id
= m_children
.Item( pos
);
2535 int old_pos
= temp
.Index( id
);
2536 new_order
[pos
] = old_pos
;
2539 GtkTreeModel
*gtk_tree_model
= GTK_TREE_MODEL( m_internal
->GetGtkModel() );
2542 iter
.user_data
= GetItem().GetID();
2543 iter
.stamp
= m_internal
->GetGtkModel()->stamp
;
2545 GtkTreePath
*path
= m_internal
->get_path( &iter
);
2547 gtk_tree_model_rows_reordered( gtk_tree_model
, path
, &iter
, new_order
);
2549 gtk_tree_path_free (path
);
2551 delete [] new_order
;
2553 for (pos
= 0; pos
< node_count
; pos
++)
2555 wxGtkTreeModelNode
*node
= m_nodes
.Item( pos
);
2560 //-----------------------------------------------------------------------------
2561 // wxDataViewCtrlInternal
2562 //-----------------------------------------------------------------------------
2564 wxDataViewCtrlInternal::wxDataViewCtrlInternal( wxDataViewCtrl
*owner
,
2565 wxDataViewModel
*wx_model
, GtkWxTreeModel
*gtk_model
)
2568 m_wx_model
= wx_model
;
2569 m_gtk_model
= gtk_model
;
2571 m_sort_order
= GTK_SORT_ASCENDING
;
2573 m_dataview_sort_column
= NULL
;
2575 if (!m_wx_model
->IsIndexListModel())
2579 wxDataViewCtrlInternal::~wxDataViewCtrlInternal()
2581 g_object_unref( m_gtk_model
);
2584 void wxDataViewCtrlInternal::InitTree()
2586 wxDataViewItem item
;
2587 m_root
= new wxGtkTreeModelNode( NULL
, item
, this );
2589 BuildBranch( m_root
);
2592 void wxDataViewCtrlInternal::BuildBranch( wxGtkTreeModelNode
*node
)
2594 if (node
->GetChildCount() == 0)
2596 wxDataViewItemArray children
;
2597 unsigned int count
= m_wx_model
->GetChildren( node
->GetItem(), children
);
2599 for (pos
= 0; pos
< count
; pos
++)
2601 wxDataViewItem child
= children
[pos
];
2603 if (m_wx_model
->IsContainer( child
))
2604 node
->AddNode( new wxGtkTreeModelNode( node
, child
, this ) );
2606 node
->AddLeave( child
.GetID() );
2608 // Don't send any events here
2613 void wxDataViewCtrlInternal::Resort()
2615 if (!m_wx_model
->IsIndexListModel())
2619 bool wxDataViewCtrlInternal::ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
)
2621 if (!m_wx_model
->IsIndexListModel())
2623 wxGtkTreeModelNode
*parent_node
= FindNode( parent
);
2624 if (m_wx_model
->IsContainer( item
))
2625 parent_node
->AddNode( new wxGtkTreeModelNode( parent_node
, item
, this ) );
2627 parent_node
->AddLeave( item
.GetID() );
2633 bool wxDataViewCtrlInternal::ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
)
2635 if (!m_wx_model
->IsIndexListModel())
2637 wxGtkTreeModelNode
*parent_node
= FindNode( parent
);
2638 parent_node
->DeleteChild( item
.GetID() );
2644 bool wxDataViewCtrlInternal::ItemChanged( const wxDataViewItem
&item
)
2646 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
, m_owner
->GetId() );
2647 event
.SetEventObject( m_owner
);
2648 event
.SetModel( m_owner
->GetModel() );
2649 event
.SetItem( item
);
2650 m_owner
->HandleWindowEvent( event
);
2655 bool wxDataViewCtrlInternal::ValueChanged( const wxDataViewItem
&item
, unsigned int col
)
2657 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
, m_owner
->GetId() );
2658 event
.SetEventObject( m_owner
);
2659 event
.SetModel( m_owner
->GetModel() );
2660 event
.SetColumn( col
);
2661 event
.SetDataViewColumn( GetOwner()->GetColumn(col
) );
2662 event
.SetItem( item
);
2663 m_owner
->HandleWindowEvent( event
);
2668 bool wxDataViewCtrlInternal::Cleared()
2673 GtkTreeModelFlags
wxDataViewCtrlInternal::get_flags()
2675 if (m_wx_model
->IsIndexListModel())
2676 return GTK_TREE_MODEL_LIST_ONLY
;
2678 return GTK_TREE_MODEL_ITERS_PERSIST
;
2681 gboolean
wxDataViewCtrlInternal::get_iter( GtkTreeIter
*iter
, GtkTreePath
*path
)
2683 if (m_wx_model
->IsIndexListModel())
2685 wxDataViewIndexListModel
*wx_model
= (wxDataViewIndexListModel
*) m_wx_model
;
2687 unsigned int i
= (unsigned int)gtk_tree_path_get_indices (path
)[0];
2689 if (i
>= wx_model
->GetLastIndex() + 1)
2692 iter
->stamp
= m_gtk_model
->stamp
;
2693 // user_data is just the index
2694 iter
->user_data
= (gpointer
) i
;
2700 int depth
= gtk_tree_path_get_depth( path
);
2702 wxGtkTreeModelNode
*node
= m_root
;
2705 for (i
= 0; i
< depth
; i
++)
2707 BuildBranch( node
);
2709 gint pos
= gtk_tree_path_get_indices (path
)[i
];
2710 if (pos
< 0) return FALSE
;
2711 if ((size_t)pos
>= node
->GetChildCount()) return FALSE
;
2713 void* id
= node
->GetChildren().Item( (size_t) pos
);
2717 iter
->stamp
= m_gtk_model
->stamp
;
2718 iter
->user_data
= id
;
2722 size_t count
= node
->GetNodes().GetCount();
2724 for (pos2
= 0; pos2
< count
; pos2
++)
2726 wxGtkTreeModelNode
*child_node
= node
->GetNodes().Item( pos2
);
2727 if (child_node
->GetItem().GetID() == id
)
2739 GtkTreePath
*wxDataViewCtrlInternal::get_path( GtkTreeIter
*iter
)
2741 GtkTreePath
*retval
= gtk_tree_path_new ();
2743 if (m_wx_model
->IsIndexListModel())
2745 // user_data is just the index
2746 int i
= (wxUIntPtr
) iter
->user_data
;
2747 gtk_tree_path_append_index (retval
, i
);
2751 void *id
= iter
->user_data
;
2753 wxGtkTreeModelNode
*node
= FindParentNode( iter
);
2756 int pos
= node
->GetChildren().Index( id
);
2758 gtk_tree_path_prepend_index( retval
, pos
);
2760 id
= node
->GetItem().GetID();
2761 node
= node
->GetParent();
2768 gboolean
wxDataViewCtrlInternal::iter_next( GtkTreeIter
*iter
)
2770 if (m_wx_model
->IsIndexListModel())
2772 wxDataViewIndexListModel
*wx_model
= (wxDataViewIndexListModel
*) m_wx_model
;
2774 int n
= (wxUIntPtr
) iter
->user_data
;
2779 if (n
>= (int) wx_model
->GetLastIndex())
2782 iter
->user_data
= (gpointer
) ++n
;
2786 wxGtkTreeModelNode
*parent
= FindParentNode( iter
);
2787 if( parent
== NULL
)
2790 int pos
= parent
->GetChildren().Index( iter
->user_data
);
2792 if (pos
== (int) parent
->GetChildCount()-1)
2795 iter
->stamp
= m_gtk_model
->stamp
;
2796 iter
->user_data
= parent
->GetChildren().Item( pos
+1 );
2802 gboolean
wxDataViewCtrlInternal::iter_children( GtkTreeIter
*iter
, GtkTreeIter
*parent
)
2804 if (m_wx_model
->IsIndexListModel())
2806 // this is a list, nodes have no children
2810 iter
->stamp
= m_gtk_model
->stamp
;
2811 iter
->user_data
= (gpointer
) -1;
2817 wxDataViewItem
item( (void*) parent
->user_data
);
2819 if (!m_wx_model
->IsContainer( item
))
2822 wxGtkTreeModelNode
*parent_node
= FindNode( parent
);
2823 BuildBranch( parent_node
);
2825 if (parent_node
->GetChildCount() == 0)
2828 iter
->stamp
= m_gtk_model
->stamp
;
2829 iter
->user_data
= (gpointer
) parent_node
->GetChildren().Item( 0 );
2835 gboolean
wxDataViewCtrlInternal::iter_has_child( GtkTreeIter
*iter
)
2837 if (m_wx_model
->IsIndexListModel())
2839 // this is a list, nodes have no children
2844 wxDataViewItem
item( (void*) iter
->user_data
);
2846 bool is_container
= m_wx_model
->IsContainer( item
);
2851 wxGtkTreeModelNode
*node
= FindNode( iter
);
2852 BuildBranch( node
);
2854 return (node
->GetChildCount() > 0);
2858 gint
wxDataViewCtrlInternal::iter_n_children( GtkTreeIter
*iter
)
2860 if (m_wx_model
->IsIndexListModel())
2862 wxDataViewIndexListModel
*wx_model
= (wxDataViewIndexListModel
*) m_wx_model
;
2865 return (gint
) wx_model
->GetLastIndex() + 1;
2871 wxDataViewItem
item( (void*) iter
->user_data
);
2873 if (!m_wx_model
->IsContainer( item
))
2876 wxGtkTreeModelNode
*parent_node
= FindNode( iter
);
2877 BuildBranch( parent_node
);
2879 // wxPrintf( "iter_n_children %d\n", parent_node->GetChildCount() );
2881 return parent_node
->GetChildCount();
2885 gboolean
wxDataViewCtrlInternal::iter_nth_child( GtkTreeIter
*iter
, GtkTreeIter
*parent
, gint n
)
2887 if (m_wx_model
->IsIndexListModel())
2889 wxDataViewIndexListModel
*wx_model
= (wxDataViewIndexListModel
*) m_wx_model
;
2897 if (n
>= (gint
) wx_model
->GetLastIndex() + 1)
2900 iter
->stamp
= m_gtk_model
->stamp
;
2901 iter
->user_data
= (gpointer
) n
;
2908 if (parent
) id
= (void*) parent
->user_data
;
2909 wxDataViewItem
item( id
);
2911 if (!m_wx_model
->IsContainer( item
))
2914 wxGtkTreeModelNode
*parent_node
= FindNode( parent
);
2915 BuildBranch( parent_node
);
2917 // wxPrintf( "iter_nth_child %d\n", n );
2919 iter
->stamp
= m_gtk_model
->stamp
;
2920 iter
->user_data
= parent_node
->GetChildren().Item( n
);
2926 gboolean
wxDataViewCtrlInternal::iter_parent( GtkTreeIter
*iter
, GtkTreeIter
*child
)
2928 if (m_wx_model
->IsIndexListModel())
2934 wxGtkTreeModelNode
*node
= FindParentNode( child
);
2938 iter
->stamp
= m_gtk_model
->stamp
;
2939 iter
->user_data
= (gpointer
) node
->GetItem().GetID();
2945 static wxGtkTreeModelNode
*
2946 wxDataViewCtrlInternal_FindNode( wxDataViewModel
* model
, wxGtkTreeModelNode
*treeNode
, const wxDataViewItem
&item
)
2952 list
.DeleteContents( true );
2953 wxDataViewItem
it( item
);
2957 wxDataViewItem
* pItem
= new wxDataViewItem( it
);
2958 list
.Insert( pItem
);
2959 it
= model
->GetParent( it
);
2962 wxGtkTreeModelNode
* node
= treeNode
;
2963 for( ItemList::compatibility_iterator n
= list
.GetFirst(); n
; n
= n
->GetNext() )
2965 if( node
&& node
->GetNodes().GetCount() != 0 )
2967 int len
= node
->GetNodes().GetCount();
2968 wxGtkTreeModelNodes nodes
= node
->GetNodes();
2970 for( ; j
< len
; j
++)
2972 if( nodes
[j
]->GetItem() == *(n
->GetData()))
2991 wxGtkTreeModelNode
*wxDataViewCtrlInternal::FindNode( GtkTreeIter
*iter
)
2996 wxDataViewItem
item( (void*) iter
->user_data
);
3000 wxGtkTreeModelNode
*result
= wxDataViewCtrlInternal_FindNode( m_wx_model
, m_root
, item
);
3004 wxLogDebug( "Not found %p", iter
->user_data
);
3012 wxGtkTreeModelNode
*wxDataViewCtrlInternal::FindNode( const wxDataViewItem
&item
)
3017 wxGtkTreeModelNode
*result
= wxDataViewCtrlInternal_FindNode( m_wx_model
, m_root
, item
);
3021 wxLogDebug( "Not found %p", item
.GetID() );
3029 static wxGtkTreeModelNode
*
3030 wxDataViewCtrlInternal_FindParentNode( wxDataViewModel
* model
, wxGtkTreeModelNode
*treeNode
, const wxDataViewItem
&item
)
3036 list
.DeleteContents( true );
3040 wxDataViewItem
it( model
->GetParent( item
) );
3043 wxDataViewItem
* pItem
= new wxDataViewItem( it
);
3044 list
.Insert( pItem
);
3045 it
= model
->GetParent( it
);
3048 wxGtkTreeModelNode
* node
= treeNode
;
3049 for( ItemList::compatibility_iterator n
= list
.GetFirst(); n
; n
= n
->GetNext() )
3051 if( node
&& node
->GetNodes().GetCount() != 0 )
3053 int len
= node
->GetNodes().GetCount();
3054 wxGtkTreeModelNodes nodes
= node
->GetNodes();
3056 for( ; j
< len
; j
++)
3058 if( nodes
[j
]->GetItem() == *(n
->GetData()))
3073 //Examine whether the node is item's parent node
3074 int len
= node
->GetChildCount();
3075 for( int i
= 0; i
< len
; i
++ )
3077 if( node
->GetChildren().Item( i
) == item
.GetID() )
3083 wxGtkTreeModelNode
*wxDataViewCtrlInternal::FindParentNode( GtkTreeIter
*iter
)
3088 wxDataViewItem
item( (void*) iter
->user_data
);
3092 return wxDataViewCtrlInternal_FindParentNode( m_wx_model
, m_root
, item
);
3095 wxGtkTreeModelNode
*wxDataViewCtrlInternal::FindParentNode( const wxDataViewItem
&item
)
3100 return wxDataViewCtrlInternal_FindParentNode( m_wx_model
, m_root
, item
);
3103 //-----------------------------------------------------------------------------
3104 // wxDataViewCtrl signal callbacks
3105 //-----------------------------------------------------------------------------
3108 wxdataview_selection_changed_callback( GtkTreeSelection
* selection
, wxDataViewCtrl
*dv
)
3110 if (!GTK_WIDGET_REALIZED(dv
->m_widget
))
3113 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
, dv
->GetId() );
3114 event
.SetItem( dv
->GetSelection() );
3115 event
.SetModel( dv
->GetModel() );
3116 dv
->HandleWindowEvent( event
);
3120 wxdataview_row_activated_callback( GtkTreeView
* treeview
, GtkTreePath
*path
,
3121 GtkTreeViewColumn
*column
, wxDataViewCtrl
*dv
)
3123 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
, dv
->GetId() );
3126 dv
->GtkGetInternal()->get_iter( &iter
, path
);
3127 wxDataViewItem
item( (void*) iter
.user_data
);;
3128 event
.SetItem( item
);
3129 event
.SetModel( dv
->GetModel() );
3130 dv
->HandleWindowEvent( event
);
3134 wxdataview_test_expand_row_callback( GtkTreeView
* treeview
, GtkTreeIter
* iter
,
3135 GtkTreePath
*path
, wxDataViewCtrl
*dv
)
3137 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
, dv
->GetId() );
3139 wxDataViewItem
item( (void*) iter
->user_data
);;
3140 event
.SetItem( item
);
3141 event
.SetModel( dv
->GetModel() );
3142 dv
->HandleWindowEvent( event
);
3144 return !event
.IsAllowed();
3148 wxdataview_row_expanded_callback( GtkTreeView
* treeview
, GtkTreeIter
* iter
,
3149 GtkTreePath
*path
, wxDataViewCtrl
*dv
)
3151 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
, dv
->GetId() );
3153 wxDataViewItem
item( (void*) iter
->user_data
);;
3154 event
.SetItem( item
);
3155 event
.SetModel( dv
->GetModel() );
3156 dv
->HandleWindowEvent( event
);
3160 wxdataview_test_collapse_row_callback( GtkTreeView
* treeview
, GtkTreeIter
* iter
,
3161 GtkTreePath
*path
, wxDataViewCtrl
*dv
)
3163 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
, dv
->GetId() );
3165 wxDataViewItem
item( (void*) iter
->user_data
);;
3166 event
.SetItem( item
);
3167 event
.SetModel( dv
->GetModel() );
3168 dv
->HandleWindowEvent( event
);
3170 return !event
.IsAllowed();
3174 wxdataview_row_collapsed_callback( GtkTreeView
* treeview
, GtkTreeIter
* iter
,
3175 GtkTreePath
*path
, wxDataViewCtrl
*dv
)
3177 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
, dv
->GetId() );
3179 wxDataViewItem
item( (void*) iter
->user_data
);;
3180 event
.SetItem( item
);
3181 event
.SetModel( dv
->GetModel() );
3182 dv
->HandleWindowEvent( event
);
3185 //-----------------------------------------------------------------------------
3187 //-----------------------------------------------------------------------------
3189 //-----------------------------------------------------------------------------
3190 // InsertChild for wxDataViewCtrl
3191 //-----------------------------------------------------------------------------
3193 static void wxInsertChildInDataViewCtrl( wxWindowGTK
* parent
, wxWindowGTK
* child
)
3195 wxDataViewCtrl
* dvc
= (wxDataViewCtrl
*) parent
;
3196 GtkWidget
*treeview
= dvc
->GtkGetTreeView();
3198 // Insert widget in GtkTreeView
3199 if (GTK_WIDGET_REALIZED(treeview
))
3200 gtk_widget_set_parent_window( child
->m_widget
,
3201 gtk_tree_view_get_bin_window( GTK_TREE_VIEW(treeview
) ) );
3202 gtk_widget_set_parent( child
->m_widget
, treeview
);
3206 void gtk_dataviewctrl_size_callback( GtkWidget
*WXUNUSED(widget
),
3207 GtkAllocation
*alloc
,
3208 wxDataViewCtrl
*win
)
3210 wxWindowList::compatibility_iterator node
= win
->GetChildren().GetFirst();
3213 wxWindow
*child
= node
->GetData();
3216 gtk_widget_size_request( child
->m_widget
, &req
);
3218 GtkAllocation alloc
;
3219 alloc
.x
= child
->m_x
;
3220 alloc
.y
= child
->m_y
;
3221 alloc
.width
= child
->m_width
;
3222 alloc
.height
= child
->m_height
;
3223 gtk_widget_size_allocate( child
->m_widget
, &alloc
);
3225 node
= node
->GetNext();
3230 //-----------------------------------------------------------------------------
3231 // "motion_notify_event"
3232 //-----------------------------------------------------------------------------
3235 gtk_dataview_motion_notify_callback( GtkWidget
*widget
,
3236 GdkEventMotion
*gdk_event
,
3237 wxDataViewCtrl
*dv
)
3239 if (gdk_event
->is_hint
)
3243 GdkModifierType state
;
3244 gdk_window_get_pointer(gdk_event
->window
, &x
, &y
, &state
);
3249 GtkTreePath
*path
= NULL
;
3250 GtkTreeViewColumn
*column
= NULL
;
3253 if (gtk_tree_view_get_path_at_pos(
3254 GTK_TREE_VIEW(dv
->GtkGetTreeView()),
3255 (int) gdk_event
->x
, (int) gdk_event
->y
,
3264 dv
->GtkGetInternal()->get_iter( &iter
, path
);
3266 // wxPrintf( "mouse %d %d\n", (int) gdk_event->x, (int) gdk_event->y );
3268 gtk_tree_path_free( path
);
3277 IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl
, wxDataViewCtrlBase
)
3279 wxDataViewCtrl::~wxDataViewCtrl()
3282 GetModel()->RemoveNotifier( m_notifier
);
3284 // remove the model from the GtkTreeView before it gets destroyed by the
3285 // wxDataViewCtrlBase's dtor
3286 gtk_tree_view_set_model( GTK_TREE_VIEW(m_treeview
), NULL
);
3291 void wxDataViewCtrl::Init()
3296 bool wxDataViewCtrl::Create(wxWindow
*parent
, wxWindowID id
,
3297 const wxPoint
& pos
, const wxSize
& size
,
3298 long style
, const wxValidator
& validator
)
3302 if (!PreCreation( parent
, pos
, size
) ||
3303 !CreateBase( parent
, id
, pos
, size
, style
, validator
))
3305 wxFAIL_MSG( wxT("wxDataViewCtrl creation failed") );
3309 m_insertCallback
= wxInsertChildInDataViewCtrl
;
3311 m_widget
= gtk_scrolled_window_new (NULL
, NULL
);
3313 GtkScrolledWindowSetBorder(m_widget
, style
);
3315 m_treeview
= gtk_tree_view_new();
3316 gtk_container_add (GTK_CONTAINER (m_widget
), m_treeview
);
3318 g_signal_connect (m_treeview
, "size_allocate",
3319 G_CALLBACK (gtk_dataviewctrl_size_callback
), this);
3322 if (!gtk_check_version(2,6,0))
3323 gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview
), TRUE
);
3326 if (style
& wxDV_MULTIPLE
)
3328 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3329 gtk_tree_selection_set_mode( selection
, GTK_SELECTION_MULTIPLE
);
3332 gtk_tree_view_set_headers_visible( GTK_TREE_VIEW(m_treeview
), (style
& wxDV_NO_HEADER
) == 0 );
3335 if (!gtk_check_version(2,10,0))
3337 GtkTreeViewGridLines grid
= GTK_TREE_VIEW_GRID_LINES_NONE
;
3339 if ((style
& wxDV_HORIZ_RULES
) != 0 &&
3340 (style
& wxDV_VERT_RULES
) != 0)
3341 grid
= GTK_TREE_VIEW_GRID_LINES_BOTH
;
3342 else if (style
& wxDV_VERT_RULES
)
3343 grid
= GTK_TREE_VIEW_GRID_LINES_VERTICAL
;
3344 else if (style
& wxDV_HORIZ_RULES
)
3345 grid
= GTK_TREE_VIEW_GRID_LINES_HORIZONTAL
;
3347 if (grid
!= GTK_TREE_VIEW_GRID_LINES_NONE
)
3348 gtk_tree_view_set_grid_lines( GTK_TREE_VIEW(m_treeview
), grid
);
3352 gtk_tree_view_set_rules_hint( GTK_TREE_VIEW(m_treeview
), (style
& wxDV_ROW_LINES
) != 0 );
3354 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (m_widget
),
3355 GTK_POLICY_AUTOMATIC
, GTK_POLICY_ALWAYS
);
3356 gtk_widget_show (m_treeview
);
3358 m_parent
->DoAddChild( this );
3362 GtkEnableSelectionEvents();
3364 g_signal_connect_after (m_treeview
, "row-activated",
3365 G_CALLBACK (wxdataview_row_activated_callback
), this);
3367 g_signal_connect (m_treeview
, "test-collapse-row",
3368 G_CALLBACK (wxdataview_test_collapse_row_callback
), this);
3370 g_signal_connect_after (m_treeview
, "row-collapsed",
3371 G_CALLBACK (wxdataview_row_collapsed_callback
), this);
3373 g_signal_connect (m_treeview
, "test-expand-row",
3374 G_CALLBACK (wxdataview_test_expand_row_callback
), this);
3376 g_signal_connect_after (m_treeview
, "row-expanded",
3377 G_CALLBACK (wxdataview_row_expanded_callback
), this);
3379 g_signal_connect (m_treeview
, "motion_notify_event",
3380 G_CALLBACK (gtk_dataview_motion_notify_callback
), this);
3385 void wxDataViewCtrl::OnInternalIdle()
3387 wxWindow::OnInternalIdle();
3389 unsigned int cols
= GetColumnCount();
3391 for (i
= 0; i
< cols
; i
++)
3393 wxDataViewColumn
*col
= GetColumn( i
);
3394 col
->OnInternalIdle();
3398 bool wxDataViewCtrl::AssociateModel( wxDataViewModel
*model
)
3400 if (!wxDataViewCtrlBase::AssociateModel( model
))
3403 GtkWxTreeModel
*gtk_model
= wxgtk_tree_model_new();
3404 m_internal
= new wxDataViewCtrlInternal( this, model
, gtk_model
);
3405 gtk_model
->internal
= m_internal
;
3407 m_notifier
= new wxGtkDataViewModelNotifier( gtk_model
, model
, this );
3409 model
->AddNotifier( m_notifier
);
3411 gtk_tree_view_set_model( GTK_TREE_VIEW(m_treeview
), GTK_TREE_MODEL(gtk_model
) );
3413 // unref in wxDataViewCtrlInternal
3414 // g_object_unref( gtk_model );
3419 bool wxDataViewCtrl::AppendColumn( wxDataViewColumn
*col
)
3421 if (!wxDataViewCtrlBase::AppendColumn(col
))
3424 m_cols
.Append( col
);
3426 gtk_tree_view_append_column( GTK_TREE_VIEW(m_treeview
),
3427 GTK_TREE_VIEW_COLUMN(col
->GetGtkHandle()) );
3432 bool wxDataViewCtrl::PrependColumn( wxDataViewColumn
*col
)
3434 if (!wxDataViewCtrlBase::PrependColumn(col
))
3437 m_cols
.Insert( col
);
3439 gtk_tree_view_insert_column( GTK_TREE_VIEW(m_treeview
),
3440 GTK_TREE_VIEW_COLUMN(col
->GetGtkHandle()), 0 );
3445 unsigned int wxDataViewCtrl::GetColumnCount() const
3447 return m_cols
.GetCount();
3450 wxDataViewColumn
* wxDataViewCtrl::GetColumn( unsigned int pos
) const
3452 GtkTreeViewColumn
*gtk_col
= gtk_tree_view_get_column( GTK_TREE_VIEW(m_treeview
), pos
);
3456 wxDataViewColumnList::const_iterator iter
;
3457 for (iter
= m_cols
.begin(); iter
!= m_cols
.end(); iter
++)
3459 wxDataViewColumn
*col
= *iter
;
3460 if (GTK_TREE_VIEW_COLUMN(col
->GetGtkHandle()) == gtk_col
)
3469 bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn
*column
)
3471 gtk_tree_view_remove_column( GTK_TREE_VIEW(m_treeview
),
3472 GTK_TREE_VIEW_COLUMN(column
->GetGtkHandle()) );
3474 m_cols
.remove( column
);
3481 bool wxDataViewCtrl::ClearColumns()
3483 wxDataViewColumnList::iterator iter
;
3484 for (iter
= m_cols
.begin(); iter
!= m_cols
.end(); iter
++)
3486 wxDataViewColumn
*col
= *iter
;
3487 gtk_tree_view_remove_column( GTK_TREE_VIEW(m_treeview
),
3488 GTK_TREE_VIEW_COLUMN(col
->GetGtkHandle()) );
3496 int wxDataViewCtrl::GetColumnPosition( const wxDataViewColumn
*column
) const
3498 GtkTreeViewColumn
*gtk_column
= GTK_TREE_VIEW_COLUMN(column
->GetConstGtkHandle());
3500 GList
*list
= gtk_tree_view_get_columns( GTK_TREE_VIEW(m_treeview
) );
3502 gint pos
= g_list_index( list
, (gconstpointer
) gtk_column
);
3504 g_list_free( list
);
3509 wxDataViewColumn
*wxDataViewCtrl::GetSortingColumn() const
3511 return m_internal
->GetDataViewSortColumn();
3514 void wxDataViewCtrl::Expand( const wxDataViewItem
& item
)
3517 iter
.user_data
= item
.GetID();
3518 GtkTreePath
*path
= m_internal
->get_path( &iter
);
3519 gtk_tree_view_expand_row( GTK_TREE_VIEW(m_treeview
), path
, false );
3520 gtk_tree_path_free( path
);
3523 void wxDataViewCtrl::Collapse( const wxDataViewItem
& item
)
3526 iter
.user_data
= item
.GetID();
3527 GtkTreePath
*path
= m_internal
->get_path( &iter
);
3528 gtk_tree_view_collapse_row( GTK_TREE_VIEW(m_treeview
), path
);
3529 gtk_tree_path_free( path
);
3532 wxDataViewItem
wxDataViewCtrl::GetSelection() const
3534 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3536 if (m_windowStyle
& wxDV_MULTIPLE
)
3538 // Report the first one
3539 GtkTreeModel
*model
;
3540 GList
*list
= gtk_tree_selection_get_selected_rows( selection
, &model
);
3544 GtkTreePath
*path
= (GtkTreePath
*) list
->data
;
3546 m_internal
->get_iter( &iter
, path
);
3549 g_list_foreach( list
, (GFunc
) gtk_tree_path_free
, NULL
);
3550 g_list_free( list
);
3552 return wxDataViewItem( (void*) iter
.user_data
);
3558 if (gtk_tree_selection_get_selected( selection
, NULL
, &iter
))
3560 wxDataViewItem
item( (void*) iter
.user_data
);
3565 return wxDataViewItem(0);
3568 int wxDataViewCtrl::GetSelections( wxDataViewItemArray
& sel
) const
3572 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3573 if (HasFlag(wxDV_MULTIPLE
))
3575 GtkTreeModel
*model
;
3576 GList
*list
= gtk_tree_selection_get_selected_rows( selection
, &model
);
3581 GtkTreePath
*path
= (GtkTreePath
*) list
->data
;
3584 m_internal
->get_iter( &iter
, path
);
3586 sel
.Add( wxDataViewItem( (void*) iter
.user_data
) );
3588 list
= g_list_next( list
);
3593 g_list_foreach( list
, (GFunc
) gtk_tree_path_free
, NULL
);
3594 g_list_free( list
);
3600 GtkTreeModel
*model
;
3602 gboolean has_selection
= gtk_tree_selection_get_selected( selection
, &model
, &iter
);
3605 sel
.Add( wxDataViewItem( (void*) iter
.user_data
) );
3613 void wxDataViewCtrl::SetSelections( const wxDataViewItemArray
& sel
)
3615 GtkDisableSelectionEvents();
3617 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3619 gtk_tree_selection_unselect_all( selection
);
3622 for (i
= 0; i
< sel
.GetCount(); i
++)
3625 iter
.user_data
= (gpointer
) sel
[i
].GetID();
3626 gtk_tree_selection_select_iter( selection
, &iter
);
3629 GtkEnableSelectionEvents();
3632 void wxDataViewCtrl::Select( const wxDataViewItem
& item
)
3634 GtkDisableSelectionEvents();
3636 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3639 iter
.user_data
= (gpointer
) item
.GetID();
3640 gtk_tree_selection_select_iter( selection
, &iter
);
3642 GtkEnableSelectionEvents();
3645 void wxDataViewCtrl::Unselect( const wxDataViewItem
& item
)
3647 GtkDisableSelectionEvents();
3649 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3652 iter
.user_data
= (gpointer
) item
.GetID();
3653 gtk_tree_selection_unselect_iter( selection
, &iter
);
3655 GtkEnableSelectionEvents();
3658 bool wxDataViewCtrl::IsSelected( const wxDataViewItem
& item
) const
3660 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3663 iter
.user_data
= (gpointer
) item
.GetID();
3665 return gtk_tree_selection_iter_is_selected( selection
, &iter
);
3668 void wxDataViewCtrl::SelectAll()
3670 GtkDisableSelectionEvents();
3672 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3674 gtk_tree_selection_select_all( selection
);
3676 GtkEnableSelectionEvents();
3679 void wxDataViewCtrl::UnselectAll()
3681 GtkDisableSelectionEvents();
3683 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3685 gtk_tree_selection_unselect_all( selection
);
3687 GtkEnableSelectionEvents();
3690 void wxDataViewCtrl::EnsureVisible( const wxDataViewItem
& item
, const wxDataViewColumn
*column
)
3693 iter
.user_data
= (gpointer
) item
.GetID();
3694 GtkTreePath
*path
= m_internal
->get_path( &iter
);
3695 gtk_tree_view_scroll_to_cell( GTK_TREE_VIEW(m_treeview
), path
, NULL
, false, 0.0, 0.0 );
3696 gtk_tree_path_free( path
);
3699 void wxDataViewCtrl::HitTest( const wxPoint
&point
,
3700 wxDataViewItem
&item
, wxDataViewColumn
*&column
) const
3702 item
= wxDataViewItem(0);
3706 wxRect
wxDataViewCtrl::GetItemRect( const wxDataViewItem
&item
,
3707 const wxDataViewColumn
*column
) const
3712 void wxDataViewCtrl::DoSetExpanderColumn()
3714 gtk_tree_view_set_expander_column( GTK_TREE_VIEW(m_treeview
),
3715 GTK_TREE_VIEW_COLUMN( GetExpanderColumn()->GetGtkHandle() ) );
3718 void wxDataViewCtrl::DoSetIndent()
3722 void wxDataViewCtrl::GtkDisableSelectionEvents()
3724 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3725 g_signal_handlers_disconnect_by_func( selection
,
3726 (gpointer
) (wxdataview_selection_changed_callback
), this);
3729 void wxDataViewCtrl::GtkEnableSelectionEvents()
3731 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3732 g_signal_connect_after (selection
, "changed",
3733 G_CALLBACK (wxdataview_selection_changed_callback
), this);
3738 wxDataViewCtrl::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
3740 return GetDefaultAttributesFromGTKWidget(gtk_tree_view_new
);
3745 // !wxUSE_GENERICDATAVIEWCTRL
3748 // wxUSE_DATAVIEWCTRL