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"
36 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
39 class wxDataViewCtrlInternal
;
41 wxDataViewCtrlInternal
*g_internal
= NULL
;
43 class wxGtkTreeModelNode
;
46 typedef struct _GtkWxTreeModel GtkWxTreeModel
;
49 //-----------------------------------------------------------------------------
50 // wxDataViewCtrlInternal
51 //-----------------------------------------------------------------------------
53 WX_DECLARE_LIST(wxDataViewItem
, ItemList
);
54 WX_DEFINE_LIST(ItemList
)
56 class wxDataViewCtrlInternal
59 wxDataViewCtrlInternal( wxDataViewCtrl
*owner
, wxDataViewModel
*wx_model
, GtkWxTreeModel
*owner
);
60 ~wxDataViewCtrlInternal();
62 GtkTreeModelFlags
get_flags();
63 gboolean
get_iter( GtkTreeIter
*iter
, GtkTreePath
*path
);
64 GtkTreePath
*get_path( GtkTreeIter
*iter
);
65 gboolean
iter_next( GtkTreeIter
*iter
);
66 gboolean
iter_children( GtkTreeIter
*iter
, GtkTreeIter
*parent
);
67 gboolean
iter_has_child( GtkTreeIter
*iter
);
68 gint
iter_n_children( GtkTreeIter
*iter
);
69 gboolean
iter_nth_child( GtkTreeIter
*iter
, GtkTreeIter
*parent
, gint n
);
70 gboolean
iter_parent( GtkTreeIter
*iter
, GtkTreeIter
*child
);
72 wxDataViewModel
* GetDataViewModel() { return m_wx_model
; }
73 wxDataViewCtrl
* GetOwner() { return m_owner
; }
74 GtkWxTreeModel
* GetGtkModel() { return m_gtk_model
; }
76 bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
77 bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
78 bool ItemChanged( const wxDataViewItem
&item
);
79 bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
83 void SetSortOrder( GtkSortType sort_order
) { m_sort_order
= sort_order
; }
84 GtkSortType
GetSortOrder() { return m_sort_order
; }
86 void SetSortColumn( int column
) { m_sort_column
= column
; }
87 int GetSortColumn() { return m_sort_column
; }
89 void SetDataViewSortColumn( wxDataViewColumn
*column
) { m_dataview_sort_column
= column
; }
90 wxDataViewColumn
*GetDataViewSortColumn() { return m_dataview_sort_column
; }
92 bool IsSorted() { return (m_sort_column
>= 0); }
97 wxGtkTreeModelNode
*FindNode( const wxDataViewItem
&item
);
98 wxGtkTreeModelNode
*FindNode( GtkTreeIter
*iter
);
99 wxGtkTreeModelNode
*FindParentNode( const wxDataViewItem
&item
);
100 wxGtkTreeModelNode
*FindParentNode( GtkTreeIter
*iter
);
101 void BuildBranch( wxGtkTreeModelNode
*branch
);
104 wxGtkTreeModelNode
*m_root
;
105 wxDataViewModel
*m_wx_model
;
106 GtkWxTreeModel
*m_gtk_model
;
107 wxDataViewCtrl
*m_owner
;
108 GtkSortType m_sort_order
;
109 wxDataViewColumn
*m_dataview_sort_column
;
114 //-----------------------------------------------------------------------------
115 // wxGtkTreeModelNode
116 //-----------------------------------------------------------------------------
118 int LINKAGEMODE
wxGtkTreeModelChildCmp( void** id1
, void** id2
)
120 int ret
= g_internal
->GetDataViewModel()->Compare( *id1
, *id2
,
121 g_internal
->GetSortColumn(), (g_internal
->GetSortOrder() == GTK_SORT_ASCENDING
) );
126 WX_DEFINE_ARRAY_PTR( wxGtkTreeModelNode
*, wxGtkTreeModelNodes
);
127 WX_DEFINE_ARRAY_PTR( void*, wxGtkTreeModelChildren
);
129 class wxGtkTreeModelNode
132 wxGtkTreeModelNode( wxGtkTreeModelNode
* parent
, const wxDataViewItem
&item
,
133 wxDataViewCtrlInternal
*internal
)
137 m_internal
= internal
;
140 ~wxGtkTreeModelNode()
142 size_t count
= m_children
.GetCount();
144 for (i
= 0; i
< count
; i
++)
146 wxGtkTreeModelNode
*child
= m_nodes
.Item( i
);
151 unsigned int AddNode( wxGtkTreeModelNode
* child
)
153 m_nodes
.Add( child
);
155 void *id
= child
->GetItem().GetID();
157 m_children
.Add( id
);
159 if (m_internal
->IsSorted() || m_internal
->GetDataViewModel()->HasDefaultCompare())
161 g_internal
= m_internal
;
162 m_children
.Sort( &wxGtkTreeModelChildCmp
);
163 return m_children
.Index( id
);
166 return m_children
.GetCount()-1;
169 unsigned int AddLeave( void* id
)
171 m_children
.Add( id
);
173 if (m_internal
->IsSorted() || m_internal
->GetDataViewModel()->HasDefaultCompare())
175 g_internal
= m_internal
;
176 m_children
.Sort( &wxGtkTreeModelChildCmp
);
177 return m_children
.Index( id
);
180 return m_children
.GetCount()-1;
183 void DeleteChild( void* id
)
185 m_children
.Remove( id
);
187 unsigned int count
= m_nodes
.GetCount();
189 for (pos
= 0; pos
< count
; pos
++)
191 wxGtkTreeModelNode
*node
= m_nodes
.Item( pos
);
192 if (node
->GetItem().GetID() == id
)
194 m_nodes
.RemoveAt( pos
);
202 wxGtkTreeModelNode
* GetParent()
204 wxGtkTreeModelNodes
&GetNodes()
206 wxGtkTreeModelChildren
&GetChildren()
207 { return m_children
; }
209 unsigned int GetChildCount() { return m_children
.GetCount(); }
210 unsigned int GetNodesCount() { return m_nodes
.GetCount(); }
212 wxDataViewItem
&GetItem() { return m_item
; }
213 wxDataViewCtrlInternal
*GetInternal() { return m_internal
; }
218 wxGtkTreeModelNode
*m_parent
;
219 wxGtkTreeModelNodes m_nodes
;
220 wxGtkTreeModelChildren m_children
;
221 wxDataViewItem m_item
;
222 wxDataViewCtrlInternal
*m_internal
;
226 //-----------------------------------------------------------------------------
228 //-----------------------------------------------------------------------------
230 extern bool g_blockEventsOnDrag
;
232 //-----------------------------------------------------------------------------
233 // define new GTK+ class wxGtkTreeModel
234 //-----------------------------------------------------------------------------
238 #define GTK_TYPE_WX_TREE_MODEL (gtk_wx_tree_model_get_type ())
239 #define GTK_WX_TREE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_WX_TREE_MODEL, GtkWxTreeModel))
240 #define GTK_WX_TREE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WX_TREE_MODEL, GtkWxTreeModelClass))
241 #define GTK_IS_WX_TREE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_WX_TREE_MODEL))
242 #define GTK_IS_WX_TREE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WX_TREE_MODEL))
243 #define GTK_WX_TREE_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WX_TREE_MODEL, GtkWxTreeModelClass))
245 GType
gtk_wx_tree_model_get_type (void);
247 typedef struct _GtkWxTreeModelClass GtkWxTreeModelClass
;
249 struct _GtkWxTreeModel
255 wxDataViewCtrlInternal
*internal
;
258 struct _GtkWxTreeModelClass
260 GObjectClass list_parent_class
;
263 static GtkWxTreeModel
*wxgtk_tree_model_new (void);
264 static void wxgtk_tree_model_init (GtkWxTreeModel
*tree_model
);
265 static void wxgtk_tree_model_class_init (GtkWxTreeModelClass
*klass
);
266 static void wxgtk_tree_model_tree_model_init (GtkTreeModelIface
*iface
);
267 static void wxgtk_tree_model_sortable_init (GtkTreeSortableIface
*iface
);
268 static void wxgtk_tree_model_finalize (GObject
*object
);
269 static GtkTreeModelFlags
wxgtk_tree_model_get_flags (GtkTreeModel
*tree_model
);
270 static gint
wxgtk_tree_model_get_n_columns (GtkTreeModel
*tree_model
);
271 static GType
wxgtk_tree_model_get_column_type (GtkTreeModel
*tree_model
,
273 static gboolean
wxgtk_tree_model_get_iter (GtkTreeModel
*tree_model
,
276 static GtkTreePath
*wxgtk_tree_model_get_path (GtkTreeModel
*tree_model
,
278 static void wxgtk_tree_model_get_value (GtkTreeModel
*tree_model
,
282 static gboolean
wxgtk_tree_model_iter_next (GtkTreeModel
*tree_model
,
284 static gboolean
wxgtk_tree_model_iter_children (GtkTreeModel
*tree_model
,
286 GtkTreeIter
*parent
);
287 static gboolean
wxgtk_tree_model_iter_has_child (GtkTreeModel
*tree_model
,
289 static gint
wxgtk_tree_model_iter_n_children (GtkTreeModel
*tree_model
,
291 static gboolean
wxgtk_tree_model_iter_nth_child (GtkTreeModel
*tree_model
,
295 static gboolean
wxgtk_tree_model_iter_parent (GtkTreeModel
*tree_model
,
300 static gboolean
wxgtk_tree_model_get_sort_column_id (GtkTreeSortable
*sortable
,
301 gint
*sort_column_id
,
303 static void wxgtk_tree_model_set_sort_column_id (GtkTreeSortable
*sortable
,
306 static void wxgtk_tree_model_set_sort_func (GtkTreeSortable
*sortable
,
308 GtkTreeIterCompareFunc func
,
310 GtkDestroyNotify destroy
);
311 static void wxgtk_tree_model_set_default_sort_func (GtkTreeSortable
*sortable
,
312 GtkTreeIterCompareFunc func
,
314 GtkDestroyNotify destroy
);
315 static gboolean
wxgtk_tree_model_has_default_sort_func (GtkTreeSortable
*sortable
);
319 static GObjectClass
*list_parent_class
= NULL
;
322 gtk_wx_tree_model_get_type (void)
324 static GType tree_model_type
= 0;
326 if (!tree_model_type
)
328 const GTypeInfo tree_model_info
=
330 sizeof (GtkWxTreeModelClass
),
331 NULL
, /* base_init */
332 NULL
, /* base_finalize */
333 (GClassInitFunc
) wxgtk_tree_model_class_init
,
334 NULL
, /* class_finalize */
335 NULL
, /* class_data */
336 sizeof (GtkWxTreeModel
),
338 (GInstanceInitFunc
) wxgtk_tree_model_init
,
341 static const GInterfaceInfo tree_model_iface_info
=
343 (GInterfaceInitFunc
) wxgtk_tree_model_tree_model_init
,
348 static const GInterfaceInfo sortable_iface_info
=
350 (GInterfaceInitFunc
) wxgtk_tree_model_sortable_init
,
355 tree_model_type
= g_type_register_static (G_TYPE_OBJECT
, "GtkWxTreeModel",
356 &tree_model_info
, (GTypeFlags
)0 );
358 g_type_add_interface_static (tree_model_type
,
360 &tree_model_iface_info
);
361 g_type_add_interface_static (tree_model_type
,
362 GTK_TYPE_TREE_SORTABLE
,
363 &sortable_iface_info
);
366 return tree_model_type
;
369 static GtkWxTreeModel
*
370 wxgtk_tree_model_new(void)
372 GtkWxTreeModel
*retval
= (GtkWxTreeModel
*) g_object_new (GTK_TYPE_WX_TREE_MODEL
, NULL
);
377 wxgtk_tree_model_class_init (GtkWxTreeModelClass
*klass
)
379 list_parent_class
= (GObjectClass
*) g_type_class_peek_parent (klass
);
380 GObjectClass
*object_class
= (GObjectClass
*) klass
;
381 object_class
->finalize
= wxgtk_tree_model_finalize
;
385 wxgtk_tree_model_tree_model_init (GtkTreeModelIface
*iface
)
387 iface
->get_flags
= wxgtk_tree_model_get_flags
;
388 iface
->get_n_columns
= wxgtk_tree_model_get_n_columns
;
389 iface
->get_column_type
= wxgtk_tree_model_get_column_type
;
390 iface
->get_iter
= wxgtk_tree_model_get_iter
;
391 iface
->get_path
= wxgtk_tree_model_get_path
;
392 iface
->get_value
= wxgtk_tree_model_get_value
;
393 iface
->iter_next
= wxgtk_tree_model_iter_next
;
394 iface
->iter_children
= wxgtk_tree_model_iter_children
;
395 iface
->iter_has_child
= wxgtk_tree_model_iter_has_child
;
396 iface
->iter_n_children
= wxgtk_tree_model_iter_n_children
;
397 iface
->iter_nth_child
= wxgtk_tree_model_iter_nth_child
;
398 iface
->iter_parent
= wxgtk_tree_model_iter_parent
;
402 wxgtk_tree_model_sortable_init (GtkTreeSortableIface
*iface
)
404 iface
->get_sort_column_id
= wxgtk_tree_model_get_sort_column_id
;
405 iface
->set_sort_column_id
= wxgtk_tree_model_set_sort_column_id
;
406 iface
->set_sort_func
= wxgtk_tree_model_set_sort_func
;
407 iface
->set_default_sort_func
= wxgtk_tree_model_set_default_sort_func
;
408 iface
->has_default_sort_func
= wxgtk_tree_model_has_default_sort_func
;
412 wxgtk_tree_model_init (GtkWxTreeModel
*tree_model
)
414 tree_model
->internal
= NULL
;
415 tree_model
->stamp
= g_random_int();
419 wxgtk_tree_model_finalize (GObject
*object
)
422 (* list_parent_class
->finalize
) (object
);
427 //-----------------------------------------------------------------------------
428 // implement callbacks from wxGtkTreeModel class by letting
429 // them call the methods of wxWidgets' wxDataViewModel
430 //-----------------------------------------------------------------------------
432 static GtkTreeModelFlags
433 wxgtk_tree_model_get_flags (GtkTreeModel
*tree_model
)
435 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
436 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), (GtkTreeModelFlags
)0 );
438 return wxtree_model
->internal
->get_flags();
442 wxgtk_tree_model_get_n_columns (GtkTreeModel
*tree_model
)
444 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
445 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), 0);
447 return wxtree_model
->internal
->GetDataViewModel()->GetColumnCount();
451 wxgtk_tree_model_get_column_type (GtkTreeModel
*tree_model
,
454 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
455 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), G_TYPE_INVALID
);
457 GType gtype
= G_TYPE_INVALID
;
459 wxString wxtype
= wxtree_model
->internal
->GetDataViewModel()->GetColumnType( (unsigned int) index
);
461 if (wxtype
== wxT("string"))
462 gtype
= G_TYPE_STRING
;
465 gtype
= G_TYPE_STRING
;
466 // wxFAIL_MSG( _T("non-string columns not supported yet") );
473 wxgtk_tree_model_get_iter (GtkTreeModel
*tree_model
,
477 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
478 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), FALSE
);
479 g_return_val_if_fail (gtk_tree_path_get_depth (path
) > 0, FALSE
);
481 return wxtree_model
->internal
->get_iter( iter
, path
);
485 wxgtk_tree_model_get_path (GtkTreeModel
*tree_model
,
488 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
489 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), NULL
);
490 g_return_val_if_fail (iter
->stamp
== GTK_WX_TREE_MODEL (wxtree_model
)->stamp
, NULL
);
492 return wxtree_model
->internal
->get_path( iter
);
496 wxgtk_tree_model_get_value (GtkTreeModel
*tree_model
,
501 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
502 g_return_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
) );
504 wxDataViewModel
*model
= wxtree_model
->internal
->GetDataViewModel();
505 wxString mtype
= model
->GetColumnType( (unsigned int) column
);
506 if (mtype
== wxT("string"))
509 g_value_init( value
, G_TYPE_STRING
);
510 wxDataViewItem
item( (void*) iter
->user_data
);
511 model
->GetValue( variant
, item
, (unsigned int) column
);
513 g_value_set_string( value
, variant
.GetString().utf8_str() );
517 wxFAIL_MSG( _T("non-string columns not supported yet") );
522 wxgtk_tree_model_iter_next (GtkTreeModel
*tree_model
,
525 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
526 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), FALSE
);
527 g_return_val_if_fail (wxtree_model
->stamp
== iter
->stamp
, FALSE
);
529 return wxtree_model
->internal
->iter_next( iter
);
533 wxgtk_tree_model_iter_children (GtkTreeModel
*tree_model
,
537 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
538 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), FALSE
);
539 g_return_val_if_fail (wxtree_model
->stamp
== parent
->stamp
, FALSE
);
541 return wxtree_model
->internal
->iter_children( iter
, parent
);
545 wxgtk_tree_model_iter_has_child (GtkTreeModel
*tree_model
,
548 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
549 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), FALSE
);
550 g_return_val_if_fail (wxtree_model
->stamp
== iter
->stamp
, FALSE
);
552 return wxtree_model
->internal
->iter_has_child( iter
);
556 wxgtk_tree_model_iter_n_children (GtkTreeModel
*tree_model
,
559 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
560 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), FALSE
);
561 g_return_val_if_fail (wxtree_model
->stamp
== iter
->stamp
, 0);
563 return wxtree_model
->internal
->iter_n_children( iter
);
567 wxgtk_tree_model_iter_nth_child (GtkTreeModel
*tree_model
,
572 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
573 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), FALSE
);
575 return wxtree_model
->internal
->iter_nth_child( iter
, parent
, n
);
579 wxgtk_tree_model_iter_parent (GtkTreeModel
*tree_model
,
583 GtkWxTreeModel
*wxtree_model
= (GtkWxTreeModel
*) tree_model
;
584 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model
), FALSE
);
585 g_return_val_if_fail (wxtree_model
->stamp
== child
->stamp
, FALSE
);
587 return wxtree_model
->internal
->iter_parent( iter
, child
);
591 gboolean
wxgtk_tree_model_get_sort_column_id (GtkTreeSortable
*sortable
,
592 gint
*sort_column_id
,
595 GtkWxTreeModel
*tree_model
= (GtkWxTreeModel
*) sortable
;
597 g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (sortable
), FALSE
);
599 if (!tree_model
->internal
->IsSorted())
602 *sort_column_id
= -1;
609 *sort_column_id
= tree_model
->internal
->GetSortColumn();
612 *order
= tree_model
->internal
->GetSortOrder();
617 wxDataViewColumn
*gs_lastLeftClickHeader
= NULL
;
619 void wxgtk_tree_model_set_sort_column_id (GtkTreeSortable
*sortable
,
623 GtkWxTreeModel
*tree_model
= (GtkWxTreeModel
*) sortable
;
624 g_return_if_fail (GTK_IS_WX_TREE_MODEL (sortable
) );
626 tree_model
->internal
->SetDataViewSortColumn( gs_lastLeftClickHeader
);
628 if ((sort_column_id
!= (gint
) tree_model
->internal
->GetSortColumn()) ||
629 (order
!= tree_model
->internal
->GetSortOrder()))
631 tree_model
->internal
->SetSortColumn( sort_column_id
);
632 tree_model
->internal
->SetSortOrder( order
);
634 gtk_tree_sortable_sort_column_changed (sortable
);
636 tree_model
->internal
->GetDataViewModel()->Resort();
639 if (gs_lastLeftClickHeader
)
641 wxDataViewCtrl
*dv
= tree_model
->internal
->GetOwner();
642 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
, dv
->GetId() );
643 event
.SetDataViewColumn( gs_lastLeftClickHeader
);
644 event
.SetModel( dv
->GetModel() );
645 dv
->GetEventHandler()->ProcessEvent( event
);
648 gs_lastLeftClickHeader
= NULL
;
651 void wxgtk_tree_model_set_sort_func (GtkTreeSortable
*sortable
,
653 GtkTreeIterCompareFunc func
,
655 GtkDestroyNotify destroy
)
657 g_return_if_fail (GTK_IS_WX_TREE_MODEL (sortable
) );
658 g_return_if_fail (func
!= NULL
);
661 void wxgtk_tree_model_set_default_sort_func (GtkTreeSortable
*sortable
,
662 GtkTreeIterCompareFunc func
,
664 GtkDestroyNotify destroy
)
666 g_return_if_fail (GTK_IS_WX_TREE_MODEL (sortable
) );
667 g_return_if_fail (func
!= NULL
);
669 wxPrintf( "wxgtk_tree_model_set_default_sort_func\n" );
672 gboolean
wxgtk_tree_model_has_default_sort_func (GtkTreeSortable
*sortable
)
677 //-----------------------------------------------------------------------------
678 // define new GTK+ class wxGtkRendererRenderer
679 //-----------------------------------------------------------------------------
683 #define GTK_TYPE_WX_CELL_RENDERER (gtk_wx_cell_renderer_get_type ())
684 #define GTK_WX_CELL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_WX_CELL_RENDERER, GtkWxCellRenderer))
685 #define GTK_WX_CELL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WX_CELL_RENDERER, GtkWxCellRendererClass))
686 #define GTK_IS_WX_CELL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_WX_CELL_RENDERER))
687 #define GTK_IS_WX_CELL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WX_CELL_RENDERER))
688 #define GTK_WX_CELL_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WX_CELL_RENDERER, GtkWxCellRendererClass))
690 GType
gtk_wx_cell_renderer_get_type (void);
692 typedef struct _GtkWxCellRenderer GtkWxCellRenderer
;
693 typedef struct _GtkWxCellRendererClass GtkWxCellRendererClass
;
695 struct _GtkWxCellRenderer
697 GtkCellRenderer parent
;
700 wxDataViewCustomRenderer
*cell
;
704 struct _GtkWxCellRendererClass
706 GtkCellRendererClass cell_parent_class
;
710 static GtkCellRenderer
*gtk_wx_cell_renderer_new (void);
711 static void gtk_wx_cell_renderer_init (
712 GtkWxCellRenderer
*cell
);
713 static void gtk_wx_cell_renderer_class_init(
714 GtkWxCellRendererClass
*klass
);
715 static void gtk_wx_cell_renderer_finalize (
717 static void gtk_wx_cell_renderer_get_size (
718 GtkCellRenderer
*cell
,
720 GdkRectangle
*rectangle
,
725 static void gtk_wx_cell_renderer_render (
726 GtkCellRenderer
*cell
,
729 GdkRectangle
*background_area
,
730 GdkRectangle
*cell_area
,
731 GdkRectangle
*expose_area
,
732 GtkCellRendererState flags
);
733 static gboolean
gtk_wx_cell_renderer_activate(
734 GtkCellRenderer
*cell
,
738 GdkRectangle
*background_area
,
739 GdkRectangle
*cell_area
,
740 GtkCellRendererState flags
);
741 static GtkCellEditable
*gtk_wx_cell_renderer_start_editing(
742 GtkCellRenderer
*cell
,
746 GdkRectangle
*background_area
,
747 GdkRectangle
*cell_area
,
748 GtkCellRendererState flags
);
751 static GObjectClass
*cell_parent_class
= NULL
;
756 gtk_wx_cell_renderer_get_type (void)
758 static GType cell_wx_type
= 0;
762 const GTypeInfo cell_wx_info
=
764 sizeof (GtkWxCellRendererClass
),
765 NULL
, /* base_init */
766 NULL
, /* base_finalize */
767 (GClassInitFunc
) gtk_wx_cell_renderer_class_init
,
768 NULL
, /* class_finalize */
769 NULL
, /* class_data */
770 sizeof (GtkWxCellRenderer
),
772 (GInstanceInitFunc
) gtk_wx_cell_renderer_init
,
775 cell_wx_type
= g_type_register_static( GTK_TYPE_CELL_RENDERER
,
776 "GtkWxCellRenderer", &cell_wx_info
, (GTypeFlags
)0 );
783 gtk_wx_cell_renderer_init (GtkWxCellRenderer
*cell
)
786 cell
->last_click
= 0;
790 gtk_wx_cell_renderer_class_init (GtkWxCellRendererClass
*klass
)
792 GObjectClass
*object_class
= G_OBJECT_CLASS (klass
);
793 GtkCellRendererClass
*cell_class
= GTK_CELL_RENDERER_CLASS (klass
);
795 cell_parent_class
= (GObjectClass
*) g_type_class_peek_parent (klass
);
797 object_class
->finalize
= gtk_wx_cell_renderer_finalize
;
799 cell_class
->get_size
= gtk_wx_cell_renderer_get_size
;
800 cell_class
->render
= gtk_wx_cell_renderer_render
;
801 cell_class
->activate
= gtk_wx_cell_renderer_activate
;
802 cell_class
->start_editing
= gtk_wx_cell_renderer_start_editing
;
806 gtk_wx_cell_renderer_finalize (GObject
*object
)
809 (* G_OBJECT_CLASS (cell_parent_class
)->finalize
) (object
);
813 gtk_wx_cell_renderer_new (void)
815 return (GtkCellRenderer
*) g_object_new (GTK_TYPE_WX_CELL_RENDERER
, NULL
);
820 static GtkCellEditable
*gtk_wx_cell_renderer_start_editing(
821 GtkCellRenderer
*renderer
,
825 GdkRectangle
*background_area
,
826 GdkRectangle
*cell_area
,
827 GtkCellRendererState flags
)
829 GtkWxCellRenderer
*wxrenderer
= (GtkWxCellRenderer
*) renderer
;
830 wxDataViewCustomRenderer
*cell
= wxrenderer
->cell
;
831 if (!cell
->HasEditorCtrl())
835 gtk_wx_cell_renderer_get_size (renderer
, widget
, cell_area
,
841 rect
.x
+= cell_area
->x
;
842 rect
.y
+= cell_area
->y
;
843 // rect.width -= renderer->xpad * 2;
844 // rect.height -= renderer->ypad * 2;
846 // wxRect renderrect( rect.x, rect.y, rect.width, rect.height );
847 wxRect
renderrect( cell_area
->x
, cell_area
->y
, cell_area
->width
, cell_area
->height
);
849 GtkTreePath
*treepath
= gtk_tree_path_new_from_string( path
);
851 cell
->GetOwner()->GetOwner()->GtkGetInternal()->get_iter( &iter
, treepath
);
852 wxDataViewItem
item( (void*) iter
.user_data
);
853 gtk_tree_path_free( treepath
);
855 cell
->StartEditing( item
, renderrect
);
861 gtk_wx_cell_renderer_get_size (GtkCellRenderer
*renderer
,
863 GdkRectangle
*cell_area
,
869 GtkWxCellRenderer
*wxrenderer
= (GtkWxCellRenderer
*) renderer
;
870 wxDataViewCustomRenderer
*cell
= wxrenderer
->cell
;
872 wxSize size
= cell
->GetSize();
874 gint calc_width
= (gint
) renderer
->xpad
* 2 + size
.x
;
875 gint calc_height
= (gint
) renderer
->ypad
* 2 + size
.y
;
882 if (cell_area
&& size
.x
> 0 && size
.y
> 0)
886 *x_offset
= (gint
)((renderer
->xalign
*
887 (cell_area
->width
- calc_width
- 2 * renderer
->xpad
)));
888 *x_offset
= MAX (*x_offset
, 0) + renderer
->xpad
;
892 *y_offset
= (gint
)((renderer
->yalign
*
893 (cell_area
->height
- calc_height
- 2 * renderer
->ypad
)));
894 *y_offset
= MAX (*y_offset
, 0) + renderer
->ypad
;
902 *height
= calc_height
;
906 gtk_wx_cell_renderer_render (GtkCellRenderer
*renderer
,
909 GdkRectangle
*background_area
,
910 GdkRectangle
*cell_area
,
911 GdkRectangle
*expose_area
,
912 GtkCellRendererState flags
)
915 GtkWxCellRenderer
*wxrenderer
= (GtkWxCellRenderer
*) renderer
;
916 wxDataViewCustomRenderer
*cell
= wxrenderer
->cell
;
918 cell
->window
= window
;
919 cell
->widget
= widget
;
920 cell
->background_area
= (void*) background_area
;
921 cell
->cell_area
= (void*) cell_area
;
922 cell
->expose_area
= (void*) expose_area
;
923 cell
->flags
= (int) flags
;
926 gtk_wx_cell_renderer_get_size (renderer
, widget
, cell_area
,
932 rect
.x
+= cell_area
->x
;
933 rect
.y
+= cell_area
->y
;
934 rect
.width
-= renderer
->xpad
* 2;
935 rect
.height
-= renderer
->ypad
* 2;
938 if (gdk_rectangle_intersect (expose_area
, &rect
, &dummy
))
940 wxRect
renderrect( rect
.x
, rect
.y
, rect
.width
, rect
.height
);
941 wxWindowDC
* dc
= (wxWindowDC
*) cell
->GetDC();
943 wxGTKWindowDCImpl
*impldc
= (wxGTKWindowDCImpl
*) dc
->GetImpl();
944 if (impldc
->m_window
== NULL
)
946 impldc
->m_window
= window
;
950 if (dc
->m_window
== NULL
)
952 dc
->m_window
= window
;
958 if (flags
& GTK_CELL_RENDERER_SELECTED
)
959 state
|= wxDATAVIEW_CELL_SELECTED
;
960 if (flags
& GTK_CELL_RENDERER_PRELIT
)
961 state
|= wxDATAVIEW_CELL_PRELIT
;
962 if (flags
& GTK_CELL_RENDERER_INSENSITIVE
)
963 state
|= wxDATAVIEW_CELL_INSENSITIVE
;
964 if (flags
& GTK_CELL_RENDERER_INSENSITIVE
)
965 state
|= wxDATAVIEW_CELL_INSENSITIVE
;
966 if (flags
& GTK_CELL_RENDERER_FOCUSED
)
967 state
|= wxDATAVIEW_CELL_FOCUSED
;
968 cell
->Render( renderrect
, dc
, state
);
973 gtk_wx_cell_renderer_activate(
974 GtkCellRenderer
*renderer
,
978 GdkRectangle
*background_area
,
979 GdkRectangle
*cell_area
,
980 GtkCellRendererState flags
)
982 GtkWxCellRenderer
*wxrenderer
= (GtkWxCellRenderer
*) renderer
;
983 wxDataViewCustomRenderer
*cell
= wxrenderer
->cell
;
986 gtk_wx_cell_renderer_get_size (renderer
, widget
, cell_area
,
992 rect
.x
+= cell_area
->x
;
993 rect
.y
+= cell_area
->y
;
994 rect
.width
-= renderer
->xpad
* 2;
995 rect
.height
-= renderer
->ypad
* 2;
997 wxRect
renderrect( rect
.x
, rect
.y
, rect
.width
, rect
.height
);
999 wxDataViewModel
*model
= cell
->GetOwner()->GetOwner()->GetModel();
1001 GtkTreePath
*treepath
= gtk_tree_path_new_from_string( path
);
1004 cell
->GetOwner()->GetOwner()->GtkGetInternal()->get_iter( &iter
, treepath
);
1005 wxDataViewItem
item( iter
.user_data
);
1006 gtk_tree_path_free( treepath
);
1008 unsigned int model_col
= cell
->GetOwner()->GetModelColumn();
1014 // activated by <ENTER>
1015 if (cell
->Activate( renderrect
, model
, item
, model_col
))
1020 else if (event
->type
== GDK_BUTTON_PRESS
)
1022 GdkEventButton
*button_event
= (GdkEventButton
*) event
;
1023 wxPoint
pt( ((int) button_event
->x
) - renderrect
.x
,
1024 ((int) button_event
->y
) - renderrect
.y
);
1027 if (button_event
->button
== 1)
1029 if (cell
->LeftClick( pt
, renderrect
, model
, item
, model_col
))
1031 // TODO: query system double-click time
1032 if (button_event
->time
- wxrenderer
->last_click
< 400)
1033 if (cell
->Activate( renderrect
, model
, item
, model_col
))
1036 if (button_event
->button
== 3)
1038 if (cell
->RightClick( pt
, renderrect
, model
, item
, model_col
))
1042 wxrenderer
->last_click
= button_event
->time
;
1050 // ---------------------------------------------------------
1051 // wxGtkDataViewModelNotifier
1052 // ---------------------------------------------------------
1054 class wxGtkDataViewModelNotifier
: public wxDataViewModelNotifier
1057 wxGtkDataViewModelNotifier( GtkWxTreeModel
*wxgtk_model
,
1058 wxDataViewModel
*wx_model
,
1059 wxDataViewCtrl
*ctrl
);
1060 ~wxGtkDataViewModelNotifier();
1062 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
1063 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
1064 virtual bool ItemChanged( const wxDataViewItem
&item
);
1065 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
1066 virtual bool Cleared();
1067 virtual void Resort();
1069 GtkWxTreeModel
*m_wxgtk_model
;
1070 wxDataViewModel
*m_wx_model
;
1071 wxDataViewCtrl
*m_owner
;
1074 // ---------------------------------------------------------
1075 // wxGtkDataViewListModelNotifier
1076 // ---------------------------------------------------------
1078 wxGtkDataViewModelNotifier::wxGtkDataViewModelNotifier(
1079 GtkWxTreeModel
* wxgtk_model
, wxDataViewModel
*wx_model
,
1080 wxDataViewCtrl
*ctrl
)
1082 m_wxgtk_model
= wxgtk_model
;
1083 m_wx_model
= wx_model
;
1087 wxGtkDataViewModelNotifier::~wxGtkDataViewModelNotifier()
1090 m_wxgtk_model
= NULL
;
1093 bool wxGtkDataViewModelNotifier::ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
)
1095 m_owner
->GtkGetInternal()->ItemAdded( parent
, item
);
1098 iter
.stamp
= m_wxgtk_model
->stamp
;
1099 iter
.user_data
= (gpointer
) item
.GetID();
1101 GtkTreePath
*path
= wxgtk_tree_model_get_path(
1102 GTK_TREE_MODEL(m_wxgtk_model
), &iter
);
1103 gtk_tree_model_row_inserted(
1104 GTK_TREE_MODEL(m_wxgtk_model
), path
, &iter
);
1105 gtk_tree_path_free (path
);
1110 bool wxGtkDataViewModelNotifier::ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
)
1113 iter
.stamp
= m_wxgtk_model
->stamp
;
1114 iter
.user_data
= (gpointer
) item
.GetID();
1116 GtkTreePath
*path
= wxgtk_tree_model_get_path(
1117 GTK_TREE_MODEL(m_wxgtk_model
), &iter
);
1118 gtk_tree_model_row_deleted(
1119 GTK_TREE_MODEL(m_wxgtk_model
), path
);
1120 gtk_tree_path_free (path
);
1122 m_owner
->GtkGetInternal()->ItemDeleted( parent
, item
);
1127 void wxGtkDataViewModelNotifier::Resort()
1129 m_owner
->GtkGetInternal()->Resort();
1132 bool wxGtkDataViewModelNotifier::ItemChanged( const wxDataViewItem
&item
)
1135 iter
.stamp
= m_wxgtk_model
->stamp
;
1136 iter
.user_data
= (gpointer
) item
.GetID();
1138 GtkTreePath
*path
= wxgtk_tree_model_get_path(
1139 GTK_TREE_MODEL(m_wxgtk_model
), &iter
);
1140 gtk_tree_model_row_changed(
1141 GTK_TREE_MODEL(m_wxgtk_model
), path
, &iter
);
1142 gtk_tree_path_free (path
);
1144 m_owner
->GtkGetInternal()->ItemChanged( item
);
1149 bool wxGtkDataViewModelNotifier::ValueChanged( const wxDataViewItem
&item
, unsigned int model_col
)
1151 // This adds GTK+'s missing MVC logic for ValueChanged
1153 for (index
= 0; index
< m_owner
->GetColumnCount(); index
++)
1155 wxDataViewColumn
*column
= m_owner
->GetColumn( index
);
1156 if (column
->GetModelColumn() == model_col
)
1158 GtkTreeView
*widget
= GTK_TREE_VIEW(m_owner
->m_treeview
);
1159 GtkTreeViewColumn
*gcolumn
= GTK_TREE_VIEW_COLUMN(column
->GetGtkHandle());
1163 iter
.stamp
= m_wxgtk_model
->stamp
;
1164 iter
.user_data
= (gpointer
) item
.GetID();
1165 GtkTreePath
*path
= wxgtk_tree_model_get_path(
1166 GTK_TREE_MODEL(m_wxgtk_model
), &iter
);
1167 GdkRectangle cell_area
;
1168 gtk_tree_view_get_cell_area( widget
, path
, gcolumn
, &cell_area
);
1169 gtk_tree_path_free( path
);
1171 GtkAdjustment
* hadjust
= gtk_tree_view_get_hadjustment( widget
);
1172 double d
= gtk_adjustment_get_value( hadjust
);
1173 int xdiff
= (int) d
;
1175 int ydiff
= gcolumn
->button
->allocation
.height
;
1177 gtk_widget_queue_draw_area( GTK_WIDGET(widget
),
1178 cell_area
.x
- xdiff
, ydiff
+ cell_area
.y
, cell_area
.width
, cell_area
.height
);
1180 m_owner
->GtkGetInternal()->ValueChanged( item
, model_col
);
1189 bool wxGtkDataViewModelNotifier::Cleared()
1191 // TODO: delete everything
1193 m_owner
->GtkGetInternal()->Cleared();
1198 // ---------------------------------------------------------
1199 // wxDataViewRenderer
1200 // ---------------------------------------------------------
1202 static gpointer s_user_data
= NULL
;
1205 wxgtk_cell_editable_editing_done( GtkCellEditable
*editable
,
1206 wxDataViewRenderer
*wxrenderer
)
1208 wxDataViewColumn
*column
= wxrenderer
->GetOwner();
1209 wxDataViewCtrl
*dv
= column
->GetOwner();
1210 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
, dv
->GetId() );
1211 event
.SetDataViewColumn( column
);
1212 event
.SetModel( dv
->GetModel() );
1213 wxDataViewItem
item( s_user_data
);
1214 event
.SetItem( item
);
1215 dv
->GetEventHandler()->ProcessEvent( event
);
1219 wxgtk_renderer_editing_started( GtkCellRenderer
*cell
, GtkCellEditable
*editable
,
1220 gchar
*path
, wxDataViewRenderer
*wxrenderer
)
1222 wxDataViewColumn
*column
= wxrenderer
->GetOwner();
1223 wxDataViewCtrl
*dv
= column
->GetOwner();
1224 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
, dv
->GetId() );
1225 event
.SetDataViewColumn( column
);
1226 event
.SetModel( dv
->GetModel() );
1227 GtkTreePath
*tree_path
= gtk_tree_path_new_from_string( path
);
1229 dv
->GtkGetInternal()->get_iter( &iter
, tree_path
);
1230 gtk_tree_path_free( tree_path
);
1231 wxDataViewItem
item( iter
.user_data
);
1232 event
.SetItem( item
);
1233 dv
->GetEventHandler()->ProcessEvent( event
);
1235 if (GTK_IS_CELL_EDITABLE(editable
))
1237 s_user_data
= iter
.user_data
;
1239 g_signal_connect (GTK_CELL_EDITABLE (editable
), "editing_done",
1240 G_CALLBACK (wxgtk_cell_editable_editing_done
),
1241 (gpointer
) wxrenderer
);
1247 IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer
, wxDataViewRendererBase
)
1249 wxDataViewRenderer::wxDataViewRenderer( const wxString
&varianttype
, wxDataViewCellMode mode
,
1251 wxDataViewRendererBase( varianttype
, mode
, align
)
1255 // NOTE: SetMode() and SetAlignment() needs to be called in the renderer's ctor,
1256 // after the m_renderer pointer has been initialized
1259 void wxDataViewRenderer::GtkInitHandlers()
1261 if (!gtk_check_version(2,6,0))
1263 g_signal_connect (GTK_CELL_RENDERER(m_renderer
), "editing_started",
1264 G_CALLBACK (wxgtk_renderer_editing_started
),
1269 void wxDataViewRenderer::SetMode( wxDataViewCellMode mode
)
1271 GtkCellRendererMode gtkMode
;
1274 case wxDATAVIEW_CELL_INERT
:
1275 gtkMode
= GTK_CELL_RENDERER_MODE_INERT
;
1277 case wxDATAVIEW_CELL_ACTIVATABLE
:
1278 gtkMode
= GTK_CELL_RENDERER_MODE_ACTIVATABLE
;
1280 case wxDATAVIEW_CELL_EDITABLE
:
1281 gtkMode
= GTK_CELL_RENDERER_MODE_EDITABLE
;
1285 // This value is most often ignored in GtkTreeView
1286 GValue gvalue
= { 0, };
1287 g_value_init( &gvalue
, gtk_cell_renderer_mode_get_type() );
1288 g_value_set_enum( &gvalue
, gtkMode
);
1289 g_object_set_property( G_OBJECT(m_renderer
), "mode", &gvalue
);
1290 g_value_unset( &gvalue
);
1293 wxDataViewCellMode
wxDataViewRenderer::GetMode() const
1295 wxDataViewCellMode ret
;
1298 g_object_get( G_OBJECT(m_renderer
), "mode", &gvalue
, NULL
);
1300 switch (g_value_get_enum(&gvalue
))
1302 case GTK_CELL_RENDERER_MODE_INERT
:
1303 ret
= wxDATAVIEW_CELL_INERT
;
1305 case GTK_CELL_RENDERER_MODE_ACTIVATABLE
:
1306 ret
= wxDATAVIEW_CELL_ACTIVATABLE
;
1308 case GTK_CELL_RENDERER_MODE_EDITABLE
:
1309 ret
= wxDATAVIEW_CELL_EDITABLE
;
1313 g_value_unset( &gvalue
);
1318 void wxDataViewRenderer::SetAlignment( int align
)
1320 // horizontal alignment:
1322 gfloat xalign
= 0.0;
1323 if (align
& wxALIGN_RIGHT
)
1325 else if (align
& wxALIGN_CENTER_HORIZONTAL
)
1328 GValue gvalue
= { 0, };
1329 g_value_init( &gvalue
, G_TYPE_FLOAT
);
1330 g_value_set_float( &gvalue
, xalign
);
1331 g_object_set_property( G_OBJECT(m_renderer
), "xalign", &gvalue
);
1332 g_value_unset( &gvalue
);
1334 // vertical alignment:
1336 gfloat yalign
= 0.0;
1337 if (align
& wxALIGN_BOTTOM
)
1339 else if (align
& wxALIGN_CENTER_VERTICAL
)
1342 GValue gvalue2
= { 0, };
1343 g_value_init( &gvalue2
, G_TYPE_FLOAT
);
1344 g_value_set_float( &gvalue2
, yalign
);
1345 g_object_set_property( G_OBJECT(m_renderer
), "yalign", &gvalue2
);
1346 g_value_unset( &gvalue2
);
1349 int wxDataViewRenderer::GetAlignment() const
1354 // horizontal alignment:
1356 g_object_get( G_OBJECT(m_renderer
), "xalign", &gvalue
, NULL
);
1357 float xalign
= g_value_get_float( &gvalue
);
1359 ret
|= wxALIGN_LEFT
;
1360 else if (xalign
== 0.5)
1361 ret
|= wxALIGN_CENTER_HORIZONTAL
;
1363 ret
|= wxALIGN_RIGHT
;
1364 g_value_unset( &gvalue
);
1367 // vertical alignment:
1369 g_object_get( G_OBJECT(m_renderer
), "yalign", &gvalue
, NULL
);
1370 float yalign
= g_value_get_float( &gvalue
);
1373 else if (yalign
== 0.5)
1374 ret
|= wxALIGN_CENTER_VERTICAL
;
1376 ret
|= wxALIGN_BOTTOM
;
1377 g_value_unset( &gvalue
);
1384 // ---------------------------------------------------------
1385 // wxDataViewTextRenderer
1386 // ---------------------------------------------------------
1389 static void wxGtkTextRendererEditedCallback( GtkCellRendererText
*renderer
,
1390 gchar
*arg1
, gchar
*arg2
, gpointer user_data
);
1393 static void wxGtkTextRendererEditedCallback( GtkCellRendererText
*renderer
,
1394 gchar
*arg1
, gchar
*arg2
, gpointer user_data
)
1396 wxDataViewTextRenderer
*cell
= (wxDataViewTextRenderer
*) user_data
;
1398 wxString tmp
= wxGTK_CONV_BACK_FONT(arg2
, cell
->GetOwner()->GetOwner()->GetFont());
1399 wxVariant value
= tmp
;
1400 if (!cell
->Validate( value
))
1403 wxDataViewModel
*model
= cell
->GetOwner()->GetOwner()->GetModel();
1405 GtkTreePath
*path
= gtk_tree_path_new_from_string( arg1
);
1407 cell
->GetOwner()->GetOwner()->GtkGetInternal()->get_iter( &iter
, path
);
1408 wxDataViewItem
item( (void*) iter
.user_data
);;
1409 gtk_tree_path_free( path
);
1411 unsigned int model_col
= cell
->GetOwner()->GetModelColumn();
1413 model
->SetValue( value
, item
, model_col
);
1414 model
->ValueChanged( item
, model_col
);
1417 IMPLEMENT_CLASS(wxDataViewTextRenderer
, wxDataViewRenderer
)
1419 wxDataViewTextRenderer::wxDataViewTextRenderer( const wxString
&varianttype
, wxDataViewCellMode mode
,
1421 wxDataViewRenderer( varianttype
, mode
, align
)
1423 m_renderer
= (GtkCellRenderer
*) gtk_cell_renderer_text_new();
1425 if (mode
& wxDATAVIEW_CELL_EDITABLE
)
1427 GValue gvalue
= { 0, };
1428 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
1429 g_value_set_boolean( &gvalue
, true );
1430 g_object_set_property( G_OBJECT(m_renderer
), "editable", &gvalue
);
1431 g_value_unset( &gvalue
);
1433 g_signal_connect_after( m_renderer
, "edited", G_CALLBACK(wxGtkTextRendererEditedCallback
), this );
1439 SetAlignment(align
);
1442 bool wxDataViewTextRenderer::SetValue( const wxVariant
&value
)
1444 wxString tmp
= value
;
1446 GValue gvalue
= { 0, };
1447 g_value_init( &gvalue
, G_TYPE_STRING
);
1448 g_value_set_string( &gvalue
, wxGTK_CONV( tmp
) );
1449 g_object_set_property( G_OBJECT(m_renderer
), "text", &gvalue
);
1450 g_value_unset( &gvalue
);
1455 bool wxDataViewTextRenderer::GetValue( wxVariant
&value
) const
1457 GValue gvalue
= { 0, };
1458 g_value_init( &gvalue
, G_TYPE_STRING
);
1459 g_object_get_property( G_OBJECT(m_renderer
), "text", &gvalue
);
1460 wxString tmp
= wxGTK_CONV_BACK( g_value_get_string( &gvalue
) );
1461 g_value_unset( &gvalue
);
1468 void wxDataViewTextRenderer::SetAlignment( int align
)
1470 wxDataViewRenderer::SetAlignment(align
);
1472 if (gtk_check_version(2,10,0))
1475 // horizontal alignment:
1476 PangoAlignment pangoAlign
= PANGO_ALIGN_LEFT
;
1477 if (align
& wxALIGN_RIGHT
)
1478 pangoAlign
= PANGO_ALIGN_RIGHT
;
1479 else if (align
& wxALIGN_CENTER_HORIZONTAL
)
1480 pangoAlign
= PANGO_ALIGN_CENTER
;
1482 GValue gvalue
= { 0, };
1483 g_value_init( &gvalue
, gtk_cell_renderer_mode_get_type() );
1484 g_value_set_enum( &gvalue
, pangoAlign
);
1485 g_object_set_property( G_OBJECT(m_renderer
), "alignment", &gvalue
);
1486 g_value_unset( &gvalue
);
1489 // ---------------------------------------------------------
1490 // wxDataViewTextRendererAttr
1491 // ---------------------------------------------------------
1493 IMPLEMENT_CLASS(wxDataViewTextRendererAttr
,wxDataViewTextRenderer
)
1495 wxDataViewTextRendererAttr::wxDataViewTextRendererAttr( const wxString
&varianttype
,
1496 wxDataViewCellMode mode
, int align
) :
1497 wxDataViewTextRenderer( varianttype
, mode
, align
)
1501 // ---------------------------------------------------------
1502 // wxDataViewBitmapRenderer
1503 // ---------------------------------------------------------
1505 IMPLEMENT_CLASS(wxDataViewBitmapRenderer
, wxDataViewRenderer
)
1507 wxDataViewBitmapRenderer::wxDataViewBitmapRenderer( const wxString
&varianttype
, wxDataViewCellMode mode
,
1509 wxDataViewRenderer( varianttype
, mode
, align
)
1511 m_renderer
= (GtkCellRenderer
*) gtk_cell_renderer_pixbuf_new();
1514 SetAlignment(align
);
1517 bool wxDataViewBitmapRenderer::SetValue( const wxVariant
&value
)
1519 if (value
.GetType() == wxT("wxBitmap"))
1524 // This may create a Pixbuf representation in the
1525 // wxBitmap object (and it will stay there)
1526 GdkPixbuf
*pixbuf
= bitmap
.GetPixbuf();
1528 GValue gvalue
= { 0, };
1529 g_value_init( &gvalue
, G_TYPE_OBJECT
);
1530 g_value_set_object( &gvalue
, pixbuf
);
1531 g_object_set_property( G_OBJECT(m_renderer
), "pixbuf", &gvalue
);
1532 g_value_unset( &gvalue
);
1537 if (value
.GetType() == wxT("wxIcon"))
1542 // This may create a Pixbuf representation in the
1543 // wxBitmap object (and it will stay there)
1544 GdkPixbuf
*pixbuf
= bitmap
.GetPixbuf();
1546 GValue gvalue
= { 0, };
1547 g_value_init( &gvalue
, G_TYPE_OBJECT
);
1548 g_value_set_object( &gvalue
, pixbuf
);
1549 g_object_set_property( G_OBJECT(m_renderer
), "pixbuf", &gvalue
);
1550 g_value_unset( &gvalue
);
1558 bool wxDataViewBitmapRenderer::GetValue( wxVariant
&value
) const
1563 // ---------------------------------------------------------
1564 // wxDataViewToggleRenderer
1565 // ---------------------------------------------------------
1568 static void wxGtkToggleRendererToggledCallback( GtkCellRendererToggle
*renderer
,
1569 gchar
*path
, gpointer user_data
);
1572 static void wxGtkToggleRendererToggledCallback( GtkCellRendererToggle
*renderer
,
1573 gchar
*path
, gpointer user_data
)
1575 wxDataViewToggleRenderer
*cell
= (wxDataViewToggleRenderer
*) user_data
;
1578 GValue gvalue
= { 0, };
1579 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
1580 g_object_get_property( G_OBJECT(renderer
), "active", &gvalue
);
1581 bool tmp
= g_value_get_boolean( &gvalue
);
1582 g_value_unset( &gvalue
);
1586 wxVariant value
= tmp
;
1587 if (!cell
->Validate( value
))
1590 wxDataViewModel
*model
= cell
->GetOwner()->GetOwner()->GetModel();
1592 GtkTreePath
*gtk_path
= gtk_tree_path_new_from_string( path
);
1594 cell
->GetOwner()->GetOwner()->GtkGetInternal()->get_iter( &iter
, gtk_path
);
1595 wxDataViewItem
item( (void*) iter
.user_data
);;
1596 gtk_tree_path_free( gtk_path
);
1598 unsigned int model_col
= cell
->GetOwner()->GetModelColumn();
1600 model
->SetValue( value
, item
, model_col
);
1601 model
->ValueChanged( item
, model_col
);
1604 IMPLEMENT_CLASS(wxDataViewToggleRenderer
, wxDataViewRenderer
)
1606 wxDataViewToggleRenderer::wxDataViewToggleRenderer( const wxString
&varianttype
,
1607 wxDataViewCellMode mode
, int align
) :
1608 wxDataViewRenderer( varianttype
, mode
, align
)
1610 m_renderer
= (GtkCellRenderer
*) gtk_cell_renderer_toggle_new();
1612 if (mode
& wxDATAVIEW_CELL_ACTIVATABLE
)
1614 g_signal_connect_after( m_renderer
, "toggled",
1615 G_CALLBACK(wxGtkToggleRendererToggledCallback
), this );
1619 GValue gvalue
= { 0, };
1620 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
1621 g_value_set_boolean( &gvalue
, false );
1622 g_object_set_property( G_OBJECT(m_renderer
), "activatable", &gvalue
);
1623 g_value_unset( &gvalue
);
1627 SetAlignment(align
);
1630 bool wxDataViewToggleRenderer::SetValue( const wxVariant
&value
)
1634 GValue gvalue
= { 0, };
1635 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
1636 g_value_set_boolean( &gvalue
, tmp
);
1637 g_object_set_property( G_OBJECT(m_renderer
), "active", &gvalue
);
1638 g_value_unset( &gvalue
);
1643 bool wxDataViewToggleRenderer::GetValue( wxVariant
&value
) const
1645 GValue gvalue
= { 0, };
1646 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
1647 g_object_get_property( G_OBJECT(m_renderer
), "active", &gvalue
);
1648 bool tmp
= g_value_get_boolean( &gvalue
);
1649 g_value_unset( &gvalue
);
1656 // ---------------------------------------------------------
1657 // wxDataViewCustomRenderer
1658 // ---------------------------------------------------------
1660 class wxDataViewCtrlDC
: public wxWindowDC
1663 wxDataViewCtrlDC( wxDataViewCtrl
*window
)
1666 wxGTKWindowDCImpl
*impl
= (wxGTKWindowDCImpl
*) GetImpl();
1668 GtkWidget
*widget
= window
->m_treeview
;
1670 impl
->m_window
= NULL
;
1672 impl
->m_context
= window
->GtkGetPangoDefaultContext();
1673 impl
->m_layout
= pango_layout_new( impl
->m_context
);
1674 impl
->m_fontdesc
= pango_font_description_copy( widget
->style
->font_desc
);
1676 impl
->m_cmap
= gtk_widget_get_colormap( widget
? widget
: window
->m_widget
);
1679 GtkWidget
*widget
= window
->m_treeview
;
1683 m_context
= window
->GtkGetPangoDefaultContext();
1684 m_layout
= pango_layout_new( m_context
);
1685 m_fontdesc
= pango_font_description_copy( widget
->style
->font_desc
);
1687 m_cmap
= gtk_widget_get_colormap( widget
? widget
: window
->m_widget
);
1689 // Set m_window later
1691 // m_owner = window;
1695 // ---------------------------------------------------------
1696 // wxDataViewCustomRenderer
1697 // ---------------------------------------------------------
1699 IMPLEMENT_CLASS(wxDataViewCustomRenderer
, wxDataViewRenderer
)
1701 wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString
&varianttype
,
1702 wxDataViewCellMode mode
, int align
,
1704 wxDataViewRenderer( varianttype
, mode
, align
)
1707 m_text_renderer
= NULL
;
1715 void wxDataViewCustomRenderer::RenderText( const wxString
&text
, int xoffset
, wxRect cell
, wxDC
*dc
, int state
)
1718 wxDataViewCtrl
*view
= GetOwner()->GetOwner();
1719 wxColour col
= (state
& wxDATAVIEW_CELL_SELECTED
) ?
1720 wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT
) :
1721 view
->GetForegroundColour();
1722 dc
->SetTextForeground(col
);
1723 dc
->DrawText( text
, cell
.x
+ xoffset
, cell
.y
+ ((cell
.height
- dc
->GetCharHeight()) / 2));
1725 if (!m_text_renderer
)
1726 m_text_renderer
= gtk_cell_renderer_text_new();
1728 GValue gvalue
= { 0, };
1729 g_value_init( &gvalue
, G_TYPE_STRING
);
1730 g_value_set_string( &gvalue
, wxGTK_CONV( text
) );
1731 g_object_set_property( G_OBJECT(m_text_renderer
), "text", &gvalue
);
1732 g_value_unset( &gvalue
);
1734 ((GdkRectangle
*) cell_area
)->x
+= xoffset
;
1735 ((GdkRectangle
*) cell_area
)->width
-= xoffset
;
1737 gtk_cell_renderer_render( m_text_renderer
,
1740 (GdkRectangle
*) background_area
,
1741 (GdkRectangle
*) cell_area
,
1742 (GdkRectangle
*) expose_area
,
1743 (GtkCellRendererState
) flags
);
1745 ((GdkRectangle
*) cell_area
)->x
-= xoffset
;
1746 ((GdkRectangle
*) cell_area
)->width
+= xoffset
;
1750 bool wxDataViewCustomRenderer::Init(wxDataViewCellMode mode
, int align
)
1752 GtkWxCellRenderer
*renderer
= (GtkWxCellRenderer
*) gtk_wx_cell_renderer_new();
1753 renderer
->cell
= this;
1755 m_renderer
= (GtkCellRenderer
*) renderer
;
1758 SetAlignment(align
);
1765 wxDataViewCustomRenderer::~wxDataViewCustomRenderer()
1770 if (m_text_renderer
)
1771 gtk_object_sink( GTK_OBJECT(m_text_renderer
) );
1774 wxDC
*wxDataViewCustomRenderer::GetDC()
1778 if (GetOwner() == NULL
)
1780 if (GetOwner()->GetOwner() == NULL
)
1782 m_dc
= new wxDataViewCtrlDC( GetOwner()->GetOwner() );
1788 // ---------------------------------------------------------
1789 // wxDataViewProgressRenderer
1790 // ---------------------------------------------------------
1792 IMPLEMENT_CLASS(wxDataViewProgressRenderer
, wxDataViewCustomRenderer
)
1794 wxDataViewProgressRenderer::wxDataViewProgressRenderer( const wxString
&label
,
1795 const wxString
&varianttype
, wxDataViewCellMode mode
, int align
) :
1796 wxDataViewCustomRenderer( varianttype
, mode
, align
, true )
1802 if (!gtk_check_version(2,6,0))
1804 m_renderer
= (GtkCellRenderer
*) gtk_cell_renderer_progress_new();
1806 GValue gvalue
= { 0, };
1807 g_value_init( &gvalue
, G_TYPE_STRING
);
1809 g_value_set_string( &gvalue
, wxGTK_CONV(m_label
) );
1810 g_object_set_property( G_OBJECT(m_renderer
), "text", &gvalue
);
1811 g_value_unset( &gvalue
);
1814 SetAlignment(align
);
1819 // Use custom cell code
1820 wxDataViewCustomRenderer::Init(mode
, align
);
1824 wxDataViewProgressRenderer::~wxDataViewProgressRenderer()
1828 bool wxDataViewProgressRenderer::SetValue( const wxVariant
&value
)
1831 if (!gtk_check_version(2,6,0))
1833 gint tmp
= (long) value
;
1834 GValue gvalue
= { 0, };
1835 g_value_init( &gvalue
, G_TYPE_INT
);
1836 g_value_set_int( &gvalue
, tmp
);
1837 g_object_set_property( G_OBJECT(m_renderer
), "value", &gvalue
);
1838 g_value_unset( &gvalue
);
1843 m_value
= (long) value
;
1845 if (m_value
< 0) m_value
= 0;
1846 if (m_value
> 100) m_value
= 100;
1852 bool wxDataViewProgressRenderer::GetValue( wxVariant
&value
) const
1857 bool wxDataViewProgressRenderer::Render( wxRect cell
, wxDC
*dc
, int state
)
1859 double pct
= (double)m_value
/ 100.0;
1861 bar
.width
= (int)(cell
.width
* pct
);
1862 dc
->SetPen( *wxTRANSPARENT_PEN
);
1863 dc
->SetBrush( *wxBLUE_BRUSH
);
1864 dc
->DrawRectangle( bar
);
1866 dc
->SetBrush( *wxTRANSPARENT_BRUSH
);
1867 dc
->SetPen( *wxBLACK_PEN
);
1868 dc
->DrawRectangle( cell
);
1873 wxSize
wxDataViewProgressRenderer::GetSize() const
1875 return wxSize(40,12);
1878 // ---------------------------------------------------------
1879 // wxDataViewDateRenderer
1880 // ---------------------------------------------------------
1882 class wxDataViewDateRendererPopupTransient
: public wxPopupTransientWindow
1885 wxDataViewDateRendererPopupTransient( wxWindow
* parent
, wxDateTime
*value
,
1886 wxDataViewModel
*model
, const wxDataViewItem
&item
, unsigned int col
) :
1887 wxPopupTransientWindow( parent
, wxBORDER_SIMPLE
)
1892 m_cal
= new wxCalendarCtrl( this, -1, *value
);
1893 wxBoxSizer
*sizer
= new wxBoxSizer( wxHORIZONTAL
);
1894 sizer
->Add( m_cal
, 1, wxGROW
);
1899 virtual void OnDismiss()
1903 void OnCalendar( wxCalendarEvent
&event
);
1905 wxCalendarCtrl
*m_cal
;
1906 wxDataViewModel
*m_model
;
1907 wxDataViewItem m_item
;
1911 DECLARE_EVENT_TABLE()
1914 BEGIN_EVENT_TABLE(wxDataViewDateRendererPopupTransient
,wxPopupTransientWindow
)
1915 EVT_CALENDAR( -1, wxDataViewDateRendererPopupTransient::OnCalendar
)
1918 void wxDataViewDateRendererPopupTransient::OnCalendar( wxCalendarEvent
&event
)
1920 wxDateTime date
= event
.GetDate();
1921 wxVariant value
= date
;
1922 m_model
->SetValue( value
, m_item
, m_col
);
1923 m_model
->ValueChanged( m_item
, m_col
);
1927 IMPLEMENT_CLASS(wxDataViewDateRenderer
, wxDataViewCustomRenderer
)
1929 wxDataViewDateRenderer::wxDataViewDateRenderer( const wxString
&varianttype
,
1930 wxDataViewCellMode mode
, int align
) :
1931 wxDataViewCustomRenderer( varianttype
, mode
, align
)
1934 SetAlignment(align
);
1937 bool wxDataViewDateRenderer::SetValue( const wxVariant
&value
)
1939 m_date
= value
.GetDateTime();
1944 bool wxDataViewDateRenderer::GetValue( wxVariant
&value
) const
1949 bool wxDataViewDateRenderer::Render( wxRect cell
, wxDC
*dc
, int state
)
1951 dc
->SetFont( GetOwner()->GetOwner()->GetFont() );
1952 wxString tmp
= m_date
.FormatDate();
1953 RenderText( tmp
, 0, cell
, dc
, state
);
1957 wxSize
wxDataViewDateRenderer::GetSize() const
1959 wxString tmp
= m_date
.FormatDate();
1961 GetView()->GetTextExtent( tmp
, &x
, &y
, &d
);
1962 return wxSize(x
,y
+d
);
1965 bool wxDataViewDateRenderer::Activate( wxRect cell
, wxDataViewModel
*model
,
1966 const wxDataViewItem
&item
, unsigned int col
)
1969 model
->GetValue( variant
, item
, col
);
1970 wxDateTime value
= variant
.GetDateTime();
1972 wxDataViewDateRendererPopupTransient
*popup
= new wxDataViewDateRendererPopupTransient(
1973 GetOwner()->GetOwner()->GetParent(), &value
, model
, item
, col
);
1974 wxPoint pos
= wxGetMousePosition();
1977 popup
->Popup( popup
->m_cal
);
1983 // ---------------------------------------------------------
1984 // wxDataViewIconTextRenderer
1985 // ---------------------------------------------------------
1987 IMPLEMENT_CLASS(wxDataViewIconTextRenderer
, wxDataViewCustomRenderer
)
1989 wxDataViewIconTextRenderer::wxDataViewIconTextRenderer(
1990 const wxString
&varianttype
, wxDataViewCellMode mode
, int align
) :
1991 wxDataViewCustomRenderer( varianttype
, mode
, align
)
1994 SetAlignment(align
);
1997 wxDataViewIconTextRenderer::~wxDataViewIconTextRenderer()
2001 bool wxDataViewIconTextRenderer::SetValue( const wxVariant
&value
)
2007 bool wxDataViewIconTextRenderer::GetValue( wxVariant
&value
) const
2012 bool wxDataViewIconTextRenderer::Render( wxRect cell
, wxDC
*dc
, int state
)
2014 const wxIcon
&icon
= m_value
.GetIcon();
2018 int yoffset
= wxMax( 0, (cell
.height
- icon
.GetHeight()) / 2 );
2019 dc
->DrawIcon( icon
, cell
.x
, cell
.y
+ yoffset
);
2020 offset
= icon
.GetWidth() + 4;
2023 RenderText( m_value
.GetText(), offset
, cell
, dc
, state
);
2028 wxSize
wxDataViewIconTextRenderer::GetSize() const
2031 if (m_value
.GetIcon().IsOk())
2032 size
.x
= 4 + m_value
.GetIcon().GetWidth();
2034 GetView()->GetTextExtent( m_value
.GetText(), &x
, &y
, &d
);
2040 wxControl
* wxDataViewIconTextRenderer::CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
)
2045 bool wxDataViewIconTextRenderer::GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
)
2050 // ---------------------------------------------------------
2052 // ---------------------------------------------------------
2056 gtk_dataview_header_button_press_callback( GtkWidget
*widget
,
2057 GdkEventButton
*gdk_event
,
2058 wxDataViewColumn
*column
)
2060 if (gdk_event
->type
!= GDK_BUTTON_PRESS
)
2063 if (gdk_event
->button
== 1)
2065 gs_lastLeftClickHeader
= column
;
2067 wxDataViewCtrl
*dv
= column
->GetOwner();
2068 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
, dv
->GetId() );
2069 event
.SetDataViewColumn( column
);
2070 event
.SetModel( dv
->GetModel() );
2071 if (dv
->GetEventHandler()->ProcessEvent( event
))
2075 if (gdk_event
->button
== 3)
2077 wxDataViewCtrl
*dv
= column
->GetOwner();
2078 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
, dv
->GetId() );
2079 event
.SetDataViewColumn( column
);
2080 event
.SetModel( dv
->GetModel() );
2081 if (dv
->GetEventHandler()->ProcessEvent( event
))
2089 static void wxGtkTreeCellDataFunc( GtkTreeViewColumn
*column
,
2090 GtkCellRenderer
*cell
,
2091 GtkTreeModel
*model
,
2097 static void wxGtkTreeCellDataFunc( GtkTreeViewColumn
*column
,
2098 GtkCellRenderer
*renderer
,
2099 GtkTreeModel
*model
,
2103 g_return_if_fail (GTK_IS_WX_TREE_MODEL (model
));
2104 GtkWxTreeModel
*tree_model
= (GtkWxTreeModel
*) model
;
2106 wxDataViewRenderer
*cell
= (wxDataViewRenderer
*) data
;
2108 wxDataViewItem
item( (void*) iter
->user_data
);
2110 wxDataViewModel
*wx_model
= tree_model
->internal
->GetDataViewModel();
2112 if (!wx_model
->IsIndexListModel())
2115 if (wx_model
->IsContainer( item
))
2117 if (wx_model
->HasContainerColumns( item
) || (cell
->GetOwner()->GetModelColumn() == 0))
2119 GValue gvalue
= { 0, };
2120 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
2121 g_value_set_boolean( &gvalue
, TRUE
);
2122 g_object_set_property( G_OBJECT(renderer
), "visible", &gvalue
);
2123 g_value_unset( &gvalue
);
2127 GValue gvalue
= { 0, };
2128 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
2129 g_value_set_boolean( &gvalue
, FALSE
);
2130 g_object_set_property( G_OBJECT(renderer
), "visible", &gvalue
);
2131 g_value_unset( &gvalue
);
2138 GValue gvalue
= { 0, };
2139 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
2140 g_value_set_boolean( &gvalue
, TRUE
);
2141 g_object_set_property( G_OBJECT(renderer
), "visible", &gvalue
);
2142 g_value_unset( &gvalue
);
2148 wx_model
->GetValue( value
, item
, cell
->GetOwner()->GetModelColumn() );
2150 if (value
.GetType() != cell
->GetVariantType())
2151 wxLogError( wxT("Wrong type, required: %s but: %s"),
2152 value
.GetType().c_str(),
2153 cell
->GetVariantType().c_str() );
2155 cell
->SetValue( value
);
2157 if (cell
->GtkHasAttributes())
2159 wxDataViewItemAttr attr
;
2160 bool colour_set
= false;
2161 bool style_set
= false;
2162 bool weight_set
= false;
2164 if (wx_model
->GetAttr( item
, cell
->GetOwner()->GetModelColumn(), attr
))
2166 // this must be a GtkCellRendererText
2167 wxColour colour
= attr
.GetColour();
2170 const GdkColor
* const gcol
= colour
.GetColor();
2172 GValue gvalue
= { 0, };
2173 g_value_init( &gvalue
, GDK_TYPE_COLOR
);
2174 g_value_set_boxed( &gvalue
, gcol
);
2175 g_object_set_property( G_OBJECT(renderer
), "foreground_gdk", &gvalue
);
2176 g_value_unset( &gvalue
);
2181 if (attr
.GetItalic())
2183 GValue gvalue
= { 0, };
2184 g_value_init( &gvalue
, PANGO_TYPE_STYLE
);
2185 g_value_set_enum( &gvalue
, PANGO_STYLE_ITALIC
);
2186 g_object_set_property( G_OBJECT(renderer
), "style", &gvalue
);
2187 g_value_unset( &gvalue
);
2194 GValue gvalue
= { 0, };
2195 g_value_init( &gvalue
, PANGO_TYPE_WEIGHT
);
2196 g_value_set_enum( &gvalue
, PANGO_WEIGHT_BOLD
);
2197 g_object_set_property( G_OBJECT(renderer
), "weight", &gvalue
);
2198 g_value_unset( &gvalue
);
2206 GValue gvalue
= { 0, };
2207 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
2208 g_value_set_boolean( &gvalue
, FALSE
);
2209 g_object_set_property( G_OBJECT(renderer
), "style-set", &gvalue
);
2210 g_value_unset( &gvalue
);
2215 GValue gvalue
= { 0, };
2216 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
2217 g_value_set_boolean( &gvalue
, FALSE
);
2218 g_object_set_property( G_OBJECT(renderer
), "weight-set", &gvalue
);
2219 g_value_unset( &gvalue
);
2224 GValue gvalue
= { 0, };
2225 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
2226 g_value_set_boolean( &gvalue
, FALSE
);
2227 g_object_set_property( G_OBJECT(renderer
), "foreground-set", &gvalue
);
2228 g_value_unset( &gvalue
);
2233 if (attr
.HasBackgroundColour())
2235 wxColour colour
= attr
.GetBackgroundColour();
2236 const GdkColor
* const gcol
= colour
.GetColor();
2238 GValue gvalue
= { 0, };
2239 g_value_init( &gvalue
, GDK_TYPE_COLOR
);
2240 g_value_set_boxed( &gvalue
, gcol
);
2241 g_object_set_property( G_OBJECT(renderer
), "cell-background_gdk", &gvalue
);
2242 g_value_unset( &gvalue
);
2246 GValue gvalue
= { 0, };
2247 g_value_init( &gvalue
, G_TYPE_BOOLEAN
);
2248 g_value_set_boolean( &gvalue
, FALSE
);
2249 g_object_set_property( G_OBJECT(renderer
), "cell-background-set", &gvalue
);
2250 g_value_unset( &gvalue
);
2256 IMPLEMENT_CLASS(wxDataViewColumn
, wxDataViewColumnBase
)
2258 #include <wx/listimpl.cpp>
2259 WX_DEFINE_LIST(wxDataViewColumnList
)
2261 wxDataViewColumn::wxDataViewColumn( const wxString
&title
, wxDataViewRenderer
*cell
,
2262 unsigned int model_column
, int width
,
2263 wxAlignment align
, int flags
) :
2264 wxDataViewColumnBase( title
, cell
, model_column
, width
, align
, flags
)
2266 Init( align
, flags
, width
);
2268 gtk_tree_view_column_set_clickable( GTK_TREE_VIEW_COLUMN(m_column
), TRUE
);
2272 wxDataViewColumn::wxDataViewColumn( const wxBitmap
&bitmap
, wxDataViewRenderer
*cell
,
2273 unsigned int model_column
, int width
,
2274 wxAlignment align
, int flags
) :
2275 wxDataViewColumnBase( bitmap
, cell
, model_column
, width
, align
, flags
)
2277 Init( align
, flags
, width
);
2279 SetBitmap( bitmap
);
2282 void wxDataViewColumn::Init(wxAlignment align
, int flags
, int width
)
2284 m_isConnected
= false;
2286 GtkCellRenderer
*renderer
= (GtkCellRenderer
*) GetRenderer()->GetGtkHandle();
2287 GtkTreeViewColumn
*column
= gtk_tree_view_column_new();
2288 m_column
= (GtkWidget
*) column
;
2291 SetAlignment( align
);
2293 // NOTE: we prefer not to call SetMinWidth(wxDVC_DEFAULT_MINWIDTH);
2294 // as GTK+ is smart and unless explicitely told, will set the minimal
2295 // width to the title's lenght, which is a better default
2297 // the GTK_TREE_VIEW_COLUMN_FIXED is required by the "fixed height" mode
2298 // that we use for the wxDataViewCtrl
2299 gtk_tree_view_column_set_fixed_width( column
, width
< 0 ? wxDVC_DEFAULT_WIDTH
: width
);
2300 gtk_tree_view_column_set_sizing( column
, GTK_TREE_VIEW_COLUMN_FIXED
);
2302 gtk_tree_view_column_pack_end( column
, renderer
, TRUE
);
2304 gtk_tree_view_column_set_cell_data_func( column
, renderer
,
2305 wxGtkTreeCellDataFunc
, (gpointer
) GetRenderer(), NULL
);
2308 wxDataViewColumn::~wxDataViewColumn()
2312 void wxDataViewColumn::OnInternalIdle()
2317 if (GTK_WIDGET_REALIZED(GetOwner()->m_treeview
))
2319 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2322 g_signal_connect(column
->button
, "button_press_event",
2323 G_CALLBACK (gtk_dataview_header_button_press_callback
), this);
2325 m_isConnected
= true;
2330 void wxDataViewColumn::SetOwner( wxDataViewCtrl
*owner
)
2332 wxDataViewColumnBase::SetOwner( owner
);
2334 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2336 gtk_tree_view_column_set_title( column
, wxGTK_CONV_FONT(GetTitle(), GetOwner()->GetFont() ) );
2339 void wxDataViewColumn::SetTitle( const wxString
&title
)
2341 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2345 // disconnect before column->button gets recreated
2346 g_signal_handlers_disconnect_by_func( column
->button
,
2347 (GtkWidget
*) gtk_dataview_header_button_press_callback
, this);
2349 m_isConnected
= false;
2352 // FIXME: can it really happen that we don't have the owner here??
2353 wxDataViewCtrl
*ctrl
= GetOwner();
2354 gtk_tree_view_column_set_title( column
, ctrl
? wxGTK_CONV_FONT(title
, ctrl
->GetFont())
2355 : wxGTK_CONV_SYS(title
) );
2357 gtk_tree_view_column_set_widget( column
, NULL
);
2360 wxString
wxDataViewColumn::GetTitle() const
2362 const gchar
*str
= gtk_tree_view_column_get_title( GTK_TREE_VIEW_COLUMN(m_column
) );
2363 return wxConvFileName
->cMB2WX(str
);
2366 void wxDataViewColumn::SetBitmap( const wxBitmap
&bitmap
)
2368 wxDataViewColumnBase::SetBitmap( bitmap
);
2370 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2373 GtkImage
*gtk_image
= GTK_IMAGE( gtk_image_new() );
2375 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
2376 if (bitmap
.GetMask())
2377 mask
= bitmap
.GetMask()->GetBitmap();
2379 if (bitmap
.HasPixbuf())
2381 gtk_image_set_from_pixbuf(GTK_IMAGE(gtk_image
),
2382 bitmap
.GetPixbuf());
2386 gtk_image_set_from_pixmap(GTK_IMAGE(gtk_image
),
2387 bitmap
.GetPixmap(), mask
);
2389 gtk_widget_show( GTK_WIDGET(gtk_image
) );
2391 gtk_tree_view_column_set_widget( column
, GTK_WIDGET(gtk_image
) );
2395 gtk_tree_view_column_set_widget( column
, NULL
);
2399 void wxDataViewColumn::SetHidden( bool hidden
)
2401 gtk_tree_view_column_set_visible( GTK_TREE_VIEW_COLUMN(m_column
), !hidden
);
2404 void wxDataViewColumn::SetResizeable( bool resizeable
)
2406 gtk_tree_view_column_set_resizable( GTK_TREE_VIEW_COLUMN(m_column
), resizeable
);
2409 void wxDataViewColumn::SetAlignment( wxAlignment align
)
2411 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2413 gfloat xalign
= 0.0;
2414 if (align
== wxALIGN_RIGHT
)
2416 if (align
== wxALIGN_CENTER_HORIZONTAL
||
2417 align
== wxALIGN_CENTER
)
2420 gtk_tree_view_column_set_alignment( column
, xalign
);
2423 wxAlignment
wxDataViewColumn::GetAlignment() const
2425 gfloat xalign
= gtk_tree_view_column_get_alignment( GTK_TREE_VIEW_COLUMN(m_column
) );
2428 return wxALIGN_RIGHT
;
2430 return wxALIGN_CENTER_HORIZONTAL
;
2432 return wxALIGN_LEFT
;
2435 void wxDataViewColumn::SetSortable( bool sortable
)
2437 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2441 gtk_tree_view_column_set_sort_column_id( column
, GetModelColumn() );
2445 gtk_tree_view_column_set_sort_column_id( column
, -1 );
2446 gtk_tree_view_column_set_sort_indicator( column
, FALSE
);
2450 bool wxDataViewColumn::IsSortable() const
2452 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2453 return (gtk_tree_view_column_get_sort_column_id( column
) != -1);
2456 bool wxDataViewColumn::IsResizeable() const
2458 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2459 return gtk_tree_view_column_get_resizable( column
);
2462 bool wxDataViewColumn::IsHidden() const
2464 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2465 return !gtk_tree_view_column_get_visible( column
);
2468 void wxDataViewColumn::SetSortOrder( bool ascending
)
2470 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2473 gtk_tree_view_column_set_sort_order( column
, GTK_SORT_ASCENDING
);
2475 gtk_tree_view_column_set_sort_order( column
, GTK_SORT_DESCENDING
);
2477 gtk_tree_view_column_set_sort_indicator( column
, TRUE
);
2480 bool wxDataViewColumn::IsSortOrderAscending() const
2482 GtkTreeViewColumn
*column
= GTK_TREE_VIEW_COLUMN(m_column
);
2484 return (gtk_tree_view_column_get_sort_order( column
) != GTK_SORT_DESCENDING
);
2487 void wxDataViewColumn::SetMinWidth( int width
)
2489 gtk_tree_view_column_set_min_width( GTK_TREE_VIEW_COLUMN(m_column
), width
);
2492 int wxDataViewColumn::GetMinWidth() const
2494 return gtk_tree_view_column_get_min_width( GTK_TREE_VIEW_COLUMN(m_column
) );
2497 int wxDataViewColumn::GetWidth() const
2499 return gtk_tree_view_column_get_width( GTK_TREE_VIEW_COLUMN(m_column
) );
2502 void wxDataViewColumn::SetWidth( int width
)
2504 gtk_tree_view_column_set_fixed_width( GTK_TREE_VIEW_COLUMN(m_column
), width
);
2508 //-----------------------------------------------------------------------------
2509 // wxGtkTreeModelNode
2510 //-----------------------------------------------------------------------------
2512 void wxGtkTreeModelNode::Resort()
2514 size_t child_count
= GetChildCount();
2515 if (child_count
== 0)
2518 size_t node_count
= GetNodesCount();
2520 if (child_count
== 1)
2522 if (node_count
== 1)
2524 wxGtkTreeModelNode
*node
= m_nodes
.Item( 0 );
2530 wxGtkTreeModelChildren temp
;
2531 WX_APPEND_ARRAY( temp
, m_children
);
2533 g_internal
= m_internal
;
2534 m_children
.Sort( &wxGtkTreeModelChildCmp
);
2536 gint
*new_order
= new gint
[child_count
];
2539 for (pos
= 0; pos
< child_count
; pos
++)
2541 void *id
= m_children
.Item( pos
);
2542 int old_pos
= temp
.Index( id
);
2543 new_order
[pos
] = old_pos
;
2546 GtkTreeModel
*gtk_tree_model
= GTK_TREE_MODEL( m_internal
->GetGtkModel() );
2549 iter
.user_data
= GetItem().GetID();
2550 iter
.stamp
= m_internal
->GetGtkModel()->stamp
;
2552 GtkTreePath
*path
= m_internal
->get_path( &iter
);
2554 gtk_tree_model_rows_reordered( gtk_tree_model
, path
, &iter
, new_order
);
2556 gtk_tree_path_free (path
);
2558 delete [] new_order
;
2560 for (pos
= 0; pos
< node_count
; pos
++)
2562 wxGtkTreeModelNode
*node
= m_nodes
.Item( pos
);
2567 //-----------------------------------------------------------------------------
2568 // wxDataViewCtrlInternal
2569 //-----------------------------------------------------------------------------
2571 wxDataViewCtrlInternal::wxDataViewCtrlInternal( wxDataViewCtrl
*owner
,
2572 wxDataViewModel
*wx_model
, GtkWxTreeModel
*gtk_model
)
2575 m_wx_model
= wx_model
;
2576 m_gtk_model
= gtk_model
;
2578 m_sort_order
= GTK_SORT_ASCENDING
;
2580 m_dataview_sort_column
= NULL
;
2582 if (!m_wx_model
->IsIndexListModel())
2586 wxDataViewCtrlInternal::~wxDataViewCtrlInternal()
2588 g_object_unref( m_gtk_model
);
2591 void wxDataViewCtrlInternal::InitTree()
2593 wxDataViewItem item
;
2594 m_root
= new wxGtkTreeModelNode( NULL
, item
, this );
2596 BuildBranch( m_root
);
2599 void wxDataViewCtrlInternal::BuildBranch( wxGtkTreeModelNode
*node
)
2601 if (node
->GetChildCount() == 0)
2603 wxDataViewItemArray children
;
2604 unsigned int count
= m_wx_model
->GetChildren( node
->GetItem(), children
);
2606 for (pos
= 0; pos
< count
; pos
++)
2608 wxDataViewItem child
= children
[pos
];
2610 if (m_wx_model
->IsContainer( child
))
2611 node
->AddNode( new wxGtkTreeModelNode( node
, child
, this ) );
2613 node
->AddLeave( child
.GetID() );
2615 // Don't send any events here
2620 void wxDataViewCtrlInternal::Resort()
2622 if (!m_wx_model
->IsIndexListModel())
2626 bool wxDataViewCtrlInternal::ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
)
2628 if (!m_wx_model
->IsIndexListModel())
2630 wxGtkTreeModelNode
*parent_node
= FindNode( parent
);
2631 if (m_wx_model
->IsContainer( item
))
2632 parent_node
->AddNode( new wxGtkTreeModelNode( parent_node
, item
, this ) );
2634 parent_node
->AddLeave( item
.GetID() );
2640 bool wxDataViewCtrlInternal::ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
)
2642 if (!m_wx_model
->IsIndexListModel())
2644 wxGtkTreeModelNode
*parent_node
= FindNode( parent
);
2645 parent_node
->DeleteChild( item
.GetID() );
2651 bool wxDataViewCtrlInternal::ItemChanged( const wxDataViewItem
&item
)
2653 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
, m_owner
->GetId() );
2654 event
.SetEventObject( m_owner
);
2655 event
.SetModel( m_owner
->GetModel() );
2656 event
.SetItem( item
);
2657 m_owner
->GetEventHandler()->ProcessEvent( event
);
2662 bool wxDataViewCtrlInternal::ValueChanged( const wxDataViewItem
&item
, unsigned int col
)
2664 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
, m_owner
->GetId() );
2665 event
.SetEventObject( m_owner
);
2666 event
.SetModel( m_owner
->GetModel() );
2667 event
.SetColumn( col
);
2668 event
.SetDataViewColumn( GetOwner()->GetColumn(col
) );
2669 event
.SetItem( item
);
2670 m_owner
->GetEventHandler()->ProcessEvent( event
);
2675 bool wxDataViewCtrlInternal::Cleared()
2680 GtkTreeModelFlags
wxDataViewCtrlInternal::get_flags()
2682 if (m_wx_model
->IsIndexListModel())
2683 return GTK_TREE_MODEL_LIST_ONLY
;
2685 return GTK_TREE_MODEL_ITERS_PERSIST
;
2688 gboolean
wxDataViewCtrlInternal::get_iter( GtkTreeIter
*iter
, GtkTreePath
*path
)
2690 if (m_wx_model
->IsIndexListModel())
2692 wxDataViewIndexListModel
*wx_model
= (wxDataViewIndexListModel
*) m_wx_model
;
2694 unsigned int i
= (unsigned int)gtk_tree_path_get_indices (path
)[0];
2696 if (i
>= wx_model
->GetLastIndex())
2699 iter
->stamp
= m_gtk_model
->stamp
;
2700 // user_data is just the index
2701 iter
->user_data
= (gpointer
) i
;
2707 int depth
= gtk_tree_path_get_depth( path
);
2709 wxGtkTreeModelNode
*node
= m_root
;
2712 for (i
= 0; i
< depth
; i
++)
2714 BuildBranch( node
);
2716 gint pos
= gtk_tree_path_get_indices (path
)[i
];
2717 if (pos
< 0) return FALSE
;
2718 if ((size_t)pos
>= node
->GetChildCount()) return FALSE
;
2720 void* id
= node
->GetChildren().Item( (size_t) pos
);
2724 iter
->stamp
= m_gtk_model
->stamp
;
2725 iter
->user_data
= id
;
2729 size_t count
= node
->GetNodes().GetCount();
2731 for (pos2
= 0; pos2
< count
; pos2
++)
2733 wxGtkTreeModelNode
*child_node
= node
->GetNodes().Item( pos2
);
2734 if (child_node
->GetItem().GetID() == id
)
2746 GtkTreePath
*wxDataViewCtrlInternal::get_path( GtkTreeIter
*iter
)
2748 GtkTreePath
*retval
= gtk_tree_path_new ();
2750 if (m_wx_model
->IsIndexListModel())
2752 // user_data is just the index
2753 int i
= (wxUIntPtr
) iter
->user_data
;
2754 gtk_tree_path_append_index (retval
, i
);
2758 void *id
= iter
->user_data
;
2760 wxGtkTreeModelNode
*node
= FindParentNode( iter
);
2763 int pos
= node
->GetChildren().Index( id
);
2765 gtk_tree_path_prepend_index( retval
, pos
);
2767 id
= node
->GetItem().GetID();
2768 node
= node
->GetParent();
2775 gboolean
wxDataViewCtrlInternal::iter_next( GtkTreeIter
*iter
)
2777 if (m_wx_model
->IsIndexListModel())
2779 wxDataViewIndexListModel
*wx_model
= (wxDataViewIndexListModel
*) m_wx_model
;
2781 int n
= (wxUIntPtr
) iter
->user_data
;
2786 if (n
>= (int) wx_model
->GetLastIndex()-2)
2789 iter
->user_data
= (gpointer
) ++n
;
2793 wxGtkTreeModelNode
*parent
= FindParentNode( iter
);
2794 if( parent
== NULL
)
2797 int pos
= parent
->GetChildren().Index( iter
->user_data
);
2799 if (pos
== (int) parent
->GetChildCount()-1)
2802 iter
->stamp
= m_gtk_model
->stamp
;
2803 iter
->user_data
= parent
->GetChildren().Item( pos
+1 );
2809 gboolean
wxDataViewCtrlInternal::iter_children( GtkTreeIter
*iter
, GtkTreeIter
*parent
)
2811 if (m_wx_model
->IsIndexListModel())
2813 // this is a list, nodes have no children
2817 iter
->stamp
= m_gtk_model
->stamp
;
2818 iter
->user_data
= (gpointer
) -1;
2824 wxDataViewItem
item( (void*) parent
->user_data
);
2826 if (!m_wx_model
->IsContainer( item
))
2829 wxGtkTreeModelNode
*parent_node
= FindNode( parent
);
2830 BuildBranch( parent_node
);
2832 if (parent_node
->GetChildCount() == 0)
2835 iter
->stamp
= m_gtk_model
->stamp
;
2836 iter
->user_data
= (gpointer
) parent_node
->GetChildren().Item( 0 );
2842 gboolean
wxDataViewCtrlInternal::iter_has_child( GtkTreeIter
*iter
)
2844 if (m_wx_model
->IsIndexListModel())
2846 // this is a list, nodes have no children
2851 wxDataViewItem
item( (void*) iter
->user_data
);
2853 bool is_container
= m_wx_model
->IsContainer( item
);
2858 wxGtkTreeModelNode
*node
= FindNode( iter
);
2859 BuildBranch( node
);
2861 return (node
->GetChildCount() > 0);
2865 gint
wxDataViewCtrlInternal::iter_n_children( GtkTreeIter
*iter
)
2867 if (m_wx_model
->IsIndexListModel())
2869 wxDataViewIndexListModel
*wx_model
= (wxDataViewIndexListModel
*) m_wx_model
;
2872 return (gint
) wx_model
->GetLastIndex()-1;
2878 wxDataViewItem
item( (void*) iter
->user_data
);
2880 if (!m_wx_model
->IsContainer( item
))
2883 wxGtkTreeModelNode
*parent_node
= FindNode( iter
);
2884 BuildBranch( parent_node
);
2886 // wxPrintf( "iter_n_children %d\n", parent_node->GetChildCount() );
2888 return parent_node
->GetChildCount();
2892 gboolean
wxDataViewCtrlInternal::iter_nth_child( GtkTreeIter
*iter
, GtkTreeIter
*parent
, gint n
)
2894 if (m_wx_model
->IsIndexListModel())
2896 wxDataViewIndexListModel
*wx_model
= (wxDataViewIndexListModel
*) m_wx_model
;
2904 if (n
>= (gint
) wx_model
->GetLastIndex()-1)
2907 iter
->stamp
= m_gtk_model
->stamp
;
2908 iter
->user_data
= (gpointer
) n
;
2915 if (parent
) id
= (void*) parent
->user_data
;
2916 wxDataViewItem
item( id
);
2918 if (!m_wx_model
->IsContainer( item
))
2921 wxGtkTreeModelNode
*parent_node
= FindNode( parent
);
2922 BuildBranch( parent_node
);
2924 // wxPrintf( "iter_nth_child %d\n", n );
2926 iter
->stamp
= m_gtk_model
->stamp
;
2927 iter
->user_data
= parent_node
->GetChildren().Item( n
);
2933 gboolean
wxDataViewCtrlInternal::iter_parent( GtkTreeIter
*iter
, GtkTreeIter
*child
)
2935 if (m_wx_model
->IsIndexListModel())
2941 wxGtkTreeModelNode
*node
= FindParentNode( child
);
2945 iter
->stamp
= m_gtk_model
->stamp
;
2946 iter
->user_data
= (gpointer
) node
->GetItem().GetID();
2952 static wxGtkTreeModelNode
*
2953 wxDataViewCtrlInternal_FindNode( wxDataViewModel
* model
, wxGtkTreeModelNode
*treeNode
, const wxDataViewItem
&item
)
2959 list
.DeleteContents( true );
2960 wxDataViewItem
it( item
);
2964 wxDataViewItem
* pItem
= new wxDataViewItem( it
);
2965 list
.Insert( pItem
);
2966 it
= model
->GetParent( it
);
2969 wxGtkTreeModelNode
* node
= treeNode
;
2970 for( ItemList::compatibility_iterator n
= list
.GetFirst(); n
; n
= n
->GetNext() )
2972 if( node
&& node
->GetNodes().GetCount() != 0 )
2974 int len
= node
->GetNodes().GetCount();
2975 wxGtkTreeModelNodes nodes
= node
->GetNodes();
2977 for( ; j
< len
; j
++)
2979 if( nodes
[j
]->GetItem() == *(n
->GetData()))
2998 wxGtkTreeModelNode
*wxDataViewCtrlInternal::FindNode( GtkTreeIter
*iter
)
3003 wxDataViewItem
item( (void*) iter
->user_data
);
3007 wxGtkTreeModelNode
*result
= wxDataViewCtrlInternal_FindNode( m_wx_model
, m_root
, item
);
3011 wxLogDebug( "Not found %p", iter
->user_data
);
3019 wxGtkTreeModelNode
*wxDataViewCtrlInternal::FindNode( const wxDataViewItem
&item
)
3024 wxGtkTreeModelNode
*result
= wxDataViewCtrlInternal_FindNode( m_wx_model
, m_root
, item
);
3028 wxLogDebug( "Not found %p", item
.GetID() );
3036 static wxGtkTreeModelNode
*
3037 wxDataViewCtrlInternal_FindParentNode( wxDataViewModel
* model
, wxGtkTreeModelNode
*treeNode
, const wxDataViewItem
&item
)
3043 list
.DeleteContents( true );
3047 wxDataViewItem
it( model
->GetParent( item
) );
3050 wxDataViewItem
* pItem
= new wxDataViewItem( it
);
3051 list
.Insert( pItem
);
3052 it
= model
->GetParent( it
);
3055 wxGtkTreeModelNode
* node
= treeNode
;
3056 for( ItemList::compatibility_iterator n
= list
.GetFirst(); n
; n
= n
->GetNext() )
3058 if( node
&& node
->GetNodes().GetCount() != 0 )
3060 int len
= node
->GetNodes().GetCount();
3061 wxGtkTreeModelNodes nodes
= node
->GetNodes();
3063 for( ; j
< len
; j
++)
3065 if( nodes
[j
]->GetItem() == *(n
->GetData()))
3080 //Examine whether the node is item's parent node
3081 int len
= node
->GetChildCount();
3082 for( int i
= 0; i
< len
; i
++ )
3084 if( node
->GetChildren().Item( i
) == item
.GetID() )
3090 wxGtkTreeModelNode
*wxDataViewCtrlInternal::FindParentNode( GtkTreeIter
*iter
)
3095 wxDataViewItem
item( (void*) iter
->user_data
);
3099 return wxDataViewCtrlInternal_FindParentNode( m_wx_model
, m_root
, item
);
3102 wxGtkTreeModelNode
*wxDataViewCtrlInternal::FindParentNode( const wxDataViewItem
&item
)
3107 return wxDataViewCtrlInternal_FindParentNode( m_wx_model
, m_root
, item
);
3110 //-----------------------------------------------------------------------------
3111 // wxDataViewCtrl signal callbacks
3112 //-----------------------------------------------------------------------------
3115 wxdataview_selection_changed_callback( GtkTreeSelection
* selection
, wxDataViewCtrl
*dv
)
3117 if (!GTK_WIDGET_REALIZED(dv
->m_widget
))
3120 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
, dv
->GetId() );
3121 event
.SetItem( dv
->GetSelection() );
3122 event
.SetModel( dv
->GetModel() );
3123 dv
->GetEventHandler()->ProcessEvent( event
);
3127 wxdataview_row_activated_callback( GtkTreeView
* treeview
, GtkTreePath
*path
,
3128 GtkTreeViewColumn
*column
, wxDataViewCtrl
*dv
)
3130 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
, dv
->GetId() );
3133 dv
->GtkGetInternal()->get_iter( &iter
, path
);
3134 wxDataViewItem
item( (void*) iter
.user_data
);;
3135 event
.SetItem( item
);
3136 event
.SetModel( dv
->GetModel() );
3137 dv
->GetEventHandler()->ProcessEvent( event
);
3141 wxdataview_test_expand_row_callback( GtkTreeView
* treeview
, GtkTreeIter
* iter
,
3142 GtkTreePath
*path
, wxDataViewCtrl
*dv
)
3144 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
, dv
->GetId() );
3146 wxDataViewItem
item( (void*) iter
->user_data
);;
3147 event
.SetItem( item
);
3148 event
.SetModel( dv
->GetModel() );
3149 dv
->GetEventHandler()->ProcessEvent( event
);
3151 return !event
.IsAllowed();
3155 wxdataview_row_expanded_callback( GtkTreeView
* treeview
, GtkTreeIter
* iter
,
3156 GtkTreePath
*path
, wxDataViewCtrl
*dv
)
3158 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
, dv
->GetId() );
3160 wxDataViewItem
item( (void*) iter
->user_data
);;
3161 event
.SetItem( item
);
3162 event
.SetModel( dv
->GetModel() );
3163 dv
->GetEventHandler()->ProcessEvent( event
);
3167 wxdataview_test_collapse_row_callback( GtkTreeView
* treeview
, GtkTreeIter
* iter
,
3168 GtkTreePath
*path
, wxDataViewCtrl
*dv
)
3170 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
, dv
->GetId() );
3172 wxDataViewItem
item( (void*) iter
->user_data
);;
3173 event
.SetItem( item
);
3174 event
.SetModel( dv
->GetModel() );
3175 dv
->GetEventHandler()->ProcessEvent( event
);
3177 return !event
.IsAllowed();
3181 wxdataview_row_collapsed_callback( GtkTreeView
* treeview
, GtkTreeIter
* iter
,
3182 GtkTreePath
*path
, wxDataViewCtrl
*dv
)
3184 wxDataViewEvent
event( wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
, dv
->GetId() );
3186 wxDataViewItem
item( (void*) iter
->user_data
);;
3187 event
.SetItem( item
);
3188 event
.SetModel( dv
->GetModel() );
3189 dv
->GetEventHandler()->ProcessEvent( event
);
3192 //-----------------------------------------------------------------------------
3194 //-----------------------------------------------------------------------------
3196 //-----------------------------------------------------------------------------
3197 // InsertChild for wxDataViewCtrl
3198 //-----------------------------------------------------------------------------
3200 static void wxInsertChildInDataViewCtrl( wxWindowGTK
* parent
, wxWindowGTK
* child
)
3202 wxDataViewCtrl
* dvc
= (wxDataViewCtrl
*) parent
;
3203 GtkWidget
*treeview
= dvc
->GtkGetTreeView();
3205 // Insert widget in GtkTreeView
3206 if (GTK_WIDGET_REALIZED(treeview
))
3207 gtk_widget_set_parent_window( child
->m_widget
,
3208 gtk_tree_view_get_bin_window( GTK_TREE_VIEW(treeview
) ) );
3209 gtk_widget_set_parent( child
->m_widget
, treeview
);
3213 void gtk_dataviewctrl_size_callback( GtkWidget
*WXUNUSED(widget
),
3214 GtkAllocation
*alloc
,
3215 wxDataViewCtrl
*win
)
3217 wxWindowList::compatibility_iterator node
= win
->GetChildren().GetFirst();
3220 wxWindow
*child
= node
->GetData();
3223 gtk_widget_size_request( child
->m_widget
, &req
);
3225 GtkAllocation alloc
;
3226 alloc
.x
= child
->m_x
;
3227 alloc
.y
= child
->m_y
;
3228 alloc
.width
= child
->m_width
;
3229 alloc
.height
= child
->m_height
;
3230 gtk_widget_size_allocate( child
->m_widget
, &alloc
);
3232 node
= node
->GetNext();
3237 //-----------------------------------------------------------------------------
3238 // "motion_notify_event"
3239 //-----------------------------------------------------------------------------
3242 gtk_dataview_motion_notify_callback( GtkWidget
*widget
,
3243 GdkEventMotion
*gdk_event
,
3244 wxDataViewCtrl
*dv
)
3246 if (gdk_event
->is_hint
)
3250 GdkModifierType state
;
3251 gdk_window_get_pointer(gdk_event
->window
, &x
, &y
, &state
);
3256 GtkTreePath
*path
= NULL
;
3257 GtkTreeViewColumn
*column
= NULL
;
3260 if (gtk_tree_view_get_path_at_pos(
3261 GTK_TREE_VIEW(dv
->GtkGetTreeView()),
3262 (int) gdk_event
->x
, (int) gdk_event
->y
,
3271 dv
->GtkGetInternal()->get_iter( &iter
, path
);
3273 // wxPrintf( "mouse %d %d\n", (int) gdk_event->x, (int) gdk_event->y );
3275 gtk_tree_path_free( path
);
3284 IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl
, wxDataViewCtrlBase
)
3286 wxDataViewCtrl::~wxDataViewCtrl()
3289 GetModel()->RemoveNotifier( m_notifier
);
3291 // remove the model from the GtkTreeView before it gets destroyed by the
3292 // wxDataViewCtrlBase's dtor
3293 gtk_tree_view_set_model( GTK_TREE_VIEW(m_treeview
), NULL
);
3298 void wxDataViewCtrl::Init()
3303 bool wxDataViewCtrl::Create(wxWindow
*parent
, wxWindowID id
,
3304 const wxPoint
& pos
, const wxSize
& size
,
3305 long style
, const wxValidator
& validator
)
3309 if (!PreCreation( parent
, pos
, size
) ||
3310 !CreateBase( parent
, id
, pos
, size
, style
, validator
))
3312 wxFAIL_MSG( wxT("wxDataViewCtrl creation failed") );
3316 m_insertCallback
= wxInsertChildInDataViewCtrl
;
3318 m_widget
= gtk_scrolled_window_new (NULL
, NULL
);
3320 GtkScrolledWindowSetBorder(m_widget
, style
);
3322 m_treeview
= gtk_tree_view_new();
3323 gtk_container_add (GTK_CONTAINER (m_widget
), m_treeview
);
3325 g_signal_connect (m_treeview
, "size_allocate",
3326 G_CALLBACK (gtk_dataviewctrl_size_callback
), this);
3329 if (!gtk_check_version(2,6,0))
3330 gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview
), TRUE
);
3333 if (style
& wxDV_MULTIPLE
)
3335 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3336 gtk_tree_selection_set_mode( selection
, GTK_SELECTION_MULTIPLE
);
3339 gtk_tree_view_set_headers_visible( GTK_TREE_VIEW(m_treeview
), (style
& wxDV_NO_HEADER
) == 0 );
3342 if (!gtk_check_version(2,10,0))
3344 GtkTreeViewGridLines grid
= GTK_TREE_VIEW_GRID_LINES_NONE
;
3346 if ((style
& wxDV_HORIZ_RULES
) != 0 &&
3347 (style
& wxDV_VERT_RULES
) != 0)
3348 grid
= GTK_TREE_VIEW_GRID_LINES_BOTH
;
3349 else if (style
& wxDV_VERT_RULES
)
3350 grid
= GTK_TREE_VIEW_GRID_LINES_VERTICAL
;
3351 else if (style
& wxDV_HORIZ_RULES
)
3352 grid
= GTK_TREE_VIEW_GRID_LINES_HORIZONTAL
;
3354 gtk_tree_view_set_grid_lines( GTK_TREE_VIEW(m_treeview
), grid
);
3359 gtk_tree_view_set_rules_hint( GTK_TREE_VIEW(m_treeview
), (style
& wxDV_HORIZ_RULES
) != 0 );
3362 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (m_widget
),
3363 GTK_POLICY_AUTOMATIC
, GTK_POLICY_ALWAYS
);
3364 gtk_widget_show (m_treeview
);
3366 m_parent
->DoAddChild( this );
3370 GtkEnableSelectionEvents();
3372 g_signal_connect_after (m_treeview
, "row-activated",
3373 G_CALLBACK (wxdataview_row_activated_callback
), this);
3375 g_signal_connect (m_treeview
, "test-collapse-row",
3376 G_CALLBACK (wxdataview_test_collapse_row_callback
), this);
3378 g_signal_connect_after (m_treeview
, "row-collapsed",
3379 G_CALLBACK (wxdataview_row_collapsed_callback
), this);
3381 g_signal_connect (m_treeview
, "test-expand-row",
3382 G_CALLBACK (wxdataview_test_expand_row_callback
), this);
3384 g_signal_connect_after (m_treeview
, "row-expanded",
3385 G_CALLBACK (wxdataview_row_expanded_callback
), this);
3387 g_signal_connect (m_treeview
, "motion_notify_event",
3388 G_CALLBACK (gtk_dataview_motion_notify_callback
), this);
3393 void wxDataViewCtrl::OnInternalIdle()
3395 wxWindow::OnInternalIdle();
3397 unsigned int cols
= GetColumnCount();
3399 for (i
= 0; i
< cols
; i
++)
3401 wxDataViewColumn
*col
= GetColumn( i
);
3402 col
->OnInternalIdle();
3406 bool wxDataViewCtrl::AssociateModel( wxDataViewModel
*model
)
3408 if (!wxDataViewCtrlBase::AssociateModel( model
))
3411 GtkWxTreeModel
*gtk_model
= wxgtk_tree_model_new();
3412 m_internal
= new wxDataViewCtrlInternal( this, model
, gtk_model
);
3413 gtk_model
->internal
= m_internal
;
3415 m_notifier
= new wxGtkDataViewModelNotifier( gtk_model
, model
, this );
3417 model
->AddNotifier( m_notifier
);
3419 gtk_tree_view_set_model( GTK_TREE_VIEW(m_treeview
), GTK_TREE_MODEL(gtk_model
) );
3421 // unref in wxDataViewCtrlInternal
3422 // g_object_unref( gtk_model );
3427 bool wxDataViewCtrl::AppendColumn( wxDataViewColumn
*col
)
3429 if (!wxDataViewCtrlBase::AppendColumn(col
))
3432 m_cols
.Append( col
);
3434 gtk_tree_view_append_column( GTK_TREE_VIEW(m_treeview
),
3435 GTK_TREE_VIEW_COLUMN(col
->GetGtkHandle()) );
3440 bool wxDataViewCtrl::PrependColumn( wxDataViewColumn
*col
)
3442 if (!wxDataViewCtrlBase::PrependColumn(col
))
3445 m_cols
.Insert( col
);
3447 gtk_tree_view_insert_column( GTK_TREE_VIEW(m_treeview
),
3448 GTK_TREE_VIEW_COLUMN(col
->GetGtkHandle()), 0 );
3453 unsigned int wxDataViewCtrl::GetColumnCount() const
3455 return m_cols
.GetCount();
3458 wxDataViewColumn
* wxDataViewCtrl::GetColumn( unsigned int pos
) const
3460 GtkTreeViewColumn
*gtk_col
= gtk_tree_view_get_column( GTK_TREE_VIEW(m_treeview
), pos
);
3464 wxDataViewColumnList::const_iterator iter
;
3465 for (iter
= m_cols
.begin(); iter
!= m_cols
.end(); iter
++)
3467 wxDataViewColumn
*col
= *iter
;
3468 if (GTK_TREE_VIEW_COLUMN(col
->GetGtkHandle()) == gtk_col
)
3477 bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn
*column
)
3479 gtk_tree_view_remove_column( GTK_TREE_VIEW(m_treeview
),
3480 GTK_TREE_VIEW_COLUMN(column
->GetGtkHandle()) );
3482 m_cols
.remove( column
);
3489 bool wxDataViewCtrl::ClearColumns()
3491 wxDataViewColumnList::iterator iter
;
3492 for (iter
= m_cols
.begin(); iter
!= m_cols
.end(); iter
++)
3494 wxDataViewColumn
*col
= *iter
;
3495 gtk_tree_view_remove_column( GTK_TREE_VIEW(m_treeview
),
3496 GTK_TREE_VIEW_COLUMN(col
->GetGtkHandle()) );
3504 int wxDataViewCtrl::GetColumnPosition( const wxDataViewColumn
*column
) const
3506 GtkTreeViewColumn
*gtk_column
= GTK_TREE_VIEW_COLUMN(column
->GetConstGtkHandle());
3508 GList
*list
= gtk_tree_view_get_columns( GTK_TREE_VIEW(m_treeview
) );
3510 gint pos
= g_list_index( list
, (gconstpointer
) gtk_column
);
3512 g_list_free( list
);
3517 wxDataViewColumn
*wxDataViewCtrl::GetSortingColumn() const
3519 return m_internal
->GetDataViewSortColumn();
3522 void wxDataViewCtrl::Expand( const wxDataViewItem
& item
)
3525 iter
.user_data
= item
.GetID();
3526 GtkTreePath
*path
= m_internal
->get_path( &iter
);
3527 gtk_tree_view_expand_row( GTK_TREE_VIEW(m_treeview
), path
, false );
3528 gtk_tree_path_free( path
);
3531 void wxDataViewCtrl::Collapse( const wxDataViewItem
& item
)
3534 iter
.user_data
= item
.GetID();
3535 GtkTreePath
*path
= m_internal
->get_path( &iter
);
3536 gtk_tree_view_collapse_row( GTK_TREE_VIEW(m_treeview
), path
);
3537 gtk_tree_path_free( path
);
3540 wxDataViewItem
wxDataViewCtrl::GetSelection() const
3542 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3544 if (m_windowStyle
& wxDV_MULTIPLE
)
3546 // Report the first one
3547 GtkTreeModel
*model
;
3548 GList
*list
= gtk_tree_selection_get_selected_rows( selection
, &model
);
3552 GtkTreePath
*path
= (GtkTreePath
*) list
->data
;
3554 m_internal
->get_iter( &iter
, path
);
3557 g_list_foreach( list
, (GFunc
) gtk_tree_path_free
, NULL
);
3558 g_list_free( list
);
3560 return wxDataViewItem( (void*) iter
.user_data
);
3566 if (gtk_tree_selection_get_selected( selection
, NULL
, &iter
))
3568 wxDataViewItem
item( (void*) iter
.user_data
);
3573 return wxDataViewItem(0);
3576 int wxDataViewCtrl::GetSelections( wxDataViewItemArray
& sel
) const
3580 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3581 if (HasFlag(wxDV_MULTIPLE
))
3583 GtkTreeModel
*model
;
3584 GList
*list
= gtk_tree_selection_get_selected_rows( selection
, &model
);
3589 GtkTreePath
*path
= (GtkTreePath
*) list
->data
;
3592 m_internal
->get_iter( &iter
, path
);
3594 sel
.Add( wxDataViewItem( (void*) iter
.user_data
) );
3596 list
= g_list_next( list
);
3601 g_list_foreach( list
, (GFunc
) gtk_tree_path_free
, NULL
);
3602 g_list_free( list
);
3608 GtkTreeModel
*model
;
3610 gboolean has_selection
= gtk_tree_selection_get_selected( selection
, &model
, &iter
);
3613 sel
.Add( wxDataViewItem( (void*) iter
.user_data
) );
3621 void wxDataViewCtrl::SetSelections( const wxDataViewItemArray
& sel
)
3623 GtkDisableSelectionEvents();
3625 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3627 gtk_tree_selection_unselect_all( selection
);
3630 for (i
= 0; i
< sel
.GetCount(); i
++)
3633 iter
.user_data
= (gpointer
) sel
[i
].GetID();
3634 gtk_tree_selection_select_iter( selection
, &iter
);
3637 GtkEnableSelectionEvents();
3640 void wxDataViewCtrl::Select( const wxDataViewItem
& item
)
3642 GtkDisableSelectionEvents();
3644 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3647 iter
.user_data
= (gpointer
) item
.GetID();
3648 gtk_tree_selection_select_iter( selection
, &iter
);
3650 GtkEnableSelectionEvents();
3653 void wxDataViewCtrl::Unselect( const wxDataViewItem
& item
)
3655 GtkDisableSelectionEvents();
3657 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3660 iter
.user_data
= (gpointer
) item
.GetID();
3661 gtk_tree_selection_unselect_iter( selection
, &iter
);
3663 GtkEnableSelectionEvents();
3666 bool wxDataViewCtrl::IsSelected( const wxDataViewItem
& item
) const
3668 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3671 iter
.user_data
= (gpointer
) item
.GetID();
3673 return gtk_tree_selection_iter_is_selected( selection
, &iter
);
3676 void wxDataViewCtrl::SelectAll()
3678 GtkDisableSelectionEvents();
3680 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3682 gtk_tree_selection_select_all( selection
);
3684 GtkEnableSelectionEvents();
3687 void wxDataViewCtrl::UnselectAll()
3689 GtkDisableSelectionEvents();
3691 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3693 gtk_tree_selection_unselect_all( selection
);
3695 GtkEnableSelectionEvents();
3698 void wxDataViewCtrl::EnsureVisible( const wxDataViewItem
& item
, const wxDataViewColumn
*column
)
3701 iter
.user_data
= (gpointer
) item
.GetID();
3702 GtkTreePath
*path
= m_internal
->get_path( &iter
);
3703 gtk_tree_view_scroll_to_cell( GTK_TREE_VIEW(m_treeview
), path
, NULL
, false, 0.0, 0.0 );
3704 gtk_tree_path_free( path
);
3707 void wxDataViewCtrl::HitTest( const wxPoint
&point
,
3708 wxDataViewItem
&item
, wxDataViewColumn
*&column
) const
3710 item
= wxDataViewItem(0);
3714 wxRect
wxDataViewCtrl::GetItemRect( const wxDataViewItem
&item
,
3715 const wxDataViewColumn
*column
) const
3720 void wxDataViewCtrl::DoSetExpanderColumn()
3722 gtk_tree_view_set_expander_column( GTK_TREE_VIEW(m_treeview
),
3723 GTK_TREE_VIEW_COLUMN( GetExpanderColumn()->GetGtkHandle() ) );
3726 void wxDataViewCtrl::DoSetIndent()
3730 void wxDataViewCtrl::GtkDisableSelectionEvents()
3732 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3733 g_signal_handlers_disconnect_by_func( selection
,
3734 (gpointer
) (wxdataview_selection_changed_callback
), this);
3737 void wxDataViewCtrl::GtkEnableSelectionEvents()
3739 GtkTreeSelection
*selection
= gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview
) );
3740 g_signal_connect_after (selection
, "changed",
3741 G_CALLBACK (wxdataview_selection_changed_callback
), this);
3746 wxDataViewCtrl::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
3748 return GetDefaultAttributesFromGTKWidget(gtk_tree_view_new
);
3753 // !wxUSE_GENERICDATAVIEWCTRL
3756 // wxUSE_DATAVIEWCTRL