Debian Codegraph @

dwtools/CategoriesEditor.cpp

raw symbols SCIP
1 /* CategoriesEditor.cpp
2 *
3 * Copyright (C) 1993-2019 David Weenink, 2008,2011-2013,2015-2018,2022,2023,2025,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. See the GNU
13 * 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 /*
20 djmw 1995
21 djmw 19980225 repaired a memory leak, caused by wrong inheritance for
22 CategoriesEditorInsert command.
23 djmw 20020408 GPL
24 djmw 20020408 Modified 'createMenus'
25 djmw 20060111 Replaced Resources.h with Preferences.h
26 djmw 20060328 Changed last argument to 0 in XtVaSetValues, XtVaGetValues and XtVaCreateManagedWidget
27 for 64-bit compatibility.
28 djmw 20070620 Latest modification.
29 pb 20080320 split off Help menu
30 pb 20080321 new Editor API
31 djmw 20090107 Removed a bug in update that caused editor to crash on replace
32 djmw 20090203 Removed potential crashes in CategoriesEditor<command>_create.
33 djmw 20110304 Thing_new
34 djmw 20111110 Use autostringvector
35 */
36
37 #include "CategoriesEditor.h"cxx . . $ `<file>/dwtools/CategoriesEditor.h`/
38 #include "EditorM.h"cxx . . $ `<file>/sys/EditorM.h`/
39 #include "NUM2.h"cxx . . $ `<file>/dwsys/NUM2.h`/
40
41 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (CategoriesEditor, Editor, 0);
42
43 static const conststring32cxx . . $ conststring32# CategoriesEditor_EMPTYLABELcxx . . $ CategoriesEditor_EMPTYLABEL. = U"(empty)";
44
45 static void menu_cb_helpcxx . . $ menu_cb_help(f1477a0307b818f9). (CategoriesEditorcxx . . $ CategoriesEditor# /* me */, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) {
46 Melder_helpcxx . . $ Melder_help(ff00d524ab0355ec). (U"CategoriesEditor");
47 }
48
49 #pragma mark - Collection extensions
50
51 /* Preconditions: */
52 /* 1 <= (position [i], newpos) <= size; */
53 /* newpos <= position [1] || newpos >= position [npos] */
54 static void Ordered_moveItemscxx . . $ Ordered_moveItems(55585468ebf7dbb2). (Orderedcxx . . $ Ordered# me, constINTVECcxx . . $ constINTVEC# position, integercxx . . $ integer# newpos) {
55 if (position.sizecxx . . $ constvector#size. < 1)
56 return;
57 const integercxx . . $ integer# min = NUMmin_ecxx . . $ NUMmin_e(ff5c8185b8e92fd6). (positioncxx . . $ constvectorview#constvectorview(fc39adb4395e9baf).), max = NUMmax_ecxx . . $ NUMmax_e(ff5c8185b8e92fd6). (positioncxx . . $ constvectorview#constvectorview(fc39adb4395e9baf).);
58
59 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (min >= 1 && max <= mycxx . . $ `melder/melder.h:44:9`! size && (newpos <= min || newpos >= max));
60
61 autovectorcxx . . $ autovector# <Daatacxx . . $ Daata#> tmp = newvectorzerocxx . . $ newvectorzero(d6d5973469733409). <Daatacxx . . $ Daata#> (position.sizecxx . . $ constvector#size.);
62
63 /*
64 Move some data from `me` into `tmp`, in a different order.
65 */
66 for (integercxx . . $ integer# i = 1; i <= position.sizecxx . . $ constvector#size.; i ++) {
67 tmp [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = (Daatacxx . . $ Daata#) mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).position [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).i]]; // dangle
68 mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).position [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).i]] = nullptr; // undangle
69 }
70
71 // create a contiguous 'hole'
72
73 integercxx . . $ integer# pos;
74 if (newpos <= min) {
75 pos = max;
76 for (integercxx . . $ integer# i = max; i >= newpos; i --) {
77 if (mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i])
78 mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).pos --] = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i];
79 }
80 pos = newpos;
81 } else {
82 pos = min;
83 for (integercxx . . $ integer# i = min; i <= newpos; i ++) {
84 if (mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i])
85 mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).pos ++] = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i];
86 }
87 pos = newpos - position.sizecxx . . $ constvector#size. + 1;
88 }
89
90 // fill the 'hole'
91
92 for (integercxx . . $ integer# i = 1; i <= position.sizecxx . . $ constvector#size.; i ++)
93 mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).pos ++] = tmp [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i];
94 }
95
96 /* Remove the item at position 'from' and insert it at position 'to'. */
97 static void Ordered_moveItemcxx . . $ Ordered_moveItem(c41183f04b8bf394). (Orderedcxx . . $ Ordered# me, integercxx . . $ integer# from, integercxx . . $ integer# to) {
98 if (from < 1 || from > mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size.)
99 from = mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size.;
100
101 if (to < 1 || to > mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size.)
102 to = mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size.;
103
104 if (from == to)
105 return;
106
107 Daatacxx . . $ Daata# tmp = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).from];
108 if (from > to) {
109 for (integercxx . . $ integer# i = from; i > to; i --)
110 mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i] = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i - 1];
111 } else {
112 for (integercxx . . $ integer# i = from; i < to; i ++)
113 mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i] = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i + 1];
114 }
115 mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).to] = tmp;
116 }
117
118 #pragma mark - Widget updates
119
120 static void notifyNumberOfSelectedcxx . . $ notifyNumberOfSelected(c5d7ed0e4fb741fd). (CategoriesEditorcxx . . $ CategoriesEditor# me) {
121 autoINTVECcxx . . $ autoINTVEC# posList = GuiList_getSelectedPositionscxx . . $ GuiList_getSelectedPositions(21bc371a31941fa7). (mycxx . . $ `melder/melder.h:44:9`! listcxx . . $ structCategoriesEditor#list.);
122 if (posList.sizecxx . . $ autovector#size. > 0) {
123 autoMelderStringcxx . . $ autoMelderString# tmpcxx . . $ autoMelderString#autoMelderString(49f6e7a06ebc5aa8).;
124 MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& tmp, posList.sizecxx . . $ autovector#size., U" selection", ( posList.sizecxx . . $ autovector#size. > 1 ? U"s." : U"." ));
125 GuiLabel_setTextcxx . . $ GuiLabel_setText(8fd1a6a47d1f7702). (mycxx . . $ `melder/melder.h:44:9`! outOfViewcxx . . $ structCategoriesEditor#outOfView., tmp.stringcxx . . $ MelderString#string.);
126 } else
127 GuiLabel_setTextcxx . . $ GuiLabel_setText(8fd1a6a47d1f7702). (mycxx . . $ `melder/melder.h:44:9`! outOfViewcxx . . $ structCategoriesEditor#outOfView., U"");
128 }
129
130 static void updateWidgetscxx . . $ updateWidgets(c5d7ed0e4fb741fd). (CategoriesEditorcxx . . $ CategoriesEditor# me) { // all buttons except undo & redo
131 const integercxx . . $ integer# size = mycxx . . $ `melder/melder.h:44:9`! categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).()->sizecxx . . $ CollectionOf#size.;
132
133 autoINTVECcxx . . $ autoINTVEC# posList = GuiList_getSelectedPositionscxx . . $ GuiList_getSelectedPositions(21bc371a31941fa7). (mycxx . . $ `melder/melder.h:44:9`! listcxx . . $ structCategoriesEditor#list.);
134
135 GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (mycxx . . $ `melder/melder.h:44:9`! insertcxx . . $ structCategoriesEditor#insert., ( posList.sizecxx . . $ autovector#size. == 1 ));
136 GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (mycxx . . $ `melder/melder.h:44:9`! insertAtEndcxx . . $ structCategoriesEditor#insertAtEnd., true);
137 GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (mycxx . . $ `melder/melder.h:44:9`! replacecxx . . $ structCategoriesEditor#replace., ( posList.sizecxx . . $ autovector#size. > 0 ));
138
139 const bool removeSensitive = ! (posList.sizecxx . . $ autovector#size. == 1 && size == 1 &&
140 str32equcxx . . $ `melder/melder_str32.h:122:9`! (CategoriesEditor_EMPTYLABELcxx . . $ CategoriesEditor_EMPTYLABEL., mycxx . . $ `melder/melder.h:44:9`! categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).()->atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).1] -> stringcxx . . $ structSimpleString#string..getcxx . . $ _autostring#get(5a2a78a048fb49a8).()));
141 GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (mycxx . . $ `melder/melder.h:44:9`! removecxx . . $ structCategoriesEditor#remove., removeSensitive);
142
143 bool moveUpIsSensitive = false, moveDownIsSensitive = false;
144 if (posList.sizecxx . . $ autovector#size. > 0) {
145 const integercxx . . $ integer# firstPos = posList [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1], lastPos = posList [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).posList.sizecxx . . $ autovector#size.];
146 const bool contiguous = ( lastPos - firstPos + 1 == posList.sizecxx . . $ autovector#size. );
147 moveUpIsSensitive = contiguous && firstPos > 1;
148 moveDownIsSensitive = contiguous && lastPos < size;
149 mycxx . . $ `melder/melder.h:44:9`! positioncxx . . $ structCategoriesEditor#position. = firstPos;
150 }
151 GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (mycxx . . $ `melder/melder.h:44:9`! moveUpcxx . . $ structCategoriesEditor#moveUp., moveUpIsSensitive);
152 GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (mycxx . . $ `melder/melder.h:44:9`! moveDowncxx . . $ structCategoriesEditor#moveDown., moveDownIsSensitive);
153
154 if (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history.) {
155 bool undoIsSensitive = true;
156 conststring32cxx . . $ conststring32# commandName = CommandHistory_commandNamecxx . . $ CommandHistory_commandName(cfbef1f0ff993ce0). (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0);
157 if (! commandName) {
158 GuiButton_setTextcxx . . $ GuiButton_setText(42a3d8c158c8d112). (mycxx . . $ `melder/melder.h:44:9`! undocxx . . $ structCategoriesEditor#undo., U"Cannot undo");
159 undoIsSensitive = false;
160 } else
161 GuiButton_setTextcxx . . $ GuiButton_setText(42a3d8c158c8d112). (mycxx . . $ `melder/melder.h:44:9`! undocxx . . $ structCategoriesEditor#undo., Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (U"Undo ", U"\"", commandName, U"\""));
162 GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (mycxx . . $ `melder/melder.h:44:9`! undocxx . . $ structCategoriesEditor#undo., undoIsSensitive);
163
164 bool redoIsSensitive = true;
165 commandName = CommandHistory_commandNamecxx . . $ CommandHistory_commandName(cfbef1f0ff993ce0). (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1);
166 if (! commandName) {
167 GuiButton_setTextcxx . . $ GuiButton_setText(42a3d8c158c8d112). (mycxx . . $ `melder/melder.h:44:9`! redocxx . . $ structCategoriesEditor#redo., U"Cannot redo");
168 redoIsSensitive = false;
169 } else
170 GuiButton_setTextcxx . . $ GuiButton_setText(42a3d8c158c8d112). (mycxx . . $ `melder/melder.h:44:9`! redocxx . . $ structCategoriesEditor#redo., Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (U"Redo ", U"\"", commandName, U"\""));
171 GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (mycxx . . $ `melder/melder.h:44:9`! redocxx . . $ structCategoriesEditor#redo., redoIsSensitive);
172 }
173 notifyNumberOfSelectedcxx . . $ notifyNumberOfSelected(c5d7ed0e4fb741fd). (me);
174 }
175
176 static void updatecxx . . $ update(706ba9d1593cbba2). (CategoriesEditorcxx . . $ CategoriesEditor# me, integercxx . . $ integer# from, integercxx . . $ integer# to, constINTVECcxx . . $ constINTVEC# select, integercxx . . $ integer# nSelect) {
177 const integercxx . . $ integer# size = mycxx . . $ `melder/melder.h:44:9`! categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).()->sizecxx . . $ CollectionOf#size.;
178
179 if (size == 0) {
180 autoSimpleStringcxx . . $ autoSimpleString# str = SimpleString_createcxx . . $ SimpleString_create(d4d4ea089a1063c6). (CategoriesEditor_EMPTYLABELcxx . . $ CategoriesEditor_EMPTYLABEL.);
181 mycxx . . $ `melder/melder.h:44:9`! categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).() -> addItem_movecxx . . $ CollectionOf#addItem_move(bcc0cff787be24fe). (strcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).());
182 updatecxx . . $ update(706ba9d1593cbba2). (me, 0, 0, select, 0); // was nullptr
183 return;
184 }
185 if (from == 0 && to == 0) {
186 from = 1;
187 to = size;
188 }
189 if (from < 1 || from > size)
190 from = size;
191 if (to < 1 || to > size)
192 to = size;
193 if (from > to) {
194 integercxx . . $ integer# tmp = from;
195 from = to;
196 to = tmp;
197 }
198
199 /*
200 Begin optimization: add the items from a table instead of separately.
201 */
202 try {
203 const integercxx . . $ integer# offset = from - 1, numberOfElements = to - from + 1;
204 autoSTRVECcxx . . $ autoSTRVEC# tablecxx . . $ _autostringautovector#_autostringautovector(1624ee8275b10bda). (numberOfElements);
205 integercxx . . $ integer# itemCount = GuiList_getNumberOfItemscxx . . $ GuiList_getNumberOfItems(699f1c5434bb2ea9). (mycxx . . $ `melder/melder.h:44:9`! listcxx . . $ structCategoriesEditor#list.);
206 for (integercxx . . $ integer# i = from; i <= to; i ++) {
207 SimpleStringcxx . . $ SimpleString# category = mycxx . . $ `melder/melder.h:44:9`! categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).()->atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i];
208 table [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).i - offset] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (i, U" ", category -> stringcxx . . $ structSimpleString#string..getcxx . . $ _autostring#get(5a2a78a048fb49a8).()));
209 }
210 if (itemCount > size) { // have any items been removed from the Categories?
211 for (integercxx . . $ integer# j = itemCount; j > size; j --)
212 GuiList_deleteItemcxx . . $ GuiList_deleteItem(f9b5f8b1da8fd2dd). (mycxx . . $ `melder/melder.h:44:9`! listcxx . . $ structCategoriesEditor#list., j);
213 itemCount = size;
214 }
215 if (to > itemCount) {
216 for (integercxx . . $ integer# j = 1; j <= to - itemCount; j ++)
217 GuiList_insertItemcxx . . $ GuiList_insertItem(896610c612ff86cf). (mycxx . . $ `melder/melder.h:44:9`! listcxx . . $ structCategoriesEditor#list., table [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).itemCount + j - offset].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), 0);
218 }
219 if (from <= itemCount) {
220 const integercxx . . $ integer# n = ( to < itemCount ? to : itemCount );
221 for (integercxx . . $ integer# j = from; j <= n; j ++)
222 GuiList_replaceItemcxx . . $ GuiList_replaceItem(896610c612ff86cf). (mycxx . . $ `melder/melder.h:44:9`! listcxx . . $ structCategoriesEditor#list., table [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).j - offset].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), j);
223 }
224 } catch (MelderErrorcxx . . $ MelderError#) {
225 throw;
226 }
227 /*
228 End of optimization
229 */
230
231 // HIGHLIGHT
232
233 GuiList_deselectAllItemscxx . . $ GuiList_deselectAllItems(bb293b59cc37ad76). (mycxx . . $ `melder/melder.h:44:9`! listcxx . . $ structCategoriesEditor#list.);
234 if (size == 1) { // the only item is always selected
235 SimpleStringcxx . . $ SimpleString# category = mycxx . . $ `melder/melder.h:44:9`! categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).()->atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).1];
236 GuiList_selectItemcxx . . $ GuiList_selectItem(f9b5f8b1da8fd2dd). (mycxx . . $ `melder/melder.h:44:9`! listcxx . . $ structCategoriesEditor#list., 1);
237 updateWidgetscxx . . $ updateWidgets(c5d7ed0e4fb741fd). (me); // instead of "notify". BUG?
238 GuiText_setStringcxx . . $ GuiText_setString(d44acbd60ea2b9be). (mycxx . . $ `melder/melder.h:44:9`! textcxx . . $ structCategoriesEditor#text., category -> stringcxx . . $ structSimpleString#string..getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
239 } else if (nSelect > 0) {
240 /*
241 Select, but postpone highlighting.
242 */
243 for (integercxx . . $ integer# i = 1; i <= nSelect; i ++)
244 GuiList_selectItemcxx . . $ GuiList_selectItem(f9b5f8b1da8fd2dd). (mycxx . . $ `melder/melder.h:44:9`! listcxx . . $ structCategoriesEditor#list., ( select [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).i] > size ? size : select [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).i] ));
245 }
246
247 // VIEWPORT
248
249 {
250 integercxx . . $ integer# top = GuiList_getTopPositioncxx . . $ GuiList_getTopPosition(699f1c5434bb2ea9). (mycxx . . $ `melder/melder.h:44:9`! listcxx . . $ structCategoriesEditor#list.);
251 const integercxx . . $ integer# bottom = GuiList_getBottomPositioncxx . . $ GuiList_getBottomPosition(699f1c5434bb2ea9). (mycxx . . $ `melder/melder.h:44:9`! listcxx . . $ structCategoriesEditor#list.);
252 const integercxx . . $ integer# visible = bottom - top + 1;
253 if (nSelect == 0) {
254 top = mycxx . . $ `melder/melder.h:44:9`! positioncxx . . $ structCategoriesEditor#position. - visible / 2;
255 } else if (select [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).nSelect] < top) {
256 // selection above visible area
257 top = select [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).1];
258 } else if (select [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).1] > bottom) {
259 // selection below visible area
260 top = select [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).nSelect] - visible + 1;
261 } else {
262 integercxx . . $ integer# deltaTopPos = -1, nUpdate = to - from + 1;
263 if ((from == select [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).1] && to == select [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).nSelect]) || // replace
264 (nUpdate > 2 && nSelect == 1)) // insert
265 {
266 deltaTopPos = 0;
267 } else if (nUpdate == nSelect + 1 && select [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).1] == from + 1) { // down
268 deltaTopPos = 1;
269 }
270 top += deltaTopPos;
271 }
272 Melder_clipcxx . . $ Melder_clip(971c667ea412f82c). (1_integercxx . . $ `operator""_integer`(85240eb457c3721a)., & top, size - visible + 1);
273 GuiList_setTopPositioncxx . . $ GuiList_setTopPosition(f9b5f8b1da8fd2dd). (mycxx . . $ `melder/melder.h:44:9`! listcxx . . $ structCategoriesEditor#list., top);
274 }
275 }
276
277 #pragma mark - Commands for Undo and Redo
278
279 Thing_definecxx . . $ `sys/Thing.h:60:9`! (CategoriesEditorCommand, Command) {
280 autoCategoriescxx . . $ autoCategories# categoriescxx . . $ structCategoriesEditorCommand#categories.;
281 autoINTVECcxx . . $ autoINTVEC# selectioncxx . . $ structCategoriesEditorCommand#selection.;
282 integercxx . . $ integer# nSelectedcxx . . $ structCategoriesEditorCommand#nSelected., newPoscxx . . $ structCategoriesEditorCommand#newPos.;
283
284 void v_docxx . . $ structCategoriesEditorCommand#v_do(49f6e7a06ebc5aa8). ()
285 override { };
286 void v_undocxx . . $ structCategoriesEditorCommand#v_undo(49f6e7a06ebc5aa8). ()
287 override { };
288 };
289
290
291 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (CategoriesEditorCommand, Command, 0);
292
293 static void CategoriesEditorCommand_initcxx . . $ CategoriesEditorCommand_init(6214af10614e3a7e). (CategoriesEditorCommandcxx . . $ CategoriesEditorCommand# me, conststring32cxx . . $ conststring32# name, Thingcxx . . $ Thing# boss,
294 integercxx . . $ integer# /*nCategories*/, integercxx . . $ integer# nSelected)
295 {
296 mycxx . . $ `melder/melder.h:44:9`! nSelectedcxx . . $ structCategoriesEditorCommand#nSelected. = nSelected;
297 Command_initcxx . . $ Command_init(47ae7cbabe6d8df8). (me, name, boss);
298 mycxx . . $ `melder/melder.h:44:9`! categoriescxx . . $ structCategoriesEditorCommand#categories. =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Categories_createcxx . . $ Categories_create(8007a1fe88fa0475).();
299 mycxx . . $ `melder/melder.h:44:9`! selectioncxx . . $ structCategoriesEditorCommand#selection. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). zero_INTVECcxx . . $ zero_INTVEC(dab5d3ef28d6a25). (nSelected);
300 }
301
302 #pragma mark Insert
303
304 Thing_definecxx . . $ `sys/Thing.h:60:9`! (CategoriesEditorInsert, CategoriesEditorCommand) {
305 void v_docxx . . $ structCategoriesEditorInsert#v_do(49f6e7a06ebc5aa8). () {
306 CategoriesEditorcxx . . $ CategoriesEditor# editor = static_cast<CategoriesEditorcxx . . $ CategoriesEditor#> (bosscxx . . $ structCommand#boss.);
307 autoSimpleStringcxx . . $ autoSimpleString# str = Data_copycxx . . $ Data_copy(97a542a26794c80e). (categoriescxx . . $ structCategoriesEditorCommand#categories.->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab).atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).1]);
308 editor -> categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).() -> addItemAtPosition_movecxx . . $ OrderedOf#addItemAtPosition_move(ca501a207ce7a6c1). (strcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(), selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]);
309 updatecxx . . $ update(706ba9d1593cbba2). (editor, selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1], 0, selectioncxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), 1);
310 };
311
312 void v_undocxx . . $ structCategoriesEditorInsert#v_undo(49f6e7a06ebc5aa8). () {
313 CategoriesEditorcxx . . $ CategoriesEditor# editor = static_cast<CategoriesEditorcxx . . $ CategoriesEditor#> (bosscxx . . $ structCommand#boss.);
314 editor -> categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).() -> removeItemcxx . . $ CollectionOf#removeItem(1624ee8275b10bda). (selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]);
315 updatecxx . . $ update(706ba9d1593cbba2). (editor, selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1], 0, selectioncxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), 1);
316 };
317 };
318
319 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (CategoriesEditorInsert, CategoriesEditorCommand, 0);
320
321 static autoCategoriesEditorInsertcxx . . $ autoCategoriesEditorInsert# CategoriesEditorInsert_createcxx . . $ CategoriesEditorInsert_create(241987f9091d5dd6). (Thingcxx . . $ Thing# boss, autoSimpleStringcxx . . $ autoSimpleString# str, integercxx . . $ integer# position) {
322 try {
323 autoCategoriesEditorInsertcxx . . $ autoCategoriesEditorInsert# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (CategoriesEditorInsert);
324 CategoriesEditorCommand_initcxx . . $ CategoriesEditorCommand_init(6214af10614e3a7e). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"Insert", boss, 1, 1);
325 mycxx . . $ `melder/melder.h:44:9`! selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1] = position;
326 mycxx . . $ `melder/melder.h:44:9`! categoriescxx . . $ structCategoriesEditorCommand#categories. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). addItem_movecxx . . $ CollectionOf#addItem_move(bcc0cff787be24fe). (strcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).());
327 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
328 } catch (MelderErrorcxx . . $ MelderError#) {
329 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"CategoriesEditorInsert not created.");
330 }
331 }
332
333 #pragma mark Remove
334
335 Thing_definecxx . . $ `sys/Thing.h:60:9`! (CategoriesEditorRemove, CategoriesEditorCommand) {
336 void v_docxx . . $ structCategoriesEditorRemove#v_do(49f6e7a06ebc5aa8). () {
337 CategoriesEditorcxx . . $ CategoriesEditor# editor = static_cast<CategoriesEditorcxx . . $ CategoriesEditor#> (bosscxx . . $ structCommand#boss.);
338 for (integercxx . . $ integer# i = nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.; i >= 1; i--) {
339 autoSimpleStringcxx . . $ autoSimpleString# item = Data_copycxx . . $ Data_copy(97a542a26794c80e). (editor -> categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).()->atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]]); // FIXME this copy can probably be replaced with a move
340 categoriescxx . . $ structCategoriesEditorCommand#categories. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). addItemAtPosition_movecxx . . $ OrderedOf#addItemAtPosition_move(ca501a207ce7a6c1). (itemcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(), 1);
341 editor -> categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).() -> removeItemcxx . . $ CollectionOf#removeItem(1624ee8275b10bda). (selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]);
342 }
343 updatecxx . . $ update(706ba9d1593cbba2). (editor, selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1], 0, selectioncxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), 0); // was nullptr
344 }
345
346 void v_undocxx . . $ structCategoriesEditorRemove#v_undo(49f6e7a06ebc5aa8). () {
347 CategoriesEditorcxx . . $ CategoriesEditor# editor = (CategoriesEditorcxx . . $ CategoriesEditor#) bosscxx . . $ structCommand#boss.;
348 for (integercxx . . $ integer# i = 1; i <= nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.; i ++) {
349 autoSimpleStringcxx . . $ autoSimpleString# item = Data_copycxx . . $ Data_copy(97a542a26794c80e). (categoriescxx . . $ structCategoriesEditorCommand#categories.->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab).atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i]);
350 editor -> categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).() -> addItemAtPosition_movecxx . . $ OrderedOf#addItemAtPosition_move(ca501a207ce7a6c1). (itemcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(), selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]);
351 }
352 updatecxx . . $ update(706ba9d1593cbba2). (editor, selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1], 0, selectioncxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.);
353 }
354 };
355
356 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (CategoriesEditorRemove, CategoriesEditorCommand, 0);
357
358 static autoCategoriesEditorRemovecxx . . $ autoCategoriesEditorRemove# CategoriesEditorRemove_createcxx . . $ CategoriesEditorRemove_create(5d660996344a4ad3). (Thingcxx . . $ Thing# boss, constINTVECcxx . . $ constINTVEC# posList) {
359 try {
360 autoCategoriesEditorRemovecxx . . $ autoCategoriesEditorRemove# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (CategoriesEditorRemove);
361 CategoriesEditorCommand_initcxx . . $ CategoriesEditorCommand_init(6214af10614e3a7e). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"Remove", boss, posList.sizecxx . . $ constvector#size., posList.sizecxx . . $ constvector#size.);
362 mycxx . . $ `melder/melder.h:44:9`! selectioncxx . . $ structCategoriesEditorCommand#selection..allcxx . . $ autovector#all(a26726dad87555bb).() <<=cxx . . $ `operator<<=`(2db3a4bfcf125477). posListcxx . . $ constvectorview#constvectorview(fc39adb4395e9baf).;
363 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
364 } catch (MelderErrorcxx . . $ MelderError#) {
365 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"CategoriesEditorRemove not created.");
366 }
367 }
368
369 #pragma mark Replace
370
371 Thing_definecxx . . $ `sys/Thing.h:60:9`! (CategoriesEditorReplace, CategoriesEditorCommand) {
372 void v_docxx . . $ structCategoriesEditorReplace#v_do(49f6e7a06ebc5aa8). () {
373 CategoriesEditorcxx . . $ CategoriesEditor# editor = static_cast<CategoriesEditorcxx . . $ CategoriesEditor#> (bosscxx . . $ structCommand#boss.);
374 for (integercxx . . $ integer# i = nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.; i >= 1; i --) {
375 /*
376 Swap categories->at [1] with categories->at [my selection [i]] under ambiguous ownership.
377 */
378 autoSimpleStringcxx . . $ autoSimpleString# tmp = Data_copycxx . . $ Data_copy(97a542a26794c80e). (categoriescxx . . $ structCategoriesEditorCommand#categories.->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab).atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).1]);
379 autoSimpleStringcxx . . $ autoSimpleString# othercxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).;
380 other. adoptFromAmbiguousOwnercxx . . $ autoSomeThing#adoptFromAmbiguousOwner(6f97683fca3ece44). (editor -> categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).()->atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]]);
381 categoriescxx . . $ structCategoriesEditorCommand#categories. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). addItemAtPosition_movecxx . . $ OrderedOf#addItemAtPosition_move(ca501a207ce7a6c1). (othercxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(), 2); // YUCK
382 editor -> categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).()->atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]] = tmp.releaseToAmbiguousOwnercxx . . $ autoSomeThing#releaseToAmbiguousOwner(258ee1c9e0a18a5c).();
383 }
384 updatecxx . . $ update(706ba9d1593cbba2). (editor, selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1], selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.], selectioncxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.);
385 }
386
387 void v_undocxx . . $ structCategoriesEditorReplace#v_undo(49f6e7a06ebc5aa8). () {
388 CategoriesEditorcxx . . $ CategoriesEditor# editor = static_cast<CategoriesEditorcxx . . $ CategoriesEditor#> (bosscxx . . $ structCommand#boss.);
389 for (integercxx . . $ integer# i = 1; i <= nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.; i ++) {
390 autoSimpleStringcxx . . $ autoSimpleString# str = Data_copycxx . . $ Data_copy(97a542a26794c80e). (categoriescxx . . $ structCategoriesEditorCommand#categories.->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab).atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i + 1]);
391 editor -> categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).() -> replaceItem_movecxx . . $ CollectionOf#replaceItem_move(ca501a207ce7a6c1). (strcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(), selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]);
392 }
393 updatecxx . . $ update(706ba9d1593cbba2). (editor, selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1], selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.], selectioncxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.);
394 }
395 };
396
397 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (CategoriesEditorReplace, CategoriesEditorCommand, 0);
398
399 static autoCategoriesEditorReplacecxx . . $ autoCategoriesEditorReplace# CategoriesEditorReplace_createcxx . . $ CategoriesEditorReplace_create(481fd28ac5e41d57). (Thingcxx . . $ Thing# boss, autoSimpleStringcxx . . $ autoSimpleString# str, constINTVECcxx . . $ constINTVEC# posList) {
400 try {
401 autoCategoriesEditorReplacecxx . . $ autoCategoriesEditorReplace# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (CategoriesEditorReplace);
402 CategoriesEditorCommand_initcxx . . $ CategoriesEditorCommand_init(6214af10614e3a7e). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"Replace", boss, posList.sizecxx . . $ constvector#size. + 1, posList.sizecxx . . $ constvector#size.);
403 mycxx . . $ `melder/melder.h:44:9`! selectioncxx . . $ structCategoriesEditorCommand#selection..allcxx . . $ autovector#all(a26726dad87555bb).() <<=cxx . . $ `operator<<=`(2db3a4bfcf125477). posListcxx . . $ constvectorview#constvectorview(fc39adb4395e9baf).;
404 mycxx . . $ `melder/melder.h:44:9`! categoriescxx . . $ structCategoriesEditorCommand#categories. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). addItem_movecxx . . $ CollectionOf#addItem_move(bcc0cff787be24fe). (strcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).());
405 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
406 } catch (MelderErrorcxx . . $ MelderError#) {
407 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"CategoriesEditorReplace not created.");
408 }
409 }
410
411 #pragma mark MoveUp
412
413 Thing_definecxx . . $ `sys/Thing.h:60:9`! (CategoriesEditorMoveUp, CategoriesEditorCommand) {
414 void v_docxx . . $ structCategoriesEditorMoveUp#v_do(49f6e7a06ebc5aa8). () {
415 CategoriesEditorcxx . . $ CategoriesEditor# editor = static_cast<CategoriesEditorcxx . . $ CategoriesEditor#> (bosscxx . . $ structCommand#boss.);
416 Ordered_moveItemscxx . . $ Ordered_moveItems(55585468ebf7dbb2). ((Orderedcxx . . $ Ordered#) editor -> categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).(), selectioncxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), newPoscxx . . $ structCategoriesEditorCommand#newPos.); // FIXME cast
417 autoINTVECcxx . . $ autoINTVEC# selectionUpdate = raw_INTVECcxx . . $ raw_INTVEC(dab5d3ef28d6a25). (nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.);
418 for (integercxx . . $ integer# i = 1; i <= nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.; i ++)
419 selectionUpdate [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = newPoscxx . . $ structCategoriesEditorCommand#newPos. + i - 1;
420 updatecxx . . $ update(706ba9d1593cbba2). (editor, newPoscxx . . $ structCategoriesEditorCommand#newPos., selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.], selectionUpdatecxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.);
421 }
422
423 void v_undocxx . . $ structCategoriesEditorMoveUp#v_undo(49f6e7a06ebc5aa8). () {
424 CategoriesEditorcxx . . $ CategoriesEditor# editor = static_cast<CategoriesEditorcxx . . $ CategoriesEditor#> (bosscxx . . $ structCommand#boss.);
425 for (integercxx . . $ integer# i = 1; i <= nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.; i ++)
426 Ordered_moveItemcxx . . $ Ordered_moveItem(c41183f04b8bf394). ((Orderedcxx . . $ Ordered#) editor -> categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).(), newPoscxx . . $ structCategoriesEditorCommand#newPos., selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.]); // FIXME cast
427 updatecxx . . $ update(706ba9d1593cbba2). (editor, newPoscxx . . $ structCategoriesEditorCommand#newPos., selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.], selectioncxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.);
428 }
429 };
430
431 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (CategoriesEditorMoveUp, CategoriesEditorCommand, 0);
432
433 static autoCategoriesEditorMoveUpcxx . . $ autoCategoriesEditorMoveUp# CategoriesEditorMoveUp_createcxx . . $ CategoriesEditorMoveUp_create(32f1754b08d809d0). (Thingcxx . . $ Thing# boss, constINTVECcxx . . $ constINTVEC# posList, integercxx . . $ integer# newPos) {
434 try {
435 autoCategoriesEditorMoveUpcxx . . $ autoCategoriesEditorMoveUp# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (CategoriesEditorMoveUp);
436 CategoriesEditorCommand_initcxx . . $ CategoriesEditorCommand_init(6214af10614e3a7e). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"Move up", boss, 0, posList.sizecxx . . $ constvector#size.);
437 mycxx . . $ `melder/melder.h:44:9`! selectioncxx . . $ structCategoriesEditorCommand#selection..allcxx . . $ autovector#all(a26726dad87555bb).() <<=cxx . . $ `operator<<=`(2db3a4bfcf125477). posListcxx . . $ constvectorview#constvectorview(fc39adb4395e9baf).;
438 mycxx . . $ `melder/melder.h:44:9`! newPoscxx . . $ structCategoriesEditorCommand#newPos. = newPos;
439 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
440 } catch (MelderErrorcxx . . $ MelderError#) {
441 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"CategoriesEditorMoveUp not created.");
442 }
443 }
444
445 #pragma mark MoveDown
446
447 Thing_definecxx . . $ `sys/Thing.h:60:9`! (CategoriesEditorMoveDown, CategoriesEditorCommand) {
448
449 void v_docxx . . $ structCategoriesEditorMoveDown#v_do(49f6e7a06ebc5aa8). () {
450 CategoriesEditorcxx . . $ CategoriesEditor# editor = static_cast<CategoriesEditorcxx . . $ CategoriesEditor#> (bosscxx . . $ structCommand#boss.);
451 Ordered_moveItemscxx . . $ Ordered_moveItems(55585468ebf7dbb2). ((Orderedcxx . . $ Ordered#) editor -> categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).(), selectioncxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), newPoscxx . . $ structCategoriesEditorCommand#newPos.); // FIXME cast
452 autoINTVECcxx . . $ autoINTVEC# selectionUpdate = raw_INTVECcxx . . $ raw_INTVEC(dab5d3ef28d6a25). (nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.);
453 for (integercxx . . $ integer# i = 1; i <= nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.; i ++)
454 selectionUpdate [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = newPoscxx . . $ structCategoriesEditorCommand#newPos. - nSelectedcxx . . $ structCategoriesEditorCommand#nSelected. + i;
455 updatecxx . . $ update(706ba9d1593cbba2). (editor, selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1], newPoscxx . . $ structCategoriesEditorCommand#newPos., selectionUpdatecxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.);
456 }
457
458 void v_undocxx . . $ structCategoriesEditorMoveDown#v_undo(49f6e7a06ebc5aa8). () {
459 CategoriesEditorcxx . . $ CategoriesEditor# editor = static_cast<CategoriesEditorcxx . . $ CategoriesEditor#> (bosscxx . . $ structCommand#boss.);
460 for (integercxx . . $ integer# i = 1; i <= nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.; i ++)
461 Ordered_moveItemcxx . . $ Ordered_moveItem(c41183f04b8bf394). ((Orderedcxx . . $ Ordered#) editor -> categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).(), newPoscxx . . $ structCategoriesEditorCommand#newPos., selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1]); // TODO 1 or i ?? // FIXME cast
462 integercxx . . $ integer# from = selectioncxx . . $ structCategoriesEditorCommand#selection. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1];
463 updatecxx . . $ update(706ba9d1593cbba2). (editor, ( from > 1 ? from -- : from ), newPoscxx . . $ structCategoriesEditorCommand#newPos., selectioncxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), nSelectedcxx . . $ structCategoriesEditorCommand#nSelected.);
464 }
465 };
466
467 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (CategoriesEditorMoveDown, CategoriesEditorCommand, 0);
468
469 static autoCategoriesEditorMoveDowncxx . . $ autoCategoriesEditorMoveDown# CategoriesEditorMoveDown_createcxx . . $ CategoriesEditorMoveDown_create(504b85ebf384e4cf). (Thingcxx . . $ Thing# boss, constINTVECcxx . . $ constINTVEC# posList, integercxx . . $ integer# newPos) {
470 try {
471 autoCategoriesEditorMoveDowncxx . . $ autoCategoriesEditorMoveDown# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (CategoriesEditorMoveDown);
472 CategoriesEditorCommand_initcxx . . $ CategoriesEditorCommand_init(6214af10614e3a7e). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"Move down", boss, 0, posList.sizecxx . . $ constvector#size.);
473 mycxx . . $ `melder/melder.h:44:9`! selectioncxx . . $ structCategoriesEditorCommand#selection..allcxx . . $ autovector#all(a26726dad87555bb).() <<=cxx . . $ `operator<<=`(2db3a4bfcf125477). posListcxx . . $ constvectorview#constvectorview(fc39adb4395e9baf).;
474 mycxx . . $ `melder/melder.h:44:9`! newPoscxx . . $ structCategoriesEditorCommand#newPos. = newPos;
475 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
476 } catch (MelderErrorcxx . . $ MelderError#) {
477 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"CategoriesEditorMoveDown not created.");
478 }
479 }
480
481 #pragma mark - Callbacks
482
483 static void gui_button_cb_removecxx . . $ gui_button_cb_remove(9d7ffd49a7356ee9). (CategoriesEditorcxx . . $ CategoriesEditor# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) {
484 autoINTVECcxx . . $ autoINTVEC# posList = GuiList_getSelectedPositionscxx . . $ GuiList_getSelectedPositions(21bc371a31941fa7). (mycxx . . $ `melder/melder.h:44:9`! listcxx . . $ structCategoriesEditor#list.);
485 if (posList.sizecxx . . $ autovector#size. > 0) {
486 autoCategoriesEditorRemovecxx . . $ autoCategoriesEditorRemove# command = CategoriesEditorRemove_createcxx . . $ CategoriesEditorRemove_create(5d660996344a4ad3). (me, posListcxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).());
487 command ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). v_docxx . . $ structCategoriesEditorRemove#v_do(49f6e7a06ebc5aa8). ();
488 if (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history.)
489 CommandHistory_insertItem_movecxx . . $ CommandHistory_insertItem_move(e8345a325df32818). (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), commandcxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).());
490 updateWidgetscxx . . $ updateWidgets(c5d7ed0e4fb741fd). (me);
491 }
492 }
493
494 static void insertcxx . . $ insert(c1edf1b74ab9cffd). (CategoriesEditorcxx . . $ CategoriesEditor# me, integercxx . . $ integer# position) {
495 autostring32cxx . . $ autostring32# text = GuiText_getStringcxx . . $ GuiText_getString(9a61f82c13ba8ebc). (mycxx . . $ `melder/melder.h:44:9`! textcxx . . $ structCategoriesEditor#text.);
496 if (text && text [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).0] != U'\0') {
497 autoSimpleStringcxx . . $ autoSimpleString# str = SimpleString_createcxx . . $ SimpleString_create(d4d4ea089a1063c6). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
498 autoCategoriesEditorInsertcxx . . $ autoCategoriesEditorInsert# command = CategoriesEditorInsert_createcxx . . $ CategoriesEditorInsert_create(241987f9091d5dd6). (me, strcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(), position);
499 command ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). v_docxx . . $ structCategoriesEditorInsert#v_do(49f6e7a06ebc5aa8). ();
500 if (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history.)
501 CommandHistory_insertItem_movecxx . . $ CommandHistory_insertItem_move(e8345a325df32818). (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), commandcxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).());
502 updateWidgetscxx . . $ updateWidgets(c5d7ed0e4fb741fd). (me);
503 }
504 }
505
506 static void gui_button_cb_insertcxx . . $ gui_button_cb_insert(9d7ffd49a7356ee9). (CategoriesEditorcxx . . $ CategoriesEditor# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) {
507 insertcxx . . $ insert(c1edf1b74ab9cffd). (me, mycxx . . $ `melder/melder.h:44:9`! positioncxx . . $ structCategoriesEditor#position.);
508 }
509
510 static void gui_button_cb_insertAtEndcxx . . $ gui_button_cb_insertAtEnd(9d7ffd49a7356ee9). (CategoriesEditorcxx . . $ CategoriesEditor# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) {
511 insertcxx . . $ insert(c1edf1b74ab9cffd). (me, mycxx . . $ `melder/melder.h:44:9`! categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).()->sizecxx . . $ CollectionOf#size. + 1);
512 mycxx . . $ `melder/melder.h:44:9`! positioncxx . . $ structCategoriesEditor#position. = mycxx . . $ `melder/melder.h:44:9`! categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).()->sizecxx . . $ CollectionOf#size.;
513 }
514
515 static void gui_button_cb_replacecxx . . $ gui_button_cb_replace(9d7ffd49a7356ee9). (CategoriesEditorcxx . . $ CategoriesEditor# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) {
516 autoINTVECcxx . . $ autoINTVEC# posList = GuiList_getSelectedPositionscxx . . $ GuiList_getSelectedPositions(21bc371a31941fa7). (mycxx . . $ `melder/melder.h:44:9`! listcxx . . $ structCategoriesEditor#list.);
517 if (posList.sizecxx . . $ autovector#size. > 0) {
518 autostring32cxx . . $ autostring32# text = GuiText_getStringcxx . . $ GuiText_getString(9a61f82c13ba8ebc). (mycxx . . $ `melder/melder.h:44:9`! textcxx . . $ structCategoriesEditor#text.);
519 if (text && text [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).0] != U'\0') {
520 autoSimpleStringcxx . . $ autoSimpleString# str = SimpleString_createcxx . . $ SimpleString_create(d4d4ea089a1063c6). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
521 autoCategoriesEditorReplacecxx . . $ autoCategoriesEditorReplace# command = CategoriesEditorReplace_createcxx . . $ CategoriesEditorReplace_create(481fd28ac5e41d57). (me, strcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(), posListcxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).());
522 command ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). v_docxx . . $ structCategoriesEditorReplace#v_do(49f6e7a06ebc5aa8). ();
523 if (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history.)
524 CommandHistory_insertItem_movecxx . . $ CommandHistory_insertItem_move(e8345a325df32818). (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), commandcxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).());
525 updateWidgetscxx . . $ updateWidgets(c5d7ed0e4fb741fd). (me);
526 }
527 }
528 }
529
530 /* Precondition: contiguous selection */
531 static void gui_button_cb_moveUpcxx . . $ gui_button_cb_moveUp(9d7ffd49a7356ee9). (CategoriesEditorcxx . . $ CategoriesEditor# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) {
532 autoINTVECcxx . . $ autoINTVEC# posList = GuiList_getSelectedPositionscxx . . $ GuiList_getSelectedPositions(21bc371a31941fa7). (mycxx . . $ `melder/melder.h:44:9`! listcxx . . $ structCategoriesEditor#list.);
533 if (posList.sizecxx . . $ autovector#size. > 0) {
534 autoCategoriesEditorMoveUpcxx . . $ autoCategoriesEditorMoveUp# command = CategoriesEditorMoveUp_createcxx . . $ CategoriesEditorMoveUp_create(32f1754b08d809d0). (me, posListcxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), posList [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1] - 1);
535 command ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). v_docxx . . $ structCategoriesEditorMoveUp#v_do(49f6e7a06ebc5aa8). ();
536 if (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history.)
537 CommandHistory_insertItem_movecxx . . $ CommandHistory_insertItem_move(e8345a325df32818). (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), commandcxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).());
538 updateWidgetscxx . . $ updateWidgets(c5d7ed0e4fb741fd). (me);
539 }
540 }
541
542 /* Precondition: contiguous selection */
543 static void gui_button_cb_moveDowncxx . . $ gui_button_cb_moveDown(9d7ffd49a7356ee9). (CategoriesEditorcxx . . $ CategoriesEditor# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) {
544 autoINTVECcxx . . $ autoINTVEC# posList = GuiList_getSelectedPositionscxx . . $ GuiList_getSelectedPositions(21bc371a31941fa7). (mycxx . . $ `melder/melder.h:44:9`! listcxx . . $ structCategoriesEditor#list.);
545 if (posList.sizecxx . . $ autovector#size. > 0) {
546 autoCategoriesEditorMoveDowncxx . . $ autoCategoriesEditorMoveDown# command = CategoriesEditorMoveDown_createcxx . . $ CategoriesEditorMoveDown_create(504b85ebf384e4cf). (me, posListcxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), posList [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).posList.sizecxx . . $ autovector#size.] + 1);
547 command ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). v_docxx . . $ structCategoriesEditorMoveDown#v_do(49f6e7a06ebc5aa8). ();
548 if (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history.)
549 CommandHistory_insertItem_movecxx . . $ CommandHistory_insertItem_move(e8345a325df32818). (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), commandcxx . . $ autoSomeThing#autoSomeThing(327dc2ad7b4df21)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).());
550 updateWidgetscxx . . $ updateWidgets(c5d7ed0e4fb741fd). (me);
551 }
552 }
553
554 static void gui_list_cb_selectionChangedcxx . . $ gui_list_cb_selectionChanged(3beaef7b55204319). (CategoriesEditorcxx . . $ CategoriesEditor# me, GuiList_SelectionChangedEventcxx . . $ GuiList_SelectionChangedEvent# /* event */) {
555 updateWidgetscxx . . $ updateWidgets(c5d7ed0e4fb741fd). (me);
556 }
557
558 static void gui_list_cb_doubleClickcxx . . $ gui_list_cb_doubleClick(890e08bf213a3272). (CategoriesEditorcxx . . $ CategoriesEditor# me, GuiList_DoubleClickEventcxx . . $ GuiList_DoubleClickEvent# event) {
559 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (event -> list == mycxx . . $ `melder/melder.h:44:9`! list);
560 // `my position` should just have been updated by the selectionChanged callback.
561
562 autoINTVECcxx . . $ autoINTVEC# posList = GuiList_getSelectedPositionscxx . . $ GuiList_getSelectedPositions(21bc371a31941fa7). (mycxx . . $ `melder/melder.h:44:9`! listcxx . . $ structCategoriesEditor#list.);
563 if (posList.sizecxx . . $ autovector#size. == 1 // often or even usually true when double-clicking?
564 && posList [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1] == mycxx . . $ `melder/melder.h:44:9`! positioncxx . . $ structCategoriesEditor#position.) // should be true, but we don't crash if it's false
565 {
566 SimpleStringcxx . . $ SimpleString# category = mycxx . . $ `melder/melder.h:44:9`! categoriescxx . . $ structCategoriesEditor#categories(d04e2de384520ed7).()->atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).mycxx . . $ `melder/melder.h:44:9`! positioncxx . . $ structCategoriesEditor#position.];
567 GuiText_setStringcxx . . $ GuiText_setString(d44acbd60ea2b9be). (mycxx . . $ `melder/melder.h:44:9`! textcxx . . $ structCategoriesEditor#text., ( category -> stringcxx . . $ structSimpleString#string. ? category -> stringcxx . . $ structSimpleString#string..getcxx . . $ _autostring#get(5a2a78a048fb49a8).() : U"" ));
568 }
569 }
570
571 static void gui_list_cb_scrollcxx . . $ gui_list_cb_scroll(5059ec987a82bc43). (CategoriesEditorcxx . . $ CategoriesEditor# me, GuiList_ScrollEventcxx . . $ GuiList_ScrollEvent# /* event */) {
572 notifyNumberOfSelectedcxx . . $ notifyNumberOfSelected(c5d7ed0e4fb741fd). (me);
573 }
574
575 static void gui_button_cb_undocxx . . $ gui_button_cb_undo(9d7ffd49a7356ee9). (CategoriesEditorcxx . . $ CategoriesEditor# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) {
576 if (CommandHistory_isOffleftcxx . . $ CommandHistory_isOffleft(1e1e8785c23ca14b). (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()))
577 return;
578 Commandcxx . . $ Command# command = CommandHistory_getItemcxx . . $ CommandHistory_getItem(af102feab7dfa2d0). (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
579 command -> v_undocxx . . $ structCommand#v_undo(49f6e7a06ebc5aa8). ();
580 CommandHistory_backcxx . . $ CommandHistory_back(7258301033e2d904). (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
581 updateWidgetscxx . . $ updateWidgets(c5d7ed0e4fb741fd). (me);
582 }
583
584 static void gui_button_cb_redocxx . . $ gui_button_cb_redo(9d7ffd49a7356ee9). (CategoriesEditorcxx . . $ CategoriesEditor# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) {
585 CommandHistory_forthcxx . . $ CommandHistory_forth(7258301033e2d904). (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
586 if (CommandHistory_isOffrightcxx . . $ CommandHistory_isOffright(1e1e8785c23ca14b). (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()))
587 return;
588 Commandcxx . . $ Command# command = CommandHistory_getItemcxx . . $ CommandHistory_getItem(af102feab7dfa2d0). (mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
589 command -> v_docxx . . $ structCommand#v_do(49f6e7a06ebc5aa8). ();
590 updateWidgetscxx . . $ updateWidgets(c5d7ed0e4fb741fd). (me);
591 }
592
593 #pragma mark - Editor methods
594
595 void structCategoriesEditorcxx . . $ structCategoriesEditor# :: v_createMenuItems_helpcxx . . $ structCategoriesEditor#v_createMenuItems_help(6ea9c8c6ea2f58a9). (EditorMenucxx . . $ EditorMenu# menu) {
596 CategoriesEditor_Parentcxx . . $ CategoriesEditor_Parent# :: v_createMenuItems_helpcxx . . $ structDataGui#v_createMenuItems_help(6ea9c8c6ea2f58a9). (menu);
597 EditorMenu_addCommandcxx . . $ EditorMenu_addCommand(b3c50ad5ffa1d58a). (menu, U"CategoriesEditor help", '?', menu_cb_helpcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).);
598 }
599
600 // origin is at top left.
601 void structCategoriesEditorcxx . . $ structCategoriesEditor# :: v_createChildrencxx . . $ structCategoriesEditor#v_createChildren(49f6e7a06ebc5aa8). () {
602 constexpr int menuBarOffset { 40 };
603 constexpr int button_width { 130 }, button_height { menuBarOffset }, list_width { 260 }, list_height { 420 };
604 constexpr int delta_x { 15 }, delta_y { menuBarOffset / 2 }, text_button_height { button_height / 2 };
605
606 int left = 5, right = left + button_width, top = 3 + menuBarOffset, bottom = top + text_button_height;
607 GuiLabel_createShowncxx . . $ GuiLabel_createShown(39026c9008a6a07). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., left, right, top, bottom, U"Positions:", 0);
608 left = right + delta_x ;
609 right = left + button_width;
610 GuiLabel_createShowncxx . . $ GuiLabel_createShown(39026c9008a6a07). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., left, right, top, bottom, U"Values:", 0);
611
612 left = 0;
613 right = left + list_width;
614 // int buttons_top = (top = bottom + delta_y);
615 int list_bottom = bottom = top + list_height;
616 listcxx . . $ structCategoriesEditor#list. = GuiList_createcxx . . $ GuiList_create(88aee17cb4a88a62). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., left, right, top, bottom, true, 0);
617 GuiList_setSelectionChangedCallbackcxx . . $ GuiList_setSelectionChangedCallback(4a4684c95b017ef2). (listcxx . . $ structCategoriesEditor#list., gui_list_cb_selectionChangedcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this);
618 GuiList_setDoubleClickCallbackcxx . . $ GuiList_setDoubleClickCallback(1ef636283ce6f16). (listcxx . . $ structCategoriesEditor#list., gui_list_cb_doubleClickcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this);
619 GuiList_setScrollCallbackcxx . . $ GuiList_setScrollCallback(89a218c210a2f369). (listcxx . . $ structCategoriesEditor#list., gui_list_cb_scrollcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this);
620 GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (listcxx . . $ structCategoriesEditor#list.);
621
622 int buttons_left = left = right + 2 * delta_x;
623 right = left + button_width;
624 bottom = top + button_height;
625 GuiLabel_createShowncxx . . $ GuiLabel_createShown(39026c9008a6a07). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., left, right, top, bottom, U"Value:", 0);
626 left = right + delta_x;
627 right = left + button_width;
628 textcxx . . $ structCategoriesEditor#text. = GuiText_createShowncxx . . $ GuiText_createShown(8bcb1f2be7fc31ee). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., left, right, top, bottom, 0);
629 GuiText_setStringcxx . . $ GuiText_setString(d44acbd60ea2b9be). (textcxx . . $ structCategoriesEditor#text., CategoriesEditor_EMPTYLABELcxx . . $ CategoriesEditor_EMPTYLABEL.);
630
631 left = buttons_left;
632 right = left + button_width;
633 top = bottom + delta_y;
634 bottom = top + button_height;
635 insertcxx . . $ structCategoriesEditor#insert. = GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., left, right, top, bottom, U"Insert", gui_button_cb_insertcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, GuiButton_DEFAULTcxx . . $ `sys/Gui.h:467:9`!);
636 left = right + delta_x;
637 right = left + button_width;
638 replacecxx . . $ structCategoriesEditor#replace. = GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., left, right, top, bottom, U"Replace", gui_button_cb_replacecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0);
639 left = buttons_left;
640 right = left + int (1.5 * button_width);
641 top = bottom + delta_y;
642 bottom = top + button_height;
643 insertAtEndcxx . . $ structCategoriesEditor#insertAtEnd. = GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., left, right, top, bottom, U"Insert at end", gui_button_cb_insertAtEndcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0);
644 top = bottom + delta_y;
645 bottom = top + button_height;
646 undocxx . . $ structCategoriesEditor#undo. = GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., left, right, top, bottom, U"Undo", gui_button_cb_undocxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0);
647 top = bottom + delta_y;
648 bottom = top + button_height;
649 redocxx . . $ structCategoriesEditor#redo. = GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., left, right, top, bottom, U"Redo", gui_button_cb_redocxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0);
650 top = bottom + delta_y;
651 bottom = top + button_height;
652 removecxx . . $ structCategoriesEditor#remove. = GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., left, right, top, bottom, U"Remove", gui_button_cb_removecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0);
653 top = bottom + delta_y;
654 bottom = top + button_height;
655 moveUpcxx . . $ structCategoriesEditor#moveUp. = GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., left, right, top, bottom, U"Move selection up", gui_button_cb_moveUpcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0);
656 top = bottom + delta_y;
657 bottom = top + button_height;
658 moveDowncxx . . $ structCategoriesEditor#moveDown. = GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., left, right, top, bottom, U"Move selection down", gui_button_cb_moveDowncxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0);
659
660 top = list_bottom + delta_y;
661 bottom = top + button_height;
662 left = 5;
663 right = left + 200;
664 outOfViewcxx . . $ structCategoriesEditor#outOfView. = GuiLabel_createShowncxx . . $ GuiLabel_createShown(39026c9008a6a07). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., left, right, top, bottom, U"", 0);
665 }
666
667 void structCategoriesEditorcxx . . $ structCategoriesEditor# :: v1_dataChangedcxx . . $ structCategoriesEditor#v1_dataChanged(c0154a85f79216c7). (Editorcxx . . $ Editor# /* sender */) {
668 autoINTVECcxx . . $ autoINTVEC# selectcxx . . $ autovector#autovector(49f6e7a06ebc5aa8).;
669 updatecxx . . $ update(706ba9d1593cbba2). (this, 0, 0, selectcxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), 0);
670 updateWidgetscxx . . $ updateWidgets(c5d7ed0e4fb741fd). (this);
671 }
672
673 #pragma mark -
674
675 autoCategoriesEditorcxx . . $ autoCategoriesEditor# CategoriesEditor_createcxx . . $ CategoriesEditor_create(c86200ba448394fd). (conststring32cxx . . $ conststring32# title, Categoriescxx . . $ Categories# categories) {
676 try {
677 autoCategoriesEditorcxx . . $ autoCategoriesEditor# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (CategoriesEditor);
678 Editor_initcxx . . $ Editor_init(13f379e38ac41ed6). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 20, 40, 600, 600, title, categories);
679 mycxx . . $ `melder/melder.h:44:9`! historycxx . . $ structCategoriesEditor#history. =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). CommandHistory_createcxx . . $ CommandHistory_create(8cfba7284879d337). ();
680 autoINTVECcxx . . $ autoINTVEC# selectcxx . . $ autovector#autovector(49f6e7a06ebc5aa8).;
681 updatecxx . . $ update(706ba9d1593cbba2). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0, 0, selectcxx . . $ constvector#constvector(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), 0);
682 updateWidgetscxx . . $ updateWidgets(c5d7ed0e4fb741fd). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
683 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
684 } catch (MelderErrorcxx . . $ MelderError#) {
685 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Categories window not created.");
686 }
687 }
688
689 /* End of file CategoriesEditor.cpp */