| 1 | /* DemoEditor.cpp |
| 2 | * |
| 3 | * Copyright (C) 2009-2026 Paul Boersma |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | * See the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include "DemoEditor.h"cxx . . $ `<file>/sys/DemoEditor.h`/ |
| 20 | #include "machine.h"cxx . . $ `<file>/sys/machine.h`/ |
| 21 | #include "praatP.h"cxx . . $ `<file>/sys/praatP.h`/ |
| 22 | #include "../kar/UnicodeData.h"cxx . . $ `<file>/kar/UnicodeData.h`/ |
| 23 | |
| 24 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (DemoEditor, Editor, 0); |
| 25 | |
| 26 | static DemoEditorcxx . . $ DemoEditor# theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor.; |
| 27 | |
| 28 | void Demo_interpreterGoesAwaycxx . . $ Demo_interpreterGoesAway(448c181fe9dacca8). (Interpretercxx . . $ Interpreter# interpreter) { |
| 29 | if (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. && interpreter == theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> interpreterReferencecxx . . $ structDemoEditor#interpreterReference.) |
| 30 | theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> interpreterReferencecxx . . $ structDemoEditor#interpreterReference. = nullptr; // undangle |
| 31 | } |
| 32 | |
| 33 | bool Demo_hasGraphicscxx . . $ Demo_hasGraphics(ce6516af4677a324). (Graphicscxx . . $ Graphics# graphics) { |
| 34 | return theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. && theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).() == graphics; |
| 35 | } |
| 36 | |
| 37 | /***** DemoEditor methods *****/ |
| 38 | |
| 39 | void structDemoEditorcxx . . $ structDemoEditor# :: v9_destroycxx . . $ structDemoEditor#v9_destroy(ced63f7c635d850d). () noexcept { |
| 40 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`! (ourcxx . . $ `melder/melder.h:42:9`! praatPicture); |
| 41 | theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. = nullptr; |
| 42 | DemoEditor_Parentcxx . . $ DemoEditor_Parent# :: v9_destroycxx . . $ structEditor#v9_destroy(ced63f7c635d850d). (); |
| 43 | } |
| 44 | |
| 45 | void structDemoEditorcxx . . $ structDemoEditor# :: v1_infocxx . . $ structDemoEditor#v1_info(49f6e7a06ebc5aa8). () { |
| 46 | DemoEditor_Parentcxx . . $ DemoEditor_Parent# :: v1_infocxx . . $ structEditor#v1_info(49f6e7a06ebc5aa8). (); |
| 47 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Colour: ", MelderColour_namecxx . . $ MelderColour_name(7dfff7c3df3cd0ae). (((PraatPicturecxx . . $ PraatPicture#) praatPicturecxx . . $ structDemoEditor#praatPicture.) -> colourcxx . . $ structPraatPicture#colour.)); |
| 48 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Font: ", kGraphics_font_getTextcxx . . $ kGraphics_font_getText(d24a1e0f071d30ac). (((PraatPicturecxx . . $ PraatPicture#) praatPicturecxx . . $ structDemoEditor#praatPicture.) -> fontcxx . . $ structPraatPicture#font.)); |
| 49 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Font size: ", ((PraatPicturecxx . . $ PraatPicture#) praatPicturecxx . . $ structDemoEditor#praatPicture.) -> fontSizecxx . . $ structPraatPicture#fontSize.); |
| 50 | } |
| 51 | |
| 52 | void structDemoEditorcxx . . $ structDemoEditor# :: v_goAwaycxx . . $ structDemoEditor#v_goAway(49f6e7a06ebc5aa8). () { |
| 53 | if (ourcxx . . $ `melder/melder.h:42:9`! waitingForInputcxx . . $ structDemoEditor#waitingForInput.) { |
| 54 | if (ourcxx . . $ `melder/melder.h:42:9`! interpreterReferencecxx . . $ structDemoEditor#interpreterReference.) { |
| 55 | const integercxx . . $ integer# lineNumber = ourcxx . . $ `melder/melder.h:42:9`! interpreterReferencecxx . . $ structDemoEditor#interpreterReference. -> lineNumbercxx . . $ structInterpreter#lineNumber.; |
| 56 | Interpreter_stopcxx . . $ Interpreter_stop(448c181fe9dacca8). (ourcxx . . $ `melder/melder.h:42:9`! interpreterReferencecxx . . $ structDemoEditor#interpreterReference.); |
| 57 | #if 0 |
| 58 | Melder_flushError ( |
| 59 | U"You interrupted the script at line ", lineNumber, U".\n" |
| 60 | U"The Demo window will now close." |
| 61 | ); |
| 62 | #endif |
| 63 | } |
| 64 | forgetcxx . . $ `sys/Thing.h:158:9`! (theReferenceToTheOnlyDemoEditor); |
| 65 | } else |
| 66 | DemoEditor_Parentcxx . . $ DemoEditor_Parent# :: v_goAwaycxx . . $ structEditor#v_goAway(49f6e7a06ebc5aa8). (); |
| 67 | } |
| 68 | |
| 69 | void structDemoEditorcxx . . $ structDemoEditor# :: v_createMenuscxx . . $ structDemoEditor#v_createMenus(49f6e7a06ebc5aa8). () { |
| 70 | DemoEditor_Parentcxx . . $ DemoEditor_Parent# :: v_createMenuscxx . . $ structEditor#v_createMenus(49f6e7a06ebc5aa8). (); |
| 71 | } |
| 72 | |
| 73 | static void gui_drawingarea_cb_exposecxx . . $ gui_drawingarea_cb_expose(fc4491f4135ef223). (DemoEditorcxx . . $ DemoEditor# me, GuiDrawingArea_ExposeEventcxx . . $ GuiDrawingArea_ExposeEvent# /* event */) { |
| 74 | if (! mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics.) |
| 75 | return; // could be the case in the very beginning |
| 76 | static integercxx . . $ integer# count=0; |
| 77 | //Melder_casual(U"gui_drawingarea_cb_expose ", ++count); |
| 78 | //Graphics_clearWs (my foregroundGraphics.get()); |
| 79 | Graphics_playcxx . . $ Graphics_play(381ee972040461e0). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 80 | } |
| 81 | |
| 82 | static void gui_drawingarea_cb_mousecxx . . $ gui_drawingarea_cb_mouse(5231b165d142db94). (DemoEditorcxx . . $ DemoEditor# me, GuiDrawingArea_MouseEventcxx . . $ GuiDrawingArea_MouseEvent# event) { |
| 83 | if (! mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics.) |
| 84 | return; // could be the case in the very beginning |
| 85 | if (! event -> isClickcxx . . $ structGuiDrawingArea_MouseEvent#isClick(50ce9a9e25b4a850).()) |
| 86 | return; |
| 87 | mycxx . . $ `melder/melder.h:44:9`! clickedcxx . . $ structDemoEditor#clicked. = true; |
| 88 | mycxx . . $ `melder/melder.h:44:9`! keyPressedcxx . . $ structDemoEditor#keyPressed. = false; |
| 89 | mycxx . . $ `melder/melder.h:44:9`! xcxx . . $ structDemoEditor#x. = event -> xcxx . . $ structGuiDrawingArea_MouseEvent#x.; |
| 90 | mycxx . . $ `melder/melder.h:44:9`! ycxx . . $ structDemoEditor#y. = event -> ycxx . . $ structGuiDrawingArea_MouseEvent#y.; |
| 91 | mycxx . . $ `melder/melder.h:44:9`! keycxx . . $ structDemoEditor#key. = UNICODE_BULLETcxx . . $ `kar/UnicodeData.h:14790:9`!; |
| 92 | mycxx . . $ `melder/melder.h:44:9`! shiftKeyPressedcxx . . $ structDemoEditor#shiftKeyPressed. = event -> shiftKeyPressedcxx . . $ structGuiDrawingArea_MouseEvent#shiftKeyPressed.; |
| 93 | mycxx . . $ `melder/melder.h:44:9`! commandKeyPressedcxx . . $ structDemoEditor#commandKeyPressed. = event -> commandKeyPressedcxx . . $ structGuiDrawingArea_MouseEvent#commandKeyPressed.; |
| 94 | mycxx . . $ `melder/melder.h:44:9`! optionKeyPressedcxx . . $ structDemoEditor#optionKeyPressed. = event -> optionKeyPressedcxx . . $ structGuiDrawingArea_MouseEvent#optionKeyPressed.; |
| 95 | if (mycxx . . $ `melder/melder.h:44:9`! waitingForInputcxx . . $ structDemoEditor#waitingForInput.) { |
| 96 | mycxx . . $ `melder/melder.h:44:9`! waitingForInputcxx . . $ structDemoEditor#waitingForInput. = false; |
| 97 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! interpreterReference, |
| 98 | U"The script that was waiting for input (e.g. your mouse click) no longer exists."); |
| 99 | try { |
| 100 | autoPraatBackgroundcxx . . $ autoPraatBackground# backgroundcxx . . $ autoPraatBackground#autoPraatBackground(49f6e7a06ebc5aa8).; |
| 101 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! interpreterReference -> owningInterpreterStack); |
| 102 | mycxx . . $ `melder/melder.h:44:9`! interpreterReferencecxx . . $ structDemoEditor#interpreterReference. -> owningInterpreterStackcxx . . $ structInterpreter#owningInterpreterStack. -> resumeFromTopcxx . . $ structInterpreterStack#resumeFromTop(49f6e7a06ebc5aa8). (); |
| 103 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 104 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"This happened after you clicked in the Demo window."); |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | static void gui_drawingarea_cb_keycxx . . $ gui_drawingarea_cb_key(fc62a3f5b29d8a0b). (DemoEditorcxx . . $ DemoEditor# me, GuiDrawingArea_KeyEventcxx . . $ GuiDrawingArea_KeyEvent# event) { |
| 110 | if (! mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics.) |
| 111 | return; // could be the case in the very beginning |
| 112 | mycxx . . $ `melder/melder.h:44:9`! clickedcxx . . $ structDemoEditor#clicked. = false; |
| 113 | mycxx . . $ `melder/melder.h:44:9`! keyPressedcxx . . $ structDemoEditor#keyPressed. = true; |
| 114 | mycxx . . $ `melder/melder.h:44:9`! xcxx . . $ structDemoEditor#x. = 0; |
| 115 | mycxx . . $ `melder/melder.h:44:9`! ycxx . . $ structDemoEditor#y. = 0; |
| 116 | mycxx . . $ `melder/melder.h:44:9`! keycxx . . $ structDemoEditor#key. = event -> keycxx . . $ structGuiDrawingArea_KeyEvent#key.; |
| 117 | tracecxx . . $ `melder/melder_debug.h:60:10`! (U"\"", mycxx . . $ `melder/melder.h:44:9`! key, U"\""); |
| 118 | mycxx . . $ `melder/melder.h:44:9`! shiftKeyPressedcxx . . $ structDemoEditor#shiftKeyPressed. = event -> shiftKeyPressedcxx . . $ structGuiDrawingArea_KeyEvent#shiftKeyPressed.; |
| 119 | mycxx . . $ `melder/melder.h:44:9`! commandKeyPressedcxx . . $ structDemoEditor#commandKeyPressed. = event -> commandKeyPressedcxx . . $ structGuiDrawingArea_KeyEvent#commandKeyPressed.; |
| 120 | mycxx . . $ `melder/melder.h:44:9`! optionKeyPressedcxx . . $ structDemoEditor#optionKeyPressed. = event -> optionKeyPressedcxx . . $ structGuiDrawingArea_KeyEvent#optionKeyPressed.; |
| 121 | if (mycxx . . $ `melder/melder.h:44:9`! waitingForInputcxx . . $ structDemoEditor#waitingForInput.) { |
| 122 | mycxx . . $ `melder/melder.h:44:9`! waitingForInputcxx . . $ structDemoEditor#waitingForInput. = false; |
| 123 | Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (mycxx . . $ `melder/melder.h:44:9`! interpreterReference, |
| 124 | U"The script that was waiting for input (e.g. your key press) no longer exists."); |
| 125 | try { |
| 126 | autoPraatBackgroundcxx . . $ autoPraatBackground# backgroundcxx . . $ autoPraatBackground#autoPraatBackground(49f6e7a06ebc5aa8).; |
| 127 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! interpreterReference -> owningInterpreterStack); |
| 128 | mycxx . . $ `melder/melder.h:44:9`! interpreterReferencecxx . . $ structDemoEditor#interpreterReference. -> owningInterpreterStackcxx . . $ structInterpreter#owningInterpreterStack. -> resumeFromTopcxx . . $ structInterpreterStack#resumeFromTop(49f6e7a06ebc5aa8). (); |
| 129 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 130 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"This happened after you pressed a key in the Demo window."); |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | static void gui_drawingarea_cb_resizecxx . . $ gui_drawingarea_cb_resize(19cb96f6e3f4558e). (DemoEditorcxx . . $ DemoEditor# me, GuiDrawingArea_ResizeEventcxx . . $ GuiDrawingArea_ResizeEvent# event) { |
| 136 | if (! mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics.) |
| 137 | return; // could be the case in the very beginning |
| 138 | tracecxx . . $ `melder/melder_debug.h:60:10`! (event -> width, U" ", event -> height); |
| 139 | Graphics_setWsViewportcxx . . $ Graphics_setWsViewport(4ffe5bb10b2fb6bd). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, event -> widthcxx . . $ structGuiDrawingArea_ResizeEvent#width., 0.0, event -> heightcxx . . $ structGuiDrawingArea_ResizeEvent#height.); |
| 140 | Graphics_setWsWindowcxx . . $ Graphics_setWsWindow(72bdb7937dbb13da). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, 100.0, 0.0, 100.0); |
| 141 | //Graphics_setViewport (my graphics.get(), 0.0, 100.0, 0.0, 100.0); |
| 142 | Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 143 | } |
| 144 | |
| 145 | void structDemoEditorcxx . . $ structDemoEditor# :: v_createChildrencxx . . $ structDemoEditor#v_createChildren(49f6e7a06ebc5aa8). () { |
| 146 | ourcxx . . $ `melder/melder.h:42:9`! drawingAreacxx . . $ structDemoEditor#drawingArea. = GuiDrawingArea_createShowncxx . . $ GuiDrawingArea_createShown(5a210e61ba6a237d). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., 0, 0, 0, 0, |
| 147 | gui_drawingarea_cb_exposecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., gui_drawingarea_cb_mousecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., |
| 148 | gui_drawingarea_cb_keycxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., gui_drawingarea_cb_resizecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., this, 0 |
| 149 | ); |
| 150 | } |
| 151 | |
| 152 | void DemoEditor_initcxx . . $ DemoEditor_init(aaf60ee962c4898e). (DemoEditorcxx . . $ DemoEditor# me) { |
| 153 | Editor_initcxx . . $ Editor_init(13f379e38ac41ed6). (me, 0, 0, 1344, 756, U"", nullptr); // 70 percent of the standard 1920x1080 screen |
| 154 | |
| 155 | mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics. =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Graphics_create_xmdrawingareacxx . . $ Graphics_create_xmdrawingarea(51b1c75797a7dddf). (mycxx . . $ `melder/melder.h:44:9`! drawingAreacxx . . $ structDemoEditor#drawingArea.); |
| 156 | Graphics_setWsWindowcxx . . $ Graphics_setWsWindow(72bdb7937dbb13da). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, 100.0, 0.0, 100.0); |
| 157 | Graphics_setWsViewportcxx . . $ Graphics_setWsViewport(4ffe5bb10b2fb6bd). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), |
| 158 | 0.0, GuiControl_getWidthcxx . . $ GuiControl_getWidth(1227891e76fac374). (mycxx . . $ `melder/melder.h:44:9`! drawingAreacxx . . $ structDemoEditor#drawingArea.), |
| 159 | 0.0, GuiControl_getHeightcxx . . $ GuiControl_getHeight(1227891e76fac374). (mycxx . . $ `melder/melder.h:44:9`! drawingAreacxx . . $ structDemoEditor#drawingArea.) |
| 160 | ); |
| 161 | Graphics_startRecordingcxx . . $ Graphics_startRecording(ce6516af4677a324). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 162 | Graphics_setViewportcxx . . $ Graphics_setViewport(72bdb7937dbb13da). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, 100.0, 0.0, 100.0); |
| 163 | Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), Melder_WHITEcxx . . $ Melder_WHITE.); |
| 164 | Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, 1.0, 0.0, 1.0); |
| 165 | Graphics_fillRectanglecxx . . $ Graphics_fillRectangle(72bdb7937dbb13da). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, 1.0, 0.0, 1.0); |
| 166 | Graphics_setColourcxx . . $ Graphics_setColour(eb47b9513d3f4721). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), Melder_BLACKcxx . . $ Melder_BLACK.); |
| 167 | Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 168 | } |
| 169 | |
| 170 | autoDemoEditorcxx . . $ autoDemoEditor# DemoEditor_createcxx . . $ DemoEditor_create(2aaf7ae1aaf2cbbb). () { |
| 171 | try { |
| 172 | autoDemoEditorcxx . . $ autoDemoEditor# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (DemoEditor); |
| 173 | DemoEditor_initcxx . . $ DemoEditor_init(aaf60ee962c4898e). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 174 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 175 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 176 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Demo window not created."); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | void Demo_opencxx . . $ Demo_open(49f6e7a06ebc5aa8). () { |
| 181 | if (Melder_batchcxx . . $ Melder_batch.) { |
| 182 | /* |
| 183 | Batch scripts have to be able to run demos. |
| 184 | */ |
| 185 | //Melder_batch = false; |
| 186 | } |
| 187 | if (! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor.) { |
| 188 | autoDemoEditorcxx . . $ autoDemoEditor# editor = DemoEditor_createcxx . . $ DemoEditor_create(2aaf7ae1aaf2cbbb). (); |
| 189 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (editor); |
| 190 | //GuiObject_show (editor -> windowForm); |
| 191 | editor ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). praatPicturecxx . . $ structDemoEditor#praatPicture. = Melder_calloc_fcxx . . $ `melder/melder_alloc.h:36:9`! (structPraatPicture, 1); |
| 192 | theCurrentPraatPicturecxx . . $ theCurrentPraatPicture. = (PraatPicturecxx . . $ PraatPicture#) editor ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). praatPicturecxx . . $ structDemoEditor#praatPicture.; |
| 193 | theCurrentPraatPicturecxx . . $ theCurrentPraatPicture. -> graphicscxx . . $ structPraatPicture#graphics. = editor ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(); |
| 194 | theCurrentPraatPicturecxx . . $ theCurrentPraatPicture. -> fontcxx . . $ structPraatPicture#font. = kGraphics_fontcxx . . $ kGraphics_font#::HELVETICAcxx . . $ kGraphics_font#HELVETICA.; |
| 195 | theCurrentPraatPicturecxx . . $ theCurrentPraatPicture. -> fontSizecxx . . $ structPraatPicture#fontSize. = 10; |
| 196 | theCurrentPraatPicturecxx . . $ theCurrentPraatPicture. -> lineTypecxx . . $ structPraatPicture#lineType. = Graphics_DRAWNcxx . . $ `sys/Graphics.h:287:9`!; |
| 197 | theCurrentPraatPicturecxx . . $ theCurrentPraatPicture. -> colourcxx . . $ structPraatPicture#colour. =cxx . . $ MelderColour#`operator=`(3ab3c3f6bc5cdda1). Melder_BLACKcxx . . $ Melder_BLACK.; |
| 198 | theCurrentPraatPicturecxx . . $ theCurrentPraatPicture. -> lineWidthcxx . . $ structPraatPicture#lineWidth. = 1.0; |
| 199 | theCurrentPraatPicturecxx . . $ theCurrentPraatPicture. -> arrowSizecxx . . $ structPraatPicture#arrowSize. = 1.0; |
| 200 | theCurrentPraatPicturecxx . . $ theCurrentPraatPicture. -> speckleSizecxx . . $ structPraatPicture#speckleSize. = 1.0; |
| 201 | theCurrentPraatPicturecxx . . $ theCurrentPraatPicture. -> x1NDCcxx . . $ structPraatPicture#x1NDC. = 0.0; |
| 202 | theCurrentPraatPicturecxx . . $ theCurrentPraatPicture. -> x2NDCcxx . . $ structPraatPicture#x2NDC. = 100.0; |
| 203 | theCurrentPraatPicturecxx . . $ theCurrentPraatPicture. -> y1NDCcxx . . $ structPraatPicture#y1NDC. = 0.0; |
| 204 | theCurrentPraatPicturecxx . . $ theCurrentPraatPicture. -> y2NDCcxx . . $ structPraatPicture#y2NDC. = 100.0; |
| 205 | theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. = editor.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(); |
| 206 | editor.releaseToUsercxx . . $ autoSomeThing#releaseToUser(ced63f7c635d850d).(); |
| 207 | } |
| 208 | if (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> waitingForInputcxx . . $ structDemoEditor#waitingForInput. &&0) |
| 209 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot work with the Demo window while it is waiting for input. " |
| 210 | U"Please click or type into the Demo window or close it."); |
| 211 | theCurrentPraatPicturecxx . . $ theCurrentPraatPicture. = (PraatPicturecxx . . $ PraatPicture#) theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> praatPicturecxx . . $ structDemoEditor#praatPicture.; |
| 212 | } |
| 213 | |
| 214 | void Demo_closecxx . . $ Demo_close(49f6e7a06ebc5aa8). () { |
| 215 | theCurrentPraatPicturecxx . . $ theCurrentPraatPicture. = & theForegroundPraatPicturecxx . . $ theForegroundPraatPicture.; |
| 216 | Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 217 | } |
| 218 | |
| 219 | int Demo_windowTitlecxx . . $ Demo_windowTitle(e049ab16a3067c7). (conststring32cxx . . $ conststring32# title) { |
| 220 | autoDemoOpencxx . . $ autoDemoOpen# democxx . . $ autoDemoOpen#autoDemoOpen(49f6e7a06ebc5aa8).; |
| 221 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor., title); |
| 222 | return 1; |
| 223 | } |
| 224 | |
| 225 | int Demo_showcxx . . $ Demo_show(b126dc7c1de90089). () { |
| 226 | if (! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor.) |
| 227 | return 0; |
| 228 | autoDemoOpencxx . . $ autoDemoOpen# democxx . . $ autoDemoOpen#autoDemoOpen(49f6e7a06ebc5aa8).; |
| 229 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> windowFormcxx . . $ structEditor#windowForm.); |
| 230 | Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 231 | #if defined (UNIXcxx . . $ `<built-in>:479:9`!) |
| 232 | Melder_sleepcxx . . $ Melder_sleep(ba8836b59fb42830). (0.02); // because GuiShell_drain is not guaranteed to drain if called within 16 ms from previous |
| 233 | #endif |
| 234 | GuiShell_draincxx . . $ GuiShell_drain(429b5b6a2695f0d7). (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> windowFormcxx . . $ structEditor#windowForm., true, false); |
| 235 | return 1; |
| 236 | } |
| 237 | |
| 238 | #if cocoacxx . . $ `sys/Gui.h:35:10`! |
| 239 | @interface DemoWindowTimer: NSObject |
| 240 | - (void) timerCallback: (NSTimer *) timer; |
| 241 | @end |
| 242 | @implementation DemoWindowTimer |
| 243 | - (void) timerCallback: (NSTimer *) timer { |
| 244 | (void) timer; |
| 245 | printf ("eureka\n"); |
| 246 | } |
| 247 | @end |
| 248 | DemoWindowTimer *theDemoWindowTimer; |
| 249 | #endif // cocoa |
| 250 | |
| 251 | void Demo_timercxx . . $ Demo_timer(ba8836b59fb42830). (double duration) { |
| 252 | #if cocoacxx . . $ `sys/Gui.h:35:10`! |
| 253 | if (! theDemoWindowTimer) |
| 254 | theDemoWindowTimer = [[DemoWindowTimer alloc] init]; |
| 255 | [NSTimer |
| 256 | scheduledTimerWithTimeInterval: duration |
| 257 | target: theDemoWindowTimer |
| 258 | selector: @selector (timerCallback) |
| 259 | userInfo: nil |
| 260 | repeats: false |
| 261 | ]; |
| 262 | #endif // cocoa |
| 263 | } |
| 264 | |
| 265 | void Demo_waitForInputcxx . . $ Demo_waitForInput(448c181fe9dacca8). (Interpretercxx . . $ Interpreter# interpreter) { |
| 266 | //TRACE |
| 267 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (interpreter); |
| 268 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (interpreter -> owningInterpreterStack); |
| 269 | |
| 270 | tracecxx . . $ `melder/melder_debug.h:60:10`! (U"is in second Pass? ", interpreter -> isInSecondPass); |
| 271 | if (interpreter -> isInSecondPasscxx . . $ structInterpreter#isInSecondPass.) { |
| 272 | interpreter -> isInSecondPasscxx . . $ structInterpreter#isInSecondPass. = false; // TODO: needed? |
| 273 | } else { |
| 274 | /* |
| 275 | This function pauses the interpreter. |
| 276 | Key or mouse input will resume the interpreter. |
| 277 | */ |
| 278 | if (! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor.) |
| 279 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Cannot do demoWaitForInput() if the Demo window isn’t visible."); |
| 280 | tracecxx . . $ `melder/melder_debug.h:60:10`! (U"is the Demo window already waiting for input? ", theReferenceToTheOnlyDemoEditor -> waitingForInput); |
| 281 | if (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> waitingForInputcxx . . $ structDemoEditor#waitingForInput. &&0) { |
| 282 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot work with the Demo window while it is waiting for input. " |
| 283 | U"Please click or type into the Demo window or close it."); |
| 284 | } |
| 285 | //GuiThing_show (theReferenceToTheOnlyDemoEditor -> windowForm); |
| 286 | theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> clickedcxx . . $ structDemoEditor#clicked. = false; |
| 287 | theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> keyPressedcxx . . $ structDemoEditor#keyPressed. = false; |
| 288 | theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> waitingForInputcxx . . $ structDemoEditor#waitingForInput. = true; |
| 289 | interpreter -> owningInterpreterStackcxx . . $ structInterpreter#owningInterpreterStack. -> haltAllcxx . . $ structInterpreterStack#haltAll(49f6e7a06ebc5aa8). (); |
| 290 | tracecxx . . $ `melder/melder_debug.h:60:10`! (U"setting the Demo window's interpreter to ", Melder_pointer (interpreter)); |
| 291 | theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> interpreterReferencecxx . . $ structDemoEditor#interpreterReference. = interpreter; |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | void Demo_peekInputcxx . . $ Demo_peekInput(448c181fe9dacca8). (Interpretercxx . . $ Interpreter# interpreter) { |
| 296 | if (! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor.) |
| 297 | return; |
| 298 | if (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> waitingForInputcxx . . $ structDemoEditor#waitingForInput. &&0) { |
| 299 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot work with the Demo window while it is waiting for input. " |
| 300 | U"Please click or type into the Demo window or close it."); |
| 301 | } |
| 302 | //GuiObject_show (theReferenceToTheOnlyDemoEditor -> windowForm); |
| 303 | theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> clickedcxx . . $ structDemoEditor#clicked. = false; |
| 304 | theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> keyPressedcxx . . $ structDemoEditor#keyPressed. = false; |
| 305 | theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> xcxx . . $ structDemoEditor#x. = 0; |
| 306 | theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> ycxx . . $ structDemoEditor#y. = 0; |
| 307 | theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> keycxx . . $ structDemoEditor#key. = U'\0'; |
| 308 | theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> shiftKeyPressedcxx . . $ structDemoEditor#shiftKeyPressed. = false; |
| 309 | theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> commandKeyPressedcxx . . $ structDemoEditor#commandKeyPressed. = false; |
| 310 | theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> optionKeyPressedcxx . . $ structDemoEditor#optionKeyPressed. = false; |
| 311 | theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> waitingForInputcxx . . $ structDemoEditor#waitingForInput. = true; |
| 312 | {// scope |
| 313 | autoMelderSaveCurrentFoldercxx . . $ autoMelderSaveCurrentFolder# saveFoldercxx . . $ autoMelderSaveCurrentFolder#autoMelderSaveCurrentFolder(49f6e7a06ebc5aa8).; |
| 314 | try { |
| 315 | #if gtkcxx . . $ `sys/Gui.h:33:10`! |
| 316 | while (gtk_events_pending ()) { |
| 317 | gtk_main_iteration (); |
| 318 | } |
| 319 | #elif cocoa |
| 320 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
| 321 | [theReferenceToTheOnlyDemoEditor -> windowForm -> d_cocoaShell flushWindow]; // TODO: needed? |
| 322 | Graphics_updateWs (theReferenceToTheOnlyDemoEditor -> graphics.get()); // make sure that even texts will be drawn |
| 323 | while (NSEvent *nsEvent = [NSApp |
| 324 | nextEventMatchingMask: NSAnyEventMask |
| 325 | untilDate: [NSDate distantPast] // don't wait |
| 326 | inMode: NSDefaultRunLoopMode |
| 327 | dequeue: YES]) |
| 328 | { |
| 329 | [NSApp sendEvent: nsEvent]; |
| 330 | } |
| 331 | [NSApp updateWindows]; // called automatically? TODO: remove |
| 332 | [pool release]; |
| 333 | #elif defined (_WIN32) |
| 334 | XEvent event; |
| 335 | while (PeekMessage (& event, 0, 0, 0, PM_REMOVE)) { |
| 336 | XtDispatchEvent (& event); |
| 337 | } |
| 338 | #endif |
| 339 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 340 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"An error made it to the outer level in the Demo window; should not occur! Please write to [email protected]"); |
| 341 | } |
| 342 | } |
| 343 | theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> waitingForInputcxx . . $ structDemoEditor#waitingForInput. = false; |
| 344 | if (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> userWantsToClosecxx . . $ structDemoEditor#userWantsToClose.) { |
| 345 | Interpreter_stopcxx . . $ Interpreter_stop(448c181fe9dacca8). (interpreter); |
| 346 | forgetcxx . . $ `sys/Thing.h:158:9`! (theReferenceToTheOnlyDemoEditor); |
| 347 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You interrupted the script."); |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | bool Demo_clickedcxx . . $ Demo_clicked(c9857a73d68e59ba). () { |
| 352 | if (! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor.) |
| 353 | return false; |
| 354 | if (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> waitingForInputcxx . . $ structDemoEditor#waitingForInput. &&0) { |
| 355 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot work with the Demo window while it is waiting for input. " |
| 356 | U"Please click or type into the Demo window or close it."); |
| 357 | } |
| 358 | return theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> clickedcxx . . $ structDemoEditor#clicked.; |
| 359 | } |
| 360 | |
| 361 | double Demo_xcxx . . $ Demo_x(31fa7155c10fdd13). () { |
| 362 | if (! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor.) |
| 363 | return undefinedcxx . . $ undefined.; |
| 364 | if (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> waitingForInputcxx . . $ structDemoEditor#waitingForInput. &&0) { |
| 365 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot work with the Demo window while it is waiting for input. " |
| 366 | U"Please click or type into the Demo window or close it."); |
| 367 | } |
| 368 | tracecxx . . $ `melder/melder_debug.h:60:10`! (U"NDC before: ", theReferenceToTheOnlyDemoEditor -> graphics -> d_x1NDC, U" ", theReferenceToTheOnlyDemoEditor -> graphics -> d_x2NDC); |
| 369 | Graphics_setInnercxx . . $ Graphics_setInner(2d838ed765120c5d). (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 370 | tracecxx . . $ `melder/melder_debug.h:60:10`! (U"NDC after: ", theReferenceToTheOnlyDemoEditor -> graphics -> d_x1NDC, U" ", theReferenceToTheOnlyDemoEditor -> graphics -> d_x2NDC); |
| 371 | double xWC, yWC; |
| 372 | tracecxx . . $ `melder/melder_debug.h:60:10`! (U"DC: x ", theReferenceToTheOnlyDemoEditor -> x, U", y ", theReferenceToTheOnlyDemoEditor -> y); |
| 373 | Graphics_DCtoWCcxx . . $ Graphics_DCtoWC(cb6c8e8090c77494). (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> xcxx . . $ structDemoEditor#x., theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> ycxx . . $ structDemoEditor#y., & xWC, & yWC); |
| 374 | tracecxx . . $ `melder/melder_debug.h:60:10`! (U"WC: x ", xWC, U", y ", yWC); |
| 375 | Graphics_unsetInnercxx . . $ Graphics_unsetInner(2d838ed765120c5d). (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 376 | return xWC; |
| 377 | } |
| 378 | |
| 379 | double Demo_ycxx . . $ Demo_y(31fa7155c10fdd13). () { |
| 380 | if (! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor.) |
| 381 | return undefinedcxx . . $ undefined.; |
| 382 | if (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> waitingForInputcxx . . $ structDemoEditor#waitingForInput. &&0) { |
| 383 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot work with the Demo window while it is waiting for input. " |
| 384 | U"Please click or type into the Demo window or close it."); |
| 385 | } |
| 386 | Graphics_setInnercxx . . $ Graphics_setInner(2d838ed765120c5d). (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 387 | double xWC, yWC; |
| 388 | Graphics_DCtoWCcxx . . $ Graphics_DCtoWC(cb6c8e8090c77494). (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> xcxx . . $ structDemoEditor#x., theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> ycxx . . $ structDemoEditor#y., & xWC, & yWC); |
| 389 | Graphics_unsetInnercxx . . $ Graphics_unsetInner(2d838ed765120c5d). (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 390 | return yWC; |
| 391 | } |
| 392 | |
| 393 | bool Demo_keyPressedcxx . . $ Demo_keyPressed(c9857a73d68e59ba). () { |
| 394 | if (! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor.) |
| 395 | return false; |
| 396 | if (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> waitingForInputcxx . . $ structDemoEditor#waitingForInput. &&0) { |
| 397 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot work with the Demo window while it is waiting for input. " |
| 398 | U"Please click or type into the Demo window or close it."); |
| 399 | } |
| 400 | return theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> keyPressedcxx . . $ structDemoEditor#keyPressed.; |
| 401 | } |
| 402 | |
| 403 | char32cxx . . $ char32# Demo_keycxx . . $ Demo_key(6dd2c6f75f2e2a2f). () { |
| 404 | if (! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor.) |
| 405 | return U'\0'; |
| 406 | if (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> waitingForInputcxx . . $ structDemoEditor#waitingForInput. &&0) { |
| 407 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot work with the Demo window while it is waiting for input. " |
| 408 | U"Please click or type into the Demo window or close it."); |
| 409 | } |
| 410 | return theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> keycxx . . $ structDemoEditor#key.; |
| 411 | } |
| 412 | |
| 413 | bool Demo_shiftKeyPressedcxx . . $ Demo_shiftKeyPressed(c9857a73d68e59ba). () { |
| 414 | if (! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor.) |
| 415 | return false; |
| 416 | if (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> waitingForInputcxx . . $ structDemoEditor#waitingForInput. &&0) { |
| 417 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot work with the Demo window while it is waiting for input. " |
| 418 | U"Please click or type into the Demo window or close it."); |
| 419 | } |
| 420 | return theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> shiftKeyPressedcxx . . $ structDemoEditor#shiftKeyPressed.; |
| 421 | } |
| 422 | |
| 423 | bool Demo_commandKeyPressedcxx . . $ Demo_commandKeyPressed(c9857a73d68e59ba). () { |
| 424 | if (! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor.) |
| 425 | return false; |
| 426 | if (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> waitingForInputcxx . . $ structDemoEditor#waitingForInput. &&0) { |
| 427 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot work with the Demo window while it is waiting for input. " |
| 428 | U"Please click or type into the Demo window or close it."); |
| 429 | } |
| 430 | return theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> commandKeyPressedcxx . . $ structDemoEditor#commandKeyPressed.; |
| 431 | } |
| 432 | |
| 433 | bool Demo_optionKeyPressedcxx . . $ Demo_optionKeyPressed(c9857a73d68e59ba). () { |
| 434 | if (! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor.) |
| 435 | return false; |
| 436 | if (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> waitingForInputcxx . . $ structDemoEditor#waitingForInput. &&0) { |
| 437 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot work with the Demo window while it is waiting for input. " |
| 438 | U"Please click or type into the Demo window or close it."); |
| 439 | } |
| 440 | return theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> optionKeyPressedcxx . . $ structDemoEditor#optionKeyPressed.; |
| 441 | } |
| 442 | |
| 443 | bool Demo_inputcxx . . $ Demo_input(2df281243f91fe91). (conststring32cxx . . $ conststring32# keys) { |
| 444 | if (! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor.) |
| 445 | return false; |
| 446 | if (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> waitingForInputcxx . . $ structDemoEditor#waitingForInput. &&0) { |
| 447 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot work with the Demo window while it is waiting for input. " |
| 448 | U"Please click or type into the Demo window or close it."); |
| 449 | } |
| 450 | return str32chrcxx . . $ str32chr(328a9ede0fba853a). (keys, theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> keycxx . . $ structDemoEditor#key.) != nullptr; |
| 451 | } |
| 452 | |
| 453 | bool Demo_clickedIncxx . . $ Demo_clickedIn(ad3a29c0330224a3). (double left, double right, double bottom, double top) { |
| 454 | if (! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. || ! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> clickedcxx . . $ structDemoEditor#clicked.) |
| 455 | return false; |
| 456 | if (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> waitingForInputcxx . . $ structDemoEditor#waitingForInput. &&0) { |
| 457 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot work with the Demo window while it is waiting for input. " |
| 458 | U"Please click or type into the Demo window or close it."); |
| 459 | } |
| 460 | if (! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> clickedcxx . . $ structDemoEditor#clicked.) |
| 461 | return false; |
| 462 | const double xWC = Demo_xcxx . . $ Demo_x(31fa7155c10fdd13). (), yWC = Demo_ycxx . . $ Demo_y(31fa7155c10fdd13). (); |
| 463 | return xWC >= left && xWC < right && yWC >= bottom && yWC < top; |
| 464 | } |
| 465 | |
| 466 | void Demo_saveToPdfFilecxx . . $ Demo_saveToPdfFile(1145552d769d7b5d). (MelderFilecxx . . $ MelderFile# file) { |
| 467 | if (! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor.) |
| 468 | return; |
| 469 | if (! theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> graphicscxx . . $ structDemoEditor#graphics.) |
| 470 | return; // could be the case in the very beginning |
| 471 | const double resolution = theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> graphicscxx . . $ structDemoEditor#graphics. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). resolutioncxx . . $ structGraphics#resolution.; |
| 472 | autoGraphicscxx . . $ autoGraphics# pdfGraphics = Graphics_create_pdffilecxx . . $ Graphics_create_pdffile(10428f15b15d8c5f). (file, resolution, |
| 473 | undefinedcxx . . $ undefined., GuiControl_getWidthcxx . . $ GuiControl_getWidth(1227891e76fac374). (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> drawingAreacxx . . $ structDemoEditor#drawingArea.) / resolution, |
| 474 | undefinedcxx . . $ undefined., GuiControl_getHeightcxx . . $ GuiControl_getHeight(1227891e76fac374). (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> drawingAreacxx . . $ structDemoEditor#drawingArea.) / resolution |
| 475 | ); |
| 476 | pdfGraphics ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). d_x2DCmaxcxx . . $ structGraphics#d_x2DCmax. = 1e9; |
| 477 | pdfGraphics ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). d_y2DCmaxcxx . . $ structGraphics#d_y2DCmax. = 1e9; |
| 478 | Graphics_setWsWindowcxx . . $ Graphics_setWsWindow(72bdb7937dbb13da). (pdfGraphics.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, 100.0, 0.0, 100.0); |
| 479 | Graphics_setWsViewportcxx . . $ Graphics_setWsViewport(4ffe5bb10b2fb6bd). (pdfGraphics.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), |
| 480 | 0.0, GuiControl_getWidthcxx . . $ GuiControl_getWidth(1227891e76fac374). (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> drawingAreacxx . . $ structDemoEditor#drawingArea.), |
| 481 | 0.0, GuiControl_getHeightcxx . . $ GuiControl_getHeight(1227891e76fac374). (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> drawingAreacxx . . $ structDemoEditor#drawingArea.) |
| 482 | ); |
| 483 | Graphics_playcxx . . $ Graphics_play(381ee972040461e0). (theReferenceToTheOnlyDemoEditorcxx . . $ theReferenceToTheOnlyDemoEditor. -> graphicscxx . . $ structDemoEditor#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), pdfGraphics.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 484 | } |
| 485 | |
| 486 | /* End of file DemoEditor.cpp */ |