Debian Codegraph @

sys/Editor.h

raw symbols SCIP
1 #cxx . . $ `<file>/sys/Editor.h`/ifndef _Editor_h_
2 #define _Editor_h_cxx . . $ `sys/Editor.h:2:9`!
3 /* Editor.h
4 *
5 * Copyright (C) 1992-2020,2022,2023,2025 Paul Boersma
6 *
7 * This code is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or (at
10 * your option) any later version.
11 *
12 * This code is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 * See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this work. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "DataGui.h"cxx . . $ `<file>/sys/DataGui.h`/
22 #include "Collection.h"cxx . . $ `<file>/sys/Collection.h`/
23 #include "Gui.h"cxx . . $ `<file>/sys/Gui.h`/
24 #include "Ui.h"cxx . . $ `<file>/sys/Ui.h`/
25 #include "Graphics.h"cxx . . $ `<file>/sys/Graphics.h`/
26
27 Thing_declarecxx . . $ theClassInfo_Editor. (Editor);
28 Thing_declarecxx . . $ `sys/Thing.h:51:9`! (ScriptEditor);
29
30 Thing_definecxx . . $ classEditorMenu. (EditorMenu, Thing) {
31 Editorcxx . . $ Editor# d_editorcxx . . $ structEditorMenu#d_editor.;
32 autostring32cxx . . $ autostring32# menuTitlecxx . . $ structEditorMenu#menuTitle.;
33 GuiMenucxx . . $ GuiMenu# menuWidgetcxx . . $ structEditorMenu#menuWidget.;
34 OrderedOfcxx . . $ OrderedOf#<structEditorCommandcxx . . $ structEditorCommand#> commandscxx . . $ structEditorMenu#commands.;
35 };
36
37 typedef MelderCallbackcxx . . $ MelderCallback# <void, structDataGuicxx . . $ structDataGui#, EditorCommandcxx . . $ EditorCommand#, UiFormcxx . . $ UiForm#, integercxx . . $ integer# /*narg*/, Stackelcxx . . $ Stackel# /*args*/, conststring32cxx . . $ conststring32#, Interpretercxx . . $ Interpreter#> DataGuiCommandCallbackcxx . . $ DataGuiCommandCallback#;
38 typedef MelderCallbackcxx . . $ MelderCallback# <void, structEditorcxx . . $ structEditor#, EditorCommandcxx . . $ EditorCommand#, UiFormcxx . . $ UiForm#, integercxx . . $ integer# /*narg*/, Stackelcxx . . $ Stackel# /*args*/, conststring32cxx . . $ conststring32#, Interpretercxx . . $ Interpreter#> EditorCommandCallbackcxx . . $ EditorCommandCallback#;
39
40 Thing_definecxx . . $ EditorCommand# (EditorCommand, Thing) {
41 Editorcxx . . $ Editor# d_editorcxx . . $ structEditorCommand#d_editor.;
42 DataGuicxx . . $ DataGui# sendercxx . . $ structEditorCommand#sender.;
43 EditorMenucxx . . $ EditorMenu# menucxx . . $ structEditorCommand#menu.;
44 autostring32cxx . . $ autostring32# itemTitlecxx . . $ structEditorCommand#itemTitle.;
45 GuiMenuItemcxx . . $ GuiMenuItem# itemWidgetcxx . . $ structEditorCommand#itemWidget.;
46 DataGuiCommandCallbackcxx . . $ DataGuiCommandCallback# commandCallbackcxx . . $ structEditorCommand#commandCallback.;
47 autostring32cxx . . $ autostring32# scriptcxx . . $ structEditorCommand#script.;
48 autoUiFormcxx . . $ autoUiForm# d_uiformcxx . . $ structEditorCommand#d_uiform.;
49 };
50
51 typedef MelderCallbackcxx . . $ MelderCallback# <void, structEditorcxx . . $ structEditor#> Editor_DataChangedCallbackcxx . . $ Editor_DataChangedCallback#;
52 typedef MelderCallbackcxx . . $ MelderCallback# <void, structEditorcxx . . $ structEditor#> Editor_DestructionCallbackcxx . . $ Editor_DestructionCallback#;
53
54 typedef MelderCallbackcxx . . $ MelderCallback# <void, structEditorcxx . . $ structEditor#, autoDaatacxx . . $ autoDaata# /* publication */> Editor_PublicationCallbackcxx . . $ Editor_PublicationCallback#;
55
56 Thing_definecxx . . $ autoSomeThing# (Editor, DataGui) {
57 GuiWindowcxx . . $ GuiWindow# windowFormcxx . . $ structEditor#windowForm.;
58 GuiMenuItemcxx . . $ GuiMenuItem# undoButtoncxx . . $ structEditor#undoButton., redoButtoncxx . . $ structEditor#redoButton., clearUndoHistoryButtoncxx . . $ structEditor#clearUndoHistoryButton., searchButtoncxx . . $ structEditor#searchButton.;
59 OrderedOfcxx . . $ OrderedOf#<structEditorMenucxx . . $ structEditorMenu#> menuscxx . . $ structEditor#menus.;
60
61 struct Undocxx . . $ structEditor#Undo# {
62 static constexpr integercxx . . $ integer# MAX_DEPTHcxx . . $ structEditor#Undo#MAX_DEPTH. = 10;
63 autoDaatacxx . . $ autoDaata# datacxx . . $ structEditor#Undo#data. [1+MAX_DEPTHcxx . . $ structEditor#Undo#MAX_DEPTH.]; // the data that can be displayed and edited
64 autostring32cxx . . $ autostring32# descriptioncxx . . $ structEditor#Undo#description. [1+MAX_DEPTHcxx . . $ structEditor#Undo#MAX_DEPTH.];
65 integercxx . . $ integer# positioncxx . . $ structEditor#Undo#position. = 0;
66 } undocxx . . $ structEditor#undo.;
67 virtual autoDaatacxx . . $ autoDaata# v_dataToSaveForUndocxx . . $ structEditor#v_dataToSaveForUndo(3481808043203226). () {
68 return ourcxx . . $ `melder/melder.h:42:9`! datacxx . . $ structDataGui#data(e8441e10bf3a9c6e).() ? Data_copycxx . . $ Data_copy(97a542a26794c80e). (ourcxx . . $ `melder/melder.h:42:9`! datacxx . . $ structDataGui#data(e8441e10bf3a9c6e).()) : autoDaatacxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).();
69 }
70 virtual void v_restoreDataFromUndocxx . . $ structEditor#v_restoreDataFromUndo(fde123624714e72). (Daatacxx . . $ Daata# savedData) {
71 Thing_swapcxx . . $ Thing_swap(3b1e0b93a75a6e5d). (ourcxx . . $ `melder/melder.h:42:9`! datacxx . . $ structDataGui#data(e8441e10bf3a9c6e).(), savedData);
72 }
73
74 Editor_DataChangedCallbackcxx . . $ Editor_DataChangedCallback# d_dataChangedCallbackcxx . . $ structEditor#d_dataChangedCallback.;
75 Editor_DestructionCallbackcxx . . $ Editor_DestructionCallback# d_destructionCallbackcxx . . $ structEditor#d_destructionCallback.;
76 Editor_PublicationCallbackcxx . . $ Editor_PublicationCallback# d_publicationCallbackcxx . . $ structEditor#d_publicationCallback.;
77 autostring32cxx . . $ autostring32# callbackSocketcxx . . $ structEditor#callbackSocket.;
78
79 void v9_destroycxx . . $ structEditor#v9_destroy(ced63f7c635d850d). () noexcept
80 override;
81 void v1_infocxx . . $ structEditor#v1_info(49f6e7a06ebc5aa8). ()
82 override;
83 void v_nameChangedcxx . . $ structEditor#v_nameChanged(49f6e7a06ebc5aa8). ()
84 override; // sets the window and icon titles to reflect the new name
85
86 virtual void v_goAwaycxx . . $ structEditor#v_goAway(49f6e7a06ebc5aa8). () { forget_nozerocxx . . $ `sys/Thing.h:165:9`! (this); }
87 virtual bool v_canFullScreencxx . . $ structEditor#v_canFullScreen(c9857a73d68e59ba). () { return false; }
88 virtual bool v_scriptablecxx . . $ structEditor#v_scriptable(c9857a73d68e59ba). () { return true; }
89
90 virtual bool v_hasMenuBarcxx . . $ structEditor#v_hasMenuBar(c9857a73d68e59ba). () { return true; }
91 virtual bool v_canReportSettingscxx . . $ structEditor#v_canReportSettings(c9857a73d68e59ba). () { return true; }
92 virtual bool v_hasEditMenucxx . . $ structEditor#v_hasEditMenu(c9857a73d68e59ba). () { return true; }
93 virtual bool v_hasPlayMenucxx . . $ structEditor#v_hasPlayMenu(c9857a73d68e59ba). () { return false; }
94 virtual bool v_hasHelpMenucxx . . $ structEditor#v_hasHelpMenu(c9857a73d68e59ba). () { return true; }
95 EditorMenucxx . . $ EditorMenu# fileMenucxx . . $ structEditor#fileMenu., editMenucxx . . $ structEditor#editMenu., queryMenucxx . . $ structEditor#queryMenu., playMenucxx . . $ structEditor#playMenu., helpMenucxx . . $ structEditor#helpMenu.;
96 void v_createMenuscxx . . $ structEditor#v_createMenus(49f6e7a06ebc5aa8). ()
97 override;
98 void v_createMenuItems_editcxx . . $ structEditor#v_createMenuItems_edit(6ea9c8c6ea2f58a9). (EditorMenucxx . . $ EditorMenu# menu)
99 override;
100
101 virtual void v_createChildrencxx . . $ structEditor#v_createChildren(49f6e7a06ebc5aa8). () { }
102
103 virtual void v1_dataChangedcxx . . $ structEditor#v1_dataChanged(c0154a85f79216c7). (Editorcxx . . $ Editor# /* sender */) { }
104
105 #include "Editor_prefs.h"cxx . . $ `<file>/sys/Editor_prefs.h`/
106 };
107
108 GuiMenuItemcxx . . $ GuiMenuItem# DataGuiMenu_addCommandcxx . . $ DataGuiMenu_addCommand(234e92b25f9579fc). (EditorMenucxx . . $ EditorMenu# me, conststring32cxx . . $ conststring32# itemTitle /* cattable */, uint32cxx . . $ uint32# flags,
109 DataGuiCommandCallbackcxx . . $ DataGuiCommandCallback# commandCallback, DataGuicxx . . $ DataGui# sender);
110 GuiMenuItemcxx . . $ GuiMenuItem# EditorMenu_addCommandcxx . . $ EditorMenu_addCommand(b3c50ad5ffa1d58a). (EditorMenucxx . . $ EditorMenu# me, conststring32cxx . . $ conststring32# itemTitle /* cattable */, uint32cxx . . $ uint32# flags,
111 EditorCommandCallbackcxx . . $ EditorCommandCallback# commandCallback);
112 GuiMenuItemcxx . . $ GuiMenuItem# EditorCommand_getItemWidgetcxx . . $ EditorCommand_getItemWidget(f17b5a03364ecd49). (EditorCommandcxx . . $ EditorCommand# me);
113
114 EditorMenucxx . . $ EditorMenu# Editor_addMenucxx . . $ Editor_addMenu(8b39ac34ca8e016f). (Editorcxx . . $ Editor# me, conststring32cxx . . $ conststring32# menuTitle, uint32cxx . . $ uint32# flags);
115 GuiObjectcxx . . $ GuiObject# EditorMenu_getMenuWidgetcxx . . $ EditorMenu_getMenuWidget(eb9e1993761fb43a). (EditorMenucxx . . $ EditorMenu# me);
116
117 GuiMenuItemcxx . . $ GuiMenuItem# Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (Editorcxx . . $ Editor# me, conststring32cxx . . $ conststring32# menuTitle, conststring32cxx . . $ conststring32# itemTitle, uint32cxx . . $ uint32# flags, EditorCommandCallbackcxx . . $ EditorCommandCallback# commandCallback);
118 GuiMenuItemcxx . . $ GuiMenuItem# Editor_addCommandScriptcxx . . $ Editor_addCommandScript(da070d3f88f8d7de). (Editorcxx . . $ Editor# me, conststring32cxx . . $ conststring32# menuTitle, conststring32cxx . . $ conststring32# itemTitle, uint32cxx . . $ uint32# flags,
119 conststring32cxx . . $ conststring32# script);
120 void Editor_setMenuSensitivecxx . . $ Editor_setMenuSensitive(7aff99cae56b3576). (Editorcxx . . $ Editor# me, conststring32cxx . . $ conststring32# menu, bool sensitive);
121
122 inline void Editor_raisecxx . . $ Editor_raise(c0154a85f79216c7). (Editorcxx . . $ Editor# me)
123 /*
124 Message: "move your window to the front", i.e.
125 if you are invisible, then make your window visible at the front;
126 if you are iconized, then deiconize yourself at the front;
127 if you are already visible, just move your window to the front."
128 */
129 {
130 GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! windowFormcxx . . $ structEditor#windowForm.);
131 }
132 inline void Editor_dataChangedcxx . . $ Editor_dataChanged(27010ae97811c311). (Editorcxx . . $ Editor# me, Editorcxx . . $ Editor# sender)
133 /*
134 Message: "your data has changed by an action from inside *or* outside yourself,
135 so you may e.g. like to redraw yourself."
136 */
137 {
138 mycxx . . $ `melder/melder.h:44:9`! v1_dataChangedcxx . . $ structEditor#v1_dataChanged(c0154a85f79216c7). (sender);
139 }
140 inline void Editor_setDataChangedCallbackcxx . . $ Editor_setDataChangedCallback(522aab46cb47898f). (Editorcxx . . $ Editor# me, Editor_DataChangedCallbackcxx . . $ Editor_DataChangedCallback# dataChangedCallback)
141 /*
142 * Message from boss: "notify me by calling this dataChangedCallback every time your data is changed from *inside* yourself."
143 *
144 * In Praat, the dataChangedCallback is useful if there is more than one editor
145 * with the same data; in this case, the owner of all those editors will
146 * (in the dataChangedCallback it installed) notify the change to the other editors
147 * by sending them a dataChanged () message.
148 */
149 {
150 mycxx . . $ `melder/melder.h:44:9`! d_dataChangedCallbackcxx . . $ structEditor#d_dataChangedCallback. =cxx . . $ MelderCallback#`operator=`(5d7f86a920c88647). dataChangedCallback;
151 }
152 inline void Editor_broadcastDataChangedcxx . . $ Editor_broadcastDataChanged(c0154a85f79216c7). (Editorcxx . . $ Editor# me)
153 /*
154 * Message to boss: "my data has changed by an action from inside myself."
155 *
156 * The editor has to call this after every menu command, click or key press that causes a change in the data.
157 */
158 {
159 if (mycxx . . $ `melder/melder.h:44:9`! d_dataChangedCallbackcxx . . $ structEditor#d_dataChangedCallback.)
160 mycxx . . $ `melder/melder.h:44:9`! d_dataChangedCallbackcxx . . $ structEditor#d_dataChangedCallback. (cxx . . $ MelderCallback#`operator()`(e7ade0e2880b4e44).me);
161 }
162 inline void Editor_setDestructionCallbackcxx . . $ Editor_setDestructionCallback(522aab46cb47898f). (Editorcxx . . $ Editor# me, Editor_DestructionCallbackcxx . . $ Editor_DestructionCallback# destructionCallback)
163 /*
164 * Message from observer: "notify me by calling this destructionCallback every time you destroy yourself."
165 *
166 * In Praat, "destroying yourself" typically happens when the user closes the editor window
167 * or when an object that is being viewed in an editor window is "Remove"d.
168 * Typically, the observer will (in the destructionCallback it installed) remove all dangling references to this editor.
169 */
170 {
171 mycxx . . $ `melder/melder.h:44:9`! d_destructionCallbackcxx . . $ structEditor#d_destructionCallback. =cxx . . $ MelderCallback#`operator=`(5d7f86a920c88647). destructionCallback;
172 }
173 inline void Editor_broadcastDestructioncxx . . $ Editor_broadcastDestruction(c0154a85f79216c7). (Editorcxx . . $ Editor# me)
174 /*
175 * Message to boss: "I am destroying all my members and will free myself shortly."
176 *
177 * The editor calls this once, namely in Editor::v9_destroy().
178 */
179 {
180 if (mycxx . . $ `melder/melder.h:44:9`! d_destructionCallbackcxx . . $ structEditor#d_destructionCallback.)
181 mycxx . . $ `melder/melder.h:44:9`! d_destructionCallbackcxx . . $ structEditor#d_destructionCallback. (cxx . . $ MelderCallback#`operator()`(e7ade0e2880b4e44).me);
182 }
183 inline void Editor_setPublicationCallbackcxx . . $ Editor_setPublicationCallback(ce9aea1332569354). (Editorcxx . . $ Editor# me, Editor_PublicationCallbackcxx . . $ Editor_PublicationCallback# publicationCallback)
184 /*
185 * Message from boss: "notify me by calling this publicationCallback every time you have a piece of data to publish."
186 *
187 * In Praat, editors typically "publish" a piece of data when the user chooses
188 * things like "Extract selected sound", "Extract visible pitch curve", or "View spectral slice".
189 * Typically, the boss will (in the publicationCallback it installed) install the published data in Praat's object list,
190 * but the editor doesn't have to know that.
191 */
192 {
193 mycxx . . $ `melder/melder.h:44:9`! d_publicationCallbackcxx . . $ structEditor#d_publicationCallback. =cxx . . $ MelderCallback#`operator=`(8613c5580d737ecd). publicationCallback;
194 }
195 inline void Editor_broadcastPublicationcxx . . $ Editor_broadcastPublication(87bd169f853965ad). (Editorcxx . . $ Editor# me, autoDaatacxx . . $ autoDaata# publication)
196 /*
197 * Message to boss: "I have a piece of data for you to publish."
198 *
199 * The editor has to call this every time the user wants to "publish" ("Extract") some data from the editor.
200 *
201 * Constraint: "publication" has to be new data, either "extracted" or "copied" from data in the editor.
202 * The boss becomes the owner of this published data,
203 * so the call to broadcastPublication() has to transfer ownership of "publication".
204 */
205 {
206 if (mycxx . . $ `melder/melder.h:44:9`! d_publicationCallbackcxx . . $ structEditor#d_publicationCallback.)
207 mycxx . . $ `melder/melder.h:44:9`! d_publicationCallbackcxx . . $ structEditor#d_publicationCallback. (cxx . . $ MelderCallback#`operator()`(e7ade0e2880b4e44).me, publicationcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).());
208 }
209
210 /***** For inheritors. *****/
211
212 void Editor_initcxx . . $ Editor_init(13f379e38ac41ed6). (Editorcxx . . $ Editor# me, int x, int y , int width, int height,
213 conststring32cxx . . $ conststring32# title, Daatacxx . . $ Daata# data);
214 /*
215 This creates my shell and my windowForm,
216 calls the v_createMenus and v_createChildren methods,
217 and manages my shell and my windowForm.
218 'width' and 'height' determine the dimensions of the editor:
219 if 'width' < 0, the width of the screen is added to it;
220 if 'height' < 0, the height of the screeen is added to it;
221 if 'width' is 0, the width is based on the children;
222 if 'height' is 0, the height is base on the children.
223 'x' and 'y' determine the position of the editor:
224 if 'x' > 0, 'x' is the distance to the left edge of the screen;
225 if 'x' < 0, |'x'| is the distance to the right edge of the screen;
226 if 'x' is 0, the editor is horizontally centred on the screen;
227 if 'y' > 0, 'y' is the distance to the top of the screen;
228 if 'y' < 0, |'y'| is the distance to the bottom of the screen;
229 if 'y' is 0, the editor is vertically centred on the screen;
230 This routine does not transfer ownership of '*pData' to the Editor,
231 and the Editor will not destroy 'data' when the Editor itself is destroyed.
232 */
233
234 void Editor_savecxx . . $ Editor_save(ed6f6b1571b749af). (Editorcxx . . $ Editor# me, conststring32cxx . . $ conststring32# cattableText); // for Undo
235
236 autoUiFormcxx . . $ autoUiForm# UiForm_createEcxx . . $ UiForm_createE(4a101de89d32d0cd). (EditorCommandcxx . . $ EditorCommand# cmd, conststring32cxx . . $ conststring32# title, conststring32cxx . . $ conststring32# invokingButtonTitle, conststring32cxx . . $ conststring32# helpTitle);
237 void UiForm_parseStringEcxx . . $ UiForm_parseStringE(9e24d991f2a74a22). (EditorCommandcxx . . $ EditorCommand# cmd, integercxx . . $ integer# narg, Stackelcxx . . $ Stackel# args, conststring32cxx . . $ conststring32# arguments, Interpretercxx . . $ Interpreter# interpreter);
238 autoUiFormcxx . . $ autoUiForm# UiOutfile_createEcxx . . $ UiOutfile_createE(4a101de89d32d0cd). (EditorCommandcxx . . $ EditorCommand# cmd, conststring32cxx . . $ conststring32# title, conststring32cxx . . $ conststring32# invokingButtonTitle, conststring32cxx . . $ conststring32# helpTitle);
239 autoUiFormcxx . . $ autoUiForm# UiInfile_createEcxx . . $ UiInfile_createE(4a101de89d32d0cd). (EditorCommandcxx . . $ EditorCommand# cmd, conststring32cxx . . $ conststring32# title, conststring32cxx . . $ conststring32# invokingButtonTitle, conststring32cxx . . $ conststring32# helpTitle);
240
241 EditorCommandcxx . . $ EditorCommand# Editor_getMenuCommandcxx . . $ Editor_getMenuCommand(6b867f4f43663f0). (Editorcxx . . $ Editor# me, conststring32cxx . . $ conststring32# menuTitle, conststring32cxx . . $ conststring32# itemTitle);
242 void Editor_doMenuCommandcxx . . $ Editor_doMenuCommand(11ddb24ea6d4513). (Editorcxx . . $ Editor# me, conststring32cxx . . $ conststring32# command, integercxx . . $ integer# narg, Stackelcxx . . $ Stackel# args, conststring32cxx . . $ conststring32# arguments, Interpretercxx . . $ Interpreter# interpreter);
243
244 #endif
245 /* End of file Editor.h */