| 1 | #cxx . . $ `<file>/demo/demo-events.c`/include <config.h>cxx . . $ `<file>/config.h`/ |
| 2 | #include <string.h> |
| 3 | #include <gtk/gtk.h> |
| 4 | #include <goocanvas.h>cxx . . $ `<file>/src/goocanvas.h`/ |
| 5 | |
| 6 | |
| 7 | static gbooleancxx . . $ gboolean# |
| 8 | on_motion_notifycxx . . $ on_motion_notify(d9fb832b8fd13035). (GooCanvasItemcxx . . $ GooCanvasItem# *item, |
| 9 | GooCanvasItemcxx . . $ GooCanvasItem# *target, |
| 10 | GdkEventMotioncxx . . $ GdkEventMotion# *event, |
| 11 | gpointercxx . . $ gpointer# data) |
| 12 | { |
| 13 | char *item_id = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 14 | |
| 15 | if (target) |
| 16 | item_id = g_object_get_datacxx . . $ g_object_get_data(973400aee2f864c2). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (target), "id"); |
| 17 | |
| 18 | if (item_id) |
| 19 | g_printcxx . . $ g_print(326aeb464d16410c). ("%s item received 'motion-notify' signal\n", item_id); |
| 20 | |
| 21 | return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!; |
| 22 | } |
| 23 | |
| 24 | |
| 25 | static void |
| 26 | setup_item_signalscxx . . $ setup_item_signals(fb89872e380c590a). (GooCanvasItemcxx . . $ GooCanvasItem# *item) |
| 27 | { |
| 28 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (item, "motion_notify_event", |
| 29 | G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (on_motion_notify), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 30 | } |
| 31 | |
| 32 | |
| 33 | static void |
| 34 | create_events_areacxx . . $ create_events_area(4e986d28227c4e63). (GtkWidgetcxx . . $ GtkWidget# *canvas, |
| 35 | gintcxx . . $ gint# area_num, |
| 36 | GooCanvasPointerEventscxx . . $ GooCanvasPointerEvents# pointer_events, |
| 37 | gcharcxx . . $ gchar# *label) |
| 38 | { |
| 39 | gintcxx . . $ gint# row = area_num / 3, col = area_num % 3; |
| 40 | gdoublecxx . . $ gdouble# x = col * 200, y = row * 150; |
| 41 | GooCanvasItemcxx . . $ GooCanvasItem# *root, *rect; |
| 42 | char *view_id; |
| 43 | GooCanvasLineDashcxx . . $ GooCanvasLineDash# *dash; |
| 44 | |
| 45 | root = goo_canvas_get_root_itemcxx . . $ goo_canvas_get_root_item(ce13d83f0f3922dc). (GOO_CANVAScxx . . $ `src/goocanvas.h:27:9`! (canvas)); |
| 46 | |
| 47 | dash = goo_canvas_line_dash_newcxx . . $ goo_canvas_line_dash_new(a64cd6185a46a0ec). (2, 5.0, 5.0); |
| 48 | |
| 49 | /* Create invisible item. */ |
| 50 | rect = goo_canvas_rect_newcxx . . $ goo_canvas_rect_new(81fa6bcda469491f). (root, x + 45, y + 35, 30, 30, |
| 51 | "fill-color", "red", |
| 52 | "visibility", GOO_CANVAS_ITEM_INVISIBLEcxx . . $ GOO_CANVAS_ITEM_INVISIBLE., |
| 53 | "line-width", 5.0, |
| 54 | "pointer-events", pointer_events, |
| 55 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 56 | view_id = g_strdup_printfcxx . . $ g_strdup_printf(a849077ff1b8d812). ("%s invisible", label); |
| 57 | g_object_set_data_fullcxx . . $ g_object_set_data_full(218df00be1d2a06c). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (rect), "id", view_id, g_freecxx . . $ g_free(5d22bdacc48458e8).); |
| 58 | setup_item_signalscxx . . $ setup_item_signals(fb89872e380c590a). (rect); |
| 59 | |
| 60 | /* Display a thin rect around it to indicate it is there. */ |
| 61 | #if 1 |
| 62 | rect = goo_canvas_rect_newcxx . . $ goo_canvas_rect_new(81fa6bcda469491f). (root, x + 42.5, y + 32.5, 36, 36, |
| 63 | "line-dash", dash, |
| 64 | "line-width", 1.0, |
| 65 | "stroke-color", "gray", |
| 66 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 67 | #endif |
| 68 | |
| 69 | /* Create unpainted item. */ |
| 70 | rect = goo_canvas_rect_newcxx . . $ goo_canvas_rect_new(81fa6bcda469491f). (root, x + 85, y + 35, 30, 30, |
| 71 | "stroke-pattern", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 72 | "line-width", 5.0, |
| 73 | "pointer-events", pointer_events, |
| 74 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 75 | view_id = g_strdup_printfcxx . . $ g_strdup_printf(a849077ff1b8d812). ("%s unpainted", label); |
| 76 | g_object_set_data_fullcxx . . $ g_object_set_data_full(218df00be1d2a06c). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (rect), "id", view_id, g_freecxx . . $ g_free(5d22bdacc48458e8).); |
| 77 | setup_item_signalscxx . . $ setup_item_signals(fb89872e380c590a). (rect); |
| 78 | |
| 79 | /* Display a thin rect around it to indicate it is there. */ |
| 80 | #if 1 |
| 81 | rect = goo_canvas_rect_newcxx . . $ goo_canvas_rect_new(81fa6bcda469491f). (root, x + 82.5, y + 32.5, 36, 36, |
| 82 | "line-dash", dash, |
| 83 | "line-width", 1.0, |
| 84 | "stroke-color", "gray", |
| 85 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 86 | #endif |
| 87 | |
| 88 | /* Create stroked item. */ |
| 89 | rect = goo_canvas_rect_newcxx . . $ goo_canvas_rect_new(81fa6bcda469491f). (root, x + 125, y + 35, 30, 30, |
| 90 | "line-width", 5.0, |
| 91 | "pointer-events", pointer_events, |
| 92 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 93 | view_id = g_strdup_printfcxx . . $ g_strdup_printf(a849077ff1b8d812). ("%s stroked", label); |
| 94 | g_object_set_data_fullcxx . . $ g_object_set_data_full(218df00be1d2a06c). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (rect), "id", view_id, g_freecxx . . $ g_free(5d22bdacc48458e8).); |
| 95 | setup_item_signalscxx . . $ setup_item_signals(fb89872e380c590a). (rect); |
| 96 | |
| 97 | /* Create filled item. */ |
| 98 | rect = goo_canvas_rect_newcxx . . $ goo_canvas_rect_new(81fa6bcda469491f). (root, x + 60, y + 75, 30, 30, |
| 99 | "fill-color", "red", |
| 100 | "stroke-pattern", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 101 | "line-width", 5.0, |
| 102 | "pointer-events", pointer_events, |
| 103 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 104 | view_id = g_strdup_printfcxx . . $ g_strdup_printf(a849077ff1b8d812). ("%s filled", label); |
| 105 | g_object_set_data_fullcxx . . $ g_object_set_data_full(218df00be1d2a06c). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (rect), "id", view_id, g_freecxx . . $ g_free(5d22bdacc48458e8).); |
| 106 | setup_item_signalscxx . . $ setup_item_signals(fb89872e380c590a). (rect); |
| 107 | |
| 108 | /* Create stroked & filled item. */ |
| 109 | rect = goo_canvas_rect_newcxx . . $ goo_canvas_rect_new(81fa6bcda469491f). (root, x + 100, y + 75, 30, 30, |
| 110 | "fill-color", "red", |
| 111 | "line-width", 5.0, |
| 112 | "pointer-events", pointer_events, |
| 113 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 114 | view_id = g_strdup_printfcxx . . $ g_strdup_printf(a849077ff1b8d812). ("%s stroked & filled", label); |
| 115 | g_object_set_data_fullcxx . . $ g_object_set_data_full(218df00be1d2a06c). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (rect), "id", view_id, g_freecxx . . $ g_free(5d22bdacc48458e8).); |
| 116 | setup_item_signalscxx . . $ setup_item_signals(fb89872e380c590a). (rect); |
| 117 | |
| 118 | goo_canvas_text_newcxx . . $ goo_canvas_text_new(a79e558f39c1c3be). (root, label, x + 100, y + 130, -1, GOO_CANVAS_ANCHOR_CENTERcxx . . $ GOO_CANVAS_ANCHOR_CENTER., |
| 119 | "font", "Sans 12", |
| 120 | "fill-color", "blue", |
| 121 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 122 | |
| 123 | goo_canvas_line_dash_unrefcxx . . $ goo_canvas_line_dash_unref(62e8a43a7deb9c62). (dash); |
| 124 | } |
| 125 | |
| 126 | |
| 127 | GtkWidgetcxx . . $ GtkWidget# * |
| 128 | create_events_pagecxx . . $ create_events_page(2369ce5e9f2c7dfd). (void) |
| 129 | { |
| 130 | GtkWidgetcxx . . $ GtkWidget# *vbox, *frame, *label, *canvas; |
| 131 | |
| 132 | vbox = gtk_box_newcxx . . $ gtk_box_new(b19e0ce02196028e). (GTK_ORIENTATION_VERTICALcxx . . $ GTK_ORIENTATION_VERTICAL., 4); |
| 133 | gtk_container_set_border_widthcxx . . $ gtk_container_set_border_width(4f2d4e7d5639aede). (GTK_CONTAINERcxx . . $ `<external>/462093496598485868/gtkcontainer.h:38:9`! (vbox), 4); |
| 134 | gtk_widget_showcxx . . $ gtk_widget_show(d7cf858254b37903). (vbox); |
| 135 | |
| 136 | /* Instructions */ |
| 137 | |
| 138 | label = gtk_label_newcxx . . $ gtk_label_new(6d90f3ec8782e10d). ("Move the mouse over the items to check they receive the right motion events.\nThe first 2 items in each group are 1) invisible and 2) visible but unpainted."); |
| 139 | gtk_box_pack_startcxx . . $ gtk_box_pack_start(e6ae6b264cb15f6b). (GTK_BOXcxx . . $ `<external>/14176280485027674556/gtkbox.h:40:9`! (vbox), label, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!, 0); |
| 140 | gtk_widget_showcxx . . $ gtk_widget_show(d7cf858254b37903). (label); |
| 141 | |
| 142 | /* Frame and canvas */ |
| 143 | |
| 144 | frame = gtk_frame_newcxx . . $ gtk_frame_new(6d90f3ec8782e10d). (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 145 | gtk_frame_set_shadow_typecxx . . $ gtk_frame_set_shadow_type(c2a1762326798d9f). (GTK_FRAMEcxx . . $ `<external>/16634037676575323791/gtkframe.h:40:9`! (frame), GTK_SHADOW_INcxx . . $ GTK_SHADOW_IN.); |
| 146 | gtk_box_pack_startcxx . . $ gtk_box_pack_start(e6ae6b264cb15f6b). (GTK_BOXcxx . . $ `<external>/14176280485027674556/gtkbox.h:40:9`! (vbox), frame, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!, 0); |
| 147 | gtk_widget_showcxx . . $ gtk_widget_show(d7cf858254b37903). (frame); |
| 148 | |
| 149 | g_object_setcxx . . $ g_object_set(1ac911bdc4e9a14d). (frame, |
| 150 | "halign", GTK_ALIGN_CENTERcxx . . $ GTK_ALIGN_CENTER., |
| 151 | "valign", GTK_ALIGN_CENTERcxx . . $ GTK_ALIGN_CENTER., |
| 152 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 153 | |
| 154 | canvas = goo_canvas_newcxx . . $ goo_canvas_new(2369ce5e9f2c7dfd). (); |
| 155 | |
| 156 | gtk_widget_set_size_requestcxx . . $ gtk_widget_set_size_request(f5b8e75990cfac4b). (canvas, 600, 450); |
| 157 | goo_canvas_set_boundscxx . . $ goo_canvas_set_bounds(c765acac0aeef5c4). (GOO_CANVAScxx . . $ `src/goocanvas.h:27:9`! (canvas), 0, 0, 600, 450); |
| 158 | gtk_container_addcxx . . $ gtk_container_add(a71b61ec882009c2). (GTK_CONTAINERcxx . . $ `<external>/462093496598485868/gtkcontainer.h:38:9`! (frame), canvas); |
| 159 | gtk_widget_showcxx . . $ gtk_widget_show(d7cf858254b37903). (canvas); |
| 160 | |
| 161 | create_events_areacxx . . $ create_events_area(4e986d28227c4e63). (canvas, 0, GOO_CANVAS_EVENTS_NONEcxx . . $ GOO_CANVAS_EVENTS_NONE., "none"); |
| 162 | create_events_areacxx . . $ create_events_area(4e986d28227c4e63). (canvas, 1, GOO_CANVAS_EVENTS_VISIBLE_PAINTEDcxx . . $ GOO_CANVAS_EVENTS_VISIBLE_PAINTED., "visible-painted"); |
| 163 | create_events_areacxx . . $ create_events_area(4e986d28227c4e63). (canvas, 2, GOO_CANVAS_EVENTS_VISIBLE_FILLcxx . . $ GOO_CANVAS_EVENTS_VISIBLE_FILL., "visible-fill"); |
| 164 | create_events_areacxx . . $ create_events_area(4e986d28227c4e63). (canvas, 3, GOO_CANVAS_EVENTS_VISIBLE_STROKEcxx . . $ GOO_CANVAS_EVENTS_VISIBLE_STROKE., "visible-stroke"); |
| 165 | create_events_areacxx . . $ create_events_area(4e986d28227c4e63). (canvas, 4, GOO_CANVAS_EVENTS_VISIBLEcxx . . $ GOO_CANVAS_EVENTS_VISIBLE., "visible"); |
| 166 | create_events_areacxx . . $ create_events_area(4e986d28227c4e63). (canvas, 5, GOO_CANVAS_EVENTS_PAINTEDcxx . . $ GOO_CANVAS_EVENTS_PAINTED., "painted"); |
| 167 | create_events_areacxx . . $ create_events_area(4e986d28227c4e63). (canvas, 6, GOO_CANVAS_EVENTS_FILLcxx . . $ GOO_CANVAS_EVENTS_FILL., "fill"); |
| 168 | create_events_areacxx . . $ create_events_area(4e986d28227c4e63). (canvas, 7, GOO_CANVAS_EVENTS_STROKEcxx . . $ GOO_CANVAS_EVENTS_STROKE., "stroke"); |
| 169 | create_events_areacxx . . $ create_events_area(4e986d28227c4e63). (canvas, 8, GOO_CANVAS_EVENTS_ALLcxx . . $ GOO_CANVAS_EVENTS_ALL., "all"); |
| 170 | |
| 171 | return vbox; |
| 172 | } |