Debian Codegraph @

sys/GuiOptionMenu.cpp

raw symbols SCIP
1 /* GuiOptionMenu.cpp
2 *
3 * Copyright (C) 1993-2018,2020,2021 Paul Boersma, 2007 Stefan de Konink, 2013 Tom Naughton
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 #include "GuiP.h"cxx . . $ `<file>/sys/GuiP.h`/
20
21 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (GuiOptionMenu, GuiControl, 0);
22
23 #if gtkcxx . . $ `sys/Gui.h:33:10`!
24 static void _guiGtkOptionMenu_destroyCallbackcxx . . $ _guiGtkOptionMenu_destroyCallback(6c58c5e2437d25a2). (GuiObjectcxx . . $ GuiObject# /* widget */, gpointer void_me) {
25 iamcxx . . $ `melder/melder.h:50:9`! (GuiOptionMenu);
26 forgetcxx . . $ `sys/Thing.h:158:9`! (me);
27 }
28 #elif motif
29 static void _guiMotifOptionMenu_destroyCallback (GuiObject /* widget */, XtPointer void_me, XtPointer /* call */) {
30 iam (GuiOptionMenu);
31 forget (me);
32 }
33 #elif cocoa
34 @implementation GuiCocoaOptionMenu {
35 GuiOptionMenu d_userData;
36 }
37 - (void) dealloc { // override
38 GuiOptionMenu me = d_userData;
39 [self removeAllItems];
40 [self setMenu:nil];
41
42 forget (me);
43 trace (U"deleting an option menu");
44 [super dealloc];
45 }
46 - (GuiThing) getUserData {
47 return d_userData;
48 }
49 - (void) setUserData: (GuiThing) userData {
50 d_userData = (GuiOptionMenu) userData;
51 }
52 @end
53 #endif
54
55 void structGuiOptionMenucxx . . $ structGuiOptionMenu# :: v_showcxx . . $ structGuiOptionMenu#v_show(49f6e7a06ebc5aa8). () {
56 #if gtkcxx . . $ `sys/Gui.h:33:10`!
57 GuiOptionMenu_Parentcxx . . $ GuiOptionMenu_Parent# :: v_showcxx . . $ structGuiThing#v_show(49f6e7a06ebc5aa8). ();
58 #elif motif
59 XtManageChild (d_xmMenuBar);
60 #elif cocoa
61 //NSLog(@"cocoa structGuiOptionMenu :: v_show"); // ?
62 #endif
63 }
64
65 void GuiOptionMenu_initcxx . . $ GuiOptionMenu_init(4af4a830f4edfcb4). (GuiOptionMenucxx . . $ GuiOptionMenu# me, GuiFormcxx . . $ GuiForm# parent, int left, int right, int top, int bottom, uint32cxx . . $ uint32# flags)
66 {
67 mycxx . . $ `melder/melder.h:44:9`! d_shellcxx . . $ structGuiThing#d_shell. = parent -> d_shellcxx . . $ structGuiThing#d_shell.;
68 mycxx . . $ `melder/melder.h:44:9`! d_parentcxx . . $ structGuiThing#d_parent. = parent;
69 #if gtkcxx . . $ `sys/Gui.h:33:10`!
70 mycxx . . $ `melder/melder.h:44:9`! d_widgetcxx . . $ structGuiThing#d_widget. = gtk_combo_box_text_new ();
71 gtk_widget_set_size_request (GTK_WIDGETcxx . . $ `<external>/6031079988677191796/gtkwidget.h:58:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), right - left, bottom - top + 8);
72 gtk_fixed_put (GTK_FIXEDcxx . . $ `<external>/4105621574481455997/gtkfixed.h:39:9`! (parent -> d_widget), GTK_WIDGETcxx . . $ `<external>/6031079988677191796/gtkwidget.h:58:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), left, top - 6);
73 gtk_widget_set_focus_on_click (GTK_WIDGETcxx . . $ `<external>/6031079988677191796/gtkwidget.h:58:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), false);
74 gtk_widget_set_can_default (GTK_WIDGETcxx . . $ `<external>/6031079988677191796/gtkwidget.h:58:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), false);
75 #elif motif
76 my d_xmMenuBar = XmCreateMenuBar (parent -> d_widget, "UiOptionMenu", nullptr, 0);
77 XtVaSetValues (my d_xmMenuBar, XmNx, left - 4, XmNy, top - 4,
78 XmNwidth, right - left + 8, XmNheight, bottom - top + 8, nullptr);
79 my d_xmCascadeButton = XmCreateCascadeButton (my d_xmMenuBar, "choice", nullptr, 0);
80 my d_widget = XmCreatePulldownMenu (my d_xmMenuBar, "choice", nullptr, 0);
81 if (flags & GuiMenu_INSENSITIVE)
82 XtSetSensitive (my d_widget, False);
83 XtVaSetValues (my d_xmCascadeButton, XmNsubMenuId, my d_widget, nullptr);
84 XtManageChild (my d_xmCascadeButton);
85 XtVaSetValues (my d_xmMenuBar, XmNwidth, right - left + 8, nullptr); // BUG: twice?
86 XtVaSetValues (my d_xmCascadeButton, XmNx, 4, XmNy, 4, XmNwidth, right - left, XmNheight, bottom - top, nullptr);
87 #elif cocoa
88 GuiCocoaOptionMenu *optionMenu = [[GuiCocoaOptionMenu alloc] init];
89 my d_widget = (GuiObject) optionMenu;
90 my v_positionInForm (my d_widget, left, right, top - 2, bottom + 3, parent);
91 [optionMenu setUserData: me];
92 // [optionMenu setBezelStyle: NSRoundedBezelStyle];
93 // [optionMenu setBordered: NO];
94 #endif
95
96 #if gtkcxx . . $ `sys/Gui.h:33:10`!
97 g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), "destroy", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (_guiGtkOptionMenu_destroyCallback), me);
98 #elif motif
99 XtAddCallback (my d_widget, XmNdestroyCallback, _guiMotifOptionMenu_destroyCallback, me);
100 #elif cocoa
101 #endif
102 }
103
104 GuiOptionMenucxx . . $ GuiOptionMenu# GuiOptionMenu_createcxx . . $ GuiOptionMenu_create(10957ba5007081ba). (GuiFormcxx . . $ GuiForm# parent, int left, int right, int top, int bottom, uint32cxx . . $ uint32# flags) {
105 autoGuiOptionMenucxx . . $ autoGuiOptionMenu# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (GuiOptionMenu);
106 GuiOptionMenu_initcxx . . $ GuiOptionMenu_init(4af4a830f4edfcb4). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), parent, left, right, top, bottom, flags);
107 return me.releaseToAmbiguousOwnercxx . . $ autoSomeThing#releaseToAmbiguousOwner(258ee1c9e0a18a5c).();
108 }
109
110 GuiOptionMenucxx . . $ GuiOptionMenu# GuiOptionMenu_createShowncxx . . $ GuiOptionMenu_createShown(10957ba5007081ba). (GuiFormcxx . . $ GuiForm# parent, int left, int right, int top, int bottom, uint32cxx . . $ uint32# flags) {
111 GuiOptionMenucxx . . $ GuiOptionMenu# me = GuiOptionMenu_createcxx . . $ GuiOptionMenu_create(10957ba5007081ba). (parent, left, right, top, bottom, flags);
112 GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (me);
113 return me;
114 }
115
116 #if motifcxx . . $ `sys/Gui.h:34:10`!
117 static void cb_optionChanged (GuiObject w, XtPointer void_me, XtPointer /* call */) {
118 iam (GuiOptionMenu);
119 for (int i = 1; i <= my d_options.size; i ++) {
120 GuiMenuItem item = my d_options.at [i];
121 if (item -> d_widget == w) {
122 XtVaSetValues (my d_xmCascadeButton, XmNlabelString, Melder_peek32to8 (item -> d_widget -> name.get()), nullptr);
123 XmToggleButtonSetState (item -> d_widget, true, false);
124 if (Melder_debug == 11)
125 Melder_warning (i, U" \"", item -> d_widget -> name.get(), U"\"");
126 } else {
127 XmToggleButtonSetState (item -> d_widget, false, false);
128 }
129 }
130 }
131 #endif
132
133 void GuiOptionMenu_addOptioncxx . . $ GuiOptionMenu_addOption(fceebdf82f762738). (GuiOptionMenucxx . . $ GuiOptionMenu# me, conststring32cxx . . $ conststring32# text) {
134 #if gtkcxx . . $ `sys/Gui.h:33:10`!
135 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXTcxx . . $ `<external>/11051365407401659522/gtkcomboboxtext.h:31:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), Melder_peek32to8 (text));
136 #elif motif
137 autoGuiMenuItem menuItem = Thing_new (GuiMenuItem);
138 menuItem -> d_widget = XtVaCreateManagedWidget (Melder_peek32to8 (text), xmToggleButtonWidgetClass, my d_widget, nullptr);
139 XtAddCallback (menuItem -> d_widget, XmNvalueChangedCallback, cb_optionChanged, (XtPointer) me);
140 my d_options. addItem_move (menuItem.move());
141 #elif cocoa
142 GuiCocoaOptionMenu *menu = (GuiCocoaOptionMenu *) my d_widget;
143 [menu addItemWithTitle: [NSString stringWithUTF8String: Melder_peek32to8 (text)]];
144 #endif
145 }
146
147 int GuiOptionMenu_getValuecxx . . $ GuiOptionMenu_getValue(946f35f31f8751a1). (GuiOptionMenucxx . . $ GuiOptionMenu# me) {
148 mycxx . . $ `melder/melder.h:44:9`! d_valuecxx . . $ structGuiOptionMenu#d_value. = 0;
149 #if gtkcxx . . $ `sys/Gui.h:33:10`!
150 // TODO: Graag even een check :)
151 mycxx . . $ `melder/melder.h:44:9`! d_valuecxx . . $ structGuiOptionMenu#d_value. = gtk_combo_box_get_active (GTK_COMBO_BOXcxx . . $ `<external>/2430749772834803202/gtkcombobox.h:32:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget)) + 1;
152 #elif motif
153 for (int i = 1; i <= my d_options.size; i ++) {
154 GuiMenuItem menuItem = my d_options.at [i];
155 if (XmToggleButtonGetState (menuItem -> d_widget))
156 my d_value = i;
157 }
158 #elif cocoa
159 GuiCocoaOptionMenu *menu = (GuiCocoaOptionMenu *) my d_widget;
160 my d_value = [menu indexOfSelectedItem] + 1;
161 #endif
162 return mycxx . . $ `melder/melder.h:44:9`! d_valuecxx . . $ structGuiOptionMenu#d_value.;
163 }
164
165 void GuiOptionMenu_setValuecxx . . $ GuiOptionMenu_setValue(cf6045fb1035e11f). (GuiOptionMenucxx . . $ GuiOptionMenu# me, int value) {
166 #if gtkcxx . . $ `sys/Gui.h:33:10`!
167 gtk_combo_box_set_active (GTK_COMBO_BOXcxx . . $ `<external>/2430749772834803202/gtkcombobox.h:32:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), value - 1);
168 #elif motif
169 for (int i = 1; i <= my d_options.size; i ++) {
170 GuiMenuItem menuItem = my d_options.at [i];
171 XmToggleButtonSetState (menuItem -> d_widget, i == value, False);
172 if (i == value)
173 XtVaSetValues (my d_xmCascadeButton, XmNlabelString, Melder_peek32to8 (menuItem -> d_widget -> name.get()), nullptr);
174 }
175 #elif cocoa
176 GuiCocoaOptionMenu *menu = (GuiCocoaOptionMenu *) my d_widget;
177 [menu selectItemAtIndex: value - 1];
178 #endif
179 mycxx . . $ `melder/melder.h:44:9`! d_valuecxx . . $ structGuiOptionMenu#d_value. = value;
180 }
181
182 /* End of file GuiOptionMenu.cpp */