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