]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/win_gtk.c
wxGTK now chooses the best visual X offers,
[wxWidgets.git] / src / gtk1 / win_gtk.c
CommitLineData
c67daf87 1/* ///////////////////////////////////////////////////////////////////////////
c67d8618 2// Name: win_gtk.c
01111366 3// Purpose: native GTK+ widget for wxWindows
c801d85f 4// Author: Robert Roebling
c67d8618 5// Id: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling
c801d85f 7// Licence: wxWindows licence
c67daf87 8/////////////////////////////////////////////////////////////////////////// */
c801d85f
KB
9
10#include "wx/gtk/win_gtk.h"
034be888 11#include "gtk/gtksignal.h"
bbf7db28 12#include "gtk/gtknotebook.h"
38c7b3d3 13
c801d85f
KB
14#ifdef __cplusplus
15extern "C" {
16#endif /* __cplusplus */
17
18static void gtk_myfixed_class_init (GtkMyFixedClass *klass);
19static void gtk_myfixed_init (GtkMyFixed *myfixed);
20static void gtk_myfixed_map (GtkWidget *widget);
034be888 21#if (GTK_MINOR_VERSION == 0)
c801d85f 22static void gtk_myfixed_unmap (GtkWidget *widget);
38c7b3d3 23#endif
c801d85f
KB
24static void gtk_myfixed_realize (GtkWidget *widget);
25static void gtk_myfixed_size_request (GtkWidget *widget,
26 GtkRequisition *requisition);
27static void gtk_myfixed_size_allocate (GtkWidget *widget,
28 GtkAllocation *allocation);
29static void gtk_myfixed_paint (GtkWidget *widget,
30 GdkRectangle *area);
31static void gtk_myfixed_draw (GtkWidget *widget,
32 GdkRectangle *area);
33static gint gtk_myfixed_expose (GtkWidget *widget,
34 GdkEventExpose *event);
35static void gtk_myfixed_add (GtkContainer *container,
36 GtkWidget *widget);
37static void gtk_myfixed_remove (GtkContainer *container,
38 GtkWidget *widget);
39static void gtk_myfixed_foreach (GtkContainer *container,
d345e841 40#if (GTK_MINOR_VERSION > 0)
75ed1d15
GL
41 gboolean include_internals,
42#endif
c801d85f
KB
43 GtkCallback callback,
44 gpointer callback_data);
034be888 45#if (GTK_MINOR_VERSION > 0)
38c7b3d3
RR
46static GtkType gtk_myfixed_child_type (GtkContainer *container);
47#endif
c801d85f 48
034be888
RR
49#if (GTK_MINOR_VERSION > 0)
50static void gtk_myfixed_scroll_set_adjustments (GtkMyFixed *myfixed,
51 GtkAdjustment *hadj,
52 GtkAdjustment *vadj);
53#endif
c801d85f 54
c801d85f
KB
55
56
034be888
RR
57static GtkContainerClass *parent_class = NULL;
58
c801d85f
KB
59guint
60gtk_myfixed_get_type ()
61{
053f9cc1 62 static guint myfixed_type = 0;
c801d85f 63
053f9cc1 64 if (!myfixed_type)
c801d85f 65 {
053f9cc1
RR
66 GtkTypeInfo myfixed_info =
67 {
68 "GtkMyFixed",
69 sizeof (GtkMyFixed),
70 sizeof (GtkMyFixedClass),
71 (GtkClassInitFunc) gtk_myfixed_class_init,
72 (GtkObjectInitFunc) gtk_myfixed_init,
034be888 73#if (GTK_MINOR_VERSION > 0)
053f9cc1
RR
74 /* reserved_1 */ NULL,
75 /* reserved_2 */ NULL,
76 (GtkClassInitFunc) NULL,
034be888 77#else
053f9cc1
RR
78 (GtkArgSetFunc) NULL,
79 (GtkArgGetFunc) NULL,
38c7b3d3 80#endif
053f9cc1
RR
81 };
82 myfixed_type = gtk_type_unique (gtk_container_get_type (), &myfixed_info);
c801d85f 83 }
053f9cc1
RR
84
85 return myfixed_type;
c801d85f
KB
86}
87
88static void
89gtk_myfixed_class_init (GtkMyFixedClass *klass)
90{
053f9cc1
RR
91 GtkObjectClass *object_class;
92 GtkWidgetClass *widget_class;
93 GtkContainerClass *container_class;
c801d85f 94
053f9cc1
RR
95 object_class = (GtkObjectClass*) klass;
96 widget_class = (GtkWidgetClass*) klass;
97 container_class = (GtkContainerClass*) klass;
f5368809 98
034be888 99#if (GTK_MINOR_VERSION > 0)
053f9cc1 100 parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
034be888 101#else
053f9cc1 102 parent_class = gtk_type_class (gtk_container_get_type ());
38c7b3d3 103#endif
c801d85f 104
053f9cc1 105 widget_class->map = gtk_myfixed_map;
034be888 106#if (GTK_MINOR_VERSION == 0)
053f9cc1 107 widget_class->unmap = gtk_myfixed_unmap;
38c7b3d3 108#endif
053f9cc1
RR
109 widget_class->realize = gtk_myfixed_realize;
110 widget_class->size_request = gtk_myfixed_size_request;
111 widget_class->size_allocate = gtk_myfixed_size_allocate;
112 widget_class->draw = gtk_myfixed_draw;
113 widget_class->expose_event = gtk_myfixed_expose;
114
115 container_class->add = gtk_myfixed_add;
116 container_class->remove = gtk_myfixed_remove;
d345e841 117#if (GTK_MINOR_VERSION > 0)
053f9cc1 118 container_class->forall = gtk_myfixed_foreach;
75ed1d15 119#else
053f9cc1 120 container_class->foreach = gtk_myfixed_foreach;
75ed1d15 121#endif
38c7b3d3 122
034be888 123#if (GTK_MINOR_VERSION > 0)
053f9cc1 124 container_class->child_type = gtk_myfixed_child_type;
38c7b3d3 125#endif
034be888
RR
126
127#if (GTK_MINOR_VERSION > 0)
053f9cc1 128 klass->set_scroll_adjustments = gtk_myfixed_scroll_set_adjustments;
034be888 129
053f9cc1 130 widget_class->set_scroll_adjustments_signal =
034be888
RR
131 gtk_signal_new ("set_scroll_adjustments",
132 GTK_RUN_LAST,
133 object_class->type,
134 GTK_SIGNAL_OFFSET (GtkMyFixedClass, set_scroll_adjustments),
135 gtk_marshal_NONE__POINTER_POINTER,
136 GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
137#endif
38c7b3d3
RR
138}
139
034be888 140#if (GTK_MINOR_VERSION > 0)
38c7b3d3
RR
141static GtkType
142gtk_myfixed_child_type (GtkContainer *container)
143{
053f9cc1 144 return GTK_TYPE_WIDGET;
c801d85f 145}
38c7b3d3 146#endif
c801d85f
KB
147
148static void
149gtk_myfixed_init (GtkMyFixed *myfixed)
150{
053f9cc1 151 GTK_WIDGET_UNSET_FLAGS (myfixed, GTK_NO_WINDOW);
38c7b3d3 152
034be888 153#if (GTK_MINOR_VERSION == 0)
053f9cc1 154 GTK_WIDGET_SET_FLAGS (myfixed, GTK_BASIC);
38c7b3d3 155#endif
f5368809 156
034be888 157#if (GTK_MINOR_VERSION > 0)
053f9cc1 158 myfixed->shadow_type = GTK_SHADOW_NONE;
034be888
RR
159#endif
160
053f9cc1 161 myfixed->children = NULL;
c801d85f
KB
162}
163
164GtkWidget*
165gtk_myfixed_new ()
166{
053f9cc1 167 GtkMyFixed *myfixed;
c801d85f 168
053f9cc1 169 myfixed = gtk_type_new (gtk_myfixed_get_type ());
c801d85f 170
053f9cc1 171 return GTK_WIDGET (myfixed);
c801d85f
KB
172}
173
034be888 174#if (GTK_MINOR_VERSION > 0)
053f9cc1
RR
175void
176gtk_myfixed_scroll_set_adjustments (GtkMyFixed *myfixed,
177 GtkAdjustment *hadj,
178 GtkAdjustment *vadj)
034be888
RR
179{
180 /* OK, this is embarassing, but this function has to be here */
181}
182
183void
053f9cc1
RR
184gtk_myfixed_set_shadow_type (GtkMyFixed *myfixed,
185 GtkShadowType type)
034be888 186{
053f9cc1
RR
187 g_return_if_fail (myfixed != NULL);
188 g_return_if_fail (GTK_IS_MYFIXED (myfixed));
034be888 189
053f9cc1 190 if ((GtkShadowType) myfixed->shadow_type != type)
034be888 191 {
053f9cc1 192 myfixed->shadow_type = type;
034be888 193
053f9cc1 194 if (GTK_WIDGET_VISIBLE (myfixed))
034be888 195 {
053f9cc1
RR
196 gtk_widget_size_allocate (GTK_WIDGET (myfixed), &(GTK_WIDGET (myfixed)->allocation));
197 gtk_widget_queue_draw (GTK_WIDGET (myfixed));
034be888
RR
198 }
199 }
200}
201#endif
202
c801d85f 203void
053f9cc1
RR
204gtk_myfixed_put (GtkMyFixed *myfixed,
205 GtkWidget *widget,
fdd3ed7a
RR
206 gint16 x,
207 gint16 y,
208 gint16 width,
209 gint16 height)
c801d85f 210{
053f9cc1
RR
211 GtkMyFixedChild *child_info;
212
213 g_return_if_fail (myfixed != NULL);
214 g_return_if_fail (GTK_IS_MYFIXED (myfixed));
215 g_return_if_fail (widget != NULL);
216
217 child_info = g_new (GtkMyFixedChild, 1);
218 child_info->widget = widget;
219 child_info->x = x;
220 child_info->y = y;
221 child_info->width = width;
222 child_info->height = height;
d4c99d6f 223
053f9cc1 224 gtk_widget_set_parent (widget, GTK_WIDGET (myfixed));
c801d85f 225
053f9cc1 226 myfixed->children = g_list_append (myfixed->children, child_info);
c801d85f 227
053f9cc1
RR
228 if (GTK_WIDGET_REALIZED (myfixed))
229 gtk_widget_realize (widget);
c801d85f 230
053f9cc1 231 if (GTK_WIDGET_VISIBLE (myfixed) && GTK_WIDGET_VISIBLE (widget))
326f9654 232 {
053f9cc1
RR
233 if (GTK_WIDGET_MAPPED (myfixed))
234 gtk_widget_map (widget);
326f9654 235
053f9cc1 236 gtk_widget_queue_resize (GTK_WIDGET (myfixed));
326f9654 237 }
c801d85f
KB
238}
239
240void
053f9cc1
RR
241gtk_myfixed_move (GtkMyFixed *myfixed,
242 GtkWidget *widget,
fdd3ed7a
RR
243 gint16 x,
244 gint16 y)
c801d85f 245{
053f9cc1
RR
246 GtkMyFixedChild *child;
247 GList *children;
c801d85f 248
053f9cc1
RR
249 g_return_if_fail (myfixed != NULL);
250 g_return_if_fail (GTK_IS_MYFIXED (myfixed));
251 g_return_if_fail (widget != NULL);
c801d85f 252
053f9cc1
RR
253 children = myfixed->children;
254 while (children)
fdd3ed7a 255 {
053f9cc1
RR
256 child = children->data;
257 children = children->next;
fdd3ed7a 258
053f9cc1 259 if (child->widget == widget)
fdd3ed7a 260 {
053f9cc1
RR
261 gtk_myfixed_set_size( myfixed, widget, x, y, child->width, child->height );
262 break;
fdd3ed7a
RR
263 }
264 }
265}
266
267void
268gtk_myfixed_resize (GtkMyFixed *myfixed,
269 GtkWidget *widget,
270 gint16 width,
271 gint16 height)
272{
053f9cc1
RR
273 GtkMyFixedChild *child;
274 GList *children;
fdd3ed7a 275
053f9cc1
RR
276 g_return_if_fail (myfixed != NULL);
277 g_return_if_fail (GTK_IS_MYFIXED (myfixed));
278 g_return_if_fail (widget != NULL);
fdd3ed7a 279
053f9cc1
RR
280 children = myfixed->children;
281 while (children)
fdd3ed7a 282 {
053f9cc1
RR
283 child = children->data;
284 children = children->next;
fdd3ed7a 285
053f9cc1 286 if (child->widget == widget)
fdd3ed7a 287 {
053f9cc1
RR
288 gtk_myfixed_set_size( myfixed, widget, child->x, child->y, width, height );
289 break;
fdd3ed7a
RR
290 }
291 }
292}
293
294void
053f9cc1
RR
295gtk_myfixed_set_size (GtkMyFixed *myfixed,
296 GtkWidget *widget,
fdd3ed7a
RR
297 gint16 x,
298 gint16 y,
299 gint16 width,
300 gint16 height)
301{
053f9cc1
RR
302 GtkMyFixedChild *child;
303 GList *children;
304 GtkAllocation child_allocation;
fdd3ed7a 305
053f9cc1
RR
306 g_return_if_fail (myfixed != NULL);
307 g_return_if_fail (GTK_IS_MYFIXED (myfixed));
308 g_return_if_fail (widget != NULL);
fdd3ed7a 309
053f9cc1
RR
310 children = myfixed->children;
311 while (children)
c801d85f 312 {
053f9cc1
RR
313 child = children->data;
314 children = children->next;
c801d85f 315
053f9cc1 316 if (child->widget == widget)
c801d85f 317 {
053f9cc1
RR
318 if ((child->x == x) &&
319 (child->y == y) &&
320 (child->width == width) &&
321 (child->height == height)) return;
fb1585ae 322
053f9cc1
RR
323 child->x = x;
324 child->y = y;
325 child->width = width;
326 child->height = height;
327
328 if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (myfixed))
329 {
330 if ((child->width > 1) && (child->height > 1) && (GTK_WIDGET_REALIZED(widget)))
331 {
332 child_allocation.x = child->x;
333 child_allocation.y = child->y;
334 child_allocation.width = MAX( child->width, 1 );
335 child_allocation.height = MAX( child->height, 1 );
336
337 /* work around for GTK bug when moving widgets outside
338 the X window -> do NOT move them entirely outside */
339 if (child_allocation.y + child_allocation.height < 0)
340 child_allocation.y = -child_allocation.height;
341 if (child_allocation.x + child_allocation.width < 0)
342 child_allocation.x = -child_allocation.width;
343
344 gtk_widget_size_allocate (widget, &child_allocation);
345 }
346 else
347 {
348 gtk_widget_queue_resize (GTK_WIDGET (myfixed));
349 }
350 }
351 break;
c801d85f
KB
352 }
353 }
354}
355
356static void
357gtk_myfixed_map (GtkWidget *widget)
358{
053f9cc1
RR
359 GtkMyFixed *myfixed;
360 GtkMyFixedChild *child;
361 GList *children;
c801d85f 362
053f9cc1
RR
363 g_return_if_fail (widget != NULL);
364 g_return_if_fail (GTK_IS_MYFIXED (widget));
c801d85f 365
053f9cc1
RR
366 GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
367 myfixed = GTK_MYFIXED (widget);
c801d85f 368
053f9cc1
RR
369 children = myfixed->children;
370 while (children)
c801d85f 371 {
053f9cc1
RR
372 child = children->data;
373 children = children->next;
c801d85f 374
053f9cc1
RR
375 if (GTK_WIDGET_VISIBLE (child->widget) && !GTK_WIDGET_MAPPED (child->widget))
376 gtk_widget_map (child->widget);
c801d85f 377 }
d872b8a9 378
053f9cc1 379 gdk_window_show (widget->window);
c801d85f
KB
380}
381
034be888 382#if (GTK_MINOR_VERSION == 0)
c801d85f
KB
383static void
384gtk_myfixed_unmap (GtkWidget *widget)
385{
053f9cc1
RR
386 g_return_if_fail (widget != NULL);
387 g_return_if_fail (GTK_IS_MYFIXED (widget));
c801d85f 388
053f9cc1 389 GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
c801d85f 390}
38c7b3d3 391#endif
c801d85f
KB
392
393static void
394gtk_myfixed_realize (GtkWidget *widget)
395{
053f9cc1
RR
396 GtkMyFixed *myfixed;
397 GdkWindowAttr attributes;
398 gint attributes_mask;
c801d85f 399
053f9cc1
RR
400 g_return_if_fail (widget != NULL);
401 g_return_if_fail (GTK_IS_MYFIXED (widget));
c801d85f 402
053f9cc1 403 myfixed = GTK_MYFIXED (widget);
d4c99d6f 404
053f9cc1 405 GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
c801d85f 406
053f9cc1 407 attributes.window_type = GDK_WINDOW_CHILD;
034be888
RR
408
409#if (GTK_MINOR_VERSION > 0)
053f9cc1
RR
410 attributes.x = widget->allocation.x;
411 attributes.y = widget->allocation.y;
412 attributes.width = widget->allocation.width;
413 attributes.height = widget->allocation.height;
414
415 if (myfixed->shadow_type != GTK_SHADOW_NONE)
416 {
417 attributes.x += 2;
418 attributes.y += 2;
419 attributes.width -= 4;
420 attributes.height -= 4;
421 }
58dea4b0 422
053f9cc1
RR
423 if (attributes.width < 2) attributes.width = 2;
424 if (attributes.height < 2) attributes.height = 2;
034be888 425#else
053f9cc1
RR
426 attributes.x = widget->allocation.x;
427 attributes.y = widget->allocation.y;
428 attributes.width = 32000;
429 attributes.height = 32000;
034be888 430#endif
053f9cc1
RR
431 attributes.wclass = GDK_INPUT_OUTPUT;
432 attributes.visual = gtk_widget_get_visual (widget);
433 attributes.colormap = gtk_widget_get_colormap (widget);
434 attributes.event_mask = gtk_widget_get_events (widget);
435 attributes.event_mask |=
436 GDK_EXPOSURE_MASK |
437 GDK_POINTER_MOTION_MASK |
438 GDK_POINTER_MOTION_HINT_MASK |
439 GDK_BUTTON_MOTION_MASK |
440 GDK_BUTTON1_MOTION_MASK |
441 GDK_BUTTON2_MOTION_MASK |
442 GDK_BUTTON3_MOTION_MASK |
443 GDK_BUTTON_PRESS_MASK |
444 GDK_BUTTON_RELEASE_MASK |
445 GDK_KEY_PRESS_MASK |
446 GDK_KEY_RELEASE_MASK |
447 GDK_ENTER_NOTIFY_MASK |
448 GDK_LEAVE_NOTIFY_MASK |
449 GDK_FOCUS_CHANGE_MASK;
450 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
451
452 widget->window = gdk_window_new( gtk_widget_get_parent_window (widget), &attributes,
453 attributes_mask);
454 gdk_window_set_user_data (widget->window, widget);
c801d85f 455
053f9cc1
RR
456 widget->style = gtk_style_attach (widget->style, widget->window);
457 gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
c801d85f
KB
458}
459
460static void
461gtk_myfixed_size_request (GtkWidget *widget,
053f9cc1 462 GtkRequisition *requisition)
c801d85f 463{
053f9cc1
RR
464 GtkMyFixed *myfixed;
465 GtkMyFixedChild *child;
466 GList *children;
467 GtkRequisition child_requisition;
c801d85f 468
053f9cc1
RR
469 g_return_if_fail (widget != NULL);
470 g_return_if_fail (GTK_IS_MYFIXED (widget));
471 g_return_if_fail (requisition != NULL);
c801d85f 472
053f9cc1 473 myfixed = GTK_MYFIXED (widget);
c801d85f 474
053f9cc1
RR
475 children = myfixed->children;
476 while (children)
c801d85f 477 {
053f9cc1
RR
478 child = children->data;
479 children = children->next;
c801d85f 480
053f9cc1 481 if (GTK_WIDGET_VISIBLE (child->widget))
c801d85f 482 {
053f9cc1 483 gtk_widget_size_request (child->widget, &child_requisition);
c801d85f
KB
484 }
485 }
d872b8a9 486
053f9cc1
RR
487 /* request very little, I'm not sure if requesting nothing
488 will always have positive effects on stability... */
489 requisition->width = 2;
490 requisition->height = 2;
c801d85f
KB
491}
492
493static void
494gtk_myfixed_size_allocate (GtkWidget *widget,
fdd3ed7a 495 GtkAllocation *allocation)
c801d85f 496{
053f9cc1
RR
497 GtkMyFixed *myfixed;
498 gint border;
499 GtkMyFixedChild *child;
500 GtkAllocation child_allocation;
501 GList *children;
c801d85f 502
053f9cc1
RR
503 g_return_if_fail (widget != NULL);
504 g_return_if_fail (GTK_IS_MYFIXED(widget));
505 g_return_if_fail (allocation != NULL);
c801d85f 506
053f9cc1 507 myfixed = GTK_MYFIXED (widget);
e208b369 508
227e5e99 509 widget->allocation = *allocation;
a0fdacee 510#if (GTK_MINOR_VERSION > 0)
053f9cc1
RR
511 if (myfixed->shadow_type == GTK_SHADOW_NONE)
512 border = 0;
513 else
514 border = 2;
ef47f9b3 515#else
053f9cc1 516 border = 0;
ef47f9b3 517#endif
034be888 518
053f9cc1
RR
519 if (GTK_WIDGET_REALIZED (widget))
520 {
521 gdk_window_move_resize( widget->window,
522 allocation->x+border, allocation->y+border,
034be888 523#if (GTK_MINOR_VERSION > 0)
053f9cc1 524 allocation->width-border*2, allocation->height-border*2
034be888 525#else
053f9cc1 526 32000, 32000
034be888 527#endif
053f9cc1
RR
528 );
529 }
c801d85f 530
053f9cc1
RR
531 children = myfixed->children;
532 while (children)
c801d85f 533 {
053f9cc1
RR
534 child = children->data;
535 children = children->next;
69cdfbf7 536
053f9cc1
RR
537 /* please look at the text in wxWindow::DoSetSize() on why the
538 test GTK_WIDGET_REALIZED() has to be here */
539 if (GTK_WIDGET_VISIBLE (child->widget))
540 {
541/* if (GTK_IS_NOTEBOOK(child->widget) && !GTK_WIDGET_REALIZED(child->widget))
542 {
543 gtk_widget_queue_resize( child->widget );
544 }
545 else */
546 {
547 child_allocation.x = child->x;
548 child_allocation.y = child->y;
549 child_allocation.width = MAX( child->width, 1 );
550 child_allocation.height = MAX( child->height, 1 );
551
552 /* work around for GTK bug when moving widgets outside
553 the X window -> do NOT move them entirely outside */
554 if (child_allocation.y + child_allocation.height < 0)
555 child_allocation.y = -child_allocation.height;
556 if (child_allocation.x + child_allocation.width < 0)
557 child_allocation.x = -child_allocation.width;
558
559 gtk_widget_size_allocate (child->widget, &child_allocation);
560 }
561 }
562 }
c801d85f
KB
563}
564
565static void
566gtk_myfixed_paint (GtkWidget *widget,
fdd3ed7a 567 GdkRectangle *area)
c801d85f 568{
053f9cc1
RR
569 g_return_if_fail (widget != NULL);
570 g_return_if_fail (GTK_IS_MYFIXED (widget));
571 g_return_if_fail (area != NULL);
572
573 if (GTK_WIDGET_DRAWABLE (widget))
574 gdk_window_clear_area (widget->window,
575 area->x, area->y,
576 area->width, area->height);
c801d85f
KB
577}
578
579static void
580gtk_myfixed_draw (GtkWidget *widget,
fdd3ed7a 581 GdkRectangle *area)
c801d85f
KB
582{
583 GtkMyFixed *myfixed;
584 GtkMyFixedChild *child;
585 GdkRectangle child_area;
586 GList *children;
587
588 g_return_if_fail (widget != NULL);
589 g_return_if_fail (GTK_IS_MYFIXED (widget));
590
591 if (GTK_WIDGET_DRAWABLE (widget))
592 {
593 myfixed = GTK_MYFIXED (widget);
594 gtk_myfixed_paint (widget, area);
595
596 children = myfixed->children;
597 while (children)
598 {
599 child = children->data;
600 children = children->next;
601
602 if (gtk_widget_intersect (child->widget, area, &child_area))
603 gtk_widget_draw (child->widget, &child_area);
604 }
605 }
606}
607
608static gint
609gtk_myfixed_expose (GtkWidget *widget,
fdd3ed7a 610 GdkEventExpose *event)
c801d85f
KB
611{
612 GtkMyFixed *myfixed;
613 GtkMyFixedChild *child;
614 GdkEventExpose child_event;
615 GList *children;
616
617 g_return_val_if_fail (widget != NULL, FALSE);
618 g_return_val_if_fail (GTK_IS_MYFIXED (widget), FALSE);
619 g_return_val_if_fail (event != NULL, FALSE);
620
621 if (GTK_WIDGET_DRAWABLE (widget))
622 {
623 myfixed = GTK_MYFIXED (widget);
624
625 child_event = *event;
626
627 children = myfixed->children;
628 while (children)
629 {
630 child = children->data;
631 children = children->next;
632
633 if (GTK_WIDGET_NO_WINDOW (child->widget) &&
634 gtk_widget_intersect (child->widget, &event->area,
635 &child_event.area))
636 gtk_widget_event (child->widget, (GdkEvent*) &child_event);
637 }
638 }
639
640 return FALSE;
641}
642
643static void
644gtk_myfixed_add (GtkContainer *container,
645 GtkWidget *widget)
646{
647 g_return_if_fail (container != NULL);
648 g_return_if_fail (GTK_IS_MYFIXED (container));
649 g_return_if_fail (widget != NULL);
650
fdd3ed7a 651 gtk_myfixed_put (GTK_MYFIXED (container), widget, 0, 0, 20, 20 );
c801d85f
KB
652}
653
654static void
655gtk_myfixed_remove (GtkContainer *container,
656 GtkWidget *widget)
657{
658 GtkMyFixed *myfixed;
659 GtkMyFixedChild *child;
660 GList *children;
661
662 g_return_if_fail (container != NULL);
663 g_return_if_fail (GTK_IS_MYFIXED (container));
664 g_return_if_fail (widget != NULL);
665
666 myfixed = GTK_MYFIXED (container);
667
668 children = myfixed->children;
669 while (children)
670 {
671 child = children->data;
672
673 if (child->widget == widget)
674 {
d872b8a9
RR
675 gboolean was_visible = GTK_WIDGET_VISIBLE (widget);
676
c801d85f
KB
677 gtk_widget_unparent (widget);
678
679 myfixed->children = g_list_remove_link (myfixed->children, children);
680 g_list_free (children);
681 g_free (child);
682
d872b8a9 683 if (was_visible && GTK_WIDGET_VISIBLE (container))
c801d85f
KB
684 gtk_widget_queue_resize (GTK_WIDGET (container));
685
686 break;
687 }
688
689 children = children->next;
690 }
691}
692
693static void
694gtk_myfixed_foreach (GtkContainer *container,
d345e841 695#if (GTK_MINOR_VERSION > 0)
75ed1d15
GL
696 gboolean include_internals,
697#endif
c801d85f
KB
698 GtkCallback callback,
699 gpointer callback_data)
700{
701 GtkMyFixed *myfixed;
702 GtkMyFixedChild *child;
703 GList *children;
704
705 g_return_if_fail (container != NULL);
706 g_return_if_fail (GTK_IS_MYFIXED (container));
707 g_return_if_fail (callback != NULL);
708
709 myfixed = GTK_MYFIXED (container);
710
711 children = myfixed->children;
712 while (children)
713 {
714 child = children->data;
715 children = children->next;
716
717 (* callback) (child->widget, callback_data);
718 }
719}
720
721
722#ifdef __cplusplus
723}
724#endif /* __cplusplus */
725