Debian Codegraph @

sys/GuiCheckButton.cpp

raw symbols SCIP
1 /* GuiCheckButton.cpp
2 *
3 * Copyright (C) 1993-2012-2018,2024 Paul Boersma,
4 * 2007-2008 Stefan de Konink, 2010 Franz Brausse, 2013 Tom Naughton
5 *
6 * This code is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
10 *
11 * This code is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this work. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "GuiP.h"cxx . . $ `<file>/sys/GuiP.h`/
21
22 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (GuiCheckButton, GuiControl, 0);
23
24 #if motifcxx . . $ `sys/Gui.h:34:10`!
25 #define iam_checkbutton \
26 Melder_assert (widget -> widgetClass == xmToggleButtonWidgetClass); \
27 GuiCheckButton me = (GuiCheckButton) widget -> userData
28 #else
29 #define iam_checkbuttoncxx . . $ `sys/GuiCheckButton.cpp:29:10`! \
30 GuiCheckButton me = (GuiCheckButton) _GuiObject_getUserData (widget)
31 #endif
32
33 #if gtkcxx . . $ `sys/Gui.h:33:10`!
34 static void _GuiGtkCheckButton_destroyCallbackcxx . . $ _GuiGtkCheckButton_destroyCallback(6c58c5e2437d25a2). (GuiObjectcxx . . $ GuiObject# widget, gpointer void_me) {
35 (void) widget;
36 iamcxx . . $ `melder/melder.h:50:9`! (GuiCheckButton);
37 forgetcxx . . $ `sys/Thing.h:158:9`! (me);
38 }
39 static void _GuiGtkCheckButton_valueChangedCallbackcxx . . $ _GuiGtkCheckButton_valueChangedCallback(6c58c5e2437d25a2). (GuiObjectcxx . . $ GuiObject# widget, gpointer void_me) {
40 iamcxx . . $ `melder/melder.h:50:9`! (GuiCheckButton);
41 if (mycxx . . $ `melder/melder.h:44:9`! d_valueChangedCallbackcxx . . $ structGuiCheckButton#d_valueChangedCallback. && ! mycxx . . $ `melder/melder.h:44:9`! d_blockValueChangedCallbackscxx . . $ structGuiControl#d_blockValueChangedCallbacks.) {
42 struct structGuiCheckButtonEventcxx . . $ structGuiCheckButtonEvent# event { me };
43 mycxx . . $ `melder/melder.h:44:9`! d_valueChangedCallbackcxx . . $ structGuiCheckButton#d_valueChangedCallback. (cxx . . $ MelderCallback#`operator()`(e7ade0e2880b4e44).mycxx . . $ `melder/melder.h:44:9`! d_valueChangedBosscxx . . $ structGuiCheckButton#d_valueChangedBoss., & event);
44 }
45 }
46 #elif motif
47 void _GuiWinCheckButton_destroy (GuiObject widget) {
48 iam_checkbutton;
49 _GuiNativeControl_destroy (widget);
50 forget (me); // NOTE: my widget is not destroyed here
51 }
52 void _GuiWinCheckButton_handleClick (GuiObject widget) {
53 iam_checkbutton;
54 if (my d_valueChangedCallback) {
55 struct structGuiCheckButtonEvent event { me };
56 my d_valueChangedCallback (my d_valueChangedBoss, & event);
57 }
58 }
59 #elif cocoa
60 @implementation GuiCocoaCheckButton {
61 GuiCheckButton d_userData;
62 }
63 - (void) dealloc { // override
64 GuiCheckButton me = d_userData;
65 forget (me);
66 trace (U"deleting a check button");
67 [super dealloc];
68 }
69 - (GuiThing) getUserData {
70 return d_userData;
71 }
72 - (void) setUserData: (GuiThing) userData {
73 Melder_assert (userData == nullptr || Thing_isa (userData, classGuiCheckButton));
74 d_userData = static_cast <GuiCheckButton> (userData);
75 }
76 - (void) _guiCocoaButton_activateCallback: (id) widget {
77 Melder_assert (self == widget); // sender (widget) and receiver (self) happen to be the same object
78 GuiCheckButton me = d_userData;
79 if (my d_valueChangedCallback) {
80 Melder_assert (! my d_blockValueChangedCallbacks);
81 struct structGuiCheckButtonEvent event { me };
82 my d_valueChangedCallback (my d_valueChangedBoss, & event);
83 }
84 }
85 @end
86 #endif
87
88 GuiCheckButtoncxx . . $ GuiCheckButton# GuiCheckButton_createcxx . . $ GuiCheckButton_create(623a0757f24fe0b2). (GuiFormcxx . . $ GuiForm# parent, int left, int right, int top, int bottom,
89 conststring32cxx . . $ conststring32# buttonText, GuiCheckButton_ValueChangedCallbackcxx . . $ GuiCheckButton_ValueChangedCallback# valueChangedCallback, Thingcxx . . $ Thing# valueChangedBoss, uint32cxx . . $ uint32# flags)
90 {
91 autoGuiCheckButtoncxx . . $ autoGuiCheckButton# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (GuiCheckButton);
92 mycxx . . $ `melder/melder.h:44:9`! d_shellcxx . . $ structGuiThing#d_shell. = parent -> d_shellcxx . . $ structGuiThing#d_shell.;
93 mycxx . . $ `melder/melder.h:44:9`! d_parentcxx . . $ structGuiThing#d_parent. = parent;
94 mycxx . . $ `melder/melder.h:44:9`! d_valueChangedCallbackcxx . . $ structGuiCheckButton#d_valueChangedCallback. =cxx . . $ MelderCallback#`operator=`(736bbe7e267e9f22). valueChangedCallback;
95 mycxx . . $ `melder/melder.h:44:9`! d_valueChangedBosscxx . . $ structGuiCheckButton#d_valueChangedBoss. = valueChangedBoss;
96 #if gtkcxx . . $ `sys/Gui.h:33:10`!
97 mycxx . . $ `melder/melder.h:44:9`! d_widgetcxx . . $ structGuiThing#d_widget. = gtk_check_button_new_with_label (Melder_peek32to8 (buttonText));
98 _GuiObject_setUserDatacxx . . $ _GuiObject_setUserData(6c58c5e2437d25a2). (mycxx . . $ `melder/melder.h:44:9`! d_widgetcxx . . $ structGuiThing#d_widget., me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
99 mycxx . . $ `melder/melder.h:44:9`! v_positionInFormcxx . . $ structGuiControl#v_positionInForm(6e76d3e0dab57625). (mycxx . . $ `melder/melder.h:44:9`! d_widgetcxx . . $ structGuiThing#d_widget., left, right, top, bottom, parent);
100 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTONcxx . . $ `<external>/15753648026364605063/gtktogglebutton.h:39:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), (flags & GuiCheckButton_SETcxx . . $ `sys/Gui.h:503:9`!) != 0);
101 if (flags & GuiCheckButton_INSENSITIVEcxx . . $ `sys/Gui.h:504:9`!) {
102 GuiThing_setSensitivecxx . . $ GuiThing_setSensitive(99178548e0926398). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), false);
103 }
104 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`! (_GuiGtkCheckButton_destroyCallback), me.get());
105 g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (GTK_TOGGLE_BUTTONcxx . . $ `<external>/15753648026364605063/gtktogglebutton.h:39:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), "toggled", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (_GuiGtkCheckButton_valueChangedCallback), me.get());
106 #elif motif
107 my d_widget = _Gui_initializeWidget (xmToggleButtonWidgetClass, parent -> d_widget, buttonText);
108 _GuiObject_setUserData (my d_widget, me.get());
109 my d_widget -> isRadioButton = false;
110 my d_widget -> window = CreateWindow (L"button", Melder_peek32toW (_GuiWin_expandAmpersands (buttonText)),
111 WS_CHILD | BS_AUTOCHECKBOX | WS_CLIPSIBLINGS,
112 my d_widget -> x, my d_widget -> y, my d_widget -> width, my d_widget -> height,
113 my d_widget -> parent -> window, (HMENU) 1, theGui.instance, nullptr);
114 SetWindowLongPtr (my d_widget -> window, GWLP_USERDATA, (LONG_PTR) my d_widget);
115 SetWindowFont (my d_widget -> window, theWinGuiNormalLabelFont (), false);
116 my v_positionInForm (my d_widget, left, right, top, bottom, parent);
117 if (flags & GuiCheckButton_SET) {
118 Button_SetCheck (my d_widget -> window, BST_CHECKED);
119 }
120 if (flags & GuiCheckButton_INSENSITIVE) {
121 GuiThing_setSensitive (me.get(), false);
122 }
123 #elif cocoa
124 GuiCocoaCheckButton *checkButton = [[GuiCocoaCheckButton alloc] init];
125 my d_widget = (GuiObject) checkButton;
126 my v_positionInForm (my d_widget, left, right, top, bottom, parent);
127 [checkButton setUserData: me.get()];
128 [checkButton setButtonType: NSSwitchButton];
129 [checkButton setTitle: (NSString *) Melder_peek32toCfstring (buttonText)];
130 [checkButton setTarget: checkButton];
131 [checkButton setAction: @selector (_guiCocoaButton_activateCallback:)];
132 if (flags & GuiCheckButton_SET) {
133 [checkButton setState: NSOnState];
134 }
135 #endif
136 return me.releaseToAmbiguousOwnercxx . . $ autoSomeThing#releaseToAmbiguousOwner(258ee1c9e0a18a5c).();
137 }
138
139 GuiCheckButtoncxx . . $ GuiCheckButton# GuiCheckButton_createShowncxx . . $ GuiCheckButton_createShown(623a0757f24fe0b2). (GuiFormcxx . . $ GuiForm# parent, int left, int right, int top, int bottom,
140 conststring32cxx . . $ conststring32# buttonText, GuiCheckButton_ValueChangedCallbackcxx . . $ GuiCheckButton_ValueChangedCallback# valueChangedCallback, Thingcxx . . $ Thing# valueChangedBoss, uint32cxx . . $ uint32# flags)
141 {
142 GuiCheckButtoncxx . . $ GuiCheckButton# me = GuiCheckButton_createcxx . . $ GuiCheckButton_create(623a0757f24fe0b2). (parent, left, right, top, bottom, buttonText, valueChangedCallback, valueChangedBoss, flags);
143 GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (me);
144 return me;
145 }
146
147 bool GuiCheckButton_getValuecxx . . $ GuiCheckButton_getValue(a8338fe19a656ed0). (GuiCheckButtoncxx . . $ GuiCheckButton# me) {
148 bool value = false;
149 #if gtkcxx . . $ `sys/Gui.h:33:10`!
150 value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTONcxx . . $ `<external>/15753648026364605063/gtktogglebutton.h:39:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget)); // gtk_check_button inherits from gtk_toggle_button
151 #elif motif
152 value = (Button_GetState (my d_widget -> window) & 0x0003) == BST_CHECKED;
153 #elif cocoa
154 GuiCocoaCheckButton *checkButton = (GuiCocoaCheckButton *) my d_widget;
155 value = [checkButton state] == NSOnState;
156 #endif
157 return value;
158 }
159
160 void GuiCheckButton_setValuecxx . . $ GuiCheckButton_setValue(7c4273eb49c3ef26). (GuiCheckButtoncxx . . $ GuiCheckButton# me, bool value) {
161 GuiControlBlockValueChangedCallbackscxx . . $ GuiControlBlockValueChangedCallbacks# blockcxx . . $ GuiControlBlockValueChangedCallbacks#GuiControlBlockValueChangedCallbacks(1363d6663f95c9c7). (me);
162 #if gtkcxx . . $ `sys/Gui.h:33:10`!
163 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTONcxx . . $ `<external>/15753648026364605063/gtktogglebutton.h:39:9`! (mycxx . . $ `melder/melder.h:44:9`! d_widget), value);
164 #elif motif
165 Button_SetCheck (my d_widget -> window, value ? BST_CHECKED : BST_UNCHECKED);
166 #elif cocoa
167 GuiCocoaCheckButton *checkButton = (GuiCocoaCheckButton *) my d_widget;
168 [checkButton setState: value ? NSOnState: NSOffState];
169 #endif
170 }
171
172 /* End of file GuiCheckButton.cpp */