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