| 1 | /* DataEditor.cpp |
| 2 | * |
| 3 | * Copyright (C) 1995-2022 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 2 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 | #define NAME_Xcxx . . $ `sys/DataEditor.cpp:19:9`! 30 |
| 20 | #define TEXT_Xcxx . . $ `sys/DataEditor.cpp:20:9`! 250 |
| 21 | #define BUTTON_Xcxx . . $ `sys/DataEditor.cpp:21:9`! 250 |
| 22 | #define LIST_Ycxx . . $ `sys/DataEditor.cpp:22:9`! (2 * Gui_TOP_DIALOG_SPACINGcxx . . $ `sys/Gui.h:90:10`! + Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!) |
| 23 | #define EDITOR_WIDTHcxx . . $ `sys/DataEditor.cpp:23:9`! 820 |
| 24 | #define EDITOR_HEIGHTcxx . . $ `sys/DataEditor.cpp:24:9`! (Machine_getMenuBarBottom () + LIST_Ycxx . . $ `sys/DataEditor.cpp:22:9`! + kDataSubEditor_MAXNUM_ROWScxx . . $ `sys/DataEditor.h:42:9`! * ROW_HEIGHTcxx . . $ `sys/DataEditor.cpp:25:9`! + 29) |
| 25 | #define ROW_HEIGHTcxx . . $ `sys/DataEditor.cpp:25:9`! 31 |
| 26 | |
| 27 | #define SCROLL_BAR_WIDTHcxx . . $ `sys/DataEditor.cpp:27:9`! Machine_getScrollBarWidth () |
| 28 | |
| 29 | #include "DataEditor.h"cxx . . $ `<file>/sys/DataEditor.h`/ |
| 30 | #include "EditorM.h"cxx . . $ `<file>/sys/EditorM.h`/ |
| 31 | #include "Collection.h"cxx . . $ `<file>/sys/Collection.h`/ |
| 32 | #include "machine.h"cxx . . $ `<file>/sys/machine.h`/ |
| 33 | |
| 34 | static Data_Descriptioncxx . . $ Data_Description# Class_getDescriptioncxx . . $ Class_getDescription(3d65f6a7e43d24a3). (ClassInfocxx . . $ ClassInfo# table) { |
| 35 | return ((Daatacxx . . $ Daata#) _Thing_dummyObjectcxx . . $ _Thing_dummyObject(5a47185acae0d935). (table)) -> v_descriptioncxx . . $ structDaata#v_description(669317afad7f96e1). (); |
| 36 | } |
| 37 | |
| 38 | static void VectorEditor_createcxx . . $ VectorEditor_create(73194d1d0e491f55). (DataEditorcxx . . $ DataEditor# root, conststring32cxx . . $ conststring32# title, void *address, |
| 39 | Data_Descriptioncxx . . $ Data_Description# description, integercxx . . $ integer# minimum, integercxx . . $ integer# maximum); |
| 40 | |
| 41 | static void MatrixEditor_createcxx . . $ MatrixEditor_create(5c2c873b0ac6372d). (DataEditorcxx . . $ DataEditor# root, conststring32cxx . . $ conststring32# title, void *address, |
| 42 | Data_Descriptioncxx . . $ Data_Description# description, integercxx . . $ integer# min1, integercxx . . $ integer# max1, integercxx . . $ integer# min2, integercxx . . $ integer# max2); |
| 43 | |
| 44 | static void StructEditor_createcxx . . $ StructEditor_create(535ad5ea7dcd6bc3). (DataEditorcxx . . $ DataEditor# root, conststring32cxx . . $ conststring32# title, void *address, Data_Descriptioncxx . . $ Data_Description# description); |
| 45 | |
| 46 | static void ClassEditor_createcxx . . $ ClassEditor_create(535ad5ea7dcd6bc3). (DataEditorcxx . . $ DataEditor# root, conststring32cxx . . $ conststring32# title, void *address, Data_Descriptioncxx . . $ Data_Description# description); |
| 47 | |
| 48 | static inline conststring32cxx . . $ conststring32# strip_dcxx . . $ strip_d(5553299aa8c4fee9). (conststring32cxx . . $ conststring32# s) { |
| 49 | return s && s [0] == U'd' && s [1] == U'_' ? & s [2] : & s [0]; |
| 50 | } |
| 51 | |
| 52 | /********** DataSubEditor **********/ |
| 53 | |
| 54 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (DataSubEditor, Editor, 0); |
| 55 | |
| 56 | void structDataSubEditorcxx . . $ structDataSubEditor# :: v9_destroycxx . . $ structDataSubEditor#v9_destroy(ced63f7c635d850d). () noexcept { |
| 57 | //for (int i = 1; i <= kDataSubEditor_MAXNUM_ROWS; i ++) |
| 58 | // Melder_free (d_fieldData [i]. history); |
| 59 | if (ourcxx . . $ `melder/melder.h:42:9`! rootcxx . . $ structDataSubEditor#root.) |
| 60 | for (integercxx . . $ integer# i = ourcxx . . $ `melder/melder.h:42:9`! rootcxx . . $ structDataSubEditor#root. -> childrencxx . . $ structDataEditor#children..sizecxx . . $ CollectionOf#size.; i > 0; i --) |
| 61 | if (ourcxx . . $ `melder/melder.h:42:9`! rootcxx . . $ structDataSubEditor#root. -> childrencxx . . $ structDataEditor#children..atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i] == this) |
| 62 | ourcxx . . $ `melder/melder.h:42:9`! rootcxx . . $ structDataSubEditor#root. -> childrencxx . . $ structDataEditor#children.. subtractItem_refcxx . . $ CollectionOf#subtractItem_ref(9e08865953f747b0). (i); |
| 63 | DataSubEditor_Parentcxx . . $ DataSubEditor_Parent# :: v9_destroycxx . . $ structEditor#v9_destroy(ced63f7c635d850d). (); |
| 64 | } |
| 65 | |
| 66 | static void updatecxx . . $ update(e8a04abbe5c0eb6e). (DataSubEditorcxx . . $ DataSubEditor# me) { |
| 67 | |
| 68 | /* Hide all the existing widgets. */ |
| 69 | |
| 70 | for (integercxx . . $ integer# i = 1; i <= kDataSubEditor_MAXNUM_ROWScxx . . $ `sys/DataEditor.h:42:9`!; i ++) { |
| 71 | mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [i]. addresscxx . . $ structDataSubEditor_FieldData#address. = nullptr; |
| 72 | mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [i]. descriptioncxx . . $ structDataSubEditor_FieldData#description. = nullptr; |
| 73 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [i]. labelcxx . . $ structDataSubEditor_FieldData#label.); |
| 74 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [i]. buttoncxx . . $ structDataSubEditor_FieldData#button.); |
| 75 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [i]. textcxx . . $ structDataSubEditor_FieldData#text.); |
| 76 | } |
| 77 | |
| 78 | mycxx . . $ `melder/melder.h:44:9`! d_irowcxx . . $ structDataSubEditor#d_irow. = 0; |
| 79 | mycxx . . $ `melder/melder.h:44:9`! v_showMemberscxx . . $ structDataSubEditor#v_showMembers(49f6e7a06ebc5aa8). (); |
| 80 | } |
| 81 | |
| 82 | static Data_Descriptioncxx . . $ Data_Description# DataSubEditor_findNumberUsecxx . . $ DataSubEditor_findNumberUse(39215541a3a7c214). (DataSubEditorcxx . . $ DataSubEditor# me, conststring32cxx . . $ conststring32# number) { |
| 83 | Data_Descriptioncxx . . $ Data_Description# structDescription, result; |
| 84 | char32cxx . . $ char32# string [100]; |
| 85 | if (mycxx . . $ `melder/melder.h:44:9`! classInfocxx . . $ structThing#classInfo. == classMatrixEditorcxx . . $ classMatrixEditor.) |
| 86 | return nullptr; // no structs inside |
| 87 | if (mycxx . . $ `melder/melder.h:44:9`! classInfocxx . . $ structThing#classInfo. == classVectorEditorcxx . . $ classVectorEditor.) { |
| 88 | if (mycxx . . $ `melder/melder.h:44:9`! d_descriptioncxx . . $ structDataSubEditor#d_description. -> typecxx . . $ structData_Description#type. != structwacxx . . $ `sys/Data.h:349:9`!) |
| 89 | return nullptr; // no structs inside |
| 90 | structDescription = * (Data_Descriptioncxx . . $ Data_Description# *) mycxx . . $ `melder/melder.h:44:9`! d_descriptioncxx . . $ structDataSubEditor#d_description. -> tagTypecxx . . $ structData_Description#tagType.; |
| 91 | } else { /* StructEditor or ClassEditor or DataEditor. */ |
| 92 | structDescription = mycxx . . $ `melder/melder.h:44:9`! d_descriptioncxx . . $ structDataSubEditor#d_description.; |
| 93 | } |
| 94 | Melder_sprintcxx . . $ Melder_sprint(2b992b0fb5123bdf). (string,100, number); |
| 95 | if ((result = Data_Description_findNumberUsecxx . . $ Data_Description_findNumberUse(4e4ed69fbd16d6e0). (structDescription, string)) != nullptr) |
| 96 | return result; |
| 97 | Melder_sprintcxx . . $ Melder_sprint(2b992b0fb5123bdf). (string,100, number, U" - 1"); |
| 98 | if ((result = Data_Description_findNumberUsecxx . . $ Data_Description_findNumberUse(4e4ed69fbd16d6e0). (structDescription, string)) != nullptr) |
| 99 | return result; |
| 100 | return nullptr; |
| 101 | } |
| 102 | |
| 103 | static void gui_button_cb_changecxx . . $ gui_button_cb_change(e0475a6d9c1a4472). (DataSubEditorcxx . . $ DataSubEditor# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) { |
| 104 | int irow = 1; |
| 105 | for (; irow <= kDataSubEditor_MAXNUM_ROWScxx . . $ `sys/DataEditor.h:42:9`!; irow ++) { |
| 106 | #if motifcxx . . $ `sys/Gui.h:34:10`! |
| 107 | const bool visible = XtIsManaged (my d_fieldData [irow]. text -> d_widget); |
| 108 | #elif gtkcxx . . $ `sys/Gui.h:33:10`! |
| 109 | gboolean visible; |
| 110 | g_object_get (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (mycxx . . $ `melder/melder.h:44:9`! d_fieldData [irow]. text -> d_widget), "visible", & visible, nullptr); |
| 111 | #elif defined (macintosh) |
| 112 | const bool visible = ! [(GuiCocoaTextField *) my d_fieldData [irow]. text -> d_widget isHidden]; |
| 113 | #else |
| 114 | const bool visible = false; |
| 115 | #endif |
| 116 | if (visible) { |
| 117 | int type = mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. descriptioncxx . . $ structDataSubEditor_FieldData#description. -> typecxx . . $ structData_Description#type.; |
| 118 | if (type > maxsingletypewacxx . . $ `sys/Data.h:348:9`!) |
| 119 | continue; |
| 120 | autostring32cxx . . $ autostring32# text = GuiText_getStringcxx . . $ GuiText_getString(9a61f82c13ba8ebc). (mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. textcxx . . $ structDataSubEditor_FieldData#text.); |
| 121 | switch (type) { |
| 122 | case bytewacxx . . $ `sys/Data.h:332:9`!: { |
| 123 | signed char oldValue = * (signed char *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address., newValue = (signed char) Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 124 | if (newValue != oldValue) { |
| 125 | Data_Descriptioncxx . . $ Data_Description# numberUse = DataSubEditor_findNumberUsecxx . . $ DataSubEditor_findNumberUse(39215541a3a7c214). (me, mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. descriptioncxx . . $ structDataSubEditor_FieldData#description. -> namecxx . . $ structData_Description#name.); |
| 126 | if (numberUse) |
| 127 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Changing field \"", strip_dcxx . . $ strip_d(5553299aa8c4fee9). (mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. descriptioncxx . . $ structDataSubEditor_FieldData#description. -> namecxx . . $ structData_Description#name.), |
| 128 | U"\" would damage the array \"", strip_dcxx . . $ strip_d(5553299aa8c4fee9). (numberUse -> namecxx . . $ structData_Description#name.), U"\"."); |
| 129 | else |
| 130 | * (signed char *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address. = newValue; |
| 131 | } |
| 132 | } break; |
| 133 | case int16wacxx . . $ `sys/Data.h:333:9`!: { |
| 134 | int16cxx . . $ int16# oldValue = * (int16cxx . . $ int16# *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address.; |
| 135 | int64cxx . . $ int64# newValue = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 136 | if (newValue != oldValue) { |
| 137 | Data_Descriptioncxx . . $ Data_Description# numberUse = DataSubEditor_findNumberUsecxx . . $ DataSubEditor_findNumberUse(39215541a3a7c214). (me, mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. descriptioncxx . . $ structDataSubEditor_FieldData#description. -> namecxx . . $ structData_Description#name.); |
| 138 | if (numberUse) |
| 139 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Changing field \"", strip_dcxx . . $ strip_d(5553299aa8c4fee9). (mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. descriptioncxx . . $ structDataSubEditor_FieldData#description. -> namecxx . . $ structData_Description#name.), |
| 140 | U"\" would damage the array \"", strip_dcxx . . $ strip_d(5553299aa8c4fee9). (numberUse -> namecxx . . $ structData_Description#name.), U"\"."); |
| 141 | else if (newValue < INT16_MINcxx . . $ `<external>/3415975807581488833/stdint.h:106:10`! || newValue > INT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:111:10`!) |
| 142 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Field \"", strip_dcxx . . $ strip_d(5553299aa8c4fee9). (mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. descriptioncxx . . $ structDataSubEditor_FieldData#description. -> namecxx . . $ structData_Description#name.), |
| 143 | U"\" can have no values less than ", INT16_MINcxx . . $ `<external>/3415975807581488833/stdint.h:106:10`!, U" or greater than ", INT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:111:10`!, U"."); |
| 144 | else |
| 145 | * (int16cxx . . $ int16# *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address. = (int16cxx . . $ int16#) newValue; // guarded conversion |
| 146 | } |
| 147 | } break; |
| 148 | case intwacxx . . $ `sys/Data.h:334:9`!: { |
| 149 | int oldValue = * (int *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address., newValue = (int) Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 150 | if (newValue != oldValue) { |
| 151 | Data_Descriptioncxx . . $ Data_Description# numberUse = DataSubEditor_findNumberUsecxx . . $ DataSubEditor_findNumberUse(39215541a3a7c214). (me, mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. descriptioncxx . . $ structDataSubEditor_FieldData#description. -> namecxx . . $ structData_Description#name.); |
| 152 | if (numberUse) |
| 153 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Changing field \"", strip_dcxx . . $ strip_d(5553299aa8c4fee9). (mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. descriptioncxx . . $ structDataSubEditor_FieldData#description. -> namecxx . . $ structData_Description#name.), |
| 154 | U"\" would damage the array \"", strip_dcxx . . $ strip_d(5553299aa8c4fee9). (numberUse -> namecxx . . $ structData_Description#name.), U"\"."); |
| 155 | else |
| 156 | * (int *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address. = newValue; |
| 157 | } |
| 158 | } break; |
| 159 | case integerwacxx . . $ `sys/Data.h:335:9`!: { |
| 160 | integercxx . . $ integer# oldValue = * (integercxx . . $ integer# *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address., newValue = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 161 | if (newValue != oldValue) { |
| 162 | Data_Descriptioncxx . . $ Data_Description# numberUse = DataSubEditor_findNumberUsecxx . . $ DataSubEditor_findNumberUse(39215541a3a7c214). (me, mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. descriptioncxx . . $ structDataSubEditor_FieldData#description. -> namecxx . . $ structData_Description#name.); |
| 163 | if (numberUse) |
| 164 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Changing field \"", strip_dcxx . . $ strip_d(5553299aa8c4fee9). (mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. descriptioncxx . . $ structDataSubEditor_FieldData#description. -> namecxx . . $ structData_Description#name.), |
| 165 | U"\" would damage the array \"", strip_dcxx . . $ strip_d(5553299aa8c4fee9). (numberUse -> namecxx . . $ structData_Description#name.), U"\"."); |
| 166 | else |
| 167 | * (integercxx . . $ integer# *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address. = newValue; |
| 168 | } |
| 169 | } break; |
| 170 | case ubytewacxx . . $ `sys/Data.h:336:9`!: { |
| 171 | * (unsigned char *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address. = (uint8cxx . . $ uint8#) Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 172 | } break; |
| 173 | case uintwacxx . . $ `sys/Data.h:337:9`!: { |
| 174 | * (unsigned int *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address. = (uint32cxx . . $ uint32#) Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 175 | } break; |
| 176 | case uintegerwacxx . . $ `sys/Data.h:338:9`!: { |
| 177 | * (uintegercxx . . $ uinteger# *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address. = (uintegercxx . . $ uinteger#) Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 178 | } break; |
| 179 | case floatwacxx . . $ `sys/Data.h:339:9`!: { |
| 180 | * (double *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address. = Melder_atofcxx . . $ Melder_atof(13d725aae188c0cd). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 181 | } break; |
| 182 | case doublewacxx . . $ `sys/Data.h:340:9`!: { |
| 183 | * (double *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address. = Melder_atofcxx . . $ Melder_atof(13d725aae188c0cd). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 184 | } break; |
| 185 | case complexwacxx . . $ `sys/Data.h:341:9`!: { dcomplexcxx . . $ dcomplex# *x = (dcomplexcxx . . $ dcomplex# *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address.; |
| 186 | double re, im; |
| 187 | sscanf (Melder_peek32to8 (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()), "%lf + %lf i", & re, & im); |
| 188 | x -> realcxx . . $ std/complex#real(ba8836b59fb42830). (re); |
| 189 | x -> imagcxx . . $ std/complex#imag(ba8836b59fb42830). (im); |
| 190 | } break; |
| 191 | case enumwacxx . . $ `sys/Data.h:342:9`!: { |
| 192 | if (Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()) < 3) |
| 193 | goto error; |
| 194 | text [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()) - 1] = U'\0'; // remove trailing ">" |
| 195 | int value = ((int (*) (conststring32cxx . . $ conststring32#)) (mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. descriptioncxx . . $ structDataSubEditor_FieldData#description. -> tagTypecxx . . $ structData_Description#tagType.)) (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).() + 1); // skip leading "<" |
| 196 | if (value < 0) |
| 197 | goto error; |
| 198 | * (signed char *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address. = (signed char) value; |
| 199 | } break; |
| 200 | case lenumwacxx . . $ `sys/Data.h:343:9`!: { |
| 201 | if (Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()) < 3) |
| 202 | goto error; |
| 203 | text [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()) - 1] = U'\0'; // remove trailing ">" |
| 204 | int value = ((int (*) (conststring32cxx . . $ conststring32#)) (mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. descriptioncxx . . $ structDataSubEditor_FieldData#description. -> tagTypecxx . . $ structData_Description#tagType.)) (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).() + 1); // skip leading "<" |
| 205 | if (value < 0) |
| 206 | goto error; |
| 207 | * (signed short *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address. = (signed short) value; |
| 208 | } break; |
| 209 | case booleanwacxx . . $ `sys/Data.h:344:9`!: { |
| 210 | bool value; |
| 211 | if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U"<true>", 6)) |
| 212 | value = true; |
| 213 | else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U"<false>", 7)) |
| 214 | value = false; |
| 215 | else |
| 216 | goto error; |
| 217 | * (bool *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address. = value; |
| 218 | } break; |
| 219 | case questionwacxx . . $ `sys/Data.h:345:9`!: { |
| 220 | bool value; |
| 221 | if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U"<yes>", 5)) |
| 222 | value = true; |
| 223 | else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U"<no>", 4)) |
| 224 | value = false; |
| 225 | else |
| 226 | goto error; |
| 227 | * (bool *) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address. = value; |
| 228 | } break; |
| 229 | case stringwacxx . . $ `sys/Data.h:346:9`!: |
| 230 | case lstringwacxx . . $ `sys/Data.h:347:9`!: { |
| 231 | char32cxx . . $ char32# *old = * (char32cxx . . $ char32# **) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address.; |
| 232 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`! (old); |
| 233 | * (char32cxx . . $ char32# **) mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. addresscxx . . $ structDataSubEditor_FieldData#address. = Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()).transfercxx . . $ _autostring#transfer(155dc7f103cdb9db).(); |
| 234 | } break; |
| 235 | default: break; |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | /* |
| 240 | Several collaborators have to be notified of this change: |
| 241 | 1. The owner (creator) of our root DataEditor: so that she can notify other editors, if any. |
| 242 | 2. All our sibling DataSubEditors. |
| 243 | */ |
| 244 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! root); |
| 245 | Editor_broadcastDataChangedcxx . . $ Editor_broadcastDataChanged(c0154a85f79216c7). (mycxx . . $ `melder/melder.h:44:9`! rootcxx . . $ structDataSubEditor#root.); |
| 246 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! root); |
| 247 | updatecxx . . $ update(e8a04abbe5c0eb6e). (me); |
| 248 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! root); |
| 249 | for (int isub = 1; isub <= mycxx . . $ `melder/melder.h:44:9`! rootcxx . . $ structDataSubEditor#root. -> childrencxx . . $ structDataEditor#children..sizecxx . . $ CollectionOf#size.; isub ++) { |
| 250 | DataSubEditorcxx . . $ DataSubEditor# subeditor = mycxx . . $ `melder/melder.h:44:9`! rootcxx . . $ structDataSubEditor#root. -> childrencxx . . $ structDataEditor#children..atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).isub]; |
| 251 | if (subeditor != me) |
| 252 | updatecxx . . $ update(e8a04abbe5c0eb6e). (subeditor); |
| 253 | } |
| 254 | return; |
| 255 | error: |
| 256 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Edit field \"", strip_dcxx . . $ strip_d(5553299aa8c4fee9). (mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [irow]. descriptioncxx . . $ structDataSubEditor_FieldData#description. -> namecxx . . $ structData_Description#name.), U"\" or click \"Cancel\"."); |
| 257 | } |
| 258 | |
| 259 | static void gui_button_cb_cancelcxx . . $ gui_button_cb_cancel(e0475a6d9c1a4472). (DataSubEditorcxx . . $ DataSubEditor# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) { |
| 260 | updatecxx . . $ update(e8a04abbe5c0eb6e). (me); |
| 261 | } |
| 262 | |
| 263 | static void gui_cb_scrollcxx . . $ gui_cb_scroll(13fec3bc2e9f178c). (DataSubEditorcxx . . $ DataSubEditor# me, GuiScrollBarEventcxx . . $ GuiScrollBarEvent# event) { |
| 264 | mycxx . . $ `melder/melder.h:44:9`! d_topFieldcxx . . $ structDataSubEditor#d_topField. = GuiScrollBar_getValuecxx . . $ GuiScrollBar_getValue(fa861a4bcb1a88a7). (event -> scrollBarcxx . . $ structGuiScrollBarEvent#scrollBar.) + 1; |
| 265 | updatecxx . . $ update(e8a04abbe5c0eb6e). (me); |
| 266 | } |
| 267 | |
| 268 | static void gui_button_cb_opencxx . . $ gui_button_cb_open(e0475a6d9c1a4472). (DataSubEditorcxx . . $ DataSubEditor# me, GuiButtonEventcxx . . $ GuiButtonEvent# event) { |
| 269 | integercxx . . $ integer# ifield = 0; |
| 270 | static MelderStringcxx . . $ MelderString# name; |
| 271 | MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& name); |
| 272 | |
| 273 | /* Identify the pressed button; it must be one of those created in the list. */ |
| 274 | |
| 275 | for (integercxx . . $ integer# i = 1; i <= kDataSubEditor_MAXNUM_ROWScxx . . $ `sys/DataEditor.h:42:9`!; i ++) |
| 276 | if (mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [i]. buttoncxx . . $ structDataSubEditor_FieldData#button. == event -> buttoncxx . . $ structGuiButtonEvent#button.) { |
| 277 | ifield = i; |
| 278 | break; |
| 279 | } |
| 280 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (ifield != 0); |
| 281 | |
| 282 | /* Launch the appropriate subeditor. */ |
| 283 | |
| 284 | DataSubEditor_FieldDatacxx . . $ DataSubEditor_FieldData# fieldData = & mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [ifield]; |
| 285 | if (! fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description.) { |
| 286 | Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"Not yet implemented."); |
| 287 | return; // not yet implemented |
| 288 | } |
| 289 | |
| 290 | if (fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. -> rankcxx . . $ structData_Description#rank. == 1 || fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. -> rankcxx . . $ structData_Description#rank. == 3 || fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. -> rankcxx . . $ structData_Description#rank. < 0) { |
| 291 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& name, fieldData -> historycxx . . $ structDataSubEditor_FieldData#history..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U". ", strip_dcxx . . $ strip_d(5553299aa8c4fee9). (fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. -> namecxx . . $ structData_Description#name.), |
| 292 | U" [", fieldData -> minimumcxx . . $ structDataSubEditor_FieldData#minimum., U"..", fieldData -> maximumcxx . . $ structDataSubEditor_FieldData#maximum., U"]"); |
| 293 | VectorEditor_createcxx . . $ VectorEditor_create(73194d1d0e491f55). (mycxx . . $ `melder/melder.h:44:9`! rootcxx . . $ structDataSubEditor#root., name.stringcxx . . $ MelderString#string., fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address., |
| 294 | fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description., fieldData -> minimumcxx . . $ structDataSubEditor_FieldData#minimum., fieldData -> maximumcxx . . $ structDataSubEditor_FieldData#maximum.); |
| 295 | } else if (fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. -> rankcxx . . $ structData_Description#rank. == 2) { |
| 296 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& name, fieldData -> historycxx . . $ structDataSubEditor_FieldData#history..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U". ", strip_dcxx . . $ strip_d(5553299aa8c4fee9). (fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. -> namecxx . . $ structData_Description#name.), |
| 297 | U" [", fieldData -> minimumcxx . . $ structDataSubEditor_FieldData#minimum., U"..", fieldData -> maximumcxx . . $ structDataSubEditor_FieldData#maximum., U"]"); |
| 298 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& name, U" [", fieldData -> min2cxx . . $ structDataSubEditor_FieldData#min2., U"..", fieldData -> max2cxx . . $ structDataSubEditor_FieldData#max2., U"]"); |
| 299 | MatrixEditor_createcxx . . $ MatrixEditor_create(5c2c873b0ac6372d). (mycxx . . $ `melder/melder.h:44:9`! rootcxx . . $ structDataSubEditor#root., name.stringcxx . . $ MelderString#string., fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address., fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description., |
| 300 | fieldData -> minimumcxx . . $ structDataSubEditor_FieldData#minimum., fieldData -> maximumcxx . . $ structDataSubEditor_FieldData#maximum., fieldData -> min2cxx . . $ structDataSubEditor_FieldData#min2., fieldData -> max2cxx . . $ structDataSubEditor_FieldData#max2.); |
| 301 | } else if (fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. -> typecxx . . $ structData_Description#type. == structwacxx . . $ `sys/Data.h:349:9`!) { |
| 302 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& name, fieldData -> historycxx . . $ structDataSubEditor_FieldData#history..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U". ", strip_dcxx . . $ strip_d(5553299aa8c4fee9). (fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. -> namecxx . . $ structData_Description#name.)); |
| 303 | StructEditor_createcxx . . $ StructEditor_create(535ad5ea7dcd6bc3). (mycxx . . $ `melder/melder.h:44:9`! rootcxx . . $ structDataSubEditor#root., name.stringcxx . . $ MelderString#string., fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address., |
| 304 | * (Data_Descriptioncxx . . $ Data_Description# *) fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. -> tagTypecxx . . $ structData_Description#tagType.); |
| 305 | } else if (fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. -> typecxx . . $ structData_Description#type. == objectwacxx . . $ `sys/Data.h:351:9`! || |
| 306 | fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. -> typecxx . . $ structData_Description#type. == collectionofwacxx . . $ `sys/Data.h:352:9`! || |
| 307 | fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. -> typecxx . . $ structData_Description#type. == collectionwacxx . . $ `sys/Data.h:353:9`!) { |
| 308 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& name, fieldData -> historycxx . . $ structDataSubEditor_FieldData#history..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U". ", strip_dcxx . . $ strip_d(5553299aa8c4fee9). (fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. -> namecxx . . $ structData_Description#name.)); |
| 309 | ClassEditor_createcxx . . $ ClassEditor_create(535ad5ea7dcd6bc3). (mycxx . . $ `melder/melder.h:44:9`! rootcxx . . $ structDataSubEditor#root., name.stringcxx . . $ MelderString#string., fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address., |
| 310 | Class_getDescriptioncxx . . $ Class_getDescription(3d65f6a7e43d24a3). ((ClassInfocxx . . $ ClassInfo#) fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. -> tagTypecxx . . $ structData_Description#tagType.)); |
| 311 | } else /*if (fieldData -> description -> type == inheritwa)*/ { |
| 312 | ClassEditor_createcxx . . $ ClassEditor_create(535ad5ea7dcd6bc3). (mycxx . . $ `melder/melder.h:44:9`! rootcxx . . $ structDataSubEditor#root., fieldData -> historycxx . . $ structDataSubEditor_FieldData#history..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address., |
| 313 | fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description.); |
| 314 | /* } else { |
| 315 | Melder_casual ( |
| 316 | U"Strange editor \"", strip_d (fieldData -> description -> name), |
| 317 | U"\" required (type ", fieldData -> description -> type, |
| 318 | U", rank ", fieldData -> description -> rank, |
| 319 | U")." |
| 320 | );*/ |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | void structDataSubEditorcxx . . $ structDataSubEditor# :: v_createChildrencxx . . $ structDataSubEditor#v_createChildren(49f6e7a06ebc5aa8). () { |
| 325 | int x = Gui_LEFT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:85:9`!, y = Gui_TOP_DIALOG_SPACINGcxx . . $ `sys/Gui.h:90:10`! + Machine_getMenuBarBottomcxx . . $ Machine_getMenuBarBottom(b126dc7c1de90089). (), buttonWidth = 120; |
| 326 | |
| 327 | GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., x, x + buttonWidth, y, y + Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, |
| 328 | U"Change", gui_button_cb_changecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0); |
| 329 | x += buttonWidth + Gui_HORIZONTAL_DIALOG_SPACINGcxx . . $ `sys/Gui.h:93:9`!; |
| 330 | GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., x, x + buttonWidth, y, y + Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, |
| 331 | U"Cancel", gui_button_cb_cancelcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0); |
| 332 | |
| 333 | y = Machine_getMenuBarBottomcxx . . $ Machine_getMenuBarBottom(b126dc7c1de90089). () + LIST_Ycxx . . $ `sys/DataEditor.cpp:22:9`!; |
| 334 | d_scrollBarcxx . . $ structDataSubEditor#d_scrollBar. = GuiScrollBar_createShowncxx . . $ GuiScrollBar_createShown(571c696f46086cf0). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., |
| 335 | - SCROLL_BAR_WIDTHcxx . . $ `sys/DataEditor.cpp:27:9`!, 0, y, 0, |
| 336 | 0, d_numberOfFieldscxx . . $ structDataSubEditor#d_numberOfFields., 0, d_numberOfFieldscxx . . $ structDataSubEditor#d_numberOfFields. < kDataSubEditor_MAXNUM_ROWScxx . . $ `sys/DataEditor.h:42:9`! ? d_numberOfFieldscxx . . $ structDataSubEditor#d_numberOfFields. : kDataSubEditor_MAXNUM_ROWScxx . . $ `sys/DataEditor.h:42:9`!, 1, kDataSubEditor_MAXNUM_ROWScxx . . $ `sys/DataEditor.h:42:9`! - 1, |
| 337 | gui_cb_scrollcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0 |
| 338 | ); |
| 339 | |
| 340 | y += 10; |
| 341 | for (int i = 1; i <= kDataSubEditor_MAXNUM_ROWScxx . . $ `sys/DataEditor.h:42:9`!; i ++) { |
| 342 | d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [i]. labelcxx . . $ structDataSubEditor_FieldData#label. = GuiLabel_createcxx . . $ GuiLabel_create(39026c9008a6a07). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., 0, 200, y, y + Gui_TEXTFIELD_HEIGHTcxx . . $ `sys/Gui.h:96:9`!, U"label", 0); // no fixed x value: sometimes indent |
| 343 | d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [i]. buttoncxx . . $ structDataSubEditor_FieldData#button. = GuiButton_createcxx . . $ GuiButton_create(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., BUTTON_Xcxx . . $ `sys/DataEditor.cpp:21:9`!, BUTTON_Xcxx . . $ `sys/DataEditor.cpp:21:9`! + buttonWidth, y, y + Gui_TEXTFIELD_HEIGHTcxx . . $ `sys/Gui.h:96:9`!, |
| 344 | U"Open", gui_button_cb_opencxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0); |
| 345 | d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [i]. textcxx . . $ structDataSubEditor_FieldData#text. = GuiText_createcxx . . $ GuiText_create(8bcb1f2be7fc31ee). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., TEXT_Xcxx . . $ `sys/DataEditor.cpp:20:9`!, -30, y, y + Gui_TEXTFIELD_HEIGHTcxx . . $ `sys/Gui.h:96:9`!, 0); |
| 346 | d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [i]. ycxx . . $ structDataSubEditor_FieldData#y. = y; |
| 347 | y += ROW_HEIGHTcxx . . $ `sys/DataEditor.cpp:25:9`!; |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | static void menu_cb_helpcxx . . $ menu_cb_help(a8f18fd576850592). (DataSubEditorcxx . . $ DataSubEditor#, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { Melder_helpcxx . . $ Melder_help(ff00d524ab0355ec). (U"Inspect"); } |
| 352 | |
| 353 | void structDataSubEditorcxx . . $ structDataSubEditor# :: v_createMenuItems_helpcxx . . $ structDataSubEditor#v_createMenuItems_help(6ea9c8c6ea2f58a9). (EditorMenucxx . . $ EditorMenu# menu) { |
| 354 | DataSubEditor_Parentcxx . . $ DataSubEditor_Parent# :: v_createMenuItems_helpcxx . . $ structDataGui#v_createMenuItems_help(6ea9c8c6ea2f58a9). (menu); |
| 355 | EditorMenu_addCommandcxx . . $ EditorMenu_addCommand(b3c50ad5ffa1d58a). (menu, U"DataEditor help", '?', menu_cb_helpcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 356 | } |
| 357 | |
| 358 | static void DataSubEditor_initcxx . . $ DataSubEditor_init(8cc2a8f0a14773ad). (DataSubEditorcxx . . $ DataSubEditor# me, DataEditorcxx . . $ DataEditor# root, conststring32cxx . . $ conststring32# title, void *address, Data_Descriptioncxx . . $ Data_Description# description) { |
| 359 | mycxx . . $ `melder/melder.h:44:9`! rootcxx . . $ structDataSubEditor#root. = root; |
| 360 | if (me != root) |
| 361 | root -> childrencxx . . $ structDataEditor#children..addItem_refcxx . . $ CollectionOf#addItem_ref(ebd0a1552f8ce24f). (me); |
| 362 | mycxx . . $ `melder/melder.h:44:9`! d_addresscxx . . $ structDataSubEditor#d_address. = address; |
| 363 | mycxx . . $ `melder/melder.h:44:9`! d_descriptioncxx . . $ structDataSubEditor#d_description. = description; |
| 364 | mycxx . . $ `melder/melder.h:44:9`! d_topFieldcxx . . $ structDataSubEditor#d_topField. = 1; |
| 365 | mycxx . . $ `melder/melder.h:44:9`! d_numberOfFieldscxx . . $ structDataSubEditor#d_numberOfFields. = mycxx . . $ `melder/melder.h:44:9`! v_countFieldscxx . . $ structDataSubEditor#v_countFields(da6335ded91d79c2). (); |
| 366 | Editor_initcxx . . $ Editor_init(13f379e38ac41ed6). (me, 0, 0, EDITOR_WIDTHcxx . . $ `sys/DataEditor.cpp:23:9`!, EDITOR_HEIGHTcxx . . $ `sys/DataEditor.cpp:24:9`!, title, nullptr); |
| 367 | updatecxx . . $ update(e8a04abbe5c0eb6e). (me); |
| 368 | } |
| 369 | |
| 370 | /********** StructEditor **********/ |
| 371 | |
| 372 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (StructEditor, DataSubEditor, 0); |
| 373 | |
| 374 | integercxx . . $ integer# structStructEditorcxx . . $ structStructEditor# :: v_countFieldscxx . . $ structStructEditor#v_countFields(da6335ded91d79c2). () { |
| 375 | return Data_Description_countMemberscxx . . $ Data_Description_countMembers(e486611939ed5677). (d_descriptioncxx . . $ structDataSubEditor#d_description.); |
| 376 | } |
| 377 | |
| 378 | static conststring32cxx . . $ conststring32# singleTypeToTextcxx . . $ singleTypeToText(b81cadf4cb98c416). (void *address, int type, void *tagType, MelderStringcxx . . $ MelderString# *buffer) { |
| 379 | switch (type) { |
| 380 | case bytewacxx . . $ `sys/Data.h:332:9`!: MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (buffer, Melder_integercxx . . $ Melder_integer(7b348ebc2004441d). (* (signed char *) address)); break; |
| 381 | case int16wacxx . . $ `sys/Data.h:333:9`!: MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (buffer, Melder_integercxx . . $ Melder_integer(7b348ebc2004441d). (* (int16cxx . . $ int16# *) address)); break; |
| 382 | case intwacxx . . $ `sys/Data.h:334:9`!: MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (buffer, Melder_integercxx . . $ Melder_integer(7b348ebc2004441d). (* (int *) address)); break; |
| 383 | case integerwacxx . . $ `sys/Data.h:335:9`!: MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (buffer, Melder_integercxx . . $ Melder_integer(7b348ebc2004441d). (* (integercxx . . $ integer# *) address)); break; |
| 384 | case ubytewacxx . . $ `sys/Data.h:336:9`!: MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (buffer, Melder_integercxx . . $ Melder_integer(7b348ebc2004441d). (* (unsigned char *) address)); break; |
| 385 | case uintwacxx . . $ `sys/Data.h:337:9`!: MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (buffer, Melder_integercxx . . $ Melder_integer(7b348ebc2004441d). (* (unsigned int *) address)); break; |
| 386 | case uintegerwacxx . . $ `sys/Data.h:338:9`!: MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (buffer, Melder_integercxx . . $ Melder_integer(7b348ebc2004441d). (* (uintegercxx . . $ uinteger# *) address)); break; |
| 387 | case floatwacxx . . $ `sys/Data.h:339:9`!: MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (buffer, Melder_singlecxx . . $ Melder_single(f05d861d9dbec9b2). (* (double *) address)); break; |
| 388 | case doublewacxx . . $ `sys/Data.h:340:9`!: MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (buffer, Melder_doublecxx . . $ Melder_double(f05d861d9dbec9b2). (* (double *) address)); break; |
| 389 | case complexwacxx . . $ `sys/Data.h:341:9`!: MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (buffer, Melder_dcomplexcxx . . $ Melder_dcomplex(4cf419d79128e8b4). (*cxx . . $ std/complex#complex(20ef1611af677bca). (dcomplexcxx . . $ dcomplex# *) address)); break; |
| 390 | case enumwacxx . . $ `sys/Data.h:342:9`!: MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (buffer, U"<", ((conststring32cxx . . $ conststring32# (*) (int)) tagType) (* (signed char *) address), U">"); break; |
| 391 | case lenumwacxx . . $ `sys/Data.h:343:9`!: MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (buffer, U"<", ((conststring32cxx . . $ conststring32# (*) (int)) tagType) (* (signed short *) address), U">"); break; |
| 392 | case booleanwacxx . . $ `sys/Data.h:344:9`!: MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (buffer, * (bool *) address ? U"<true>" : U"<false>"); break; |
| 393 | case questionwacxx . . $ `sys/Data.h:345:9`!: MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (buffer, * (bool *) address ? U"<yes>" : U"<no>" ); break; |
| 394 | case stringwacxx . . $ `sys/Data.h:346:9`!: |
| 395 | case lstringwacxx . . $ `sys/Data.h:347:9`!: { |
| 396 | char32cxx . . $ char32# *string = * (char32cxx . . $ char32# **) address; |
| 397 | if (! string) { |
| 398 | MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (buffer); // convert null string to empty string |
| 399 | return buffer -> stringcxx . . $ MelderString#string.; |
| 400 | } |
| 401 | return string; // may be much longer than the usual size of 'buffer' |
| 402 | } break; |
| 403 | default: return U"(unknown)"; |
| 404 | } |
| 405 | return buffer -> stringcxx . . $ MelderString#string.; // Mind the special return for strings above. |
| 406 | } |
| 407 | |
| 408 | static void showStructMembercxx . . $ showStructMember(9940c3895d9bbf88). ( |
| 409 | void *structAddress, /* The address of (the first member of) the struct. */ |
| 410 | Data_Descriptioncxx . . $ Data_Description# structDescription, /* The description of (the first member of) the struct. */ |
| 411 | Data_Descriptioncxx . . $ Data_Description# memberDescription, /* The description of the current member. */ |
| 412 | DataSubEditor_FieldDatacxx . . $ DataSubEditor_FieldData# fieldData, /* The widgets in which to show the info about the current member. */ |
| 413 | char32cxx . . $ char32# *history) |
| 414 | { |
| 415 | int type = memberDescription -> typecxx . . $ structData_Description#type., rank = memberDescription -> rankcxx . . $ structData_Description#rank.; |
| 416 | bool isSingleType = ( type <= maxsingletypewacxx . . $ `sys/Data.h:348:9`! && rank == 0 ); |
| 417 | unsigned char *memberAddress = (unsigned char *) structAddress + memberDescription -> offsetcxx . . $ structData_Description#offset.; |
| 418 | if (type == inheritwacxx . . $ `sys/Data.h:354:9`!) { |
| 419 | GuiLabel_setTextcxx . . $ GuiLabel_setText(8fd1a6a47d1f7702). (fieldData -> labelcxx . . $ structDataSubEditor_FieldData#label., |
| 420 | Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (U"Class part \"", memberDescription -> namecxx . . $ structData_Description#name., U"\":")); |
| 421 | } else { |
| 422 | GuiLabel_setTextcxx . . $ GuiLabel_setText(8fd1a6a47d1f7702). (fieldData -> labelcxx . . $ structDataSubEditor_FieldData#label., |
| 423 | Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (U" ", strip_dcxx . . $ strip_d(5553299aa8c4fee9). (memberDescription -> namecxx . . $ structData_Description#name.), |
| 424 | ( rank == 0 ? U"" : rank == 1 || rank == 3 || rank < 0 ? U" [ ]" : U" [ ] [ ]" ))); |
| 425 | } |
| 426 | //GuiControl_move (fieldData -> label, type == inheritwa ? 0 : NAME_X, fieldData -> y); |
| 427 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (fieldData -> labelcxx . . $ structDataSubEditor_FieldData#label.); |
| 428 | |
| 429 | /* Show the value (for a single type) or a button (for a composite type). */ |
| 430 | if (isSingleType) { |
| 431 | #if motifcxx . . $ `sys/Gui.h:34:10`! |
| 432 | XtVaSetValues (fieldData -> text -> d_widget, XmNcolumns, 60, nullptr); // TODO: change to GuiObject_size |
| 433 | #endif |
| 434 | autoMelderStringcxx . . $ autoMelderString# buffercxx . . $ autoMelderString#autoMelderString(49f6e7a06ebc5aa8).; |
| 435 | conststring32cxx . . $ conststring32# text = singleTypeToTextcxx . . $ singleTypeToText(b81cadf4cb98c416). (memberAddress, type, memberDescription -> tagTypecxx . . $ structData_Description#tagType., & buffer); |
| 436 | GuiText_setStringcxx . . $ GuiText_setString(d44acbd60ea2b9be). (fieldData -> textcxx . . $ structDataSubEditor_FieldData#text., text); |
| 437 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (fieldData -> textcxx . . $ structDataSubEditor_FieldData#text.); |
| 438 | fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address. = memberAddress; |
| 439 | fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. = memberDescription; |
| 440 | fieldData -> rankcxx . . $ structDataSubEditor_FieldData#rank. = 0; |
| 441 | } else if (rank == 1) { |
| 442 | void *arrayAddress = * (void **) memberAddress; |
| 443 | integercxx . . $ integer# minimum, maximum; |
| 444 | if (! arrayAddress) |
| 445 | return; // no button for empty fields |
| 446 | Data_Description_evaluateIntegercxx . . $ Data_Description_evaluateInteger(9a36bcb04ff11e98). (structAddress, structDescription, |
| 447 | memberDescription -> min1cxx . . $ structData_Description#min1., & minimum); |
| 448 | Data_Description_evaluateIntegercxx . . $ Data_Description_evaluateInteger(9a36bcb04ff11e98). (structAddress, structDescription, |
| 449 | memberDescription -> max1cxx . . $ structData_Description#max1., & maximum); |
| 450 | if (maximum < minimum) |
| 451 | return; // no button if no elements |
| 452 | fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address. = arrayAddress; // indirect |
| 453 | fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. = memberDescription; |
| 454 | fieldData -> minimumcxx . . $ structDataSubEditor_FieldData#minimum. = minimum; // normally 1 |
| 455 | fieldData -> maximumcxx . . $ structDataSubEditor_FieldData#maximum. = maximum; |
| 456 | fieldData -> rankcxx . . $ structDataSubEditor_FieldData#rank. = 1; |
| 457 | fieldData -> historycxx . . $ structDataSubEditor_FieldData#history. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (history); |
| 458 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (fieldData -> buttoncxx . . $ structDataSubEditor_FieldData#button.); |
| 459 | } else if (rank < 0) { |
| 460 | /* |
| 461 | This represents an in-line array. |
| 462 | */ |
| 463 | integercxx . . $ integer# maximum; /* But: capacity = - rank */ |
| 464 | Data_Description_evaluateIntegercxx . . $ Data_Description_evaluateInteger(9a36bcb04ff11e98). (structAddress, structDescription, |
| 465 | memberDescription -> max1cxx . . $ structData_Description#max1., & maximum); |
| 466 | if (-- maximum < 0) |
| 467 | return; // subtract one for zero-based array; no button if no elements |
| 468 | fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address. = memberAddress; /* Direct. */ |
| 469 | fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. = memberDescription; |
| 470 | fieldData -> minimumcxx . . $ structDataSubEditor_FieldData#minimum. = 0; // in-line arrays start with index 0 |
| 471 | fieldData -> maximumcxx . . $ structDataSubEditor_FieldData#maximum. = maximum; // probably between -1 and capacity - 1 |
| 472 | fieldData -> rankcxx . . $ structDataSubEditor_FieldData#rank. = rank; |
| 473 | fieldData -> historycxx . . $ structDataSubEditor_FieldData#history. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (history); |
| 474 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (fieldData -> buttoncxx . . $ structDataSubEditor_FieldData#button.); |
| 475 | } else if (rank == 3) { |
| 476 | /* |
| 477 | This represents an in-line set. |
| 478 | */ |
| 479 | fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address. = memberAddress; // direct |
| 480 | fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. = memberDescription; |
| 481 | fieldData -> minimumcxx . . $ structDataSubEditor_FieldData#minimum. = str32equcxx . . $ `melder/melder_str32.h:122:9`! (((conststring32cxx . . $ conststring32# (*) (int)) memberDescription -> min1cxx . . $ structData_Description#min1.) (0), U"_") ? 1 : 0; |
| 482 | fieldData -> maximumcxx . . $ structDataSubEditor_FieldData#maximum. = ((int (*) (conststring32cxx . . $ conststring32#)) memberDescription -> max1cxx . . $ structData_Description#max1.) (U"\n"); |
| 483 | fieldData -> rankcxx . . $ structDataSubEditor_FieldData#rank. = rank; |
| 484 | fieldData -> historycxx . . $ structDataSubEditor_FieldData#history. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (history); |
| 485 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (fieldData -> buttoncxx . . $ structDataSubEditor_FieldData#button.); |
| 486 | } else if (rank == 2) { |
| 487 | constMATcxx . . $ constMAT# mat = * (constMATcxx . . $ constMAT# *) memberAddress; |
| 488 | //Melder_casual (U"Showing matrix member with ", mat.nrow, U" rows and ", mat.ncol, U" columns."); |
| 489 | if (NUMisEmptycxx . . $ NUMisEmpty(d1d1b198a4d2bdd0). (mat)) |
| 490 | return; // no button for empty fields |
| 491 | integercxx . . $ integer# min1, max1, min2, max2; |
| 492 | Data_Description_evaluateIntegercxx . . $ Data_Description_evaluateInteger(9a36bcb04ff11e98). (structAddress, structDescription, |
| 493 | memberDescription -> min1cxx . . $ structData_Description#min1., & min1); |
| 494 | Data_Description_evaluateIntegercxx . . $ Data_Description_evaluateInteger(9a36bcb04ff11e98). (structAddress, structDescription, |
| 495 | memberDescription -> max1cxx . . $ structData_Description#max1., & max1); |
| 496 | Data_Description_evaluateIntegercxx . . $ Data_Description_evaluateInteger(9a36bcb04ff11e98). (structAddress, structDescription, |
| 497 | memberDescription -> min2cxx . . $ structData_Description#min2., & min2); |
| 498 | Data_Description_evaluateIntegercxx . . $ Data_Description_evaluateInteger(9a36bcb04ff11e98). (structAddress, structDescription, |
| 499 | memberDescription -> max2cxx . . $ structData_Description#max2., & max2); |
| 500 | if (max1 < min1 || max2 < min2) |
| 501 | return; // no button if no elements |
| 502 | fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address. = memberAddress; // direct |
| 503 | fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. = memberDescription; |
| 504 | fieldData -> minimumcxx . . $ structDataSubEditor_FieldData#minimum. = min1; // normally 1 |
| 505 | fieldData -> maximumcxx . . $ structDataSubEditor_FieldData#maximum. = max1; |
| 506 | fieldData -> min2cxx . . $ structDataSubEditor_FieldData#min2. = min2; |
| 507 | fieldData -> max2cxx . . $ structDataSubEditor_FieldData#max2. = max2; |
| 508 | fieldData -> rankcxx . . $ structDataSubEditor_FieldData#rank. = 2; |
| 509 | fieldData -> historycxx . . $ structDataSubEditor_FieldData#history. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (history); |
| 510 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (fieldData -> buttoncxx . . $ structDataSubEditor_FieldData#button.); |
| 511 | } else if (type == structwacxx . . $ `sys/Data.h:349:9`!) { // in-line struct |
| 512 | fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address. = memberAddress; // direct |
| 513 | fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. = memberDescription; |
| 514 | fieldData -> rankcxx . . $ structDataSubEditor_FieldData#rank. = 0; |
| 515 | fieldData -> historycxx . . $ structDataSubEditor_FieldData#history. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (history); |
| 516 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (fieldData -> buttoncxx . . $ structDataSubEditor_FieldData#button.); |
| 517 | } else if (type == objectwacxx . . $ `sys/Data.h:351:9`! || type == collectionwacxx . . $ `sys/Data.h:353:9`!) { |
| 518 | fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address. = * (Daatacxx . . $ Daata# *) memberAddress; // indirect // FIXME: not guaranteed for auto objects |
| 519 | if (! fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address.) |
| 520 | return; // no button if no object |
| 521 | fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. = memberDescription; |
| 522 | fieldData -> rankcxx . . $ structDataSubEditor_FieldData#rank. = 0; |
| 523 | fieldData -> historycxx . . $ structDataSubEditor_FieldData#history. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (history); |
| 524 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (fieldData -> buttoncxx . . $ structDataSubEditor_FieldData#button.); |
| 525 | } else if (type == collectionofwacxx . . $ `sys/Data.h:352:9`!) { |
| 526 | fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address. = (Daatacxx . . $ Daata#) memberAddress; // direct // FIXME: not guaranteed for auto objects |
| 527 | //Melder_casual (U"Daata ", Melder_pointer (fieldData -> address)); |
| 528 | //Melder_casual (U"Class ", ((Daata) fieldData -> address) -> classInfo -> className); |
| 529 | if (! fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address.) |
| 530 | return; // no button if no object |
| 531 | fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. = memberDescription; |
| 532 | fieldData -> rankcxx . . $ structDataSubEditor_FieldData#rank. = 0; |
| 533 | fieldData -> historycxx . . $ structDataSubEditor_FieldData#history. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (history); |
| 534 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (fieldData -> buttoncxx . . $ structDataSubEditor_FieldData#button.); |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | static void showStructMemberscxx . . $ showStructMembers(88dab76137bd8b85). (DataSubEditorcxx . . $ DataSubEditor# me, void *structAddress, Data_Descriptioncxx . . $ Data_Description# structDescription, int fromMember, char32cxx . . $ char32# *history) { |
| 539 | integercxx . . $ integer# i = 1; |
| 540 | Data_Descriptioncxx . . $ Data_Description# memberDescription = structDescription; |
| 541 | for (; i < fromMember && memberDescription -> namecxx . . $ structData_Description#name. != nullptr; i ++, memberDescription ++) |
| 542 | (void) 0; |
| 543 | for (; memberDescription -> namecxx . . $ structData_Description#name. != nullptr; memberDescription ++) { |
| 544 | if (++ mycxx . . $ `melder/melder.h:44:9`! d_irowcxx . . $ structDataSubEditor#d_irow. > kDataSubEditor_MAXNUM_ROWScxx . . $ `sys/DataEditor.h:42:9`!) |
| 545 | return; |
| 546 | showStructMembercxx . . $ showStructMember(9940c3895d9bbf88). (structAddress, structDescription, memberDescription, & mycxx . . $ `melder/melder.h:44:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [mycxx . . $ `melder/melder.h:44:9`! d_irowcxx . . $ structDataSubEditor#d_irow.], history); |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | void structStructEditorcxx . . $ structStructEditor# :: v_showMemberscxx . . $ structStructEditor#v_showMembers(49f6e7a06ebc5aa8). () { |
| 551 | showStructMemberscxx . . $ showStructMembers(88dab76137bd8b85). (this, ourcxx . . $ `melder/melder.h:42:9`! d_addresscxx . . $ structDataSubEditor#d_address., ourcxx . . $ `melder/melder.h:42:9`! d_descriptioncxx . . $ structDataSubEditor#d_description., ourcxx . . $ `melder/melder.h:42:9`! d_topFieldcxx . . $ structDataSubEditor#d_topField., ourcxx . . $ `melder/melder.h:42:9`! namecxx . . $ structThing#name..getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 552 | } |
| 553 | |
| 554 | static void StructEditor_initcxx . . $ StructEditor_init(910a0200d6e9e21b). (StructEditorcxx . . $ StructEditor# me, DataEditorcxx . . $ DataEditor# root, conststring32cxx . . $ conststring32# title, void *address, Data_Descriptioncxx . . $ Data_Description# description) { |
| 555 | DataSubEditor_initcxx . . $ DataSubEditor_init(8cc2a8f0a14773ad). (me, root, title, address, description); |
| 556 | } |
| 557 | |
| 558 | static void StructEditor_createcxx . . $ StructEditor_create(535ad5ea7dcd6bc3). (DataEditorcxx . . $ DataEditor# root, conststring32cxx . . $ conststring32# title, void *address, Data_Descriptioncxx . . $ Data_Description# description) { |
| 559 | try { |
| 560 | autoStructEditorcxx . . $ autoStructEditor# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (StructEditor); |
| 561 | StructEditor_initcxx . . $ StructEditor_init(910a0200d6e9e21b). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), root, title, address, description); |
| 562 | return me.releaseToUsercxx . . $ autoSomeThing#releaseToUser(ced63f7c635d850d).(); |
| 563 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 564 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Struct inspector window not created."); |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | /********** VectorEditor **********/ |
| 569 | |
| 570 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (VectorEditor, DataSubEditor, 0); |
| 571 | |
| 572 | integercxx . . $ integer# structVectorEditorcxx . . $ structVectorEditor# :: v_countFieldscxx . . $ structVectorEditor#v_countFields(da6335ded91d79c2). () { |
| 573 | integercxx . . $ integer# numberOfElements = d_maximumcxx . . $ structVectorEditor#d_maximum. - d_minimumcxx . . $ structVectorEditor#d_minimum. + 1; |
| 574 | if (d_descriptioncxx . . $ structDataSubEditor#d_description. -> typecxx . . $ structData_Description#type. == structwacxx . . $ `sys/Data.h:349:9`!) |
| 575 | return numberOfElements * (Data_Description_countMemberscxx . . $ Data_Description_countMembers(e486611939ed5677). (* (Data_Descriptioncxx . . $ Data_Description# *) d_descriptioncxx . . $ structDataSubEditor#d_description. -> tagTypecxx . . $ structData_Description#tagType.) + 1); |
| 576 | else |
| 577 | return numberOfElements; |
| 578 | } |
| 579 | |
| 580 | void structVectorEditorcxx . . $ structVectorEditor# :: v_showMemberscxx . . $ structVectorEditor#v_showMembers(49f6e7a06ebc5aa8). () { |
| 581 | int type = ourcxx . . $ `melder/melder.h:42:9`! d_descriptioncxx . . $ structDataSubEditor#d_description. -> typecxx . . $ structData_Description#type.; |
| 582 | bool isSingleType = ( type <= maxsingletypewacxx . . $ `sys/Data.h:348:9`! ); |
| 583 | integercxx . . $ integer# elementSize = ( type == structwacxx . . $ `sys/Data.h:349:9`! ? |
| 584 | Data_Description_countMemberscxx . . $ Data_Description_countMembers(e486611939ed5677). (* (Data_Descriptioncxx . . $ Data_Description# *) d_descriptioncxx . . $ structDataSubEditor#d_description. -> tagTypecxx . . $ structData_Description#tagType.) + 1 : 1 ); |
| 585 | integercxx . . $ integer# firstElement = d_minimumcxx . . $ structVectorEditor#d_minimum. + (d_topFieldcxx . . $ structDataSubEditor#d_topField. - 1) / elementSize; |
| 586 | |
| 587 | for (integercxx . . $ integer# ielement = firstElement; ielement <= d_maximumcxx . . $ structVectorEditor#d_maximum.; ielement ++) { |
| 588 | int skip = ielement == firstElement ? (ourcxx . . $ `melder/melder.h:42:9`! d_topFieldcxx . . $ structDataSubEditor#d_topField. - 1) % elementSize : 0; |
| 589 | |
| 590 | if (++ ourcxx . . $ `melder/melder.h:42:9`! d_irowcxx . . $ structDataSubEditor#d_irow. > kDataSubEditor_MAXNUM_ROWScxx . . $ `sys/DataEditor.h:42:9`!) return; |
| 591 | DataSubEditor_FieldDatacxx . . $ DataSubEditor_FieldData# fieldData = & ourcxx . . $ `melder/melder.h:42:9`! d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [d_irowcxx . . $ structDataSubEditor#d_irow.]; |
| 592 | |
| 593 | if (isSingleType) { |
| 594 | /* |
| 595 | TODO: assume the address refers to a constVEC; |
| 596 | this is not yet true of Collections, and |
| 597 | indirect has to be changed to direct in showStructMember() |
| 598 | */ |
| 599 | unsigned char *elementAddress = (unsigned char *) ourcxx . . $ `melder/melder.h:42:9`! d_addresscxx . . $ structDataSubEditor#d_address. + (ielement - 1) * ourcxx . . $ `melder/melder.h:42:9`! d_descriptioncxx . . $ structDataSubEditor#d_description. -> sizecxx . . $ structData_Description#size.; |
| 600 | |
| 601 | GuiControl_movecxx . . $ GuiControl_move(8866d61c560ae333). (fieldData -> labelcxx . . $ structDataSubEditor_FieldData#label., 0, fieldData -> ycxx . . $ structDataSubEditor_FieldData#y.); |
| 602 | GuiLabel_setTextcxx . . $ GuiLabel_setText(8fd1a6a47d1f7702). (fieldData -> labelcxx . . $ structDataSubEditor_FieldData#label., |
| 603 | Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (strip_dcxx . . $ strip_d(5553299aa8c4fee9). (ourcxx . . $ `melder/melder.h:42:9`! d_descriptioncxx . . $ structDataSubEditor#d_description. -> namecxx . . $ structData_Description#name.), U" [", |
| 604 | ( ourcxx . . $ `melder/melder.h:42:9`! d_descriptioncxx . . $ structDataSubEditor#d_description. -> rankcxx . . $ structData_Description#rank. == 3 ? ((conststring32cxx . . $ conststring32# (*) (int)) ourcxx . . $ `melder/melder.h:42:9`! d_descriptioncxx . . $ structDataSubEditor#d_description. -> min1cxx . . $ structData_Description#min1.) (ielement) : Melder_integercxx . . $ Melder_integer(7b348ebc2004441d). (ielement) ), |
| 605 | U"]")); |
| 606 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (fieldData -> labelcxx . . $ structDataSubEditor_FieldData#label.); |
| 607 | |
| 608 | autoMelderStringcxx . . $ autoMelderString# buffercxx . . $ autoMelderString#autoMelderString(49f6e7a06ebc5aa8).; |
| 609 | conststring32cxx . . $ conststring32# text = singleTypeToTextcxx . . $ singleTypeToText(b81cadf4cb98c416). (elementAddress, type, ourcxx . . $ `melder/melder.h:42:9`! d_descriptioncxx . . $ structDataSubEditor#d_description. -> tagTypecxx . . $ structData_Description#tagType., & buffer); |
| 610 | #if motifcxx . . $ `sys/Gui.h:34:10`! |
| 611 | XtVaSetValues (fieldData -> text -> d_widget, XmNcolumns, 60, nullptr); // TODO: change to GuiObject_size |
| 612 | #endif |
| 613 | GuiText_setStringcxx . . $ GuiText_setString(d44acbd60ea2b9be). (fieldData -> textcxx . . $ structDataSubEditor_FieldData#text., text); |
| 614 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (fieldData -> textcxx . . $ structDataSubEditor_FieldData#text.); |
| 615 | fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address. = elementAddress; |
| 616 | fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. = d_descriptioncxx . . $ structDataSubEditor#d_description.; |
| 617 | } else if (type == structwacxx . . $ `sys/Data.h:349:9`!) { |
| 618 | /* |
| 619 | TODO: assume the address refers to a constVEC; |
| 620 | this is not yet true of Collections, and |
| 621 | indirect has to be changed to direct in showStructMember() |
| 622 | */ |
| 623 | unsigned char *elementAddress = (unsigned char *) ourcxx . . $ `melder/melder.h:42:9`! d_addresscxx . . $ structDataSubEditor#d_address. + (ielement - 1) * ourcxx . . $ `melder/melder.h:42:9`! d_descriptioncxx . . $ structDataSubEditor#d_description. -> sizecxx . . $ structData_Description#size.; |
| 624 | |
| 625 | static MelderStringcxx . . $ MelderString# history; |
| 626 | MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& history, ourcxx . . $ `melder/melder.h:42:9`! namecxx . . $ structThing#name..getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 627 | |
| 628 | /* Replace things like [1..100] by things like [19]. */ |
| 629 | |
| 630 | if (history.stringcxx . . $ MelderString#string. [history.lengthcxx . . $ MelderString#length. - 1] == ']') { |
| 631 | char32cxx . . $ char32# *openingBracket = str32rchrcxx . . $ str32rchr(328a9ede0fba853a). (history.stringcxx . . $ MelderString#string., U'['); |
| 632 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (openingBracket != nullptr); |
| 633 | * openingBracket = '\0'; |
| 634 | history.lengthcxx . . $ MelderString#length. = openingBracket - history.stringcxx . . $ MelderString#string.; |
| 635 | } |
| 636 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& history, U"[", ielement, U"]"); |
| 637 | |
| 638 | if (skip) { |
| 639 | ourcxx . . $ `melder/melder.h:42:9`! d_irowcxx . . $ structDataSubEditor#d_irow. --; |
| 640 | } else { |
| 641 | GuiControl_movecxx . . $ GuiControl_move(8866d61c560ae333). (fieldData -> labelcxx . . $ structDataSubEditor_FieldData#label., 0, fieldData -> ycxx . . $ structDataSubEditor_FieldData#y.); |
| 642 | GuiLabel_setTextcxx . . $ GuiLabel_setText(8fd1a6a47d1f7702). (fieldData -> labelcxx . . $ structDataSubEditor_FieldData#label., |
| 643 | Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (strip_dcxx . . $ strip_d(5553299aa8c4fee9). (d_descriptioncxx . . $ structDataSubEditor#d_description. -> namecxx . . $ structData_Description#name.), U" [", ielement, U"]: ---------------------------")); |
| 644 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (fieldData -> labelcxx . . $ structDataSubEditor_FieldData#label.); |
| 645 | } |
| 646 | showStructMemberscxx . . $ showStructMembers(88dab76137bd8b85). (this, elementAddress, * (Data_Descriptioncxx . . $ Data_Description# *) d_descriptioncxx . . $ structDataSubEditor#d_description. -> tagTypecxx . . $ structData_Description#tagType., skip, history.stringcxx . . $ MelderString#string.); |
| 647 | } else if (type == objectwacxx . . $ `sys/Data.h:351:9`!) { |
| 648 | /* |
| 649 | TODO: assume the address refers to the items of a Collection (?) |
| 650 | */ |
| 651 | unsigned char *elementAddress = (unsigned char *) ourcxx . . $ `melder/melder.h:42:9`! d_addresscxx . . $ structDataSubEditor#d_address. + ielement * ourcxx . . $ `melder/melder.h:42:9`! d_descriptioncxx . . $ structDataSubEditor#d_description. -> sizecxx . . $ structData_Description#size.; |
| 652 | |
| 653 | static MelderStringcxx . . $ MelderString# history; |
| 654 | MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& history, ourcxx . . $ `melder/melder.h:42:9`! namecxx . . $ structThing#name..getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 655 | if (history.stringcxx . . $ MelderString#string. [history.lengthcxx . . $ MelderString#length. - 1] == U']') { |
| 656 | char32cxx . . $ char32# *openingBracket = str32rchrcxx . . $ str32rchr(328a9ede0fba853a). (history.stringcxx . . $ MelderString#string., U'['); |
| 657 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (openingBracket != nullptr); |
| 658 | * openingBracket = U'\0'; |
| 659 | history.lengthcxx . . $ MelderString#length. = openingBracket - history.stringcxx . . $ MelderString#string.; |
| 660 | } |
| 661 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& history, U"[", ielement, U"]"); |
| 662 | |
| 663 | GuiControl_movecxx . . $ GuiControl_move(8866d61c560ae333). (fieldData -> labelcxx . . $ structDataSubEditor_FieldData#label., 0, fieldData -> ycxx . . $ structDataSubEditor_FieldData#y.); |
| 664 | GuiLabel_setTextcxx . . $ GuiLabel_setText(8fd1a6a47d1f7702). (fieldData -> labelcxx . . $ structDataSubEditor_FieldData#label., Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (strip_dcxx . . $ strip_d(5553299aa8c4fee9). (ourcxx . . $ `melder/melder.h:42:9`! d_descriptioncxx . . $ structDataSubEditor#d_description. -> namecxx . . $ structData_Description#name.), U" [", ielement, U"]")); |
| 665 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (fieldData -> labelcxx . . $ structDataSubEditor_FieldData#label.); |
| 666 | |
| 667 | Daatacxx . . $ Daata# object = * (Daatacxx . . $ Daata# *) elementAddress; |
| 668 | if (! object) |
| 669 | return; // no button if no object |
| 670 | if (! Class_getDescriptioncxx . . $ Class_getDescription(3d65f6a7e43d24a3). (object -> classInfocxx . . $ structThing#classInfo.)) |
| 671 | return; // no button if no description for this class |
| 672 | fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address. = object; |
| 673 | fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. = Class_getDescriptioncxx . . $ Class_getDescription(3d65f6a7e43d24a3). (object -> classInfocxx . . $ structThing#classInfo.); |
| 674 | fieldData -> rankcxx . . $ structDataSubEditor_FieldData#rank. = 0; |
| 675 | fieldData -> historycxx . . $ structDataSubEditor_FieldData#history. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (history.stringcxx . . $ MelderString#string.); |
| 676 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (fieldData -> buttoncxx . . $ structDataSubEditor_FieldData#button.); |
| 677 | } |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | static void VectorEditor_createcxx . . $ VectorEditor_create(73194d1d0e491f55). (DataEditorcxx . . $ DataEditor# root, conststring32cxx . . $ conststring32# title, void *address, |
| 682 | Data_Descriptioncxx . . $ Data_Description# description, integercxx . . $ integer# minimum, integercxx . . $ integer# maximum) |
| 683 | { |
| 684 | try { |
| 685 | autoVectorEditorcxx . . $ autoVectorEditor# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (VectorEditor); |
| 686 | mycxx . . $ `melder/melder.h:44:9`! d_minimumcxx . . $ structVectorEditor#d_minimum. = minimum; |
| 687 | mycxx . . $ `melder/melder.h:44:9`! d_maximumcxx . . $ structVectorEditor#d_maximum. = maximum; |
| 688 | DataSubEditor_initcxx . . $ DataSubEditor_init(8cc2a8f0a14773ad). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), root, title, address, description); |
| 689 | return me.releaseToUsercxx . . $ autoSomeThing#releaseToUser(ced63f7c635d850d).(); |
| 690 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 691 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Vector inspector window not created."); |
| 692 | } |
| 693 | } |
| 694 | |
| 695 | /********** MatrixEditor **********/ |
| 696 | |
| 697 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (MatrixEditor, DataSubEditor, 0); |
| 698 | |
| 699 | integercxx . . $ integer# structMatrixEditorcxx . . $ structMatrixEditor# :: v_countFieldscxx . . $ structMatrixEditor#v_countFields(da6335ded91d79c2). () { |
| 700 | integercxx . . $ integer# numberOfElements = (d_maximumcxx . . $ structMatrixEditor#d_maximum. - d_minimumcxx . . $ structMatrixEditor#d_minimum. + 1) * (d_max2cxx . . $ structMatrixEditor#d_max2. - d_min2cxx . . $ structMatrixEditor#d_min2. + 1); |
| 701 | if (d_descriptioncxx . . $ structDataSubEditor#d_description. -> typecxx . . $ structData_Description#type. == structwacxx . . $ `sys/Data.h:349:9`!) |
| 702 | return numberOfElements * (Data_Description_countMemberscxx . . $ Data_Description_countMembers(e486611939ed5677). (* (Data_Descriptioncxx . . $ Data_Description# *) d_descriptioncxx . . $ structDataSubEditor#d_description. -> tagTypecxx . . $ structData_Description#tagType.) + 1); |
| 703 | else |
| 704 | return numberOfElements; |
| 705 | } |
| 706 | |
| 707 | void structMatrixEditorcxx . . $ structMatrixEditor# :: v_showMemberscxx . . $ structMatrixEditor#v_showMembers(49f6e7a06ebc5aa8). () { |
| 708 | int type = ourcxx . . $ `melder/melder.h:42:9`! d_descriptioncxx . . $ structDataSubEditor#d_description. -> typecxx . . $ structData_Description#type.; |
| 709 | bool isSingleType = ( type <= maxsingletypewacxx . . $ `sys/Data.h:348:9`! ); |
| 710 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (isSingleType); // allow no struct matrices |
| 711 | integercxx . . $ integer# rowSize = ourcxx . . $ `melder/melder.h:42:9`! d_max2cxx . . $ structMatrixEditor#d_max2. - ourcxx . . $ `melder/melder.h:42:9`! d_min2cxx . . $ structMatrixEditor#d_min2. + 1; |
| 712 | constMATcxx . . $ constMAT# mat = * (constMATcxx . . $ constMAT# *) d_addresscxx . . $ structDataSubEditor#d_address.; // HACK: this could be a MAT or an INTMAT |
| 713 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (rowSize == mat.ncol); // HACK: this should work correctly even for an INTMAT |
| 714 | integercxx . . $ integer# firstRow = d_minimumcxx . . $ structMatrixEditor#d_minimum. + (d_topFieldcxx . . $ structDataSubEditor#d_topField. - 1) / rowSize; |
| 715 | integercxx . . $ integer# firstColumn = d_min2cxx . . $ structMatrixEditor#d_min2. + (d_topFieldcxx . . $ structDataSubEditor#d_topField. - 1 - (firstRow - d_minimumcxx . . $ structMatrixEditor#d_minimum.) * rowSize); |
| 716 | |
| 717 | for (integercxx . . $ integer# irow = firstRow; irow <= d_maximumcxx . . $ structMatrixEditor#d_maximum.; irow ++) |
| 718 | for (integercxx . . $ integer# icolumn = irow == firstRow ? firstColumn : d_min2cxx . . $ structMatrixEditor#d_min2.; icolumn <= d_max2cxx . . $ structMatrixEditor#d_max2.; icolumn ++) { |
| 719 | unsigned char *elementAddress = (unsigned char *) mat.cellscxx . . $ constmatrix#cells. + ((irow - 1) * rowSize + (icolumn - 1)) * d_descriptioncxx . . $ structDataSubEditor#d_description. -> sizecxx . . $ structData_Description#size.; |
| 720 | // not & mat [irow] [icol], because that HACK would not work for an INTMAT |
| 721 | |
| 722 | if (++ d_irowcxx . . $ structDataSubEditor#d_irow. > kDataSubEditor_MAXNUM_ROWScxx . . $ `sys/DataEditor.h:42:9`!) |
| 723 | return; |
| 724 | DataSubEditor_FieldDatacxx . . $ DataSubEditor_FieldData# fieldData = & d_fieldDatacxx . . $ structDataSubEditor#d_fieldData. [d_irowcxx . . $ structDataSubEditor#d_irow.]; |
| 725 | |
| 726 | if (isSingleType) { |
| 727 | GuiControl_movecxx . . $ GuiControl_move(8866d61c560ae333). (fieldData -> labelcxx . . $ structDataSubEditor_FieldData#label., 0, fieldData -> ycxx . . $ structDataSubEditor_FieldData#y.); |
| 728 | GuiLabel_setTextcxx . . $ GuiLabel_setText(8fd1a6a47d1f7702). (fieldData -> labelcxx . . $ structDataSubEditor_FieldData#label., Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (strip_dcxx . . $ strip_d(5553299aa8c4fee9). (d_descriptioncxx . . $ structDataSubEditor#d_description. -> namecxx . . $ structData_Description#name.), U" [", irow, U"] [", icolumn, U"]")); |
| 729 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (fieldData -> labelcxx . . $ structDataSubEditor_FieldData#label.); |
| 730 | |
| 731 | autoMelderStringcxx . . $ autoMelderString# buffercxx . . $ autoMelderString#autoMelderString(49f6e7a06ebc5aa8).; |
| 732 | conststring32cxx . . $ conststring32# text = singleTypeToTextcxx . . $ singleTypeToText(b81cadf4cb98c416). (elementAddress, type, d_descriptioncxx . . $ structDataSubEditor#d_description. -> tagTypecxx . . $ structData_Description#tagType., & buffer); |
| 733 | #if motifcxx . . $ `sys/Gui.h:34:10`! |
| 734 | XtVaSetValues (fieldData -> text -> d_widget, XmNcolumns, 60, nullptr); // TODO: change to GuiObject_size |
| 735 | #endif |
| 736 | GuiText_setStringcxx . . $ GuiText_setString(d44acbd60ea2b9be). (fieldData -> textcxx . . $ structDataSubEditor_FieldData#text., text); |
| 737 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (fieldData -> textcxx . . $ structDataSubEditor_FieldData#text.); |
| 738 | fieldData -> addresscxx . . $ structDataSubEditor_FieldData#address. = elementAddress; |
| 739 | fieldData -> descriptioncxx . . $ structDataSubEditor_FieldData#description. = d_descriptioncxx . . $ structDataSubEditor#d_description.; |
| 740 | } |
| 741 | } |
| 742 | } |
| 743 | |
| 744 | static void MatrixEditor_createcxx . . $ MatrixEditor_create(5c2c873b0ac6372d). (DataEditorcxx . . $ DataEditor# root, conststring32cxx . . $ conststring32# title, void *address, |
| 745 | Data_Descriptioncxx . . $ Data_Description# description, integercxx . . $ integer# min1, integercxx . . $ integer# max1, integercxx . . $ integer# min2, integercxx . . $ integer# max2) |
| 746 | { |
| 747 | try { |
| 748 | autoMatrixEditorcxx . . $ autoMatrixEditor# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (MatrixEditor); |
| 749 | mycxx . . $ `melder/melder.h:44:9`! d_minimumcxx . . $ structMatrixEditor#d_minimum. = min1; |
| 750 | mycxx . . $ `melder/melder.h:44:9`! d_maximumcxx . . $ structMatrixEditor#d_maximum. = max1; |
| 751 | mycxx . . $ `melder/melder.h:44:9`! d_min2cxx . . $ structMatrixEditor#d_min2. = min2; |
| 752 | mycxx . . $ `melder/melder.h:44:9`! d_max2cxx . . $ structMatrixEditor#d_max2. = max2; |
| 753 | DataSubEditor_initcxx . . $ DataSubEditor_init(8cc2a8f0a14773ad). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), root, title, address, description); |
| 754 | return me.releaseToUsercxx . . $ autoSomeThing#releaseToUser(ced63f7c635d850d).(); |
| 755 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 756 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Matrix inspector window not created."); |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | /********** ClassEditor **********/ |
| 761 | |
| 762 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (ClassEditor, StructEditor, 0); |
| 763 | |
| 764 | static void ClassEditor_showMembers_recursivecxx . . $ ClassEditor_showMembers_recursive(10fb34844ba127f). (ClassEditorcxx . . $ ClassEditor# me, ClassInfocxx . . $ ClassInfo# klas) { |
| 765 | ClassInfocxx . . $ ClassInfo# parentClass = klas -> semanticParentcxx . . $ structClassInfo#semanticParent.; |
| 766 | Data_Descriptioncxx . . $ Data_Description# description = Class_getDescriptioncxx . . $ Class_getDescription(3d65f6a7e43d24a3). (klas); |
| 767 | int classFieldsTraversed = 0; |
| 768 | while (Class_getDescriptioncxx . . $ Class_getDescription(3d65f6a7e43d24a3). (parentClass) == description) |
| 769 | parentClass = parentClass -> semanticParentcxx . . $ structClassInfo#semanticParent.; |
| 770 | if (parentClass != classDaatacxx . . $ classDaata.) { |
| 771 | ClassEditor_showMembers_recursivecxx . . $ ClassEditor_showMembers_recursive(10fb34844ba127f). (me, parentClass); |
| 772 | classFieldsTraversed = Data_Description_countMemberscxx . . $ Data_Description_countMembers(e486611939ed5677). (Class_getDescriptioncxx . . $ Class_getDescription(3d65f6a7e43d24a3). (parentClass)); |
| 773 | //Melder_casual (U"ClassEditor_showMembers_recursive: classFieldsTraversed = ", classFieldsTraversed); |
| 774 | } |
| 775 | showStructMemberscxx . . $ showStructMembers(88dab76137bd8b85). (me, mycxx . . $ `melder/melder.h:44:9`! d_addresscxx . . $ structDataSubEditor#d_address., description, mycxx . . $ `melder/melder.h:44:9`! d_irowcxx . . $ structDataSubEditor#d_irow. ? 1 : mycxx . . $ `melder/melder.h:44:9`! d_topFieldcxx . . $ structDataSubEditor#d_topField. - classFieldsTraversed, mycxx . . $ `melder/melder.h:44:9`! namecxx . . $ structThing#name..getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 776 | } |
| 777 | |
| 778 | void structClassEditorcxx . . $ structClassEditor# :: v_showMemberscxx . . $ structClassEditor#v_showMembers(49f6e7a06ebc5aa8). () { |
| 779 | ClassEditor_showMembers_recursivecxx . . $ ClassEditor_showMembers_recursive(10fb34844ba127f). (this, ((Daatacxx . . $ Daata#) d_addresscxx . . $ structDataSubEditor#d_address.) -> classInfocxx . . $ structThing#classInfo.); |
| 780 | } |
| 781 | |
| 782 | static void ClassEditor_initcxx . . $ ClassEditor_init(5a3e50af100a6f41). (ClassEditorcxx . . $ ClassEditor# me, DataEditorcxx . . $ DataEditor# root, conststring32cxx . . $ conststring32# title, void *address, Data_Descriptioncxx . . $ Data_Description# description) { |
| 783 | if (! description) |
| 784 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Class ", Thing_className ((Thing) address), U" cannot be inspected."); |
| 785 | StructEditor_initcxx . . $ StructEditor_init(910a0200d6e9e21b). (me, root, title, address, description); |
| 786 | } |
| 787 | |
| 788 | static void ClassEditor_createcxx . . $ ClassEditor_create(535ad5ea7dcd6bc3). (DataEditorcxx . . $ DataEditor# root, conststring32cxx . . $ conststring32# title, void *address, Data_Descriptioncxx . . $ Data_Description# description) { |
| 789 | try { |
| 790 | autoClassEditorcxx . . $ autoClassEditor# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (ClassEditor); |
| 791 | ClassEditor_initcxx . . $ ClassEditor_init(5a3e50af100a6f41). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), root, title, address, description); |
| 792 | return me.releaseToUsercxx . . $ autoSomeThing#releaseToUser(ced63f7c635d850d).(); |
| 793 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 794 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Class inspector window not created."); |
| 795 | } |
| 796 | } |
| 797 | |
| 798 | /********** DataEditor **********/ |
| 799 | |
| 800 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (DataEditor, ClassEditor, 0); |
| 801 | |
| 802 | static void DataEditor_destroyAllChildrencxx . . $ DataEditor_destroyAllChildren(5b80a29318b82943). (DataEditorcxx . . $ DataEditor# me) { |
| 803 | /* |
| 804 | To destroy all children, we travel them from youngest to oldest, |
| 805 | because the array of children will change from under us: |
| 806 | */ |
| 807 | for (int i = mycxx . . $ `melder/melder.h:44:9`! childrencxx . . $ structDataEditor#children..sizecxx . . $ CollectionOf#size.; i >= 1; i --) { |
| 808 | /* |
| 809 | An optimization coming! |
| 810 | |
| 811 | Instead of |
| 812 | DataSubEditor child = my children [i]; |
| 813 | forget (child); |
| 814 | we isolate the child from the parent before destroying the child, |
| 815 | so that the child won't try to remove the reference |
| 816 | that the parent has to her. |
| 817 | So first we make the parent forget the moribund child, |
| 818 | which prevents a dangling pointer: |
| 819 | */ |
| 820 | DataSubEditorcxx . . $ DataSubEditor# child = mycxx . . $ `melder/melder.h:44:9`! childrencxx . . $ structDataEditor#children.. subtractItem_refcxx . . $ CollectionOf#subtractItem_ref(9e08865953f747b0). (i); |
| 821 | /* |
| 822 | That was fast, because subtracting the last item involves no shifting |
| 823 | of the remaining items. |
| 824 | |
| 825 | Second, we make the child forget the parent, |
| 826 | so that the child won't try to remove the reference |
| 827 | that the parent had to her (but no longer has): |
| 828 | */ |
| 829 | child -> rootcxx . . $ structDataSubEditor#root. = nullptr; |
| 830 | /* |
| 831 | The child is now fully isolated, so we are ready to destroy her: |
| 832 | */ |
| 833 | forgetcxx . . $ `sys/Thing.h:158:9`! (child); |
| 834 | /* |
| 835 | This procedure was an optimization because if we just destroyed each child, |
| 836 | each child would remove itself from the array by (1) searching for itself |
| 837 | and (2) shifting the remaining children, both of which have a complexity |
| 838 | that is linear in the number of children. So we would end up with quadratic complexity, |
| 839 | whereas the procedure that we use above has linear complexity. |
| 840 | |
| 841 | This linear complexity makes this procedure good enough for `v9_destroy()` |
| 842 | (where obtaining linear complexity would have been easy anyway), |
| 843 | and nice enough for `v1_dataChanged()`. |
| 844 | |
| 845 | Something to note is that this procedure doesn't care whether the autoCollection |
| 846 | `children` owns its items or not. |
| 847 | */ |
| 848 | } |
| 849 | } |
| 850 | |
| 851 | void structDataEditorcxx . . $ structDataEditor# :: v9_destroycxx . . $ structDataEditor#v9_destroy(ced63f7c635d850d). () noexcept { |
| 852 | DataEditor_destroyAllChildrencxx . . $ DataEditor_destroyAllChildren(5b80a29318b82943). (this); |
| 853 | DataEditor_Parentcxx . . $ DataEditor_Parent# :: v9_destroycxx . . $ structDataSubEditor#v9_destroy(ced63f7c635d850d). (); |
| 854 | } |
| 855 | |
| 856 | void structDataEditorcxx . . $ structDataEditor# :: v1_dataChangedcxx . . $ structDataEditor#v1_dataChanged(c0154a85f79216c7). (Editorcxx . . $ Editor# sender) { |
| 857 | if (this == sender) |
| 858 | return; |
| 859 | /* |
| 860 | Someone *else* changed our data. |
| 861 | We know that the top-level data is still accessible, |
| 862 | so we update the top-level window to show the change: |
| 863 | */ |
| 864 | updatecxx . . $ update(e8a04abbe5c0eb6e). (this); |
| 865 | /* |
| 866 | Changing the data may have changed any part of the *structure* of the data, |
| 867 | so we do not know if the data visible in any of the subeditors is still valid. |
| 868 | We follow the most straightforward solution, which is to simply close all the child windows, |
| 869 | which guarantees the removal of all dangling visual representations: |
| 870 | */ |
| 871 | DataEditor_destroyAllChildrencxx . . $ DataEditor_destroyAllChildren(5b80a29318b82943). (this); |
| 872 | } |
| 873 | |
| 874 | autoDataEditorcxx . . $ autoDataEditor# DataEditor_createcxx . . $ DataEditor_create(5c508204efd4b98). (conststring32cxx . . $ conststring32# title, Daatacxx . . $ Daata# data) { |
| 875 | try { |
| 876 | ClassInfocxx . . $ ClassInfo# klas = data -> classInfocxx . . $ structThing#classInfo.; |
| 877 | if (Class_getDescriptioncxx . . $ Class_getDescription(3d65f6a7e43d24a3). (klas) == nullptr) |
| 878 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Class ", klas -> className, U" cannot be inspected."); |
| 879 | autoDataEditorcxx . . $ autoDataEditor# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (DataEditor); |
| 880 | ClassEditor_initcxx . . $ ClassEditor_init(5a3e50af100a6f41). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), title, data, Class_getDescriptioncxx . . $ Class_getDescription(3d65f6a7e43d24a3). (klas)); |
| 881 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 882 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 883 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Inspector window not created."); |
| 884 | } |
| 885 | } |
| 886 | |
| 887 | /* End of file DataEditor.cpp */ |