]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/dataview.cpp
implemented page close event for wxAuiNotebook
[wxWidgets.git] / src / gtk / dataview.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/dataview.cpp
3 // Purpose: wxDataViewCtrl GTK+2 implementation
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #if wxUSE_DATAVIEWCTRL
14
15 #include "wx/dataview.h"
16
17 #ifndef wxUSE_GENERICDATAVIEWCTRL
18
19 #ifndef WX_PRECOMP
20 #include "wx/log.h"
21 #include "wx/dcclient.h"
22 #include "wx/sizer.h"
23 #endif
24
25 #include "wx/stockitem.h"
26 #include "wx/calctrl.h"
27 #include "wx/popupwin.h"
28 #include "wx/icon.h"
29
30
31 #include "wx/gtk/private.h"
32 #include "wx/gtk/win_gtk.h"
33
34 #include <gobject/gvaluecollector.h>
35 #include <gtk/gtktreemodel.h>
36 #include <gtk/gtktreednd.h>
37
38 #include <gdk/gdkkeysyms.h>
39
40 //-----------------------------------------------------------------------------
41 // classes
42 //-----------------------------------------------------------------------------
43
44 class wxDataViewCtrl;
45
46 //-----------------------------------------------------------------------------
47 // data
48 //-----------------------------------------------------------------------------
49
50 extern bool g_blockEventsOnDrag;
51
52 //-----------------------------------------------------------------------------
53 // define new GTK+ class wxGtkListStore
54 //-----------------------------------------------------------------------------
55
56 extern "C" {
57
58 #define GTK_TYPE_WX_LIST_STORE (gtk_wx_list_store_get_type ())
59 #define GTK_WX_LIST_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_WX_LIST_STORE, GtkWxListStore))
60 #define GTK_WX_LIST_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WX_LIST_STORE, GtkWxListStoreClass))
61 #define GTK_IS_WX_LIST_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_WX_LIST_STORE))
62 #define GTK_IS_WX_LIST_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WX_LIST_STORE))
63 #define GTK_WX_LIST_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WX_LIST_STORE, GtkWxListStoreClass))
64
65 GType gtk_wx_list_store_get_type (void);
66
67 typedef struct _GtkWxListStore GtkWxListStore;
68 typedef struct _GtkWxListStoreClass GtkWxListStoreClass;
69
70 struct _GtkWxListStore
71 {
72 GObject parent;
73
74 /*< private >*/
75 gint stamp;
76 wxDataViewListModel *model;
77 };
78
79 struct _GtkWxListStoreClass
80 {
81 GObjectClass list_parent_class;
82 };
83
84 static GtkWxListStore *wxgtk_list_store_new (void);
85 static void wxgtk_list_store_init (GtkWxListStore *list_store);
86 static void wxgtk_list_store_class_init (GtkWxListStoreClass *klass);
87 static void wxgtk_list_store_tree_model_init (GtkTreeModelIface *iface);
88 static void wxgtk_list_store_finalize (GObject *object);
89 static GtkTreeModelFlags wxgtk_list_store_get_flags (GtkTreeModel *tree_model);
90 static gint wxgtk_list_store_get_n_columns (GtkTreeModel *tree_model);
91 static GType wxgtk_list_store_get_column_type (GtkTreeModel *tree_model,
92 gint index);
93 static gboolean wxgtk_list_store_get_iter (GtkTreeModel *tree_model,
94 GtkTreeIter *iter,
95 GtkTreePath *path);
96 static GtkTreePath *wxgtk_list_store_get_path (GtkTreeModel *tree_model,
97 GtkTreeIter *iter);
98 static void wxgtk_list_store_get_value (GtkTreeModel *tree_model,
99 GtkTreeIter *iter,
100 gint column,
101 GValue *value);
102 static gboolean wxgtk_list_store_iter_next (GtkTreeModel *tree_model,
103 GtkTreeIter *iter);
104 static gboolean wxgtk_list_store_iter_children (GtkTreeModel *tree_model,
105 GtkTreeIter *iter,
106 GtkTreeIter *parent);
107 static gboolean wxgtk_list_store_iter_has_child (GtkTreeModel *tree_model,
108 GtkTreeIter *iter);
109 static gint wxgtk_list_store_iter_n_children (GtkTreeModel *tree_model,
110 GtkTreeIter *iter);
111 static gboolean wxgtk_list_store_iter_nth_child (GtkTreeModel *tree_model,
112 GtkTreeIter *iter,
113 GtkTreeIter *parent,
114 gint n);
115 static gboolean wxgtk_list_store_iter_parent (GtkTreeModel *tree_model,
116 GtkTreeIter *iter,
117 GtkTreeIter *child);
118
119 static GObjectClass *list_parent_class = NULL;
120
121 GType
122 gtk_wx_list_store_get_type (void)
123 {
124 static GType list_store_type = 0;
125
126 if (!list_store_type)
127 {
128 static const GTypeInfo list_store_info =
129 {
130 sizeof (GtkWxListStoreClass),
131 NULL, /* base_init */
132 NULL, /* base_finalize */
133 (GClassInitFunc) wxgtk_list_store_class_init,
134 NULL, /* class_finalize */
135 NULL, /* class_data */
136 sizeof (GtkWxListStore),
137 0,
138 (GInstanceInitFunc) wxgtk_list_store_init,
139 };
140
141 static const GInterfaceInfo tree_model_info =
142 {
143 (GInterfaceInitFunc) wxgtk_list_store_tree_model_init,
144 NULL,
145 NULL
146 };
147
148 list_store_type = g_type_register_static (G_TYPE_OBJECT, "GtkWxListStore",
149 &list_store_info, (GTypeFlags)0 );
150
151 g_type_add_interface_static (list_store_type,
152 GTK_TYPE_TREE_MODEL,
153 &tree_model_info);
154 }
155
156 return list_store_type;
157 }
158
159 static GtkWxListStore *
160 wxgtk_list_store_new(void)
161 {
162 GtkWxListStore *retval = (GtkWxListStore *) g_object_new (GTK_TYPE_WX_LIST_STORE, NULL);
163 return retval;
164 }
165
166 static void
167 wxgtk_list_store_class_init (GtkWxListStoreClass *klass)
168 {
169 list_parent_class = (GObjectClass*) g_type_class_peek_parent (klass);
170 GObjectClass *object_class = (GObjectClass*) klass;
171 object_class->finalize = wxgtk_list_store_finalize;
172 }
173
174 static void
175 wxgtk_list_store_tree_model_init (GtkTreeModelIface *iface)
176 {
177 iface->get_flags = wxgtk_list_store_get_flags;
178 iface->get_n_columns = wxgtk_list_store_get_n_columns;
179 iface->get_column_type = wxgtk_list_store_get_column_type;
180 iface->get_iter = wxgtk_list_store_get_iter;
181 iface->get_path = wxgtk_list_store_get_path;
182 iface->get_value = wxgtk_list_store_get_value;
183 iface->iter_next = wxgtk_list_store_iter_next;
184 iface->iter_children = wxgtk_list_store_iter_children;
185 iface->iter_has_child = wxgtk_list_store_iter_has_child;
186 iface->iter_n_children = wxgtk_list_store_iter_n_children;
187 iface->iter_nth_child = wxgtk_list_store_iter_nth_child;
188 iface->iter_parent = wxgtk_list_store_iter_parent;
189 }
190
191 static void
192 wxgtk_list_store_init (GtkWxListStore *list_store)
193 {
194 list_store->model = NULL;
195 list_store->stamp = g_random_int();
196 }
197
198 static void
199 wxgtk_list_store_finalize (GObject *object)
200 {
201 /* GtkWxListStore *list_store = GTK_WX_LIST_STORE (object); */
202
203 /* we need to sort out, which class deletes what */
204 /* delete list_store->model; */
205
206 /* must chain up */
207 (* list_parent_class->finalize) (object);
208 }
209
210 } // extern "C"
211
212 //-----------------------------------------------------------------------------
213 // implement callbacks from wxGtkListStore class by letting
214 // them call the methods of wxWidgets' wxDataViewListModel
215 //-----------------------------------------------------------------------------
216
217 static GtkTreeModelFlags
218 wxgtk_list_store_get_flags (GtkTreeModel *tree_model)
219 {
220 g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), (GtkTreeModelFlags)0 );
221
222 // GTK+ list store uses a linked list for storing the
223 // items and a pointer to a child is used as the member
224 // field of a GtkTreeIter. This means that the iter is
225 // valid in the GtkListStore as long as the child exists.
226 // We use the index of the row and since the index of a
227 // specific row will change if a row above is deleted,
228 // the iter does not persist
229 return /* GTK_TREE_MODEL_ITERS_PERSIST | */ GTK_TREE_MODEL_LIST_ONLY;
230 }
231
232 static gint
233 wxgtk_list_store_get_n_columns (GtkTreeModel *tree_model)
234 {
235 GtkWxListStore *list_store = (GtkWxListStore *) tree_model;
236 g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), 0);
237
238 return list_store->model->GetNumberOfCols();
239 }
240
241 static GType
242 wxgtk_list_store_get_column_type (GtkTreeModel *tree_model,
243 gint index)
244 {
245 GtkWxListStore *list_store = (GtkWxListStore *) tree_model;
246 g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), G_TYPE_INVALID);
247
248 GType gtype = G_TYPE_INVALID;
249
250 wxString wxtype = list_store->model->GetColType( (unsigned int) index );
251
252 if (wxtype == wxT("string"))
253 gtype = G_TYPE_STRING;
254
255 return gtype;
256 }
257
258 static gboolean
259 wxgtk_list_store_get_iter (GtkTreeModel *tree_model,
260 GtkTreeIter *iter,
261 GtkTreePath *path)
262 {
263 GtkWxListStore *list_store = (GtkWxListStore *) tree_model;
264 g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), FALSE);
265 g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE);
266
267 unsigned int i = (unsigned int)gtk_tree_path_get_indices (path)[0];
268
269 if (i >= list_store->model->GetNumberOfRows())
270 return FALSE;
271
272 iter->stamp = list_store->stamp;
273 // user_data is just the index
274 iter->user_data = (gpointer) i;
275
276 return TRUE;
277 }
278
279 static GtkTreePath *
280 wxgtk_list_store_get_path (GtkTreeModel *tree_model,
281 GtkTreeIter *iter)
282 {
283 g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), NULL);
284 g_return_val_if_fail (iter->stamp == GTK_WX_LIST_STORE (tree_model)->stamp, NULL);
285
286 GtkTreePath *retval = gtk_tree_path_new ();
287 // user_data is just the index
288 int i = (wxUIntPtr) iter->user_data;
289 gtk_tree_path_append_index (retval, i);
290 return retval;
291 }
292
293 static void
294 wxgtk_list_store_get_value (GtkTreeModel *tree_model,
295 GtkTreeIter *iter,
296 gint column,
297 GValue *value)
298 {
299 GtkWxListStore *list_store = (GtkWxListStore *) tree_model;
300 g_return_if_fail (GTK_IS_WX_LIST_STORE (tree_model) );
301
302 #if 0
303 wxDataViewListModel *model = list_store->model;
304 wxString mtype = model->GetColType( (unsigned int) column );
305 if (mtype == wxT("string"))
306 {
307 wxVariant variant;
308 g_value_init( value, G_TYPE_STRING );
309 model->GetValue( variant, (unsigned int) column, (unsigned int) iter->user_data );
310 g_value_set_string( value, wxGTK_CONV(variant.GetString()) );
311 }
312 else
313 {
314 }
315 #endif
316
317 #if 0
318 GtkTreeDataList *list;
319 gint tmp_column = column;
320
321 g_return_if_fail (column < GTK_LIST_STORE (tree_model)->n_columns);
322 g_return_if_fail (GTK_LIST_STORE (tree_model)->stamp == iter->stamp);
323
324 list = G_SLIST (iter->user_data)->data;
325
326 while (tmp_column-- > 0 && list)
327 list = list->next;
328
329 if (list == NULL)
330 g_value_init (value, GTK_LIST_STORE (tree_model)->column_headers[column]);
331 else
332 _gtk_tree_data_list_node_to_value (list,
333 GTK_LIST_STORE (tree_model)->column_headers[column],
334 value);
335 #endif
336
337 }
338
339 static gboolean
340 wxgtk_list_store_iter_next (GtkTreeModel *tree_model,
341 GtkTreeIter *iter)
342 {
343 g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), FALSE);
344 GtkWxListStore *list_store = (GtkWxListStore *) tree_model;
345
346 g_return_val_if_fail (list_store->stamp == iter->stamp, FALSE);
347
348 int n = (wxUIntPtr) iter->user_data;
349
350 if (n == -1)
351 return FALSE;
352
353 if (n >= (int) list_store->model->GetNumberOfRows()-1)
354 return FALSE;
355
356 iter->user_data = (gpointer) ++n;
357
358 return TRUE;
359 }
360
361 static gboolean
362 wxgtk_list_store_iter_children (GtkTreeModel *tree_model,
363 GtkTreeIter *iter,
364 GtkTreeIter *parent)
365 {
366 g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), FALSE);
367 GtkWxListStore *list_store = (GtkWxListStore *) tree_model;
368
369 // this is a list, nodes have no children
370 if (parent)
371 return FALSE;
372
373 iter->stamp = list_store->stamp;
374 iter->user_data = (gpointer) -1;
375
376 return TRUE;
377 }
378
379 static gboolean
380 wxgtk_list_store_iter_has_child (GtkTreeModel *tree_model,
381 GtkTreeIter *iter)
382 {
383 return FALSE;
384 }
385
386 static gint
387 wxgtk_list_store_iter_n_children (GtkTreeModel *tree_model,
388 GtkTreeIter *iter)
389 {
390 g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), -1);
391 GtkWxListStore *list_store = (GtkWxListStore *) tree_model;
392
393 if (iter == NULL)
394 return (gint) list_store->model->GetNumberOfRows();
395
396 g_return_val_if_fail (list_store->stamp == iter->stamp, -1);
397
398 return 0;
399 }
400
401 static gboolean
402 wxgtk_list_store_iter_nth_child (GtkTreeModel *tree_model,
403 GtkTreeIter *iter,
404 GtkTreeIter *parent,
405 gint n)
406 {
407 g_return_val_if_fail (GTK_IS_WX_LIST_STORE (tree_model), FALSE);
408 GtkWxListStore *list_store = (GtkWxListStore *) tree_model;
409
410 if (parent)
411 return FALSE;
412
413 if (n < 0)
414 return FALSE;
415
416 if (n >= (gint) list_store->model->GetNumberOfRows())
417 return FALSE;
418
419 iter->stamp = list_store->stamp;
420 iter->user_data = (gpointer) n;
421
422 return TRUE;
423 }
424
425 static gboolean
426 wxgtk_list_store_iter_parent (GtkTreeModel *tree_model,
427 GtkTreeIter *iter,
428 GtkTreeIter *child)
429 {
430 return FALSE;
431 }
432
433 //-----------------------------------------------------------------------------
434 // define new GTK+ class wxGtkRendererRenderer
435 //-----------------------------------------------------------------------------
436
437 extern "C" {
438
439 #define GTK_TYPE_WX_CELL_RENDERER (gtk_wx_cell_renderer_get_type ())
440 #define GTK_WX_CELL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_WX_CELL_RENDERER, GtkWxCellRenderer))
441 #define GTK_WX_CELL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WX_CELL_RENDERER, GtkWxCellRendererClass))
442 #define GTK_IS_WX_CELL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_WX_CELL_RENDERER))
443 #define GTK_IS_WX_CELL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WX_CELL_RENDERER))
444 #define GTK_WX_CELL_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WX_CELL_RENDERER, GtkWxCellRendererClass))
445
446 GType gtk_wx_cell_renderer_get_type (void);
447
448 typedef struct _GtkWxCellRenderer GtkWxCellRenderer;
449 typedef struct _GtkWxCellRendererClass GtkWxCellRendererClass;
450
451 struct _GtkWxCellRenderer
452 {
453 GtkCellRenderer parent;
454
455 /*< private >*/
456 wxDataViewCustomRenderer *cell;
457 guint32 last_click;
458 };
459
460 struct _GtkWxCellRendererClass
461 {
462 GtkCellRendererClass cell_parent_class;
463 };
464
465
466 static GtkCellRenderer *gtk_wx_cell_renderer_new (void);
467 static void gtk_wx_cell_renderer_init (
468 GtkWxCellRenderer *cell );
469 static void gtk_wx_cell_renderer_class_init(
470 GtkWxCellRendererClass *klass );
471 static void gtk_wx_cell_renderer_finalize (
472 GObject *object );
473 static void gtk_wx_cell_renderer_get_size (
474 GtkCellRenderer *cell,
475 GtkWidget *widget,
476 GdkRectangle *rectangle,
477 gint *x_offset,
478 gint *y_offset,
479 gint *width,
480 gint *height );
481 static void gtk_wx_cell_renderer_render (
482 GtkCellRenderer *cell,
483 GdkWindow *window,
484 GtkWidget *widget,
485 GdkRectangle *background_area,
486 GdkRectangle *cell_area,
487 GdkRectangle *expose_area,
488 GtkCellRendererState flags );
489 static gboolean gtk_wx_cell_renderer_activate(
490 GtkCellRenderer *cell,
491 GdkEvent *event,
492 GtkWidget *widget,
493 const gchar *path,
494 GdkRectangle *background_area,
495 GdkRectangle *cell_area,
496 GtkCellRendererState flags );
497
498 static GObjectClass *cell_parent_class = NULL;
499
500 } // extern "C"
501
502 GType
503 gtk_wx_cell_renderer_get_type (void)
504 {
505 static GType cell_wx_type = 0;
506
507 if (!cell_wx_type)
508 {
509 static const GTypeInfo cell_wx_info =
510 {
511 sizeof (GtkWxCellRendererClass),
512 NULL, /* base_init */
513 NULL, /* base_finalize */
514 (GClassInitFunc) gtk_wx_cell_renderer_class_init,
515 NULL, /* class_finalize */
516 NULL, /* class_data */
517 sizeof (GtkWxCellRenderer),
518 0, /* n_preallocs */
519 (GInstanceInitFunc) gtk_wx_cell_renderer_init,
520 };
521
522 cell_wx_type = g_type_register_static( GTK_TYPE_CELL_RENDERER,
523 "GtkWxCellRenderer", &cell_wx_info, (GTypeFlags)0 );
524 }
525
526 return cell_wx_type;
527 }
528
529 static void
530 gtk_wx_cell_renderer_init (GtkWxCellRenderer *cell)
531 {
532 cell->cell = NULL;
533 cell->last_click = 0;
534 }
535
536 static void
537 gtk_wx_cell_renderer_class_init (GtkWxCellRendererClass *klass)
538 {
539 GObjectClass *object_class = G_OBJECT_CLASS (klass);
540 GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass);
541
542 cell_parent_class = (GObjectClass*) g_type_class_peek_parent (klass);
543
544 object_class->finalize = gtk_wx_cell_renderer_finalize;
545
546 cell_class->get_size = gtk_wx_cell_renderer_get_size;
547 cell_class->render = gtk_wx_cell_renderer_render;
548 cell_class->activate = gtk_wx_cell_renderer_activate;
549 }
550
551 static void
552 gtk_wx_cell_renderer_finalize (GObject *object)
553 {
554 /* must chain up */
555 (* G_OBJECT_CLASS (cell_parent_class)->finalize) (object);
556 }
557
558 GtkCellRenderer*
559 gtk_wx_cell_renderer_new (void)
560 {
561 return (GtkCellRenderer*) g_object_new (GTK_TYPE_WX_CELL_RENDERER, NULL);
562 }
563
564 static void
565 gtk_wx_cell_renderer_get_size (GtkCellRenderer *renderer,
566 GtkWidget *widget,
567 GdkRectangle *cell_area,
568 gint *x_offset,
569 gint *y_offset,
570 gint *width,
571 gint *height)
572 {
573 GtkWxCellRenderer *wxrenderer = (GtkWxCellRenderer *) renderer;
574 wxDataViewCustomRenderer *cell = wxrenderer->cell;
575
576 wxSize size = cell->GetSize();
577
578 gint calc_width = (gint) renderer->xpad * 2 + size.x;
579 gint calc_height = (gint) renderer->ypad * 2 + size.y;
580
581 if (x_offset)
582 *x_offset = 0;
583 if (y_offset)
584 *y_offset = 0;
585
586 if (cell_area && size.x > 0 && size.y > 0)
587 {
588 if (x_offset)
589 {
590 *x_offset = (gint)((renderer->xalign *
591 (cell_area->width - calc_width - 2 * renderer->xpad)));
592 *x_offset = MAX (*x_offset, 0) + renderer->xpad;
593 }
594 if (y_offset)
595 {
596 *y_offset = (gint)((renderer->yalign *
597 (cell_area->height - calc_height - 2 * renderer->ypad)));
598 *y_offset = MAX (*y_offset, 0) + renderer->ypad;
599 }
600 }
601
602 if (width)
603 *width = calc_width;
604
605 if (height)
606 *height = calc_height;
607 }
608
609 static void
610 gtk_wx_cell_renderer_render (GtkCellRenderer *renderer,
611 GdkWindow *window,
612 GtkWidget *widget,
613 GdkRectangle *background_area,
614 GdkRectangle *cell_area,
615 GdkRectangle *expose_area,
616 GtkCellRendererState flags)
617
618 {
619 GtkWxCellRenderer *wxrenderer = (GtkWxCellRenderer *) renderer;
620 wxDataViewCustomRenderer *cell = wxrenderer->cell;
621
622 GdkRectangle rect;
623 gtk_wx_cell_renderer_get_size (renderer, widget, cell_area,
624 &rect.x,
625 &rect.y,
626 &rect.width,
627 &rect.height);
628
629 rect.x += cell_area->x;
630 rect.y += cell_area->y;
631 rect.width -= renderer->xpad * 2;
632 rect.height -= renderer->ypad * 2;
633
634 GdkRectangle dummy;
635 if (gdk_rectangle_intersect (expose_area, &rect, &dummy))
636 {
637 wxRect renderrect( rect.x, rect.y, rect.width, rect.height );
638 wxWindowDC* dc = (wxWindowDC*) cell->GetDC();
639 if (dc->m_window == NULL)
640 {
641 dc->m_window = window;
642 dc->SetUpDC();
643 }
644
645 int state = 0;
646 if (flags & GTK_CELL_RENDERER_SELECTED)
647 state |= wxDATAVIEW_CELL_SELECTED;
648 if (flags & GTK_CELL_RENDERER_PRELIT)
649 state |= wxDATAVIEW_CELL_PRELIT;
650 if (flags & GTK_CELL_RENDERER_INSENSITIVE)
651 state |= wxDATAVIEW_CELL_INSENSITIVE;
652 if (flags & GTK_CELL_RENDERER_INSENSITIVE)
653 state |= wxDATAVIEW_CELL_INSENSITIVE;
654 if (flags & GTK_CELL_RENDERER_FOCUSED)
655 state |= wxDATAVIEW_CELL_FOCUSED;
656 cell->Render( renderrect, dc, state );
657 }
658 }
659
660 static gboolean
661 gtk_wx_cell_renderer_activate(
662 GtkCellRenderer *renderer,
663 GdkEvent *event,
664 GtkWidget *widget,
665 const gchar *path,
666 GdkRectangle *background_area,
667 GdkRectangle *cell_area,
668 GtkCellRendererState flags )
669 {
670 GtkWxCellRenderer *wxrenderer = (GtkWxCellRenderer *) renderer;
671 wxDataViewCustomRenderer *cell = wxrenderer->cell;
672
673 GdkRectangle rect;
674 gtk_wx_cell_renderer_get_size (renderer, widget, cell_area,
675 &rect.x,
676 &rect.y,
677 &rect.width,
678 &rect.height);
679
680 rect.x += cell_area->x;
681 rect.y += cell_area->y;
682 rect.width -= renderer->xpad * 2;
683 rect.height -= renderer->ypad * 2;
684
685 wxRect renderrect( rect.x, rect.y, rect.width, rect.height );
686
687 wxDataViewListModel *model = cell->GetOwner()->GetOwner()->GetModel();
688
689 GtkTreePath *treepath = gtk_tree_path_new_from_string( path );
690 unsigned int model_row = (unsigned int)gtk_tree_path_get_indices (treepath)[0];
691 gtk_tree_path_free( treepath );
692
693 unsigned int model_col = cell->GetOwner()->GetModelColumn();
694
695 if (event->type == GDK_BUTTON_PRESS)
696 {
697 GdkEventButton *button_event = (GdkEventButton*) event;
698 wxPoint pt( ((int) button_event->x) - renderrect.x,
699 ((int) button_event->y) - renderrect.y );
700
701 bool ret = false;
702 if (button_event->button == 1)
703 {
704 if (cell->LeftClick( pt, renderrect, model, model_col, model_row ))
705 ret = true;
706 // TODO: query system double-click time
707 if (button_event->time - wxrenderer->last_click < 400)
708 if (cell->Activate( renderrect, model, model_col, model_row ))
709 ret = true;
710 }
711 if (button_event->button == 3)
712 {
713 if (cell->RightClick( pt, renderrect, model, model_col, model_row ))
714 ret = true;
715 }
716
717 wxrenderer->last_click = button_event->time;
718
719 return ret;
720 }
721
722 return false;
723 }
724
725 // ---------------------------------------------------------
726 // wxGtkDataViewListModelNotifier
727 // ---------------------------------------------------------
728
729 class wxGtkDataViewListModelNotifier: public wxDataViewListModelNotifier
730 {
731 public:
732 wxGtkDataViewListModelNotifier( GtkWxListStore* gtk_store, wxDataViewListModel *wx_model );
733
734 virtual bool RowAppended();
735 virtual bool RowPrepended();
736 virtual bool RowInserted( unsigned int before );
737 virtual bool RowDeleted( unsigned int row );
738 virtual bool RowChanged( unsigned int row );
739 virtual bool ValueChanged( unsigned int col, unsigned int row );
740 virtual bool RowsReordered( unsigned int *new_order );
741 virtual bool Cleared();
742
743 GtkWxListStore *m_gtk_store;
744 wxDataViewListModel *m_wx_model;
745 };
746
747 // ---------------------------------------------------------
748 // wxGtkDataViewListModelNotifier
749 // ---------------------------------------------------------
750
751 wxGtkDataViewListModelNotifier::wxGtkDataViewListModelNotifier(
752 GtkWxListStore* gtk_store, wxDataViewListModel *wx_model )
753 {
754 m_gtk_store = gtk_store;
755 m_wx_model = wx_model;
756 }
757
758 bool wxGtkDataViewListModelNotifier::RowAppended()
759 {
760 unsigned int pos = m_wx_model->GetNumberOfRows()-1;
761
762 GtkTreeIter iter;
763 iter.stamp = m_gtk_store->stamp;
764 iter.user_data = (gpointer) pos;
765
766 GtkTreePath *path = gtk_tree_path_new ();
767 gtk_tree_path_append_index (path, (gint) pos);
768 gtk_tree_model_row_inserted (GTK_TREE_MODEL (m_gtk_store), path, &iter);
769 gtk_tree_path_free (path);
770
771 return true;
772 }
773
774 bool wxGtkDataViewListModelNotifier::RowPrepended()
775 {
776 GtkTreeIter iter;
777 iter.stamp = m_gtk_store->stamp;
778 iter.user_data = (gpointer) 0;
779
780 GtkTreePath *path = gtk_tree_path_new ();
781 gtk_tree_path_append_index (path, (gint) 0);
782 gtk_tree_model_row_inserted (GTK_TREE_MODEL (m_gtk_store), path, &iter);
783 gtk_tree_path_free (path);
784
785 return true;
786 }
787
788 bool wxGtkDataViewListModelNotifier::RowInserted( unsigned int before )
789 {
790 GtkTreeIter iter;
791 iter.stamp = m_gtk_store->stamp;
792 iter.user_data = (gpointer) before;
793
794 GtkTreePath *path = gtk_tree_path_new ();
795 gtk_tree_path_append_index (path, (gint) before);
796 gtk_tree_model_row_inserted (GTK_TREE_MODEL (m_gtk_store), path, &iter);
797 gtk_tree_path_free (path);
798
799 return true;
800 }
801
802 bool wxGtkDataViewListModelNotifier::RowDeleted( unsigned int row )
803 {
804 GtkTreePath *path = gtk_tree_path_new ();
805 gtk_tree_path_append_index (path, (gint) row);
806 gtk_tree_model_row_deleted (GTK_TREE_MODEL (m_gtk_store), path);
807 gtk_tree_path_free (path);
808
809 return true;
810 }
811
812 bool wxGtkDataViewListModelNotifier::RowChanged( unsigned int row )
813 {
814 GtkTreeIter iter;
815 iter.stamp = m_gtk_store->stamp;
816 iter.user_data = (gpointer) row;
817 GtkTreePath *path = gtk_tree_model_get_path (GTK_TREE_MODEL (m_gtk_store), &iter);
818 gtk_tree_model_row_changed (GTK_TREE_MODEL (m_gtk_store), path, &iter);
819 gtk_tree_path_free (path);
820
821 return true;
822 }
823
824 bool wxGtkDataViewListModelNotifier::ValueChanged( unsigned int model_col, unsigned int model_row )
825 {
826 // This adds GTK+'s missing MVC logic for ValueChanged
827 wxNode *node = GetOwner()->m_viewingColumns.GetFirst();
828 while (node)
829 {
830 wxDataViewViewingColumn* viewing_column = (wxDataViewViewingColumn*) node->GetData();
831 if (viewing_column->m_modelColumn == model_col)
832 {
833 GtkTreeView *widget = GTK_TREE_VIEW(viewing_column->m_viewColumn->GetOwner()->m_treeview);
834 GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(viewing_column->m_viewColumn->GetGtkHandle());
835
836 // Get cell area
837 GtkTreePath *path = gtk_tree_path_new();
838 gtk_tree_path_append_index( path, model_row );
839 GdkRectangle cell_area;
840 gtk_tree_view_get_cell_area( widget, path, column, &cell_area );
841 gtk_tree_path_free( path );
842
843 int ydiff = column->button->allocation.height;
844 // Redraw
845 gtk_widget_queue_draw_area( GTK_WIDGET(widget),
846 cell_area.x, ydiff + cell_area.y, cell_area.width, cell_area.height );
847 }
848
849 node = node->GetNext();
850 }
851
852 return true;
853 }
854
855 bool wxGtkDataViewListModelNotifier::RowsReordered( unsigned int *new_order )
856 {
857 // Assume sizeof(unsigned int)= == sizeof(gint)
858
859 GtkTreePath *path = gtk_tree_path_new ();
860 gtk_tree_model_rows_reordered (GTK_TREE_MODEL (m_gtk_store), path, NULL, (gint*)new_order);
861 gtk_tree_path_free (path);
862
863 // This adds GTK+'s missing MVC logic for RowsReordered
864 wxNode *node = GetOwner()->m_viewingColumns.GetFirst();
865 while (node)
866 {
867 wxDataViewViewingColumn* viewing_column = (wxDataViewViewingColumn*) node->GetData();
868 GtkTreeView *widget = GTK_TREE_VIEW(viewing_column->m_viewColumn->GetOwner()->m_treeview);
869 // Doesn't work yet...
870 gtk_widget_queue_draw( GTK_WIDGET(widget) );
871
872 node = node->GetNext();
873 }
874
875 return true;
876 }
877
878 bool wxGtkDataViewListModelNotifier::Cleared()
879 {
880 return false;
881 }
882
883 // ---------------------------------------------------------
884 // wxDataViewRenderer
885 // ---------------------------------------------------------
886
887 IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer, wxDataViewRendererBase)
888
889 wxDataViewRenderer::wxDataViewRenderer( const wxString &varianttype, wxDataViewCellMode mode ) :
890 wxDataViewRendererBase( varianttype, mode )
891 {
892 m_renderer = NULL;
893 }
894
895 // ---------------------------------------------------------
896 // wxDataViewTextRenderer
897 // ---------------------------------------------------------
898
899 extern "C" {
900 static void wxGtkTextRendererEditedCallback( GtkCellRendererText *renderer,
901 gchar *arg1, gchar *arg2, gpointer user_data );
902 }
903
904 static void wxGtkTextRendererEditedCallback( GtkCellRendererText *renderer,
905 gchar *arg1, gchar *arg2, gpointer user_data )
906 {
907 wxDataViewTextRenderer *cell = (wxDataViewTextRenderer*) user_data;
908
909 wxString tmp = wxGTK_CONV_BACK( arg2 );
910 wxVariant value = tmp;
911 if (!cell->Validate( value ))
912 return;
913
914 wxDataViewListModel *model = cell->GetOwner()->GetOwner()->GetModel();
915
916 GtkTreePath *path = gtk_tree_path_new_from_string( arg1 );
917 unsigned int model_row = (unsigned int)gtk_tree_path_get_indices (path)[0];
918 gtk_tree_path_free( path );
919
920 unsigned int model_col = cell->GetOwner()->GetModelColumn();
921
922 model->SetValue( value, model_col, model_row );
923 model->ValueChanged( model_col, model_row );
924 }
925
926 IMPLEMENT_CLASS(wxDataViewTextRenderer, wxDataViewRenderer)
927
928 wxDataViewTextRenderer::wxDataViewTextRenderer( const wxString &varianttype, wxDataViewCellMode mode ) :
929 wxDataViewRenderer( varianttype, mode )
930 {
931 m_renderer = (void*) gtk_cell_renderer_text_new();
932
933 if (m_mode & wxDATAVIEW_CELL_EDITABLE)
934 {
935 GValue gvalue = { 0, };
936 g_value_init( &gvalue, G_TYPE_BOOLEAN );
937 g_value_set_boolean( &gvalue, true );
938 g_object_set_property( G_OBJECT(m_renderer), "editable", &gvalue );
939 g_value_unset( &gvalue );
940
941 g_signal_connect_after( m_renderer, "edited", G_CALLBACK(wxGtkTextRendererEditedCallback), this );
942 }
943 }
944
945 bool wxDataViewTextRenderer::SetValue( const wxVariant &value )
946 {
947 wxString tmp = value;
948
949 GValue gvalue = { 0, };
950 g_value_init( &gvalue, G_TYPE_STRING );
951 #if wxUSE_UNICODE
952 g_value_set_string( &gvalue, wxGTK_CONV( tmp ) );
953 #else
954 g_value_set_string( &gvalue, wxGTK_CONV_FONT( tmp, GetOwner()->GetOwner()->GetFont() ) );
955 #endif
956 g_object_set_property( G_OBJECT(m_renderer), "text", &gvalue );
957 g_value_unset( &gvalue );
958
959 return true;
960 }
961
962 bool wxDataViewTextRenderer::GetValue( wxVariant &value )
963 {
964 GValue gvalue = { 0, };
965 g_value_init( &gvalue, G_TYPE_STRING );
966 g_object_get_property( G_OBJECT(m_renderer), "text", &gvalue );
967 wxString tmp = wxGTK_CONV_BACK( g_value_get_string( &gvalue ) );
968 g_value_unset( &gvalue );
969
970 value = tmp;
971
972 return true;
973 }
974
975 // ---------------------------------------------------------
976 // wxDataViewBitmapRenderer
977 // ---------------------------------------------------------
978
979 IMPLEMENT_CLASS(wxDataViewBitmapRenderer, wxDataViewRenderer)
980
981 wxDataViewBitmapRenderer::wxDataViewBitmapRenderer( const wxString &varianttype, wxDataViewCellMode mode ) :
982 wxDataViewRenderer( varianttype, mode )
983 {
984 m_renderer = (void*) gtk_cell_renderer_pixbuf_new();
985 }
986
987 bool wxDataViewBitmapRenderer::SetValue( const wxVariant &value )
988 {
989 if (value.GetType() == wxT("wxBitmap"))
990 {
991 wxBitmap bitmap;
992 bitmap << value;
993
994 // This may create a Pixbuf representation in the
995 // wxBitmap object (and it will stay there)
996 GdkPixbuf *pixbuf = bitmap.GetPixbuf();
997
998 GValue gvalue = { 0, };
999 g_value_init( &gvalue, G_TYPE_OBJECT );
1000 g_value_set_object( &gvalue, pixbuf );
1001 g_object_set_property( G_OBJECT(m_renderer), "pixbuf", &gvalue );
1002 g_value_unset( &gvalue );
1003
1004 return true;
1005 }
1006
1007 if (value.GetType() == wxT("wxIcon"))
1008 {
1009 wxIcon bitmap;
1010 bitmap << value;
1011
1012 // This may create a Pixbuf representation in the
1013 // wxBitmap object (and it will stay there)
1014 GdkPixbuf *pixbuf = bitmap.GetPixbuf();
1015
1016 GValue gvalue = { 0, };
1017 g_value_init( &gvalue, G_TYPE_OBJECT );
1018 g_value_set_object( &gvalue, pixbuf );
1019 g_object_set_property( G_OBJECT(m_renderer), "pixbuf", &gvalue );
1020 g_value_unset( &gvalue );
1021
1022 return true;
1023 }
1024
1025 return false;
1026 }
1027
1028 bool wxDataViewBitmapRenderer::GetValue( wxVariant &value )
1029 {
1030 return false;
1031 }
1032
1033 // ---------------------------------------------------------
1034 // wxDataViewToggleRenderer
1035 // ---------------------------------------------------------
1036
1037 extern "C" {
1038 static void wxGtkToggleRendererToggledCallback( GtkCellRendererToggle *renderer,
1039 gchar *path, gpointer user_data );
1040 }
1041
1042 static void wxGtkToggleRendererToggledCallback( GtkCellRendererToggle *renderer,
1043 gchar *path, gpointer user_data )
1044 {
1045 wxDataViewToggleRenderer *cell = (wxDataViewToggleRenderer*) user_data;
1046
1047 // get old value
1048 GValue gvalue = { 0, };
1049 g_value_init( &gvalue, G_TYPE_BOOLEAN );
1050 g_object_get_property( G_OBJECT(renderer), "active", &gvalue );
1051 bool tmp = g_value_get_boolean( &gvalue );
1052 g_value_unset( &gvalue );
1053 // invert it
1054 tmp = !tmp;
1055
1056 wxVariant value = tmp;
1057 if (!cell->Validate( value ))
1058 return;
1059
1060 wxDataViewListModel *model = cell->GetOwner()->GetOwner()->GetModel();
1061
1062 GtkTreePath *gtk_path = gtk_tree_path_new_from_string( path );
1063 unsigned int model_row = (unsigned int)gtk_tree_path_get_indices (gtk_path)[0];
1064 gtk_tree_path_free( gtk_path );
1065
1066 unsigned int model_col = cell->GetOwner()->GetModelColumn();
1067
1068 model->SetValue( value, model_col, model_row );
1069 model->ValueChanged( model_col, model_row );
1070 }
1071
1072 IMPLEMENT_CLASS(wxDataViewToggleRenderer, wxDataViewRenderer)
1073
1074 wxDataViewToggleRenderer::wxDataViewToggleRenderer( const wxString &varianttype,
1075 wxDataViewCellMode mode ) :
1076 wxDataViewRenderer( varianttype, mode )
1077 {
1078 m_renderer = (void*) gtk_cell_renderer_toggle_new();
1079
1080 if (m_mode & wxDATAVIEW_CELL_ACTIVATABLE)
1081 {
1082 g_signal_connect_after( m_renderer, "toggled", G_CALLBACK(wxGtkToggleRendererToggledCallback), this );
1083 }
1084 else
1085 {
1086
1087 GValue gvalue = { 0, };
1088 g_value_init( &gvalue, G_TYPE_BOOLEAN );
1089 g_value_set_boolean( &gvalue, false );
1090 g_object_set_property( G_OBJECT(m_renderer), "activatable", &gvalue );
1091 g_value_unset( &gvalue );
1092
1093 GValue gvalue2 = { 0, };
1094 g_value_init( &gvalue2, gtk_cell_renderer_mode_get_type() );
1095 g_value_set_enum( &gvalue2, GTK_CELL_RENDERER_MODE_INERT );
1096 g_object_set_property( G_OBJECT(m_renderer), "mode", &gvalue2 );
1097 g_value_unset( &gvalue2 );
1098
1099 }
1100 }
1101
1102 bool wxDataViewToggleRenderer::SetValue( const wxVariant &value )
1103 {
1104 bool tmp = value;
1105
1106 GValue gvalue = { 0, };
1107 g_value_init( &gvalue, G_TYPE_BOOLEAN );
1108 g_value_set_boolean( &gvalue, tmp );
1109 g_object_set_property( G_OBJECT(m_renderer), "active", &gvalue );
1110 g_value_unset( &gvalue );
1111
1112 return true;
1113 }
1114
1115 bool wxDataViewToggleRenderer::GetValue( wxVariant &value )
1116 {
1117 GValue gvalue = { 0, };
1118 g_value_init( &gvalue, G_TYPE_BOOLEAN );
1119 g_object_get_property( G_OBJECT(m_renderer), "active", &gvalue );
1120 bool tmp = g_value_get_boolean( &gvalue );
1121 g_value_unset( &gvalue );
1122
1123 value = tmp;
1124
1125 return true;
1126 }
1127
1128 // ---------------------------------------------------------
1129 // wxDataViewCustomRenderer
1130 // ---------------------------------------------------------
1131
1132 class wxDataViewCtrlDC: public wxWindowDC
1133 {
1134 public:
1135 wxDataViewCtrlDC( wxDataViewCtrl *window )
1136 {
1137 GtkWidget *widget = window->m_treeview;
1138 // Set later
1139 m_window = NULL;
1140
1141 m_context = window->GtkGetPangoDefaultContext();
1142 m_layout = pango_layout_new( m_context );
1143 m_fontdesc = pango_font_description_copy( widget->style->font_desc );
1144
1145 m_cmap = gtk_widget_get_colormap( widget ? widget : window->m_widget );
1146
1147 // Set m_window later
1148 // SetUpDC();
1149 // m_owner = window;
1150 }
1151 };
1152
1153 // ---------------------------------------------------------
1154 // wxDataViewCustomRenderer
1155 // ---------------------------------------------------------
1156
1157 IMPLEMENT_CLASS(wxDataViewCustomRenderer, wxDataViewRenderer)
1158
1159 wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString &varianttype,
1160 wxDataViewCellMode mode, bool no_init ) :
1161 wxDataViewRenderer( varianttype, mode )
1162 {
1163 m_dc = NULL;
1164
1165 if (no_init)
1166 m_renderer = NULL;
1167 else
1168 Init();
1169 }
1170
1171 bool wxDataViewCustomRenderer::Init()
1172 {
1173 GtkWxCellRenderer *renderer = (GtkWxCellRenderer *) gtk_wx_cell_renderer_new();
1174 renderer->cell = this;
1175
1176 m_renderer = (void*) renderer;
1177
1178 if (m_mode & wxDATAVIEW_CELL_ACTIVATABLE)
1179 {
1180 GValue gvalue = { 0, };
1181 g_value_init( &gvalue, gtk_cell_renderer_mode_get_type() );
1182 g_value_set_enum( &gvalue, GTK_CELL_RENDERER_MODE_ACTIVATABLE );
1183 g_object_set_property( G_OBJECT(m_renderer), "mode", &gvalue );
1184 g_value_unset( &gvalue );
1185 }
1186
1187 return true;
1188 }
1189
1190 wxDataViewCustomRenderer::~wxDataViewCustomRenderer()
1191 {
1192 if (m_dc)
1193 delete m_dc;
1194 }
1195
1196 wxDC *wxDataViewCustomRenderer::GetDC()
1197 {
1198 if (m_dc == NULL)
1199 {
1200 if (GetOwner() == NULL)
1201 return NULL;
1202 if (GetOwner()->GetOwner() == NULL)
1203 return NULL;
1204 m_dc = new wxDataViewCtrlDC( GetOwner()->GetOwner() );
1205 }
1206
1207 return m_dc;
1208 }
1209
1210 // ---------------------------------------------------------
1211 // wxDataViewProgressRenderer
1212 // ---------------------------------------------------------
1213
1214 IMPLEMENT_CLASS(wxDataViewProgressRenderer, wxDataViewCustomRenderer)
1215
1216 wxDataViewProgressRenderer::wxDataViewProgressRenderer( const wxString &label,
1217 const wxString &varianttype, wxDataViewCellMode mode ) :
1218 wxDataViewCustomRenderer( varianttype, mode, true )
1219 {
1220 m_label = label;
1221 m_value = 0;
1222
1223 #ifdef __WXGTK26__
1224 if (!gtk_check_version(2,6,0))
1225 {
1226 m_renderer = (void*) gtk_cell_renderer_progress_new();
1227
1228 GValue gvalue = { 0, };
1229 g_value_init( &gvalue, G_TYPE_STRING );
1230 #if wxUSE_UNICODE
1231 g_value_set_string( &gvalue, wxGTK_CONV(m_label) );
1232 #else
1233 g_value_set_string( &gvalue, wxGTK_CONV_SYS(m_label) );
1234 #endif
1235 g_object_set_property( G_OBJECT(m_renderer), "text", &gvalue );
1236 g_value_unset( &gvalue );
1237 }
1238 else
1239 #endif
1240 {
1241 // Use custom cell code
1242 wxDataViewCustomRenderer::Init();
1243 }
1244 }
1245
1246 wxDataViewProgressRenderer::~wxDataViewProgressRenderer()
1247 {
1248 }
1249
1250 bool wxDataViewProgressRenderer::SetValue( const wxVariant &value )
1251 {
1252 #ifdef __WXGTK26__
1253 if (!gtk_check_version(2,6,0))
1254 {
1255 gint tmp = (long) value;
1256 GValue gvalue = { 0, };
1257 g_value_init( &gvalue, G_TYPE_INT );
1258 g_value_set_int( &gvalue, tmp );
1259 g_object_set_property( G_OBJECT(m_renderer), "value", &gvalue );
1260 g_value_unset( &gvalue );
1261 }
1262 else
1263 #endif
1264 {
1265 m_value = (long) value;
1266
1267 if (m_value < 0) m_value = 0;
1268 if (m_value > 100) m_value = 100;
1269 }
1270
1271 return true;
1272 }
1273
1274 bool wxDataViewProgressRenderer::Render( wxRect cell, wxDC *dc, int state )
1275 {
1276 double pct = (double)m_value / 100.0;
1277 wxRect bar = cell;
1278 bar.width = (int)(cell.width * pct);
1279 dc->SetPen( *wxTRANSPARENT_PEN );
1280 dc->SetBrush( *wxBLUE_BRUSH );
1281 dc->DrawRectangle( bar );
1282
1283 dc->SetBrush( *wxTRANSPARENT_BRUSH );
1284 dc->SetPen( *wxBLACK_PEN );
1285 dc->DrawRectangle( cell );
1286
1287 return true;
1288 }
1289
1290 wxSize wxDataViewProgressRenderer::GetSize()
1291 {
1292 return wxSize(40,12);
1293 }
1294
1295 // ---------------------------------------------------------
1296 // wxDataViewDateRenderer
1297 // ---------------------------------------------------------
1298
1299 class wxDataViewDateRendererPopupTransient: public wxPopupTransientWindow
1300 {
1301 public:
1302 wxDataViewDateRendererPopupTransient( wxWindow* parent, wxDateTime *value,
1303 wxDataViewListModel *model, unsigned int col, unsigned int row ) :
1304 wxPopupTransientWindow( parent, wxBORDER_SIMPLE )
1305 {
1306 m_model = model;
1307 m_col = col;
1308 m_row = row;
1309 m_cal = new wxCalendarCtrl( this, -1, *value );
1310 wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
1311 sizer->Add( m_cal, 1, wxGROW );
1312 SetSizer( sizer );
1313 sizer->Fit( this );
1314 }
1315
1316 virtual void OnDismiss()
1317 {
1318 }
1319
1320 void OnCalendar( wxCalendarEvent &event );
1321
1322 wxCalendarCtrl *m_cal;
1323 wxDataViewListModel *m_model;
1324 unsigned int m_col;
1325 unsigned int m_row;
1326
1327 private:
1328 DECLARE_EVENT_TABLE()
1329 };
1330
1331 BEGIN_EVENT_TABLE(wxDataViewDateRendererPopupTransient,wxPopupTransientWindow)
1332 EVT_CALENDAR( -1, wxDataViewDateRendererPopupTransient::OnCalendar )
1333 END_EVENT_TABLE()
1334
1335 void wxDataViewDateRendererPopupTransient::OnCalendar( wxCalendarEvent &event )
1336 {
1337 wxDateTime date = event.GetDate();
1338 wxVariant value = date;
1339 m_model->SetValue( value, m_col, m_row );
1340 m_model->ValueChanged( m_col, m_row );
1341 DismissAndNotify();
1342 }
1343
1344 IMPLEMENT_CLASS(wxDataViewDateRenderer, wxDataViewCustomRenderer)
1345
1346 wxDataViewDateRenderer::wxDataViewDateRenderer( const wxString &varianttype,
1347 wxDataViewCellMode mode ) :
1348 wxDataViewCustomRenderer( varianttype, mode )
1349 {
1350 }
1351
1352 bool wxDataViewDateRenderer::SetValue( const wxVariant &value )
1353 {
1354 m_date = value.GetDateTime();
1355
1356 return true;
1357 }
1358
1359 bool wxDataViewDateRenderer::Render( wxRect cell, wxDC *dc, int state )
1360 {
1361 dc->SetFont( GetOwner()->GetOwner()->GetFont() );
1362 wxString tmp = m_date.FormatDate();
1363 dc->DrawText( tmp, cell.x, cell.y );
1364
1365 return true;
1366 }
1367
1368 wxSize wxDataViewDateRenderer::GetSize()
1369 {
1370 wxDataViewCtrl* view = GetOwner()->GetOwner();
1371 wxString tmp = m_date.FormatDate();
1372 wxCoord x,y,d;
1373 view->GetTextExtent( tmp, &x, &y, &d );
1374 return wxSize(x,y+d);
1375 }
1376
1377 bool wxDataViewDateRenderer::Activate( wxRect cell, wxDataViewListModel *model, unsigned int col, unsigned int row )
1378 {
1379 wxVariant variant;
1380 model->GetValue( variant, col, row );
1381 wxDateTime value = variant.GetDateTime();
1382
1383 wxDataViewDateRendererPopupTransient *popup = new wxDataViewDateRendererPopupTransient(
1384 GetOwner()->GetOwner()->GetParent(), &value, model, col, row );
1385 wxPoint pos = wxGetMousePosition();
1386 popup->Move( pos );
1387 popup->Layout();
1388 popup->Popup( popup->m_cal );
1389
1390 return true;
1391 }
1392
1393 // ---------------------------------------------------------
1394 // wxDataViewColumn
1395 // ---------------------------------------------------------
1396
1397
1398 static gboolean
1399 gtk_dataview_header_button_press_callback( GtkWidget *widget,
1400 GdkEventButton *gdk_event,
1401 wxDataViewColumn *column )
1402 {
1403 if (gdk_event->type != GDK_BUTTON_PRESS)
1404 return TRUE;
1405
1406 if (gdk_event->button == 1)
1407 {
1408 wxDataViewCtrl *dv = column->GetOwner();
1409 wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, dv->GetId() );
1410 event.SetDataViewColumn( column );
1411 event.SetModel( dv->GetModel() );
1412 dv->GetEventHandler()->ProcessEvent( event );
1413 }
1414
1415 return TRUE;
1416 }
1417
1418 extern "C" {
1419 static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *column,
1420 GtkCellRenderer *cell,
1421 GtkTreeModel *model,
1422 GtkTreeIter *iter,
1423 gpointer data );
1424 }
1425
1426
1427 static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *column,
1428 GtkCellRenderer *renderer,
1429 GtkTreeModel *model,
1430 GtkTreeIter *iter,
1431 gpointer data )
1432 {
1433 g_return_if_fail (GTK_IS_WX_LIST_STORE (model));
1434 GtkWxListStore *list_store = (GtkWxListStore *) model;
1435
1436 wxDataViewRenderer *cell = (wxDataViewRenderer*) data;
1437
1438 unsigned int model_row = (unsigned int) iter->user_data;
1439
1440 wxVariant value;
1441 list_store->model->GetValue( value, cell->GetOwner()->GetModelColumn(), model_row );
1442
1443 if (value.GetType() != cell->GetVariantType())
1444 wxLogError( wxT("Wrong type, required: %s but: %s"),
1445 value.GetType().c_str(),
1446 cell->GetVariantType().c_str() );
1447
1448 cell->SetValue( value );
1449 }
1450
1451 IMPLEMENT_CLASS(wxDataViewColumn, wxDataViewColumnBase)
1452
1453 wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewRenderer *cell, unsigned int model_column,
1454 int width, int flags ) :
1455 wxDataViewColumnBase( title, cell, model_column, width, flags )
1456 {
1457 m_isConnected = false;
1458
1459 GtkCellRenderer *renderer = (GtkCellRenderer *) cell->GetGtkHandle();
1460
1461 GtkTreeViewColumn *column = gtk_tree_view_column_new();
1462 m_column = (void*) column;
1463
1464 gtk_tree_view_column_set_clickable( column, true );
1465
1466 SetTitle( title );
1467
1468 if (flags & wxDATAVIEW_COL_RESIZABLE)
1469 gtk_tree_view_column_set_resizable( column, true );
1470 if (flags & wxDATAVIEW_COL_HIDDEN)
1471 gtk_tree_view_column_set_visible( column, false );
1472 if (flags & wxDATAVIEW_COL_SORTABLE)
1473 gtk_tree_view_column_set_sort_indicator( column, true );
1474
1475 if (width > 0)
1476 gtk_tree_view_column_set_fixed_width( column, width );
1477 else
1478 gtk_tree_view_column_set_fixed_width( column, 70 ); // FIXME
1479
1480 gtk_tree_view_column_set_sizing( column, GTK_TREE_VIEW_COLUMN_FIXED );
1481
1482 gtk_tree_view_column_pack_end( column, renderer, FALSE );
1483
1484 gtk_tree_view_column_set_cell_data_func( column, renderer,
1485 wxGtkTreeCellDataFunc, (gpointer) cell, NULL );
1486
1487 }
1488
1489 wxDataViewColumn::wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *cell, unsigned int model_column,
1490 int width, int flags ) :
1491 wxDataViewColumnBase( bitmap, cell, model_column, width, flags )
1492 {
1493 m_isConnected = false;
1494
1495 GtkCellRenderer *renderer = (GtkCellRenderer *) cell->GetGtkHandle();
1496
1497 GtkTreeViewColumn *column = gtk_tree_view_column_new();
1498 m_column = (void*) column;
1499
1500 SetBitmap( bitmap );
1501
1502 if (flags & wxDATAVIEW_COL_RESIZABLE)
1503 gtk_tree_view_column_set_resizable( column, true );
1504 if (flags & wxDATAVIEW_COL_HIDDEN)
1505 gtk_tree_view_column_set_visible( column, false );
1506 if (flags & wxDATAVIEW_COL_SORTABLE)
1507 gtk_tree_view_column_set_sort_indicator( column, true );
1508
1509 if (width > 0)
1510 gtk_tree_view_column_set_fixed_width( column, width );
1511 else
1512 gtk_tree_view_column_set_fixed_width( column, 70 ); // FIXME
1513
1514 gtk_tree_view_column_set_sizing( column, GTK_TREE_VIEW_COLUMN_FIXED );
1515
1516 gtk_tree_view_column_pack_end( column, renderer, FALSE );
1517
1518 gtk_tree_view_column_set_cell_data_func( column, renderer,
1519 wxGtkTreeCellDataFunc, (gpointer) cell, NULL );
1520 }
1521
1522 wxDataViewColumn::~wxDataViewColumn()
1523 {
1524 }
1525
1526 void wxDataViewColumn::OnInternalIdle()
1527 {
1528 if (m_isConnected)
1529 return;
1530
1531 if (GTK_WIDGET_REALIZED(GetOwner()->m_treeview))
1532 {
1533 GtkTreeViewColumn *column = (GtkTreeViewColumn *)m_column;
1534 if (column->button)
1535 {
1536 g_signal_connect(column->button, "button_press_event",
1537 G_CALLBACK (gtk_dataview_header_button_press_callback), this);
1538
1539 m_isConnected = true;
1540 }
1541 }
1542 }
1543
1544 void wxDataViewColumn::SetOwner( wxDataViewCtrl *owner )
1545 {
1546 wxDataViewColumnBase::SetOwner( owner );
1547
1548 GtkTreeViewColumn *column = (GtkTreeViewColumn *)m_column;
1549
1550 #if wxUSE_UNICODE
1551 #else
1552 gtk_tree_view_column_set_title( column, wxGTK_CONV_FONT(GetTitle(), GetOwner()->GetFont() ) );
1553 #endif
1554 }
1555
1556 void wxDataViewColumn::SetTitle( const wxString &title )
1557 {
1558 wxDataViewColumnBase::SetTitle( title );
1559
1560 GtkTreeViewColumn *column = (GtkTreeViewColumn *)m_column;
1561
1562 if (m_isConnected)
1563 {
1564 // disconnect before column->button gets recreated
1565 g_signal_handlers_disconnect_by_func( column->button,
1566 (void*) gtk_dataview_header_button_press_callback, this);
1567
1568 m_isConnected = false;
1569 }
1570
1571 #if wxUSE_UNICODE
1572 gtk_tree_view_column_set_title( column, wxGTK_CONV(title) );
1573 #else
1574 if (GetOwner())
1575 gtk_tree_view_column_set_title( column, wxGTK_CONV_FONT(title, GetOwner()->GetFont() ) );
1576 else
1577 gtk_tree_view_column_set_title( column, "" );
1578 #endif
1579
1580 gtk_tree_view_column_set_widget( column, NULL );
1581 }
1582
1583 void wxDataViewColumn::SetBitmap( const wxBitmap &bitmap )
1584 {
1585 wxDataViewColumnBase::SetBitmap( bitmap );
1586
1587 GtkTreeViewColumn *column = (GtkTreeViewColumn *)m_column;
1588 if (bitmap.Ok())
1589 {
1590 GtkImage *gtk_image = GTK_IMAGE( gtk_image_new() );
1591
1592 GdkBitmap *mask = (GdkBitmap *) NULL;
1593 if (bitmap.GetMask())
1594 mask = bitmap.GetMask()->GetBitmap();
1595
1596 if (bitmap.HasPixbuf())
1597 {
1598 gtk_image_set_from_pixbuf(GTK_IMAGE(gtk_image),
1599 bitmap.GetPixbuf());
1600 }
1601 else
1602 {
1603 gtk_image_set_from_pixmap(GTK_IMAGE(gtk_image),
1604 bitmap.GetPixmap(), mask);
1605 }
1606 gtk_widget_show( GTK_WIDGET(gtk_image) );
1607
1608 gtk_tree_view_column_set_widget( column, GTK_WIDGET(gtk_image) );
1609 }
1610 else
1611 {
1612 gtk_tree_view_column_set_widget( column, NULL );
1613 }
1614 }
1615
1616 void wxDataViewColumn::SetAlignment( wxAlignment align )
1617 {
1618 GtkTreeViewColumn *column = (GtkTreeViewColumn *)m_column;
1619
1620 gfloat xalign = 0.0;
1621 if (align == wxALIGN_RIGHT)
1622 xalign = 1.0;
1623 if (align == wxALIGN_CENTER)
1624 xalign = 0.5;
1625
1626 gtk_tree_view_column_set_alignment( column, xalign );
1627 }
1628
1629 void wxDataViewColumn::SetSortable( bool sortable )
1630 {
1631 GtkTreeViewColumn *column = (GtkTreeViewColumn *)m_column;
1632 gtk_tree_view_column_set_sort_indicator( column, sortable );
1633 }
1634
1635 bool wxDataViewColumn::GetSortable()
1636 {
1637 GtkTreeViewColumn *column = (GtkTreeViewColumn *)m_column;
1638 return gtk_tree_view_column_get_sort_indicator( column );
1639 }
1640
1641 void wxDataViewColumn::SetSortOrder( bool ascending )
1642 {
1643 GtkTreeViewColumn *column = (GtkTreeViewColumn *)m_column;
1644
1645 if (ascending)
1646 gtk_tree_view_column_set_sort_order( column, GTK_SORT_ASCENDING );
1647 else
1648 gtk_tree_view_column_set_sort_order( column, GTK_SORT_DESCENDING );
1649 }
1650
1651 bool wxDataViewColumn::IsSortOrderAscending()
1652 {
1653 GtkTreeViewColumn *column = (GtkTreeViewColumn *)m_column;
1654
1655 return (gtk_tree_view_column_get_sort_order( column ) != GTK_SORT_DESCENDING);
1656 }
1657
1658 int wxDataViewColumn::GetWidth()
1659 {
1660 return gtk_tree_view_column_get_width( (GtkTreeViewColumn *)m_column );
1661 }
1662
1663 void wxDataViewColumn::SetFixedWidth( int width )
1664 {
1665 gtk_tree_view_column_set_fixed_width( (GtkTreeViewColumn *)m_column, width );
1666 }
1667
1668 int wxDataViewColumn::GetFixedWidth()
1669 {
1670 return gtk_tree_view_column_get_fixed_width( (GtkTreeViewColumn *)m_column );
1671 }
1672
1673 //-----------------------------------------------------------------------------
1674 // wxDataViewCtrl signal callbacks
1675 //-----------------------------------------------------------------------------
1676
1677 static void
1678 wxdataview_selection_changed_callback( GtkTreeSelection* selection, wxDataViewCtrl *dv )
1679 {
1680 if (!GTK_WIDGET_REALIZED(dv->m_widget))
1681 return;
1682
1683 wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ROW_SELECTED, dv->GetId() );
1684 event.SetRow( dv->GetSelection() );
1685 event.SetModel( dv->GetModel() );
1686 dv->GetEventHandler()->ProcessEvent( event );
1687 }
1688
1689 static void
1690 wxdataview_row_activated_callback( GtkTreeView* treeview, GtkTreePath *path,
1691 GtkTreeViewColumn *column, wxDataViewCtrl *dv )
1692 {
1693 wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ROW_ACTIVATED, dv->GetId() );
1694 unsigned int row = (unsigned int)gtk_tree_path_get_indices (path)[0];
1695 event.SetRow( row );
1696 event.SetModel( dv->GetModel() );
1697 dv->GetEventHandler()->ProcessEvent( event );
1698 }
1699
1700 //-----------------------------------------------------------------------------
1701 // wxDataViewCtrl
1702 //-----------------------------------------------------------------------------
1703
1704 IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl, wxDataViewCtrlBase)
1705
1706 wxDataViewCtrl::~wxDataViewCtrl()
1707 {
1708 if (m_notifier)
1709 GetModel()->RemoveNotifier( m_notifier );
1710 }
1711
1712 void wxDataViewCtrl::Init()
1713 {
1714 m_notifier = NULL;
1715 }
1716
1717 bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id,
1718 const wxPoint& pos, const wxSize& size,
1719 long style, const wxValidator& validator )
1720 {
1721 Init();
1722
1723 m_needParent = true;
1724 m_acceptsFocus = true;
1725
1726 if (!PreCreation( parent, pos, size ) ||
1727 !CreateBase( parent, id, pos, size, style, validator ))
1728 {
1729 wxFAIL_MSG( wxT("wxDataViewCtrl creation failed") );
1730 return false;
1731 }
1732
1733 m_widget = gtk_scrolled_window_new (NULL, NULL);
1734
1735 GtkScrolledWindowSetBorder(m_widget, style);
1736
1737 m_treeview = gtk_tree_view_new();
1738 gtk_container_add (GTK_CONTAINER (m_widget), m_treeview);
1739
1740 #ifdef __WXGTK26__
1741 if (!gtk_check_version(2,6,0))
1742 gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), TRUE );
1743 #endif
1744
1745 if (style & wxDV_MULTIPLE)
1746 {
1747 GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );
1748 gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE );
1749 }
1750
1751 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (m_widget),
1752 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
1753 gtk_widget_show (m_treeview);
1754
1755 m_parent->DoAddChild( this );
1756
1757 PostCreation(size);
1758
1759 GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );
1760 g_signal_connect_after (selection, "changed",
1761 G_CALLBACK (wxdataview_selection_changed_callback), this);
1762 g_signal_connect_after (m_treeview, "row_activated",
1763 G_CALLBACK (wxdataview_row_activated_callback), this);
1764
1765 return true;
1766 }
1767
1768 void wxDataViewCtrl::OnInternalIdle()
1769 {
1770 wxWindow::OnInternalIdle();
1771
1772 unsigned int cols = GetNumberOfColumns();
1773 unsigned int i;
1774 for (i = 0; i < cols; i++)
1775 {
1776 wxDataViewColumn *col = GetColumn( i );
1777 col->OnInternalIdle();
1778 }
1779 }
1780
1781 bool wxDataViewCtrl::AssociateModel( wxDataViewListModel *model )
1782 {
1783 if (!wxDataViewCtrlBase::AssociateModel( model ))
1784 return false;
1785
1786 GtkWxListStore *gtk_store = wxgtk_list_store_new();
1787 gtk_store->model = model;
1788
1789 m_notifier = new wxGtkDataViewListModelNotifier( gtk_store, model );
1790
1791 model->AddNotifier( m_notifier );
1792
1793 gtk_tree_view_set_model( GTK_TREE_VIEW(m_treeview), GTK_TREE_MODEL(gtk_store) );
1794 g_object_unref( gtk_store );
1795
1796 return true;
1797 }
1798
1799 bool wxDataViewCtrl::AppendColumn( wxDataViewColumn *col )
1800 {
1801 if (!wxDataViewCtrlBase::AppendColumn(col))
1802 return false;
1803
1804 GtkTreeViewColumn *column = (GtkTreeViewColumn *)col->GetGtkHandle();
1805
1806 gtk_tree_view_append_column( GTK_TREE_VIEW(m_treeview), column );
1807
1808 return true;
1809 }
1810
1811 void wxDataViewCtrl::SetSelection( int row )
1812 {
1813 GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );
1814
1815 if (row < 0)
1816 {
1817 gtk_tree_selection_unselect_all( selection );
1818 }
1819 else
1820 {
1821 GtkTreePath *path = gtk_tree_path_new ();
1822 gtk_tree_path_append_index( path, row );
1823
1824 gtk_tree_selection_select_path( selection, path );
1825
1826 gtk_tree_path_free( path );
1827 }
1828 }
1829
1830 void wxDataViewCtrl::Unselect( unsigned int row )
1831 {
1832 GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );
1833
1834 GtkTreePath *path = gtk_tree_path_new ();
1835 gtk_tree_path_append_index( path, row );
1836
1837 gtk_tree_selection_unselect_path( selection, path );
1838
1839 gtk_tree_path_free( path );
1840 }
1841
1842 void wxDataViewCtrl::SetSelectionRange( unsigned int from, unsigned int to )
1843 {
1844 }
1845
1846 void wxDataViewCtrl::SetSelections( const wxArrayInt& aSelections)
1847 {
1848 }
1849
1850 bool wxDataViewCtrl::IsSelected( unsigned int row ) const
1851 {
1852 GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );
1853
1854 GtkTreePath *path = gtk_tree_path_new ();
1855 gtk_tree_path_append_index( path, row );
1856
1857 gboolean ret = gtk_tree_selection_path_is_selected( selection, path );
1858
1859 gtk_tree_path_free( path );
1860
1861 return ret;
1862 }
1863
1864 int wxDataViewCtrl::GetSelection() const
1865 {
1866 GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );
1867 if (HasFlag(wxDV_MULTIPLE))
1868 {
1869 GtkTreeModel *model;
1870 GList *list = gtk_tree_selection_get_selected_rows( selection, &model );
1871
1872 // do something
1873 if (list)
1874 {
1875 // list = g_list_nth( list, 0 ); should be a noop
1876 GtkTreePath *path = (GtkTreePath*) list->data;
1877
1878 unsigned int row = (unsigned int)gtk_tree_path_get_indices (path)[0];
1879
1880 // delete list
1881 g_list_foreach( list, (GFunc) gtk_tree_path_free, NULL );
1882 g_list_free( list );
1883
1884 return (int) row;
1885 }
1886 }
1887 else
1888 {
1889
1890 GtkTreeModel *model;
1891 GtkTreeIter iter;
1892 gboolean has_selection = gtk_tree_selection_get_selected( selection, &model, &iter );
1893 if (has_selection)
1894 {
1895 unsigned int row = (wxUIntPtr) iter.user_data;
1896 return (int) row;
1897 }
1898 }
1899
1900 return -1;
1901 }
1902
1903 int wxDataViewCtrl::GetSelections(wxArrayInt& aSelections) const
1904 {
1905 aSelections.Clear();
1906
1907 GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );
1908 if (HasFlag(wxDV_MULTIPLE))
1909 {
1910 GtkTreeModel *model;
1911 GList *list = gtk_tree_selection_get_selected_rows( selection, &model );
1912
1913 int count = 0;
1914 while (list)
1915 {
1916
1917 // list = g_list_nth( list, 0 ); should be a noop
1918 GtkTreePath *path = (GtkTreePath*) list->data;
1919
1920 unsigned int row = (unsigned int)gtk_tree_path_get_indices (path)[0];
1921
1922 aSelections.Add( (int) row );
1923
1924 list = g_list_next( list );
1925 }
1926
1927 // delete list
1928 g_list_foreach( list, (GFunc) gtk_tree_path_free, NULL );
1929 g_list_free( list );
1930
1931 return count;
1932 }
1933 else
1934 {
1935 GtkTreeModel *model;
1936 GtkTreeIter iter;
1937 gboolean has_selection = gtk_tree_selection_get_selected( selection, &model, &iter );
1938 if (has_selection)
1939 {
1940 unsigned int row = (wxUIntPtr) iter.user_data;
1941 aSelections.Add( (int) row );
1942 return 1;
1943 }
1944 }
1945
1946 return 0;
1947 }
1948
1949 // static
1950 wxVisualAttributes
1951 wxDataViewCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
1952 {
1953 return GetDefaultAttributesFromGTKWidget(gtk_tree_view_new);
1954 }
1955
1956
1957 #endif
1958 // !wxUSE_GENERICDATAVIEWCTRL
1959
1960 #endif
1961 // wxUSE_DATAVIEWCTRL