]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/win_gtk.c
added Collapse() and Expand()
[wxWidgets.git] / src / gtk / win_gtk.c
1 /* ///////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/win_gtk.c
3 // Purpose: Native GTK+ widget for wxWidgets, based on GtkLayout and
4 // GtkFixed. It makes use of the gravity window property and
5 // therefore does not work with GTK 1.0.
6 // Author: Robert Roebling
7 // Id: $Id$
8 // Copyright: (c) 1998 Robert Roebling
9 // Licence: wxWidgets licence
10 /////////////////////////////////////////////////////////////////////////// */
11
12 #ifdef VMS
13 #define XCheckIfEvent XCHECKIFEVENT
14 #endif
15
16 #include "wx/platform.h"
17 #include "wx/gtk/win_gtk.h"
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif /* __cplusplus */
22
23 typedef struct _GtkPizzaChild GtkPizzaChild;
24 typedef struct _GtkPizzaClass GtkPizzaClass;
25 typedef struct _GtkPizzaAdjData GtkPizzaAdjData;
26
27 struct _GtkPizzaClass
28 {
29 GtkContainerClass parent_class;
30
31 void (*set_scroll_adjustments) (GtkPizza *pizza,
32 GtkAdjustment *hadjustment,
33 GtkAdjustment *vadjustment);
34 };
35
36 struct _GtkPizzaChild
37 {
38 GtkWidget *widget;
39 gint x;
40 gint y;
41 };
42
43 struct _GtkPizzaAdjData
44 {
45 gint dx;
46 gint dy;
47 };
48
49 static void gtk_pizza_class_init (GtkPizzaClass *klass);
50 static void gtk_pizza_init (GtkPizza *pizza);
51
52 static void gtk_pizza_realize (GtkWidget *widget);
53 static void gtk_pizza_unrealize (GtkWidget *widget);
54
55 static void gtk_pizza_map (GtkWidget *widget);
56
57 static void gtk_pizza_size_request (GtkWidget *widget,
58 GtkRequisition *requisition);
59 static void gtk_pizza_size_allocate (GtkWidget *widget,
60 GtkAllocation *allocation);
61 static void gtk_pizza_style_set (GtkWidget *widget,
62 GtkStyle *previous_style);
63 static void gtk_pizza_add (GtkContainer *container,
64 GtkWidget *widget);
65 static void gtk_pizza_remove (GtkContainer *container,
66 GtkWidget *widget);
67 static void gtk_pizza_forall (GtkContainer *container,
68 gboolean include_internals,
69 GtkCallback callback,
70 gpointer callback_data);
71
72 static void gtk_pizza_allocate_child (GtkPizza *pizza,
73 GtkPizzaChild *child);
74 static void gtk_pizza_adjust_allocations_recurse (GtkWidget *widget,
75 gpointer cb_data);
76
77 static GtkType gtk_pizza_child_type (GtkContainer *container);
78
79 static void gtk_pizza_scroll_set_adjustments (GtkPizza *pizza,
80 GtkAdjustment *hadj,
81 GtkAdjustment *vadj);
82
83 static GtkWidgetClass* pizza_parent_class;
84
85 GtkType
86 gtk_pizza_get_type ()
87 {
88 static GtkType pizza_type = 0;
89
90 if (!pizza_type)
91 {
92 const GTypeInfo pizza_info =
93 {
94 sizeof (GtkPizzaClass),
95 NULL, /* base_init */
96 NULL, /* base_finalize */
97 (GClassInitFunc) gtk_pizza_class_init,
98 NULL, /* class_finalize */
99 NULL, /* class_data */
100 sizeof (GtkPizza),
101 16, /* n_preallocs */
102 (GInstanceInitFunc) gtk_pizza_init,
103 NULL
104 };
105 pizza_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkPizza", &pizza_info, (GTypeFlags)0);
106 }
107
108 return pizza_type;
109 }
110
111 /* Marshaller needed for set_scroll_adjustments signal,
112 generated with GLib-2.4.6 glib-genmarshal */
113 #define g_marshal_value_peek_object(v) g_value_get_object (v)
114 static void
115 g_cclosure_user_marshal_VOID__OBJECT_OBJECT (GClosure *closure,
116 GValue *return_value,
117 guint n_param_values,
118 const GValue *param_values,
119 gpointer invocation_hint,
120 gpointer marshal_data)
121 {
122 typedef void (*GMarshalFunc_VOID__OBJECT_OBJECT) (gpointer data1,
123 gpointer arg_1,
124 gpointer arg_2,
125 gpointer data2);
126 register GMarshalFunc_VOID__OBJECT_OBJECT callback;
127 register GCClosure *cc = (GCClosure*) closure;
128 register gpointer data1, data2;
129
130 g_return_if_fail (n_param_values == 3);
131
132 if (G_CCLOSURE_SWAP_DATA (closure))
133 {
134 data1 = closure->data;
135 data2 = g_value_peek_pointer (param_values + 0);
136 }
137 else
138 {
139 data1 = g_value_peek_pointer (param_values + 0);
140 data2 = closure->data;
141 }
142 callback = (GMarshalFunc_VOID__OBJECT_OBJECT) (marshal_data ? marshal_data : cc->callback);
143
144 callback (data1,
145 g_marshal_value_peek_object (param_values + 1),
146 g_marshal_value_peek_object (param_values + 2),
147 data2);
148 }
149
150 static void
151 gtk_pizza_class_init (GtkPizzaClass *klass)
152 {
153 GtkObjectClass *object_class;
154 GtkWidgetClass *widget_class;
155 GtkContainerClass *container_class;
156
157 object_class = (GtkObjectClass*) klass;
158 widget_class = (GtkWidgetClass*) klass;
159 container_class = (GtkContainerClass*) klass;
160 pizza_parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
161
162 widget_class->map = gtk_pizza_map;
163 widget_class->realize = gtk_pizza_realize;
164 widget_class->unrealize = gtk_pizza_unrealize;
165 widget_class->size_request = gtk_pizza_size_request;
166 widget_class->size_allocate = gtk_pizza_size_allocate;
167 widget_class->style_set = gtk_pizza_style_set;
168
169 container_class->add = gtk_pizza_add;
170 container_class->remove = gtk_pizza_remove;
171 container_class->forall = gtk_pizza_forall;
172
173 container_class->child_type = gtk_pizza_child_type;
174
175 klass->set_scroll_adjustments = gtk_pizza_scroll_set_adjustments;
176
177 widget_class->set_scroll_adjustments_signal =
178 g_signal_new(
179 "set_scroll_adjustments",
180 G_TYPE_FROM_CLASS(object_class),
181 G_SIGNAL_RUN_LAST,
182 G_STRUCT_OFFSET(GtkPizzaClass, set_scroll_adjustments),
183 NULL,
184 NULL,
185 g_cclosure_user_marshal_VOID__OBJECT_OBJECT,
186 G_TYPE_NONE,
187 2,
188 GTK_TYPE_ADJUSTMENT,
189 GTK_TYPE_ADJUSTMENT);
190 }
191
192 static GtkType
193 gtk_pizza_child_type (GtkContainer *container)
194 {
195 return GTK_TYPE_WIDGET;
196 }
197
198 static void
199 gtk_pizza_init (GtkPizza *pizza)
200 {
201 GTK_WIDGET_SET_FLAGS (pizza, GTK_CAN_FOCUS);
202 GTK_WIDGET_UNSET_FLAGS (pizza, GTK_NO_WINDOW);
203
204 pizza->children = NULL;
205
206 pizza->bin_window = NULL;
207
208 pizza->m_xoffset = 0;
209 pizza->m_yoffset = 0;
210 }
211
212 GtkWidget*
213 gtk_pizza_new ()
214 {
215 GtkPizza *pizza;
216
217 pizza = g_object_new (gtk_pizza_get_type (), NULL);
218
219 pizza->m_noscroll = FALSE;
220
221 return GTK_WIDGET (pizza);
222 }
223
224 GtkWidget*
225 gtk_pizza_new_no_scroll ()
226 {
227 GtkPizza *pizza;
228
229 pizza = g_object_new (gtk_pizza_get_type (), NULL);
230
231 pizza->m_noscroll = TRUE;
232
233 return GTK_WIDGET (pizza);
234 }
235
236 gint gtk_pizza_get_xoffset (GtkPizza *pizza)
237 {
238 g_return_val_if_fail ( (pizza != NULL), -1 );
239 g_return_val_if_fail ( (GTK_IS_PIZZA (pizza)), -1 );
240
241 return pizza->m_xoffset;
242 }
243
244 gint gtk_pizza_get_yoffset (GtkPizza *pizza)
245 {
246 g_return_val_if_fail ( (pizza != NULL), -1 );
247 g_return_val_if_fail ( (GTK_IS_PIZZA (pizza)), -1 );
248
249 return pizza->m_yoffset;
250 }
251
252 void gtk_pizza_set_xoffset (GtkPizza *pizza, gint xoffset)
253 {
254 g_return_if_fail (pizza != NULL);
255 g_return_if_fail (GTK_IS_PIZZA (pizza));
256
257 pizza->m_xoffset = xoffset;
258 // do something
259 }
260
261 void gtk_pizza_set_yoffset (GtkPizza *pizza, gint yoffset)
262 {
263 g_return_if_fail (pizza != NULL);
264 g_return_if_fail (GTK_IS_PIZZA (pizza));
265
266 pizza->m_xoffset = yoffset;
267 // do something
268 }
269
270 gint gtk_pizza_get_rtl_offset (GtkPizza *pizza)
271 {
272 gint border;
273
274 g_return_val_if_fail ( (pizza != NULL), 0 );
275 g_return_val_if_fail ( (GTK_IS_PIZZA (pizza)), 0 );
276
277 if (!pizza->bin_window) return 0;
278
279 border = pizza->container.border_width;
280
281 return GTK_WIDGET(pizza)->allocation.width - border*2;
282 }
283
284
285 static void
286 gtk_pizza_scroll_set_adjustments (GtkPizza *pizza,
287 GtkAdjustment *hadj,
288 GtkAdjustment *vadj)
289 {
290 /* We handle scrolling in the wxScrolledWindow, not here. */
291 }
292
293 void
294 gtk_pizza_put (GtkPizza *pizza,
295 GtkWidget *widget,
296 gint x,
297 gint y,
298 gint width,
299 gint height)
300 {
301 GtkPizzaChild *child_info;
302
303 g_return_if_fail (pizza != NULL);
304 g_return_if_fail (GTK_IS_PIZZA (pizza));
305 g_return_if_fail (widget != NULL);
306
307 child_info = g_new (GtkPizzaChild, 1);
308
309 child_info->widget = widget;
310 child_info->x = x;
311 child_info->y = y;
312
313 pizza->children = g_list_append (pizza->children, child_info);
314
315 if (GTK_WIDGET_REALIZED (pizza))
316 gtk_widget_set_parent_window (widget, pizza->bin_window);
317
318 gtk_widget_set_parent (widget, GTK_WIDGET (pizza));
319
320 gtk_widget_set_size_request( widget, width, height );
321 if (GTK_WIDGET_REALIZED (pizza))
322 gtk_pizza_allocate_child (pizza, child_info);
323 }
324
325 void
326 gtk_pizza_set_size (GtkPizza *pizza,
327 GtkWidget *widget,
328 gint x,
329 gint y,
330 gint width,
331 gint height)
332 {
333 GtkPizzaChild *child;
334 GList *children;
335
336 g_return_if_fail (pizza != NULL);
337 g_return_if_fail (GTK_IS_PIZZA (pizza));
338 g_return_if_fail (widget != NULL);
339
340 #ifndef WX_WARN_ILLEGAL_SETSIZE
341 /* this really shouldn't happen -- but it does, a lot, right now and we
342 can't pass negative values to gtk_widget_set_size_request() without getting
343 a warning printed out, so filter them out here */
344 if ( width < 0 )
345 width = 0;
346 if ( height < 0 )
347 height = 0;
348 #endif
349
350 children = pizza->children;
351 while (children)
352 {
353 child = children->data;
354 children = children->next;
355
356 if (child->widget == widget)
357 {
358 if (child->x != x || child->y != y)
359 {
360 child->x = x;
361 child->y = y;
362 gtk_widget_queue_resize(widget);
363 }
364
365 gtk_widget_set_size_request (widget, width, height);
366
367 return;
368 }
369 }
370 }
371
372 static void
373 gtk_pizza_map (GtkWidget *widget)
374 {
375 GtkPizza *pizza;
376 GtkPizzaChild *child;
377 GList *children;
378
379 g_return_if_fail (widget != NULL);
380 g_return_if_fail (GTK_IS_PIZZA (widget));
381
382 GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
383 pizza = GTK_PIZZA (widget);
384
385 children = pizza->children;
386 while (children)
387 {
388 child = children->data;
389 children = children->next;
390
391 if ( GTK_WIDGET_VISIBLE (child->widget) &&
392 !GTK_WIDGET_MAPPED (child->widget) )
393 {
394 gtk_widget_map (child->widget);
395 }
396 }
397
398 gdk_window_show (widget->window);
399 gdk_window_show (pizza->bin_window);
400 }
401
402 static void
403 gtk_pizza_realize (GtkWidget *widget)
404 {
405 GtkPizza *pizza;
406 GdkWindowAttr attributes;
407 gint attributes_mask;
408 GtkPizzaChild *child;
409 GList *children;
410 int border;
411 int w, h;
412
413 g_return_if_fail (widget != NULL);
414 g_return_if_fail (GTK_IS_PIZZA (widget));
415
416 pizza = GTK_PIZZA (widget);
417 GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
418
419 attributes.window_type = GDK_WINDOW_CHILD;
420
421 attributes.x = widget->allocation.x;
422 attributes.y = widget->allocation.y;
423 attributes.width = widget->allocation.width;
424 attributes.height = widget->allocation.height;
425
426 /* minimal size */
427 if (attributes.width < 2) attributes.width = 2;
428 if (attributes.height < 2) attributes.height = 2;
429
430 border = pizza->container.border_width;
431 w = attributes.width - 2 * border;
432 h = attributes.height - 2 * border;
433 if (w < 2) w = 2;
434 if (h < 2) h = 2;
435
436 if (!pizza->m_noscroll)
437 {
438 attributes.x += border;
439 attributes.y += border;
440 attributes.width = w;
441 attributes.height = h;
442 }
443
444 attributes.wclass = GDK_INPUT_OUTPUT;
445 attributes.visual = gtk_widget_get_visual (widget);
446 attributes.colormap = gtk_widget_get_colormap (widget);
447 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK;
448 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
449
450 widget->window = gdk_window_new(gtk_widget_get_parent_window (widget),
451 &attributes, attributes_mask);
452 gdk_window_set_user_data (widget->window, widget);
453
454 attributes.x = 0;
455 attributes.y = 0;
456 if (pizza->m_noscroll)
457 {
458 attributes.x = border;
459 attributes.y = border;
460 attributes.width = w;
461 attributes.height = h;
462 }
463
464 attributes.event_mask = gtk_widget_get_events (widget);
465 attributes.event_mask |= GDK_EXPOSURE_MASK |
466 GDK_SCROLL_MASK |
467 GDK_POINTER_MOTION_MASK |
468 GDK_POINTER_MOTION_HINT_MASK |
469 GDK_BUTTON_MOTION_MASK |
470 GDK_BUTTON1_MOTION_MASK |
471 GDK_BUTTON2_MOTION_MASK |
472 GDK_BUTTON3_MOTION_MASK |
473 GDK_BUTTON_PRESS_MASK |
474 GDK_BUTTON_RELEASE_MASK |
475 GDK_KEY_PRESS_MASK |
476 GDK_KEY_RELEASE_MASK |
477 GDK_ENTER_NOTIFY_MASK |
478 GDK_LEAVE_NOTIFY_MASK |
479 GDK_FOCUS_CHANGE_MASK;
480
481 pizza->bin_window = gdk_window_new(widget->window,
482 &attributes, attributes_mask);
483 gdk_window_set_user_data (pizza->bin_window, widget);
484
485 widget->style = gtk_style_attach (widget->style, widget->window);
486 gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
487 gtk_style_set_background (widget->style, pizza->bin_window, GTK_STATE_NORMAL );
488
489 /*
490 gdk_window_set_back_pixmap( widget->window, NULL, FALSE );
491 gdk_window_set_back_pixmap( pizza->bin_window, NULL, FALSE );
492 */
493
494 /* cannot be done before realisation */
495 children = pizza->children;
496 while (children)
497 {
498 child = children->data;
499 children = children->next;
500
501 gtk_widget_set_parent_window (child->widget, pizza->bin_window);
502 }
503 }
504
505 static void
506 gtk_pizza_unrealize (GtkWidget *widget)
507 {
508 GtkPizza *pizza;
509
510 g_return_if_fail (widget != NULL);
511 g_return_if_fail (GTK_IS_PIZZA (widget));
512
513 pizza = GTK_PIZZA (widget);
514
515 gdk_window_set_user_data (pizza->bin_window, NULL);
516 gdk_window_destroy (pizza->bin_window);
517 pizza->bin_window = NULL;
518
519 if (pizza_parent_class->unrealize)
520 pizza_parent_class->unrealize(widget);
521 }
522
523 static void
524 gtk_pizza_size_request (GtkWidget *widget,
525 GtkRequisition *requisition)
526 {
527 GtkPizza *pizza;
528 GtkPizzaChild *child;
529 GList *children;
530 GtkRequisition child_requisition;
531
532 g_return_if_fail (widget != NULL);
533 g_return_if_fail (GTK_IS_PIZZA (widget));
534 g_return_if_fail (requisition != NULL);
535
536 pizza = GTK_PIZZA (widget);
537
538 children = pizza->children;
539 while (children)
540 {
541 child = children->data;
542 children = children->next;
543
544 if (GTK_WIDGET_VISIBLE (child->widget))
545 {
546 gtk_widget_size_request (child->widget, &child_requisition);
547 }
548 }
549
550 /* request very little, I'm not sure if requesting nothing
551 will always have positive effects on stability... */
552 requisition->width = 2;
553 requisition->height = 2;
554 }
555
556 static void
557 gtk_pizza_size_allocate (GtkWidget *widget,
558 GtkAllocation *allocation)
559 {
560 GtkPizza *pizza;
561 gint border;
562 gint x,y,w,h;
563 GtkPizzaChild *child;
564 GList *children;
565 gboolean only_resize;
566
567 g_return_if_fail (widget != NULL);
568 g_return_if_fail (GTK_IS_PIZZA(widget));
569 g_return_if_fail (allocation != NULL);
570
571 pizza = GTK_PIZZA (widget);
572
573 only_resize = ((widget->allocation.x == allocation->x) &&
574 (widget->allocation.y == allocation->y));
575 widget->allocation = *allocation;
576
577 if (GTK_WIDGET_REALIZED(widget))
578 {
579 border = pizza->container.border_width;
580
581 x = allocation->x + border;
582 y = allocation->y + border;
583 w = allocation->width - border*2;
584 h = allocation->height - border*2;
585 if (w < 0)
586 w = 0;
587 if (h < 0)
588 h = 0;
589
590 if (pizza->m_noscroll)
591 {
592 if (only_resize)
593 gdk_window_resize( widget->window, allocation->width, allocation->height );
594 else
595 gdk_window_move_resize( widget->window, allocation->x, allocation->y,
596 allocation->width, allocation->height );
597
598 gdk_window_move_resize( pizza->bin_window, border, border, w, h );
599 }
600 else
601 {
602 if (only_resize)
603 gdk_window_resize( widget->window, w, h );
604 else
605 gdk_window_move_resize( widget->window, x, y, w, h );
606
607 gdk_window_resize( pizza->bin_window, w, h );
608 }
609 }
610
611 children = pizza->children;
612 while (children)
613 {
614 child = children->data;
615 children = children->next;
616
617 gtk_pizza_allocate_child (pizza, child);
618 }
619 }
620
621 static void
622 gtk_pizza_style_set(GtkWidget *widget, GtkStyle *previous_style)
623 {
624 if (GTK_WIDGET_REALIZED(widget))
625 {
626 gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL);
627 gtk_style_set_background(widget->style, GTK_PIZZA(widget)->bin_window, GTK_STATE_NORMAL );
628 }
629
630 pizza_parent_class->style_set(widget, previous_style);
631 }
632
633 static void
634 gtk_pizza_add (GtkContainer *container,
635 GtkWidget *widget)
636 {
637 g_return_if_fail (container != NULL);
638 g_return_if_fail (GTK_IS_PIZZA (container));
639 g_return_if_fail (widget != NULL);
640
641 gtk_pizza_put (GTK_PIZZA (container), widget, 0, 0, 20, 20 );
642 }
643
644 static void
645 gtk_pizza_remove (GtkContainer *container,
646 GtkWidget *widget)
647 {
648 GtkPizza *pizza;
649 GtkPizzaChild *child;
650 GList *children;
651
652 g_return_if_fail (container != NULL);
653 g_return_if_fail (GTK_IS_PIZZA (container));
654 g_return_if_fail (widget != NULL);
655
656 pizza = GTK_PIZZA (container);
657
658 children = pizza->children;
659 while (children)
660 {
661 child = children->data;
662
663 if (child->widget == widget)
664 {
665 gtk_widget_unparent (widget);
666
667 /* security checks */
668 g_return_if_fail (GTK_IS_WIDGET (widget));
669
670 pizza->children = g_list_remove_link (pizza->children, children);
671 g_list_free (children);
672 g_free (child);
673
674 /* security checks */
675 g_return_if_fail (GTK_IS_WIDGET (widget));
676
677 break;
678 }
679
680 children = children->next;
681 }
682 }
683
684 static void
685 gtk_pizza_forall (GtkContainer *container,
686 gboolean include_internals,
687 GtkCallback callback,
688 gpointer callback_data)
689 {
690 GtkPizza *pizza;
691 GtkPizzaChild *child;
692 GList *children;
693
694 g_return_if_fail (container != NULL);
695 g_return_if_fail (GTK_IS_PIZZA (container));
696 g_return_if_fail (callback != (GtkCallback)NULL);
697
698 pizza = GTK_PIZZA (container);
699
700 children = pizza->children;
701 while (children)
702 {
703 child = children->data;
704 children = children->next;
705
706 (* callback) (child->widget, callback_data);
707 }
708 }
709
710 static void
711 gtk_pizza_allocate_child (GtkPizza *pizza,
712 GtkPizzaChild *child)
713 {
714 GtkAllocation allocation;
715 GtkRequisition requisition;
716
717 allocation.x = child->x - pizza->m_xoffset;
718 allocation.y = child->y - pizza->m_yoffset;
719 gtk_widget_get_child_requisition (child->widget, &requisition);
720 allocation.width = requisition.width;
721 allocation.height = requisition.height;
722
723 if (gtk_widget_get_direction( GTK_WIDGET(pizza) ) == GTK_TEXT_DIR_RTL)
724 {
725 /* reverse horizontal placement */
726 gint offset,border;
727
728 offset = GTK_WIDGET(pizza)->allocation.width;
729 border = pizza->container.border_width;
730 offset -= border*2;
731
732 allocation.x = offset - child->x - allocation.width + pizza->m_xoffset;
733 }
734
735 gtk_widget_size_allocate (child->widget, &allocation);
736 }
737
738 static void
739 gtk_pizza_adjust_allocations_recurse (GtkWidget *widget,
740 gpointer cb_data)
741 {
742 GtkPizzaAdjData *data = cb_data;
743
744 widget->allocation.x += data->dx;
745 widget->allocation.y += data->dy;
746
747 if (GTK_WIDGET_NO_WINDOW (widget) && GTK_IS_CONTAINER (widget))
748 {
749 gtk_container_forall (GTK_CONTAINER (widget),
750 gtk_pizza_adjust_allocations_recurse,
751 cb_data);
752 }
753 }
754
755 static void
756 gtk_pizza_adjust_allocations (GtkPizza *pizza,
757 gint dx,
758 gint dy)
759 {
760 GList *tmp_list;
761 GtkPizzaAdjData data;
762
763 data.dx = dx;
764 data.dy = dy;
765
766 tmp_list = pizza->children;
767 while (tmp_list)
768 {
769 GtkPizzaChild *child = tmp_list->data;
770 tmp_list = tmp_list->next;
771
772 child->widget->allocation.x += dx;
773 child->widget->allocation.y += dy;
774
775 if (GTK_WIDGET_NO_WINDOW (child->widget) &&
776 GTK_IS_CONTAINER (child->widget))
777 {
778 gtk_container_forall (GTK_CONTAINER (child->widget),
779 gtk_pizza_adjust_allocations_recurse,
780 &data);
781 }
782 }
783 }
784
785 void
786 gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy)
787 {
788 pizza->m_xoffset += dx;
789 pizza->m_yoffset += dy;
790
791 gtk_pizza_adjust_allocations (pizza, -dx, -dy);
792
793 if (pizza->bin_window)
794 gdk_window_scroll( pizza->bin_window, -dx, -dy );
795 }
796
797 #ifdef __cplusplus
798 }
799 #endif /* __cplusplus */