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