| 1 | /* GuiDrawingArea.cpp |
| 2 | * |
| 3 | * Copyright (C) 1993-2018,2020-2023,2025,2026 Paul Boersma, |
| 4 | * 2008 Stefan de Konink, 2010 Franz Brausse, 2013 Tom Naughton |
| 5 | * |
| 6 | * This code is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or (at |
| 9 | * your option) any later version. |
| 10 | * |
| 11 | * This code is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 14 | * See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #include "GuiP.h"cxx . . $ `<file>/sys/GuiP.h`/ |
| 21 | #if gtkcxx . . $ `sys/Gui.h:33:10`! |
| 22 | #include "gdk/gdkkeysyms.h" |
| 23 | #include <locale.h> |
| 24 | #endif |
| 25 | #include "GraphicsP.h"cxx . . $ `<file>/sys/GraphicsP.h`/ |
| 26 | |
| 27 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (GuiDrawingArea, GuiControl, 0); |
| 28 | |
| 29 | #if motifcxx . . $ `sys/Gui.h:34:10`! |
| 30 | #define iam_drawingarea \ |
| 31 | Melder_assert (widget -> widgetClass == xmDrawingAreaWidgetClass); \ |
| 32 | GuiDrawingArea me = (GuiDrawingArea) widget -> userData |
| 33 | #else |
| 34 | #define iam_drawingareacxx . . $ `sys/GuiDrawingArea.cpp:34:10`! \ |
| 35 | GuiDrawingArea me = (GuiDrawingArea) _GuiObject_getUserData (widget) |
| 36 | #endif |
| 37 | |
| 38 | #if gtkcxx . . $ `sys/Gui.h:33:10`! |
| 39 | #pragma mark - GTK CALLBACKS (WITH CAIRO) |
| 40 | static void _guiGtkDrawingArea_destroyCallbackcxx . . $ _guiGtkDrawingArea_destroyCallback(6c58c5e2437d25a2). (GuiObjectcxx . . $ GuiObject# widget, gpointer void_me) { |
| 41 | (void) widget; |
| 42 | iamcxx . . $ `melder/melder.h:50:9`! (GuiDrawingArea); |
| 43 | forgetcxx . . $ `sys/Thing.h:158:9`! (me); |
| 44 | } |
| 45 | static gboolean _guiGtkDrawingArea_drawCallbackcxx . . $ _guiGtkDrawingArea_drawCallback(f1cb6b4e75704d81). (GuiObjectcxx . . $ GuiObject# widget, cairo_t *cairoGraphicsContext, gpointer void_me) { |
| 46 | tracecxx . . $ `melder/melder_debug.h:60:10`! (U"begin"); |
| 47 | iamcxx . . $ `melder/melder.h:50:9`! (GuiDrawingArea); |
| 48 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (me); |
| 49 | if (mycxx . . $ `melder/melder.h:44:9`! d_exposeCallbackcxx . . $ structGuiDrawingArea#d_exposeCallback.) { |
| 50 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! numberOfGraphicses > 0); |
| 51 | structGuiDrawingArea_ExposeEventcxx . . $ structGuiDrawingArea_ExposeEvent# event { me, 0 }; |
| 52 | event. xcxx . . $ structGuiDrawingArea_ExposeEvent#x. = 0; |
| 53 | event. ycxx . . $ structGuiDrawingArea_ExposeEvent#y. = 0; |
| 54 | event. widthcxx . . $ structGuiDrawingArea_ExposeEvent#width. = gtk_widget_get_allocated_width (GTK_WIDGETcxx . . $ `<external>/6031079988677191796/gtkwidget.h:58:9`! (widget)); |
| 55 | event. heightcxx . . $ structGuiDrawingArea_ExposeEvent#height. = gtk_widget_get_allocated_height (GTK_WIDGETcxx . . $ `<external>/6031079988677191796/gtkwidget.h:58:9`! (widget)); |
| 56 | try { |
| 57 | for (int igraphics = 1; igraphics <= mycxx . . $ `melder/melder.h:44:9`! numberOfGraphicsescxx . . $ structGuiDrawingArea#numberOfGraphicses.; igraphics ++) |
| 58 | ((GraphicsScreencxx . . $ GraphicsScreen#) mycxx . . $ `melder/melder.h:44:9`! graphicsescxx . . $ structGuiDrawingArea#graphicses. [igraphics]) -> d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext. = cairoGraphicsContext; |
| 59 | mycxx . . $ `melder/melder.h:44:9`! d_exposeCallbackcxx . . $ structGuiDrawingArea#d_exposeCallback. (cxx . . $ MelderCallback#`operator()`(e7ade0e2880b4e44).mycxx . . $ `melder/melder.h:44:9`! d_exposeBosscxx . . $ structGuiDrawingArea#d_exposeBoss., & event); |
| 60 | for (int igraphics = 1; igraphics <= mycxx . . $ `melder/melder.h:44:9`! numberOfGraphicsescxx . . $ structGuiDrawingArea#numberOfGraphicses.; igraphics ++) |
| 61 | ((GraphicsScreencxx . . $ GraphicsScreen#) mycxx . . $ `melder/melder.h:44:9`! graphicsescxx . . $ structGuiDrawingArea#graphicses. [igraphics]) -> d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext. = nullptr; |
| 62 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 63 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Redrawing not completed"); |
| 64 | } |
| 65 | tracecxx . . $ `melder/melder_debug.h:60:10`! (U"the draw callback handled drawing"); |
| 66 | return true; |
| 67 | } |
| 68 | tracecxx . . $ `melder/melder_debug.h:60:10`! (U"GTK will handle redrawing"); |
| 69 | return false; |
| 70 | } |
| 71 | static structGuiDrawingArea_MouseEventcxx . . $ structGuiDrawingArea_MouseEvent#::Phasecxx . . $ structGuiDrawingArea_MouseEvent#Phase# previousPhasecxx . . $ previousPhase. = structGuiDrawingArea_MouseEventcxx . . $ structGuiDrawingArea_MouseEvent#::Phasecxx . . $ structGuiDrawingArea_MouseEvent#Phase#::DROPcxx . . $ structGuiDrawingArea_MouseEvent#Phase#DROP.; |
| 72 | static gboolean _guiGtkDrawingArea_mouseDownCallbackcxx . . $ _guiGtkDrawingArea_mouseDownCallback(2d2a8f722e23ecc4). (GuiObjectcxx . . $ GuiObject# widget, GdkEvent *e, gpointer void_me) { |
| 73 | iamcxx . . $ `melder/melder.h:50:9`! (GuiDrawingArea); |
| 74 | if (mycxx . . $ `melder/melder.h:44:9`! mouseCallbackcxx . . $ structGuiDrawingArea#mouseCallback.) { |
| 75 | structGuiDrawingArea_MouseEventcxx . . $ structGuiDrawingArea_MouseEvent# event { me, 0 }; |
| 76 | event. xcxx . . $ structGuiDrawingArea_MouseEvent#x. = ((GdkEventButton *) e) -> xcxx . . $ _GdkEventButton#x.; |
| 77 | event. ycxx . . $ structGuiDrawingArea_MouseEvent#y. = ((GdkEventButton *) e) -> ycxx . . $ _GdkEventButton#y.; |
| 78 | event. shiftKeyPressedcxx . . $ structGuiDrawingArea_MouseEvent#shiftKeyPressed. = (((GdkEventButton *) e) -> statecxx . . $ _GdkEventButton#state. & GDK_SHIFT_MASK) != 0; |
| 79 | event. commandKeyPressedcxx . . $ structGuiDrawingArea_MouseEvent#commandKeyPressed. = (((GdkEventButton *) e) -> statecxx . . $ _GdkEventButton#state. & GDK_CONTROL_MASK) != 0; |
| 80 | event. optionKeyPressedcxx . . $ structGuiDrawingArea_MouseEvent#optionKeyPressed. = (((GdkEventButton *) e) -> statecxx . . $ _GdkEventButton#state. & GDK_MOD1_MASK) != 0; |
| 81 | if (previousPhasecxx . . $ previousPhase. == structGuiDrawingArea_MouseEventcxx . . $ structGuiDrawingArea_MouseEvent#::Phasecxx . . $ structGuiDrawingArea_MouseEvent#Phase#::CLICKcxx . . $ structGuiDrawingArea_MouseEvent#Phase#CLICK.) { |
| 82 | /* |
| 83 | Apparently a double-click. |
| 84 | On other platforms, a mouse-up event is always generated, even within a double-click. |
| 85 | On Linux, we generate it ourselves. |
| 86 | */ |
| 87 | try { |
| 88 | previousPhasecxx . . $ previousPhase. = event. phasecxx . . $ structGuiDrawingArea_MouseEvent#phase. = structGuiDrawingArea_MouseEventcxx . . $ structGuiDrawingArea_MouseEvent#::Phasecxx . . $ structGuiDrawingArea_MouseEvent#Phase#::DROPcxx . . $ structGuiDrawingArea_MouseEvent#Phase#DROP.; |
| 89 | mycxx . . $ `melder/melder.h:44:9`! mouseCallbackcxx . . $ structGuiDrawingArea#mouseCallback. (cxx . . $ MelderCallback#`operator()`(e7ade0e2880b4e44).mycxx . . $ `melder/melder.h:44:9`! mouseBosscxx . . $ structGuiDrawingArea#mouseBoss., & event); |
| 90 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 91 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Mouse drop not completely handled."); |
| 92 | } |
| 93 | } |
| 94 | try { |
| 95 | previousPhasecxx . . $ previousPhase. = event. phasecxx . . $ structGuiDrawingArea_MouseEvent#phase. = structGuiDrawingArea_MouseEventcxx . . $ structGuiDrawingArea_MouseEvent#::Phasecxx . . $ structGuiDrawingArea_MouseEvent#Phase#::CLICKcxx . . $ structGuiDrawingArea_MouseEvent#Phase#CLICK.; |
| 96 | mycxx . . $ `melder/melder.h:44:9`! mouseCallbackcxx . . $ structGuiDrawingArea#mouseCallback. (cxx . . $ MelderCallback#`operator()`(e7ade0e2880b4e44).mycxx . . $ `melder/melder.h:44:9`! mouseBosscxx . . $ structGuiDrawingArea#mouseBoss., & event); |
| 97 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 98 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Mouse click not completely handled."); |
| 99 | } |
| 100 | return true; |
| 101 | } |
| 102 | return false; |
| 103 | } |
| 104 | static gboolean _guiGtkDrawingArea_mouseDraggedCallbackcxx . . $ _guiGtkDrawingArea_mouseDraggedCallback(2d2a8f722e23ecc4). (GuiObjectcxx . . $ GuiObject# widget, GdkEvent *e, gpointer void_me) { |
| 105 | iamcxx . . $ `melder/melder.h:50:9`! (GuiDrawingArea); |
| 106 | if (mycxx . . $ `melder/melder.h:44:9`! mouseCallbackcxx . . $ structGuiDrawingArea#mouseCallback.) { |
| 107 | structGuiDrawingArea_MouseEventcxx . . $ structGuiDrawingArea_MouseEvent# event { me, 0 }; |
| 108 | event. xcxx . . $ structGuiDrawingArea_MouseEvent#x. = ((GdkEventButton *) e) -> xcxx . . $ _GdkEventButton#x.; |
| 109 | event. ycxx . . $ structGuiDrawingArea_MouseEvent#y. = ((GdkEventButton *) e) -> ycxx . . $ _GdkEventButton#y.; |
| 110 | event. shiftKeyPressedcxx . . $ structGuiDrawingArea_MouseEvent#shiftKeyPressed. = (((GdkEventButton *) e) -> statecxx . . $ _GdkEventButton#state. & GDK_SHIFT_MASK) != 0; |
| 111 | event. commandKeyPressedcxx . . $ structGuiDrawingArea_MouseEvent#commandKeyPressed. = (((GdkEventButton *) e) -> statecxx . . $ _GdkEventButton#state. & GDK_CONTROL_MASK) != 0; |
| 112 | event. optionKeyPressedcxx . . $ structGuiDrawingArea_MouseEvent#optionKeyPressed. = (((GdkEventButton *) e) -> statecxx . . $ _GdkEventButton#state. & GDK_MOD1_MASK) != 0; |
| 113 | try { |
| 114 | previousPhasecxx . . $ previousPhase. = event. phasecxx . . $ structGuiDrawingArea_MouseEvent#phase. = structGuiDrawingArea_MouseEventcxx . . $ structGuiDrawingArea_MouseEvent#::Phasecxx . . $ structGuiDrawingArea_MouseEvent#Phase#::DRAGcxx . . $ structGuiDrawingArea_MouseEvent#Phase#DRAG.; |
| 115 | mycxx . . $ `melder/melder.h:44:9`! mouseCallbackcxx . . $ structGuiDrawingArea#mouseCallback. (cxx . . $ MelderCallback#`operator()`(e7ade0e2880b4e44).mycxx . . $ `melder/melder.h:44:9`! mouseBosscxx . . $ structGuiDrawingArea#mouseBoss., & event); |
| 116 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 117 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Mouse drag not completely handled."); |
| 118 | } |
| 119 | return true; |
| 120 | } |
| 121 | return false; |
| 122 | } |
| 123 | static gboolean _guiGtkDrawingArea_mouseUpCallbackcxx . . $ _guiGtkDrawingArea_mouseUpCallback(2d2a8f722e23ecc4). (GuiObjectcxx . . $ GuiObject# widget, GdkEvent *e, gpointer void_me) { |
| 124 | iamcxx . . $ `melder/melder.h:50:9`! (GuiDrawingArea); |
| 125 | if (mycxx . . $ `melder/melder.h:44:9`! mouseCallbackcxx . . $ structGuiDrawingArea#mouseCallback.) { |
| 126 | structGuiDrawingArea_MouseEventcxx . . $ structGuiDrawingArea_MouseEvent# event { me, 0 }; |
| 127 | event. xcxx . . $ structGuiDrawingArea_MouseEvent#x. = ((GdkEventButton *) e) -> xcxx . . $ _GdkEventButton#x.; |
| 128 | event. ycxx . . $ structGuiDrawingArea_MouseEvent#y. = ((GdkEventButton *) e) -> ycxx . . $ _GdkEventButton#y.; |
| 129 | event. shiftKeyPressedcxx . . $ structGuiDrawingArea_MouseEvent#shiftKeyPressed. = (((GdkEventButton *) e) -> statecxx . . $ _GdkEventButton#state. & GDK_SHIFT_MASK) != 0; |
| 130 | event. commandKeyPressedcxx . . $ structGuiDrawingArea_MouseEvent#commandKeyPressed. = (((GdkEventButton *) e) -> statecxx . . $ _GdkEventButton#state. & GDK_CONTROL_MASK) != 0; |
| 131 | event. optionKeyPressedcxx . . $ structGuiDrawingArea_MouseEvent#optionKeyPressed. = (((GdkEventButton *) e) -> statecxx . . $ _GdkEventButton#state. & GDK_MOD1_MASK) != 0; |
| 132 | try { |
| 133 | previousPhasecxx . . $ previousPhase. = event. phasecxx . . $ structGuiDrawingArea_MouseEvent#phase. = structGuiDrawingArea_MouseEventcxx . . $ structGuiDrawingArea_MouseEvent#::Phasecxx . . $ structGuiDrawingArea_MouseEvent#Phase#::DROPcxx . . $ structGuiDrawingArea_MouseEvent#Phase#DROP.; |
| 134 | mycxx . . $ `melder/melder.h:44:9`! mouseCallbackcxx . . $ structGuiDrawingArea#mouseCallback. (cxx . . $ MelderCallback#`operator()`(e7ade0e2880b4e44).mycxx . . $ `melder/melder.h:44:9`! mouseBosscxx . . $ structGuiDrawingArea#mouseBoss., & event); |
| 135 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 136 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Mouse drop not completely handled."); |
| 137 | } |
| 138 | return true; |
| 139 | } |
| 140 | return false; |
| 141 | } |
| 142 | static gboolean _guiGtkDrawingArea_keyCallbackcxx . . $ _guiGtkDrawingArea_keyCallback(2d2a8f722e23ecc4). (GuiObjectcxx . . $ GuiObject# widget, GdkEvent *gevent, gpointer void_me) { |
| 143 | iamcxx . . $ `melder/melder.h:50:9`! (GuiDrawingArea); |
| 144 | tracecxx . . $ `melder/melder_debug.h:60:10`! (U"begin"); |
| 145 | if (mycxx . . $ `melder/melder.h:44:9`! d_keyCallbackcxx . . $ structGuiDrawingArea#d_keyCallback. && gevent -> typecxx . . $ _GdkEvent#type. == GDK_KEY_PRESS) { |
| 146 | structGuiDrawingArea_KeyEventcxx . . $ structGuiDrawingArea_KeyEvent# event { me, 0 }; |
| 147 | GdkEventKey *gkeyEvent = (GdkEventKey *) gevent; |
| 148 | event. keycxx . . $ structGuiDrawingArea_KeyEvent#key. = gkeyEvent -> keyvalcxx . . $ _GdkEventKey#keyval.; |
| 149 | /* |
| 150 | * Translate with the help of /usr/include/gtk-2.0/gdk/gdkkeysyms.h |
| 151 | */ |
| 152 | if (event. keycxx . . $ structGuiDrawingArea_KeyEvent#key. == GDK_KEY_Escapecxx . . $ `<external>/1674857343504785238/gdkkeysyms.h:48:9`!) event. keycxx . . $ structGuiDrawingArea_KeyEvent#key. = 27; |
| 153 | if (event. keycxx . . $ structGuiDrawingArea_KeyEvent#key. == GDK_KEY_Leftcxx . . $ `<external>/1674857343504785238/gdkkeysyms.h:76:9`!) event. keycxx . . $ structGuiDrawingArea_KeyEvent#key. = 0x2190; |
| 154 | if (event. keycxx . . $ structGuiDrawingArea_KeyEvent#key. == GDK_KEY_Upcxx . . $ `<external>/1674857343504785238/gdkkeysyms.h:77:9`!) event. keycxx . . $ structGuiDrawingArea_KeyEvent#key. = 0x2191; |
| 155 | if (event. keycxx . . $ structGuiDrawingArea_KeyEvent#key. == GDK_KEY_Rightcxx . . $ `<external>/1674857343504785238/gdkkeysyms.h:78:9`!) event. keycxx . . $ structGuiDrawingArea_KeyEvent#key. = 0x2192; |
| 156 | if (event. keycxx . . $ structGuiDrawingArea_KeyEvent#key. == GDK_KEY_Downcxx . . $ `<external>/1674857343504785238/gdkkeysyms.h:79:9`!) event. keycxx . . $ structGuiDrawingArea_KeyEvent#key. = 0x2193; |
| 157 | event. shiftKeyPressedcxx . . $ structGuiDrawingArea_KeyEvent#shiftKeyPressed. = (gkeyEvent -> statecxx . . $ _GdkEventKey#state. & GDK_SHIFT_MASK) != 0; |
| 158 | event. commandKeyPressedcxx . . $ structGuiDrawingArea_KeyEvent#commandKeyPressed. = (gkeyEvent -> statecxx . . $ _GdkEventKey#state. & GDK_CONTROL_MASK) != 0; |
| 159 | event. optionKeyPressedcxx . . $ structGuiDrawingArea_KeyEvent#optionKeyPressed. = (gkeyEvent -> statecxx . . $ _GdkEventKey#state. & GDK_MOD1_MASK) != 0; |
| 160 | try { |
| 161 | mycxx . . $ `melder/melder.h:44:9`! d_keyCallbackcxx . . $ structGuiDrawingArea#d_keyCallback. (cxx . . $ MelderCallback#`operator()`(e7ade0e2880b4e44).mycxx . . $ `melder/melder.h:44:9`! d_keyBosscxx . . $ structGuiDrawingArea#d_keyBoss., & event); |
| 162 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 163 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Key press not completely handled."); |
| 164 | } |
| 165 | /* |
| 166 | * FIXME: here we should empty the type-ahead buffer |
| 167 | */ |
| 168 | return true; |
| 169 | } |
| 170 | return false; // if the drawing area has no keyCallback, the system will send the key press to a text field. |
| 171 | } |
| 172 | static gboolean _guiGtkDrawingArea_resizeCallbackcxx . . $ _guiGtkDrawingArea_resizeCallback(37d343a1b97342f0). (GuiObjectcxx . . $ GuiObject# widget, GtkAllocation *allocation, gpointer void_me) { |
| 173 | iamcxx . . $ `melder/melder.h:50:9`! (GuiDrawingArea); |
| 174 | if (mycxx . . $ `melder/melder.h:44:9`! d_resizeCallbackcxx . . $ structGuiDrawingArea#d_resizeCallback.) { |
| 175 | structGuiDrawingArea_ResizeEventcxx . . $ structGuiDrawingArea_ResizeEvent# event { me, 0 }; |
| 176 | tracecxx . . $ `melder/melder_debug.h:60:10`! (U"drawingArea resized to ", allocation -> width, U" x ", allocation -> height, U"."); |
| 177 | event. widthcxx . . $ structGuiDrawingArea_ResizeEvent#width. = allocation -> width; |
| 178 | event. heightcxx . . $ structGuiDrawingArea_ResizeEvent#height. = allocation -> height; |
| 179 | //g_debug("%d %d", allocation->width, allocation->height); |
| 180 | try { |
| 181 | mycxx . . $ `melder/melder.h:44:9`! d_resizeCallbackcxx . . $ structGuiDrawingArea#d_resizeCallback. (cxx . . $ MelderCallback#`operator()`(e7ade0e2880b4e44).mycxx . . $ `melder/melder.h:44:9`! d_resizeBosscxx . . $ structGuiDrawingArea#d_resizeBoss., & event); |
| 182 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 183 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Window resizing not completely handled."); |
| 184 | } |
| 185 | return true; |
| 186 | } |
| 187 | return false; |
| 188 | } |
| 189 | static void _guiGtkDrawingArea_handleZoomcxx . . $ _guiGtkDrawingArea_handleZoom(a579a53ea2bbba08). (GuiObjectcxx . . $ GuiObject# widget, double delta) { |
| 190 | iam_drawingareacxx . . $ `sys/GuiDrawingArea.cpp:34:10`!; |
| 191 | if (mycxx . . $ `melder/melder.h:44:9`! d_zoomCallbackcxx . . $ structGuiDrawingArea#d_zoomCallback.) { |
| 192 | struct structGuiDrawingArea_ZoomEventcxx . . $ structGuiDrawingArea_ZoomEvent# event { me }; |
| 193 | event. deltacxx . . $ structGuiDrawingArea_ZoomEvent#delta. = delta; |
| 194 | try { |
| 195 | mycxx . . $ `melder/melder.h:44:9`! d_zoomCallbackcxx . . $ structGuiDrawingArea#d_zoomCallback. (cxx . . $ MelderCallback#`operator()`(e7ade0e2880b4e44).mycxx . . $ `melder/melder.h:44:9`! d_zoomBosscxx . . $ structGuiDrawingArea#d_zoomBoss., & event); |
| 196 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 197 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Zoom not completely handled."); |
| 198 | } |
| 199 | } |
| 200 | } |
| 201 | #if 0 // GTK 3 |
| 202 | static void _guiGtkDrawingArea_zoomCallback (GtkGestureZoom *w, gdouble scale, gpointer void_me) { |
| 203 | iam (GuiDrawingArea); |
| 204 | TRACE |
| 205 | trace (1); |
| 206 | if (! my d_zoomCallback) |
| 207 | return; |
| 208 | trace (3); |
| 209 | const double zoomDelta = (scale - 1.0) * 100.0; |
| 210 | if (zoomDelta != 0.0) { |
| 211 | trace (5); |
| 212 | _guiGtkDrawingArea_handleZoom (w, zoomDelta); |
| 213 | trace (6); |
| 214 | } |
| 215 | } |
| 216 | #elif 0 // GTK 4 |
| 217 | static gboolean _guiGtkDrawingArea_pinchCallback (GuiObject w, GdkEventTouchpadPinch *event, gpointer void_me) { |
| 218 | iam (GuiDrawingArea); |
| 219 | TRACE |
| 220 | trace (1); |
| 221 | if (my d_zoomCallback) { |
| 222 | if (event -> phase == GDK_TOUCHPAD_GESTURE_PHASE_UPDATE) { |
| 223 | const double zoomDelta = (event -> scale - 1.0) * 100.0; |
| 224 | if (zoomDelta != 0.0) |
| 225 | _guiGtkDrawingArea_handleZoom (w, zoomDelta); |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | #endif |
| 230 | static gboolean _guiGtkDrawingArea_swipeCallbackcxx . . $ _guiGtkDrawingArea_swipeCallback(d2c8d9bf54a5a824). (GuiObjectcxx . . $ GuiObject# w, GdkEventScroll *event, gpointer void_me) { |
| 231 | iamcxx . . $ `melder/melder.h:50:9`! (GuiDrawingArea); |
| 232 | tracecxx . . $ `melder/melder_debug.h:60:10`! (U"_guiGtkDrawingArea_swipeCallback ", Melder_pointer (mycxx . . $ `melder/melder.h:44:9`! d_horizontalScrollBar), Melder_pointer (mycxx . . $ `melder/melder.h:44:9`! d_verticalScrollBar)); |
| 233 | constexpr double zoomStepSize = 12.0; |
| 234 | const bool shiftKeyPressed = (event -> statecxx . . $ _GdkEventScroll#state. & GDK_SHIFT_MASK) != 0; |
| 235 | const bool controlKeyPressed = (event -> statecxx . . $ _GdkEventScroll#state. & GDK_CONTROL_MASK) != 0; |
| 236 | if (controlKeyPressed && mycxx . . $ `melder/melder.h:44:9`! d_zoomCallbackcxx . . $ structGuiDrawingArea#d_zoomCallback.) { |
| 237 | double zoomDelta = 0.0; |
| 238 | switch (event -> directioncxx . . $ _GdkEventScroll#direction.) { |
| 239 | case GDK_SCROLL_UP: |
| 240 | zoomDelta = zoomStepSize; |
| 241 | break; |
| 242 | case GDK_SCROLL_DOWN: |
| 243 | zoomDelta = - zoomStepSize; |
| 244 | break; |
| 245 | case GDK_SCROLL_LEFT: |
| 246 | zoomDelta = - zoomStepSize; |
| 247 | break; |
| 248 | case GDK_SCROLL_RIGHT: |
| 249 | zoomDelta = zoomStepSize; |
| 250 | break; |
| 251 | #ifdef GDK_SCROLL_SMOOTH |
| 252 | case GDK_SCROLL_SMOOTH: |
| 253 | if (event -> delta_y != 0.0) |
| 254 | zoomDelta = - event -> delta_y * zoomStepSize; |
| 255 | else if (event -> delta_x != 0.0) |
| 256 | zoomDelta = - event -> delta_x * zoomStepSize; |
| 257 | break; |
| 258 | #endif |
| 259 | } |
| 260 | if (zoomDelta != 0.0) |
| 261 | _guiGtkDrawingArea_handleZoomcxx . . $ _guiGtkDrawingArea_handleZoom(a579a53ea2bbba08). (w, zoomDelta); |
| 262 | return true; |
| 263 | } |
| 264 | const bool mapVerticalToHorizontal = (mycxx . . $ `melder/melder.h:44:9`! d_horizontalScrollBarcxx . . $ structGuiDrawingArea#d_horizontalScrollBar. && (! mycxx . . $ `melder/melder.h:44:9`! d_verticalScrollBarcxx . . $ structGuiDrawingArea#d_verticalScrollBar. || shiftKeyPressed)); |
| 265 | double hSteps = 0.0; |
| 266 | double vSteps = 0.0; |
| 267 | switch (event -> directioncxx . . $ _GdkEventScroll#direction.) { |
| 268 | case GDK_SCROLL_LEFT: |
| 269 | hSteps -= 1.0; |
| 270 | break; |
| 271 | case GDK_SCROLL_RIGHT: |
| 272 | hSteps += 1.0; |
| 273 | break; |
| 274 | case GDK_SCROLL_UP: |
| 275 | if (mapVerticalToHorizontal) |
| 276 | hSteps -= 1.0; |
| 277 | else |
| 278 | vSteps -= 1.0; |
| 279 | break; |
| 280 | case GDK_SCROLL_DOWN: |
| 281 | if (mapVerticalToHorizontal) |
| 282 | hSteps += 1.0; |
| 283 | else |
| 284 | vSteps += 1.0; |
| 285 | break; |
| 286 | #ifdef GDK_SCROLL_SMOOTH |
| 287 | case GDK_SCROLL_SMOOTH: |
| 288 | if (event -> delta_x != 0.0) |
| 289 | hSteps += event -> delta_x; |
| 290 | if (event -> delta_y != 0.0) { |
| 291 | if (mapVerticalToHorizontal) |
| 292 | hSteps += event -> delta_y; |
| 293 | else |
| 294 | vSteps += event -> delta_y; |
| 295 | } |
| 296 | break; |
| 297 | #endif |
| 298 | } |
| 299 | if (mycxx . . $ `melder/melder.h:44:9`! d_horizontalScrollBarcxx . . $ structGuiDrawingArea#d_horizontalScrollBar. && hSteps != 0.0) { |
| 300 | double hv = gtk_range_get_value (GTK_RANGEcxx . . $ `<external>/4737863252880297041/gtkrange.h:40:9`! (mycxx . . $ `melder/melder.h:44:9`! d_horizontalScrollBar -> d_widget)); |
| 301 | GtkAdjustment *adjustment = gtk_range_get_adjustment (GTK_RANGEcxx . . $ `<external>/4737863252880297041/gtkrange.h:40:9`! (mycxx . . $ `melder/melder.h:44:9`! d_horizontalScrollBar -> d_widget)); |
| 302 | gdouble hi; |
| 303 | g_object_get (adjustment, "step_increment", & hi, nullptr); |
| 304 | gtk_range_set_value (GTK_RANGEcxx . . $ `<external>/4737863252880297041/gtkrange.h:40:9`! (mycxx . . $ `melder/melder.h:44:9`! d_horizontalScrollBar -> d_widget), hv + hSteps * hi); |
| 305 | } |
| 306 | if (mycxx . . $ `melder/melder.h:44:9`! d_verticalScrollBarcxx . . $ structGuiDrawingArea#d_verticalScrollBar. && vSteps != 0.0) { |
| 307 | double vv = gtk_range_get_value (GTK_RANGEcxx . . $ `<external>/4737863252880297041/gtkrange.h:40:9`! (mycxx . . $ `melder/melder.h:44:9`! d_verticalScrollBar -> d_widget)); |
| 308 | GtkAdjustment *adjustment = gtk_range_get_adjustment (GTK_RANGEcxx . . $ `<external>/4737863252880297041/gtkrange.h:40:9`! (mycxx . . $ `melder/melder.h:44:9`! d_verticalScrollBar -> d_widget)); |
| 309 | gdouble vi; |
| 310 | g_object_get (adjustment, "step_increment", & vi, nullptr); |
| 311 | gtk_range_set_value (GTK_RANGEcxx . . $ `<external>/4737863252880297041/gtkrange.h:40:9`! (mycxx . . $ `melder/melder.h:44:9`! d_verticalScrollBar -> d_widget), vv + vSteps * vi); |
| 312 | } |
| 313 | return true; |
| 314 | } |
| 315 | #elif motif |
| 316 | #pragma mark - MOTIF CALLBACKS (WITH GDI) |
| 317 | void _GuiWinDrawingArea_destroy (GuiObject widget) { |
| 318 | iam_drawingarea; |
| 319 | DestroyWindow (widget -> window); |
| 320 | forget (me); // NOTE: my widget is not destroyed here |
| 321 | } |
| 322 | void _GuiWinDrawingArea_update (GuiObject widget) { |
| 323 | iam_drawingarea; |
| 324 | Melder_assert (my numberOfGraphicses > 0); |
| 325 | GraphicsScreen graphics = (GraphicsScreen) my graphicses [1]; |
| 326 | Melder_assert (Thing_isa (graphics, classGraphicsScreen)); |
| 327 | HDC memoryDC = CreateCompatibleDC (graphics -> d_gdiGraphicsContext); |
| 328 | HBITMAP memoryBitmap = CreateCompatibleBitmap (graphics -> d_gdiGraphicsContext, widget -> width, widget -> height); |
| 329 | SelectObject (memoryDC, memoryBitmap); |
| 330 | SetBkMode (memoryDC, TRANSPARENT); // not the default! |
| 331 | SelectPen (memoryDC, GetStockPen (BLACK_PEN)); |
| 332 | SelectBrush (memoryDC, GetStockBrush (BLACK_BRUSH)); |
| 333 | SetTextAlign (memoryDC, TA_LEFT | TA_BASELINE | TA_NOUPDATECP); // baseline is not the default! |
| 334 | HDC saveContext = graphics -> d_gdiGraphicsContext; |
| 335 | for (int igraphics = 1; igraphics <= my numberOfGraphicses; igraphics ++) |
| 336 | ((GraphicsScreen) my graphicses [igraphics]) -> d_gdiGraphicsContext = memoryDC; |
| 337 | if (my d_exposeCallback) { |
| 338 | structGuiDrawingArea_ExposeEvent event { me }; |
| 339 | try { |
| 340 | my d_exposeCallback (my d_exposeBoss, & event); |
| 341 | } catch (MelderError) { |
| 342 | Melder_flushError (U"Redrawing not completed"); |
| 343 | } |
| 344 | } |
| 345 | for (int igraphics = 1; igraphics <= my numberOfGraphicses; igraphics ++) |
| 346 | ((GraphicsScreen) my graphicses [igraphics]) -> d_gdiGraphicsContext = saveContext; |
| 347 | BitBlt (graphics -> d_gdiGraphicsContext, 0, 0, widget -> width, widget -> height, memoryDC, 0, 0, SRCCOPY); |
| 348 | DeleteObject (memoryBitmap); |
| 349 | DeleteDC (memoryDC); |
| 350 | ValidateRect (widget -> window, nullptr); |
| 351 | } |
| 352 | void _GuiWinDrawingArea_handleMouse (GuiObject widget, structGuiDrawingArea_MouseEvent::Phase phase, int x, int y) { |
| 353 | iam_drawingarea; |
| 354 | if (my mouseCallback) { |
| 355 | structGuiDrawingArea_MouseEvent event { me, 0 }; |
| 356 | event. x = x; |
| 357 | event. y = y; |
| 358 | event. phase = phase; |
| 359 | //Melder_casual (U": phase ", (int) phase); |
| 360 | event. shiftKeyPressed = GetKeyState (VK_SHIFT) < 0; |
| 361 | event. optionKeyPressed = GetKeyState (VK_MENU) < 0; |
| 362 | event. commandKeyPressed = GetKeyState (VK_CONTROL) < 0; |
| 363 | try { |
| 364 | my mouseCallback (my mouseBoss, & event); |
| 365 | } catch (MelderError) { |
| 366 | switch (phase) { |
| 367 | case structGuiDrawingArea_MouseEvent::Phase::CLICK: |
| 368 | Melder_flushError (U"Mouse click not completely handled."); |
| 369 | break; case structGuiDrawingArea_MouseEvent::Phase::DRAG: |
| 370 | Melder_flushError (U"Mouse drag not completely handled."); |
| 371 | break; case structGuiDrawingArea_MouseEvent::Phase::DROP: |
| 372 | Melder_flushError (U"Mouse drop not completely handled."); |
| 373 | break; |
| 374 | } |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | void _GuiWinDrawingArea_handleKey (GuiObject widget, TCHAR kar) { // TODO: event? |
| 379 | iam_drawingarea; |
| 380 | if (my d_keyCallback) { |
| 381 | structGuiDrawingArea_KeyEvent event { me, 0 }; |
| 382 | event. key = kar; |
| 383 | event. shiftKeyPressed = GetKeyState (VK_SHIFT) < 0; // TODO: event -> key? |
| 384 | event. optionKeyPressed = GetKeyState (VK_MENU) < 0; |
| 385 | event. commandKeyPressed = GetKeyState (VK_CONTROL) < 0; |
| 386 | try { |
| 387 | my d_keyCallback (my d_keyBoss, & event); |
| 388 | } catch (MelderError) { |
| 389 | Melder_flushError (U"Key press not completely handled."); |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | void _GuiWinDrawingArea_shellResize (GuiObject widget) { |
| 394 | iam_drawingarea; |
| 395 | if (my d_resizeCallback) { |
| 396 | structGuiDrawingArea_ResizeEvent event { me }; |
| 397 | event. width = widget -> width; |
| 398 | event. height = widget -> height; |
| 399 | try { |
| 400 | my d_resizeCallback (my d_resizeBoss, & event); |
| 401 | } catch (MelderError) { |
| 402 | Melder_flushError (U"Window resizing not completely handled."); |
| 403 | } |
| 404 | } |
| 405 | } |
| 406 | void _GuiWinDrawingArea_handleZoom (GuiObject widget, double delta) { |
| 407 | iam_drawingarea; |
| 408 | //TRACE |
| 409 | trace (delta); |
| 410 | if (my d_zoomCallback) { |
| 411 | struct structGuiDrawingArea_ZoomEvent event { me }; |
| 412 | event. delta = delta; |
| 413 | try { |
| 414 | my d_zoomCallback (my d_zoomBoss, & event); |
| 415 | } catch (MelderError) { |
| 416 | Melder_flushError (U"Zoom not completely handled."); |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | #elif cocoa |
| 421 | #pragma mark - COCOA CALLBACKS (WITH QUARTZ) |
| 422 | @implementation GuiCocoaDrawingArea { |
| 423 | GuiDrawingArea userData; |
| 424 | bool inited; |
| 425 | NSTrackingArea *trackingArea; |
| 426 | } |
| 427 | - (id) initWithFrame: (NSRect) frame { |
| 428 | self = [super initWithFrame: frame]; |
| 429 | if (self) { |
| 430 | self -> trackingArea = [[NSTrackingArea alloc] |
| 431 | initWithRect: [self visibleRect] |
| 432 | options: NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingInVisibleRect | NSTrackingActiveAlways |
| 433 | owner: self |
| 434 | userInfo: nil |
| 435 | ]; |
| 436 | trace (U"Retain count of tracking area after creation: ", [self -> trackingArea retainCount]); // probably 1 |
| 437 | [self addTrackingArea: self -> trackingArea]; // this retains the tracking area |
| 438 | trace (U"Retain count of tracking area after inclusion: ", [self -> trackingArea retainCount]); // probably 2 |
| 439 | [self -> trackingArea release]; |
| 440 | trace (U"Retain count of tracking area after release: ", [self -> trackingArea retainCount]); // probably 1 |
| 441 | } |
| 442 | return self; |
| 443 | } |
| 444 | - (void) dealloc { // override |
| 445 | GuiDrawingArea me = self -> userData; |
| 446 | if (Melder_debug == 55) |
| 447 | Melder_casual (U"\t\tGuiCocoaDrawingArea-", Melder_pointer (self), U" dealloc for ", Melder_pointer (me)); |
| 448 | forget (me); |
| 449 | trace (U"Retain count of tracking area before exclusion: ", [self -> trackingArea retainCount]); // probably 1 |
| 450 | [self removeTrackingArea: self -> trackingArea]; // this releases the tracking area |
| 451 | //trace (U"Retain count of tracking area before destruction: ", [self -> trackingArea retainCount]); // probably 0 (a crash) |
| 452 | trace (U"deleting a drawing area"); |
| 453 | [super dealloc]; |
| 454 | } |
| 455 | - (GuiThing) getUserData { |
| 456 | return self -> userData; |
| 457 | } |
| 458 | - (void) setUserData: (GuiThing) newUserData { |
| 459 | self -> userData = static_cast <GuiDrawingArea> (newUserData); |
| 460 | } |
| 461 | - (void) resizeCallback: (NSRect) rect { |
| 462 | GuiDrawingArea me = (GuiDrawingArea) self -> userData; |
| 463 | if (me && my d_resizeCallback) { |
| 464 | structGuiDrawingArea_ResizeEvent event = { me, 0, 0 }; |
| 465 | event. width = rect. size. width; |
| 466 | event. height = rect. size. height; |
| 467 | try { |
| 468 | my d_resizeCallback (my d_resizeBoss, & event); |
| 469 | } catch (MelderError) { |
| 470 | Melder_flushError (U"Window resizing not completely handled."); |
| 471 | } |
| 472 | } |
| 473 | } |
| 474 | - (void) drawRect: (NSRect) dirtyRect { |
| 475 | trace (U"dirtyRect: ", dirtyRect.origin.x, U", ", dirtyRect.origin.y, U", ", dirtyRect.size.width, U", ", dirtyRect.size.height); |
| 476 | GuiDrawingArea me = (GuiDrawingArea) self -> userData; |
| 477 | if (Melder_debug == 55) |
| 478 | Melder_casual (U"\t\tGuiCocoaDrawingArea-", Melder_pointer (self), U" draw to ", Melder_pointer (me)); |
| 479 | if (! self -> inited) { |
| 480 | // Last chance to do this. Is there a better place? |
| 481 | [self resizeCallback: [self frame]]; |
| 482 | self -> inited = true; |
| 483 | } |
| 484 | if (me && my d_exposeCallback && my numberOfGraphicses > 0) { // asserting my numberOfGraphicses could crash if Editor_init gives a warning |
| 485 | structGuiDrawingArea_ExposeEvent event = { me, 0, 0, 0, 0 }; |
| 486 | if (Melder_debug == 55) |
| 487 | Melder_casual (U"\t", Thing_messageNameAndAddress (me), U" draw for ", Melder_pointer (my d_exposeBoss)); |
| 488 | try { |
| 489 | for (integer igraphics = 1; igraphics <= my numberOfGraphicses; igraphics ++) { |
| 490 | GraphicsScreen graphics = static_cast <GraphicsScreen> (my graphicses [igraphics]); |
| 491 | if (graphics -> d_macView) { |
| 492 | graphics -> d_macGraphicsContext = [[NSGraphicsContext currentContext] CGContext]; |
| 493 | Melder_assert (!! graphics -> d_macGraphicsContext); |
| 494 | } |
| 495 | } |
| 496 | my d_exposeCallback (my d_exposeBoss, & event); |
| 497 | for (integer igraphics = 1; igraphics <= my numberOfGraphicses; igraphics ++) { |
| 498 | GraphicsScreen graphics = static_cast <GraphicsScreen> (my graphicses [igraphics]); |
| 499 | if (graphics -> d_macView) |
| 500 | graphics -> d_macGraphicsContext = nullptr; |
| 501 | } |
| 502 | } catch (MelderError) { |
| 503 | Melder_flushError (U"Redrawing not completed"); |
| 504 | } |
| 505 | } |
| 506 | } |
| 507 | - (void) setFrame: (NSRect) rect { |
| 508 | [self resizeCallback: rect]; |
| 509 | [super setFrame: rect]; |
| 510 | } |
| 511 | - (BOOL) acceptsFirstResponder { |
| 512 | /* |
| 513 | * This overridden method tells the event chain whether the drawing area can accept key events. |
| 514 | * It is important that the Demo window and the RunnerMFC window accept key events. |
| 515 | * A side effect of accepting key events is that the drawing area obtains the key focus when the user clicks in the drawing area. |
| 516 | * It is important, however, that the drawing area of the TextGrid window cannot take away the key focus |
| 517 | * from the text field at the top; therefore, that drawing area should not accept key events. |
| 518 | * The implementation below is based on the fact that, naturally, the Demo window and the RunnerMFC window |
| 519 | * have a key callback, and the drawing area of the TextGrid window has not |
| 520 | * (a side effect of this implementation is that the drawing area of the Manual window does not take away |
| 521 | * the key focus from the Search field, a situation that cannot hurt). |
| 522 | */ |
| 523 | GuiDrawingArea me = (GuiDrawingArea) self -> userData; |
| 524 | return !! my d_keyCallback; |
| 525 | } |
| 526 | - (void) mouseEntered: (NSEvent *) nsEvent { |
| 527 | (void) nsEvent; |
| 528 | [[NSCursor crosshairCursor] push]; |
| 529 | } |
| 530 | - (void) mouseExited: (NSEvent *) nsEvent { |
| 531 | (void) nsEvent; |
| 532 | [[NSCursor currentCursor] pop]; |
| 533 | } |
| 534 | - (void) mouse: (NSEvent *) nsEvent inPhase: (structGuiDrawingArea_MouseEvent::Phase) phase { |
| 535 | GuiDrawingArea me = (GuiDrawingArea) self -> userData; |
| 536 | if (me && my mouseCallback) { |
| 537 | structGuiDrawingArea_MouseEvent event = { me, 0, 0, phase, false, false, false }; |
| 538 | NSPoint local_point = [self convertPoint: [nsEvent locationInWindow] fromView: nil]; |
| 539 | event. x = local_point. x; |
| 540 | event. y = local_point. y; |
| 541 | NSUInteger modifiers = [nsEvent modifierFlags]; |
| 542 | event. shiftKeyPressed = modifiers & NSEventModifierFlagShift; |
| 543 | event. optionKeyPressed = modifiers & NSEventModifierFlagOption; |
| 544 | event. commandKeyPressed = modifiers & NSEventModifierFlagCommand; |
| 545 | try { |
| 546 | my mouseCallback (my mouseBoss, & event); |
| 547 | } catch (MelderError) { |
| 548 | switch (phase) { |
| 549 | case structGuiDrawingArea_MouseEvent::Phase::CLICK: |
| 550 | Melder_flushError (U"Mouse click not completely handled."); |
| 551 | break; case structGuiDrawingArea_MouseEvent::Phase::DRAG: |
| 552 | Melder_flushError (U"Mouse drag not completely handled."); |
| 553 | break; case structGuiDrawingArea_MouseEvent::Phase::DROP: |
| 554 | Melder_flushError (U"Mouse drop not completely handled."); |
| 555 | break; |
| 556 | } |
| 557 | } |
| 558 | } |
| 559 | } |
| 560 | - (void) mouseDown: (NSEvent *) nsEvent { |
| 561 | [self mouse: nsEvent inPhase: structGuiDrawingArea_MouseEvent::Phase::CLICK]; |
| 562 | } |
| 563 | - (void) mouseDragged: (NSEvent *) nsEvent { |
| 564 | [self mouse: nsEvent inPhase: structGuiDrawingArea_MouseEvent::Phase::DRAG]; |
| 565 | } |
| 566 | - (void) mouseUp: (NSEvent *) nsEvent { |
| 567 | [self mouse: nsEvent inPhase: structGuiDrawingArea_MouseEvent::Phase::DROP]; |
| 568 | } |
| 569 | - (void) scrollWheel: (NSEvent *) nsEvent { |
| 570 | GuiDrawingArea me = (GuiDrawingArea) self -> userData; |
| 571 | if (me && (my d_horizontalScrollBar || my d_verticalScrollBar)) { |
| 572 | /* |
| 573 | Automatically implemented by macOS: Shift-Wheel means horizontal scrolling. |
| 574 | |
| 575 | To implement here: |
| 576 | - Command-Wheel means zooming. |
| 577 | - Wheel means horizontal scrolling if there is no vertical scrollbar. |
| 578 | */ |
| 579 | const bool commandKeyPressed = ( ([nsEvent modifierFlags] & NSEventModifierFlagCommand) != 0 ); |
| 580 | const CGFloat deltaX = [nsEvent scrollingDeltaX]; |
| 581 | const CGFloat deltaY = [nsEvent scrollingDeltaY]; |
| 582 | const CGFloat biggestDelta = ( fabs (deltaX) > fabs (deltaY) ? deltaX : deltaY ); |
| 583 | if (commandKeyPressed) { |
| 584 | /* |
| 585 | Implement zooming. |
| 586 | */ |
| 587 | const CGFloat relativeSpeed = 0.01; |
| 588 | if (my d_horizontalScrollBar && my d_verticalScrollBar) { |
| 589 | [(GuiCocoaScrollBar *) my d_horizontalScrollBar -> d_widget magnifyBy: deltaX * relativeSpeed]; |
| 590 | [(GuiCocoaScrollBar *) my d_verticalScrollBar -> d_widget magnifyBy: deltaY * relativeSpeed]; |
| 591 | } else if (my d_horizontalScrollBar) |
| 592 | [(GuiCocoaScrollBar *) my d_horizontalScrollBar -> d_widget magnifyBy: biggestDelta * relativeSpeed]; |
| 593 | else |
| 594 | [(GuiCocoaScrollBar *) my d_verticalScrollBar -> d_widget magnifyBy: biggestDelta * relativeSpeed]; |
| 595 | } else { |
| 596 | /* |
| 597 | Implement scrolling. |
| 598 | */ |
| 599 | if (my d_horizontalScrollBar && my d_verticalScrollBar) { |
| 600 | [(GuiCocoaScrollBar *) my d_horizontalScrollBar -> d_widget scrollBy: deltaX]; |
| 601 | [(GuiCocoaScrollBar *) my d_verticalScrollBar -> d_widget scrollBy: deltaY]; |
| 602 | } else if (my d_horizontalScrollBar) |
| 603 | [(GuiCocoaScrollBar *) my d_horizontalScrollBar -> d_widget scrollBy: biggestDelta]; |
| 604 | else |
| 605 | [(GuiCocoaScrollBar *) my d_verticalScrollBar -> d_widget scrollBy: biggestDelta]; |
| 606 | } |
| 607 | } else { |
| 608 | [super scrollWheel: nsEvent]; |
| 609 | } |
| 610 | } |
| 611 | - (void) magnifyWithEvent: (NSEvent *) nsEvent { |
| 612 | GuiDrawingArea me = (GuiDrawingArea) self -> userData; |
| 613 | if (me && (my d_horizontalScrollBar || my d_verticalScrollBar)) { |
| 614 | if (my d_horizontalScrollBar) { |
| 615 | GuiCocoaScrollBar *cocoaScrollBar = (GuiCocoaScrollBar *) my d_horizontalScrollBar -> d_widget; |
| 616 | [cocoaScrollBar magnifyBy: [nsEvent magnification]]; |
| 617 | } |
| 618 | if (my d_verticalScrollBar) { |
| 619 | GuiCocoaScrollBar *cocoaScrollBar = (GuiCocoaScrollBar *) my d_verticalScrollBar -> d_widget; |
| 620 | [cocoaScrollBar magnifyBy: [nsEvent magnification]]; |
| 621 | } |
| 622 | } else { |
| 623 | [super magnifyWithEvent: nsEvent]; |
| 624 | } |
| 625 | } |
| 626 | - (BOOL) isFlipped { |
| 627 | return YES; |
| 628 | } |
| 629 | - (void) keyDown: (NSEvent *) nsEvent { |
| 630 | trace (U"key pressed "); |
| 631 | GuiDrawingArea me = (GuiDrawingArea) self -> userData; |
| 632 | if (me && my d_keyCallback) { |
| 633 | structGuiDrawingArea_KeyEvent event = { me, U'\0', false, false, false }; |
| 634 | event. key = [[nsEvent charactersIgnoringModifiers] characterAtIndex: 0]; |
| 635 | if (event. key == NSLeftArrowFunctionKey) |
| 636 | event. key = 0x2190; |
| 637 | if (event. key == NSRightArrowFunctionKey) |
| 638 | event. key = 0x2192; |
| 639 | if (event. key == NSUpArrowFunctionKey) |
| 640 | event. key = 0x2191; |
| 641 | if (event. key == NSDownArrowFunctionKey) |
| 642 | event. key = 0x2193; |
| 643 | trace (U"key ", event. key); |
| 644 | NSUInteger modifiers = [nsEvent modifierFlags]; |
| 645 | event. shiftKeyPressed = modifiers & NSEventModifierFlagShift; |
| 646 | event. optionKeyPressed = modifiers & NSEventModifierFlagOption; |
| 647 | event. commandKeyPressed = modifiers & NSEventModifierFlagCommand; |
| 648 | try { |
| 649 | my d_keyCallback (my d_keyBoss, & event); |
| 650 | } catch (MelderError) { |
| 651 | Melder_flushError (U"Key press not completely handled."); |
| 652 | } |
| 653 | } |
| 654 | } |
| 655 | - (void) cancelOperation: (id) sender { |
| 656 | Melder_casual (U"escape key pressed"); |
| 657 | } |
| 658 | @end |
| 659 | #endif |
| 660 | |
| 661 | void structGuiDrawingAreacxx . . $ structGuiDrawingArea# :: v9_destroycxx . . $ structGuiDrawingArea#v9_destroy(ced63f7c635d850d). () noexcept { |
| 662 | if (Melder_debugcxx . . $ Melder_debug. == 55) |
| 663 | Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"\t", Thing_messageNameAndAddresscxx . . $ Thing_messageNameAndAddress(fbb3dc34e3ef688d). (this), U" v9_destroy"); |
| 664 | #if cocoacxx . . $ `sys/Gui.h:35:10`! |
| 665 | if (our d_widget) |
| 666 | [our d_widget setUserData: nullptr]; // undangle reference to this |
| 667 | #endif |
| 668 | GuiDrawingArea_Parentcxx . . $ GuiDrawingArea_Parent# :: v9_destroycxx . . $ structThing#v9_destroy(ced63f7c635d850d). (); |
| 669 | } |
| 670 | |
| 671 | GuiDrawingAreacxx . . $ GuiDrawingArea# GuiDrawingArea_createcxx . . $ GuiDrawingArea_create(5a210e61ba6a237d). (GuiFormcxx . . $ GuiForm# parent, int left, int right, int top, int bottom, |
| 672 | GuiDrawingArea_ExposeCallbackcxx . . $ GuiDrawingArea_ExposeCallback# exposeCallback, |
| 673 | GuiDrawingArea_MouseCallbackcxx . . $ GuiDrawingArea_MouseCallback# mouseCallback, |
| 674 | GuiDrawingArea_KeyCallbackcxx . . $ GuiDrawingArea_KeyCallback# keyCallback, |
| 675 | GuiDrawingArea_ResizeCallbackcxx . . $ GuiDrawingArea_ResizeCallback# resizeCallback, |
| 676 | GuiDrawingArea_ZoomCallbackcxx . . $ GuiDrawingArea_ZoomCallback# zoomCallback, Thingcxx . . $ Thing# boss, |
| 677 | uint32cxx . . $ uint32# /* flags */) |
| 678 | { |
| 679 | autoGuiDrawingAreacxx . . $ autoGuiDrawingArea# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (GuiDrawingArea); |
| 680 | if (Melder_debugcxx . . $ Melder_debug. == 55) |
| 681 | Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"\t", Thing_messageNameAndAddresscxx . . $ Thing_messageNameAndAddress(fbb3dc34e3ef688d). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()), U" init in ", Thing_messageNameAndAddresscxx . . $ Thing_messageNameAndAddress(fbb3dc34e3ef688d). (parent -> d_shellcxx . . $ structGuiThing#d_shell.)); |
| 682 | mycxx . . $ `melder/melder.h:44:9`! d_shellcxx . . $ structGuiThing#d_shell. = parent -> d_shellcxx . . $ structGuiThing#d_shell.; |
| 683 | mycxx . . $ `melder/melder.h:44:9`! d_shellcxx . . $ structGuiThing#d_shell. -> drawingAreacxx . . $ structGuiShell#drawingArea. = me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(); |
| 684 | mycxx . . $ `melder/melder.h:44:9`! d_parentcxx . . $ structGuiThing#d_parent. = parent; |
| 685 | mycxx . . $ `melder/melder.h:44:9`! d_exposeCallbackcxx . . $ structGuiDrawingArea#d_exposeCallback. =cxx . . $ MelderCallback#`operator=`(ad58c8464e916fec). exposeCallback; |
| 686 | mycxx . . $ `melder/melder.h:44:9`! d_exposeBosscxx . . $ structGuiDrawingArea#d_exposeBoss. = boss; |
| 687 | mycxx . . $ `melder/melder.h:44:9`! mouseCallbackcxx . . $ structGuiDrawingArea#mouseCallback. =cxx . . $ MelderCallback#`operator=`(b97e83e3f9ab7552). mouseCallback; |
| 688 | mycxx . . $ `melder/melder.h:44:9`! mouseBosscxx . . $ structGuiDrawingArea#mouseBoss. = boss; |
| 689 | mycxx . . $ `melder/melder.h:44:9`! d_keyCallbackcxx . . $ structGuiDrawingArea#d_keyCallback. =cxx . . $ MelderCallback#`operator=`(547a127c1fab29b1). keyCallback; |
| 690 | mycxx . . $ `melder/melder.h:44:9`! d_keyBosscxx . . $ structGuiDrawingArea#d_keyBoss. = boss; |
| 691 | mycxx . . $ `melder/melder.h:44:9`! d_resizeCallbackcxx . . $ structGuiDrawingArea#d_resizeCallback. =cxx . . $ MelderCallback#`operator=`(9334ad62f8fdf0ca). resizeCallback; |
| 692 | mycxx . . $ `melder/melder.h:44:9`! d_resizeBosscxx . . $ structGuiDrawingArea#d_resizeBoss. = boss; |
| 693 | mycxx . . $ `melder/melder.h:44:9`! d_zoomCallbackcxx . . $ structGuiDrawingArea#d_zoomCallback. =cxx . . $ MelderCallback#`operator=`(650680ba9693f3f1). zoomCallback; |
| 694 | mycxx . . $ `melder/melder.h:44:9`! d_zoomBosscxx . . $ structGuiDrawingArea#d_zoomBoss. = boss; |
| 695 | #if gtkcxx . . $ `sys/Gui.h:33:10`! |
| 696 | mycxx . . $ `melder/melder.h:44:9`! d_widgetcxx . . $ structGuiThing#d_widget. = gtk_drawing_area_new (); |
| 697 | GdkEventMask mask = (GdkEventMask) (GDK_EXPOSURE_MASK // receive exposure events |
| 698 | | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK // receive click events |
| 699 | | GDK_BUTTON_MOTION_MASK // receive motion notifies when a button is pressed |
| 700 | | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK |
| 701 | | GDK_POINTER_MOTION_HINT_MASK); // receive fewer motion notify events (the cb might take time) |
| 702 | gtk_widget_set_events (GTK_WIDGETcxx . . $ `<external>/6031079988677191796/gtkwidget.h:58:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), mask); |
| 703 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), "draw", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (_guiGtkDrawingArea_drawCallback), me.get()); |
| 704 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), "destroy", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (_guiGtkDrawingArea_destroyCallback), me.get()); |
| 705 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), "button-press-event", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (_guiGtkDrawingArea_mouseDownCallback), me.get()); |
| 706 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), "button-release-event", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (_guiGtkDrawingArea_mouseUpCallback), me.get()); |
| 707 | //g_signal_connect (G_OBJECT (my d_widget), "drag-motion-event", G_CALLBACK (_guiGtkDrawingArea_mouseUpCallback), me.get()); |
| 708 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), "motion-notify-event", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (_guiGtkDrawingArea_mouseDraggedCallback), me.get()); |
| 709 | if (parent) { |
| 710 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (parent -> d_widget); |
| 711 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (gtk_widget_get_toplevel (GTK_WIDGETcxx . . $ `<external>/6031079988677191796/gtkwidget.h:58:9`! (parent -> d_widget))), "key-press-event", |
| 712 | G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (_guiGtkDrawingArea_keyCallback), me.get()); |
| 713 | } |
| 714 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), "size-allocate", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (_guiGtkDrawingArea_resizeCallback), me.get()); |
| 715 | |
| 716 | _GuiObject_setUserDatacxx . . $ _GuiObject_setUserData(6c58c5e2437d25a2). (mycxx . . $ `melder/melder.h:44:9`! d_widgetcxx . . $ structGuiThing#d_widget., me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 717 | mycxx . . $ `melder/melder.h:44:9`! v_positionInFormcxx . . $ structGuiControl#v_positionInForm(6e76d3e0dab57625). (mycxx . . $ `melder/melder.h:44:9`! d_widgetcxx . . $ structGuiThing#d_widget., left, right, top, bottom, parent); |
| 718 | #elif motif |
| 719 | my d_widget = _Gui_initializeWidget (xmDrawingAreaWidgetClass, parent -> d_widget, U"drawingArea"); |
| 720 | _GuiObject_setUserData (my d_widget, me.get()); |
| 721 | my d_widget -> window = CreateWindowEx (0, Melder_peek32toW (_GuiWin_getDrawingAreaClassName ()), L"drawingArea", |
| 722 | WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS, |
| 723 | my d_widget -> x, my d_widget -> y, my d_widget -> width, my d_widget -> height, my d_widget -> parent -> window, nullptr, theGui.instance, nullptr); |
| 724 | SetWindowLongPtr (my d_widget -> window, GWLP_USERDATA, (LONG_PTR) my d_widget); |
| 725 | my v_positionInForm (my d_widget, left, right, top, bottom, parent); |
| 726 | if (! my d_widget -> shell -> textFocus) |
| 727 | my d_widget -> shell -> textFocus = my d_widget; // even if not-yet-managed. But in that case it will not receive global focus |
| 728 | #elif cocoa |
| 729 | GuiCocoaDrawingArea *drawingArea = [[GuiCocoaDrawingArea alloc] init]; |
| 730 | if (Melder_debug == 55) |
| 731 | Melder_casual (U"\t\tGuiCocoaDrawingArea-", Melder_pointer (drawingArea), U" init in ", Thing_messageNameAndAddress (me.get())); |
| 732 | my d_widget = (GuiObject) drawingArea; |
| 733 | my v_positionInForm (my d_widget, left, right, top, bottom, parent); |
| 734 | [drawingArea setUserData: me.get()]; |
| 735 | if (keyCallback) { |
| 736 | [[drawingArea window] makeFirstResponder: drawingArea]; // needed in DemoWindow |
| 737 | } |
| 738 | #endif |
| 739 | return me.releaseToAmbiguousOwnercxx . . $ autoSomeThing#releaseToAmbiguousOwner(258ee1c9e0a18a5c).(); |
| 740 | } |
| 741 | |
| 742 | GuiDrawingAreacxx . . $ GuiDrawingArea# GuiDrawingArea_createShowncxx . . $ GuiDrawingArea_createShown(5a210e61ba6a237d). (GuiFormcxx . . $ GuiForm# parent, int left, int right, int top, int bottom, |
| 743 | GuiDrawingArea_ExposeCallbackcxx . . $ GuiDrawingArea_ExposeCallback# exposeCallback, |
| 744 | GuiDrawingArea_MouseCallbackcxx . . $ GuiDrawingArea_MouseCallback# mouseCallback, |
| 745 | GuiDrawingArea_KeyCallbackcxx . . $ GuiDrawingArea_KeyCallback# keyCallback, |
| 746 | GuiDrawingArea_ResizeCallbackcxx . . $ GuiDrawingArea_ResizeCallback# resizeCallback, |
| 747 | GuiDrawingArea_ZoomCallbackcxx . . $ GuiDrawingArea_ZoomCallback# zoomCallback, Thingcxx . . $ Thing# boss, |
| 748 | uint32cxx . . $ uint32# flags) |
| 749 | { |
| 750 | GuiDrawingAreacxx . . $ GuiDrawingArea# me = GuiDrawingArea_createcxx . . $ GuiDrawingArea_create(5a210e61ba6a237d). (parent, left, right, top, bottom, |
| 751 | exposeCallback, mouseCallback, |
| 752 | keyCallback, resizeCallback, zoomCallback, boss, flags |
| 753 | ); |
| 754 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (me); |
| 755 | return me; |
| 756 | } |
| 757 | |
| 758 | GuiDrawingAreacxx . . $ GuiDrawingArea# GuiDrawingArea_createcxx . . $ GuiDrawingArea_create(90010d40394de761). (GuiScrolledWindowcxx . . $ GuiScrolledWindow# parent, int width, int height, |
| 759 | GuiDrawingArea_ExposeCallbackcxx . . $ GuiDrawingArea_ExposeCallback# exposeCallback, |
| 760 | GuiDrawingArea_MouseCallbackcxx . . $ GuiDrawingArea_MouseCallback# mouseCallback, |
| 761 | GuiDrawingArea_KeyCallbackcxx . . $ GuiDrawingArea_KeyCallback# keyCallback, |
| 762 | GuiDrawingArea_ResizeCallbackcxx . . $ GuiDrawingArea_ResizeCallback# resizeCallback, |
| 763 | GuiDrawingArea_ZoomCallbackcxx . . $ GuiDrawingArea_ZoomCallback# zoomCallback, Thingcxx . . $ Thing# boss, |
| 764 | uint32cxx . . $ uint32# /* flags */) |
| 765 | { |
| 766 | autoGuiDrawingAreacxx . . $ autoGuiDrawingArea# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (GuiDrawingArea); |
| 767 | mycxx . . $ `melder/melder.h:44:9`! d_shellcxx . . $ structGuiThing#d_shell. = parent -> d_shellcxx . . $ structGuiThing#d_shell.; |
| 768 | mycxx . . $ `melder/melder.h:44:9`! d_shellcxx . . $ structGuiThing#d_shell. -> drawingAreacxx . . $ structGuiShell#drawingArea. = me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(); |
| 769 | mycxx . . $ `melder/melder.h:44:9`! d_parentcxx . . $ structGuiThing#d_parent. = parent; |
| 770 | mycxx . . $ `melder/melder.h:44:9`! d_exposeCallbackcxx . . $ structGuiDrawingArea#d_exposeCallback. =cxx . . $ MelderCallback#`operator=`(ad58c8464e916fec). exposeCallback; |
| 771 | mycxx . . $ `melder/melder.h:44:9`! d_exposeBosscxx . . $ structGuiDrawingArea#d_exposeBoss. = boss; |
| 772 | mycxx . . $ `melder/melder.h:44:9`! mouseCallbackcxx . . $ structGuiDrawingArea#mouseCallback. =cxx . . $ MelderCallback#`operator=`(b97e83e3f9ab7552). mouseCallback; |
| 773 | mycxx . . $ `melder/melder.h:44:9`! mouseBosscxx . . $ structGuiDrawingArea#mouseBoss. = boss; |
| 774 | mycxx . . $ `melder/melder.h:44:9`! d_keyCallbackcxx . . $ structGuiDrawingArea#d_keyCallback. =cxx . . $ MelderCallback#`operator=`(547a127c1fab29b1). keyCallback; |
| 775 | mycxx . . $ `melder/melder.h:44:9`! d_keyBosscxx . . $ structGuiDrawingArea#d_keyBoss. = boss; |
| 776 | mycxx . . $ `melder/melder.h:44:9`! d_resizeCallbackcxx . . $ structGuiDrawingArea#d_resizeCallback. =cxx . . $ MelderCallback#`operator=`(9334ad62f8fdf0ca). resizeCallback; |
| 777 | mycxx . . $ `melder/melder.h:44:9`! d_resizeBosscxx . . $ structGuiDrawingArea#d_resizeBoss. = boss; |
| 778 | mycxx . . $ `melder/melder.h:44:9`! d_zoomCallbackcxx . . $ structGuiDrawingArea#d_zoomCallback. =cxx . . $ MelderCallback#`operator=`(650680ba9693f3f1). zoomCallback; |
| 779 | mycxx . . $ `melder/melder.h:44:9`! d_zoomBosscxx . . $ structGuiDrawingArea#d_zoomBoss. = boss; |
| 780 | #if gtkcxx . . $ `sys/Gui.h:33:10`! |
| 781 | mycxx . . $ `melder/melder.h:44:9`! d_widgetcxx . . $ structGuiThing#d_widget. = gtk_drawing_area_new (); |
| 782 | GdkEventMask mask = (GdkEventMask) (GDK_EXPOSURE_MASK // receive exposure events |
| 783 | | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK // receive click events |
| 784 | | GDK_BUTTON_MOTION_MASK // receive motion notifies when a button is pressed |
| 785 | | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK |
| 786 | | GDK_POINTER_MOTION_HINT_MASK); // receive fewer motion notify events (the cb might take time) |
| 787 | gtk_widget_set_events (GTK_WIDGETcxx . . $ `<external>/6031079988677191796/gtkwidget.h:58:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), mask); |
| 788 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), "draw", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (_guiGtkDrawingArea_drawCallback), me.get()); |
| 789 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), "destroy", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (_guiGtkDrawingArea_destroyCallback), me.get()); |
| 790 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), "button-press-event", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (_guiGtkDrawingArea_mouseDownCallback), me.get()); |
| 791 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), "button-release-event", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (_guiGtkDrawingArea_mouseUpCallback), me.get()); |
| 792 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), "motion-notify-event", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (_guiGtkDrawingArea_mouseDraggedCallback), me.get()); |
| 793 | if (parent) { |
| 794 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (gtk_widget_get_toplevel (GTK_WIDGETcxx . . $ `<external>/6031079988677191796/gtkwidget.h:58:9`! (parent -> d_widget))), "key-press-event", |
| 795 | G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (_guiGtkDrawingArea_keyCallback), me.get()); |
| 796 | } |
| 797 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), "size-allocate", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (_guiGtkDrawingArea_resizeCallback), me.get()); |
| 798 | _GuiObject_setUserDatacxx . . $ _GuiObject_setUserData(6c58c5e2437d25a2). (mycxx . . $ `melder/melder.h:44:9`! d_widgetcxx . . $ structGuiThing#d_widget., me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 799 | mycxx . . $ `melder/melder.h:44:9`! v_positionInScrolledWindowcxx . . $ structGuiControl#v_positionInScrolledWindow(bd0f8bf0b668f63a). (mycxx . . $ `melder/melder.h:44:9`! d_widgetcxx . . $ structGuiThing#d_widget., width, height, parent); |
| 800 | #elif motif |
| 801 | my d_widget = _Gui_initializeWidget (xmDrawingAreaWidgetClass, parent -> d_widget, U"drawingArea"); |
| 802 | _GuiObject_setUserData (my d_widget, me.get()); |
| 803 | my d_widget -> window = CreateWindowEx (0, Melder_peek32toW (_GuiWin_getDrawingAreaClassName ()), L"drawingArea", |
| 804 | WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS, |
| 805 | 0, 0, my d_widget -> width, my d_widget -> height, my d_widget -> parent -> window, nullptr, theGui.instance, nullptr); |
| 806 | SetWindowLongPtr (my d_widget -> window, GWLP_USERDATA, (LONG_PTR) my d_widget); |
| 807 | my v_positionInScrolledWindow (my d_widget, width, height, parent); |
| 808 | if (! my d_widget -> shell -> textFocus) |
| 809 | my d_widget -> shell -> textFocus = my d_widget; // even if not-yet-managed. But in that case it will not receive global focus |
| 810 | #elif cocoa |
| 811 | GuiCocoaDrawingArea *drawingArea = [[GuiCocoaDrawingArea alloc] init]; |
| 812 | my d_widget = (GuiObject) drawingArea; |
| 813 | my v_positionInScrolledWindow (my d_widget, width, height, parent); |
| 814 | [drawingArea setUserData: me.get()]; |
| 815 | #endif |
| 816 | return me.releaseToAmbiguousOwnercxx . . $ autoSomeThing#releaseToAmbiguousOwner(258ee1c9e0a18a5c).(); |
| 817 | } |
| 818 | |
| 819 | GuiDrawingAreacxx . . $ GuiDrawingArea# GuiDrawingArea_createShowncxx . . $ GuiDrawingArea_createShown(90010d40394de761). (GuiScrolledWindowcxx . . $ GuiScrolledWindow# parent, int width, int height, |
| 820 | GuiDrawingArea_ExposeCallbackcxx . . $ GuiDrawingArea_ExposeCallback# exposeCallback, |
| 821 | GuiDrawingArea_MouseCallbackcxx . . $ GuiDrawingArea_MouseCallback# mouseCallback, |
| 822 | GuiDrawingArea_KeyCallbackcxx . . $ GuiDrawingArea_KeyCallback# keyCallback, |
| 823 | GuiDrawingArea_ResizeCallbackcxx . . $ GuiDrawingArea_ResizeCallback# resizeCallback, |
| 824 | GuiDrawingArea_ZoomCallbackcxx . . $ GuiDrawingArea_ZoomCallback# zoomCallback, Thingcxx . . $ Thing# boss, |
| 825 | uint32cxx . . $ uint32# flags) |
| 826 | { |
| 827 | GuiDrawingAreacxx . . $ GuiDrawingArea# me = GuiDrawingArea_createcxx . . $ GuiDrawingArea_create(90010d40394de761). (parent, width, height, |
| 828 | exposeCallback, mouseCallback, |
| 829 | keyCallback, resizeCallback, zoomCallback, boss, flags |
| 830 | ); |
| 831 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (me); |
| 832 | return me; |
| 833 | } |
| 834 | |
| 835 | void GuiDrawingArea_setSwipablecxx . . $ GuiDrawingArea_setSwipable(7e7a359b55bf9e27). (GuiDrawingAreacxx . . $ GuiDrawingArea# me, GuiScrollBarcxx . . $ GuiScrollBar# horizontalScrollBar, GuiScrollBarcxx . . $ GuiScrollBar# verticalScrollBar) { |
| 836 | mycxx . . $ `melder/melder.h:44:9`! d_horizontalScrollBarcxx . . $ structGuiDrawingArea#d_horizontalScrollBar. = horizontalScrollBar; |
| 837 | mycxx . . $ `melder/melder.h:44:9`! d_verticalScrollBarcxx . . $ structGuiDrawingArea#d_verticalScrollBar. = verticalScrollBar; |
| 838 | #if gtkcxx . . $ `sys/Gui.h:33:10`! |
| 839 | gtk_widget_add_events (GTK_WIDGETcxx . . $ `<external>/6031079988677191796/gtkwidget.h:58:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), GDK_SCROLL_MASK); |
| 840 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), "scroll-event", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (_guiGtkDrawingArea_swipeCallback), me); |
| 841 | #if 0 // GTK 3 |
| 842 | GtkGesture *zoom = gtk_gesture_zoom_new (GTK_WIDGET (my d_widget)); |
| 843 | g_object_ref (zoom); |
| 844 | g_signal_connect (zoom, "scale-changed", G_CALLBACK (_guiGtkDrawingArea_zoomCallback), me); |
| 845 | #elif 0 |
| 846 | gtk_widget_add_events (GTK_WIDGET (my d_widget), GDK_TOUCHPAD_GESTURE_MASK | GDK_SMOOTH_SCROLL_MASK); |
| 847 | g_signal_connect (G_OBJECT (my d_widget), "event", G_CALLBACK (_guiGtkDrawingArea_genericEventCallback), me); |
| 848 | #elif 0 // GTK 4 |
| 849 | g_signal_connect (G_OBJECT (my d_widget), "touchpad-pinch", G_CALLBACK (_guiGtkDrawingArea_pinchCallback), me); |
| 850 | #endif |
| 851 | #endif |
| 852 | } |
| 853 | |
| 854 | void GuiDrawingArea_setExposeCallbackcxx . . $ GuiDrawingArea_setExposeCallback(a33fb5a9b9a36a6c). (GuiDrawingAreacxx . . $ GuiDrawingArea# me, GuiDrawingArea_ExposeCallbackcxx . . $ GuiDrawingArea_ExposeCallback# callback, Thingcxx . . $ Thing# boss) { |
| 855 | mycxx . . $ `melder/melder.h:44:9`! d_exposeCallbackcxx . . $ structGuiDrawingArea#d_exposeCallback. =cxx . . $ MelderCallback#`operator=`(ad58c8464e916fec). callback; |
| 856 | mycxx . . $ `melder/melder.h:44:9`! d_exposeBosscxx . . $ structGuiDrawingArea#d_exposeBoss. = boss; |
| 857 | } |
| 858 | |
| 859 | void GuiDrawingArea_setMouseCallbackcxx . . $ GuiDrawingArea_setMouseCallback(766d4929d482e652). (GuiDrawingAreacxx . . $ GuiDrawingArea# me, GuiDrawingArea_MouseCallbackcxx . . $ GuiDrawingArea_MouseCallback# callback, Thingcxx . . $ Thing# boss) { |
| 860 | mycxx . . $ `melder/melder.h:44:9`! mouseCallbackcxx . . $ structGuiDrawingArea#mouseCallback. =cxx . . $ MelderCallback#`operator=`(b97e83e3f9ab7552). callback; |
| 861 | mycxx . . $ `melder/melder.h:44:9`! mouseBosscxx . . $ structGuiDrawingArea#mouseBoss. = boss; |
| 862 | } |
| 863 | |
| 864 | void GuiDrawingArea_setResizeCallbackcxx . . $ GuiDrawingArea_setResizeCallback(aa4956f4008e2588). (GuiDrawingAreacxx . . $ GuiDrawingArea# me, GuiDrawingArea_ResizeCallbackcxx . . $ GuiDrawingArea_ResizeCallback# callback, Thingcxx . . $ Thing# boss) { |
| 865 | mycxx . . $ `melder/melder.h:44:9`! d_resizeCallbackcxx . . $ structGuiDrawingArea#d_resizeCallback. =cxx . . $ MelderCallback#`operator=`(9334ad62f8fdf0ca). callback; |
| 866 | mycxx . . $ `melder/melder.h:44:9`! d_resizeBosscxx . . $ structGuiDrawingArea#d_resizeBoss. = boss; |
| 867 | } |
| 868 | |
| 869 | void GuiDrawingArea_setZoomCallbackcxx . . $ GuiDrawingArea_setZoomCallback(15a7b1d70535470). (GuiDrawingAreacxx . . $ GuiDrawingArea# me, GuiDrawingArea_ZoomCallbackcxx . . $ GuiDrawingArea_ZoomCallback# callback, Thingcxx . . $ Thing# boss) { |
| 870 | mycxx . . $ `melder/melder.h:44:9`! d_zoomCallbackcxx . . $ structGuiDrawingArea#d_zoomCallback. =cxx . . $ MelderCallback#`operator=`(650680ba9693f3f1). callback; |
| 871 | mycxx . . $ `melder/melder.h:44:9`! d_zoomBosscxx . . $ structGuiDrawingArea#d_zoomBoss. = boss; |
| 872 | } |
| 873 | |
| 874 | /* End of file GuiDrawingArea.cpp */ |