Debian Codegraph @

ui/UIButton.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * 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 program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/ui/UIButton.cpp $
21 * $Revision: 29 $
22 * $Date: 5/02/99 7:18p $
23 * $Author: Samir $
24 *
25 * Button code.
26 *
27 * $Log: /DescentIII/Main/ui/UIButton.cpp $
28 *
29 * 29 5/02/99 7:18p Samir
30 * a little better error checking with mouse input. also with fix from
31 * grtext.cpp, fixed phony button problem.
32 *
33 * 28 5/02/99 6:09p Samir
34 * unlock focus for buttons when mouse goes up regardless of state.
35 *
36 * 27 5/02/99 2:08a Samir
37 * added Enable and Disable and only accept locking of button if mouse is
38 * inside the button.
39 *
40 * 26 5/01/99 1:14a Samir
41 * fixed mouse sequencing probs with selections being canceled out by
42 * UISystem.
43 *
44 * 25 4/17/99 5:59a Jeff
45 * Linux wants m_ButtonFont defined
46 *
47 * 24 4/14/99 1:52a Jeff
48 * fixed case mismatched #includes
49 *
50 * 23 3/09/99 12:21p Samir
51 * only allow checking of boxes if mouse is in checkbox at all times, not
52 * when clicked on once.
53 *
54 * 22 2/21/99 6:36p Samir
55 * focusing changes and key input changes to ui.,
56 *
57 * 21 2/16/99 11:58a Samir
58 * format buttons to fit their state.
59 *
60 * 20 12/08/98 3:18p Samir
61 * checking a check box calls OnSelect
62 *
63 * 19 9/30/98 4:33p Samir
64 * disabled gadgets display dim text.
65 *
66 * 18 9/23/98 3:00p Samir
67 * took out unnecessary code.
68 *
69 * 17 5/22/98 5:02p Jeff
70 * Added a flag for radio buttons so the button part won't be drawn (just
71 * the text)
72 *
73 * 16 5/22/98 1:31p Jeff
74 * changed text saturation for radio button
75 *
76 * 15 5/01/98 6:23p Samir
77 * darkened buttons a bit.
78 *
79 * 14 4/24/98 2:42a Samir
80 * added UICheckBox
81 *
82 * 13 3/10/98 12:50p Samir
83 * Added highlight to radio button.
84 *
85 * 12 3/05/98 6:40p Samir
86 * Implemented radio buttons.
87 *
88 * 11 2/10/98 4:55p Samir
89 * Added radio buttons.
90 *
91 * 10 1/30/98 7:05p Samir
92 * Each gadget now has their own coordinate system.
93 *
94 * 9 1/23/98 5:34p Samir
95 * Allow for nonpersistant UIItems.
96 *
97 * 8 1/18/98 4:22p Samir
98 * Implemented new UIItem system.
99 *
100 * 7 1/13/98 4:29p Samir
101 * Added gadget buttons.
102 *
103 * 6 1/08/98 12:18p Samir
104 * Buttons draw text color based off of UITextItem color.
105 *
106 * 5 1/05/98 4:36p Samir
107 * Moved centering and fittext control flags to UIGadget class.
108 *
109 * 4 1/05/98 3:48p Jason
110 * added SetAllText function for buttons
111 *
112 * 3 1/05/98 3:18p Samir
113 * Added some button flags.
114 *
115 * 2 1/02/98 12:43p Samir
116 * New UIButton interface.
117 *
118 * 1 12/30/97 4:36p Samir
119 * Initial revision
120 *
121 * $NoKeywords: $
122 */
123
124 #include <cstring>
125
126 #include "UIlib.h"cxx . . $ `<file>/ui/UIlib.h`/
127
128 #if defined(POSIXcxx . . $ `<built-in>:478:9`!)
129 int UIButtoncxx . . $ UIButton#::m_ButtonFontcxx . . $ UIButton#m_ButtonFont.;
130 #endif
131
132 // tUIButton
133 // This is a simple 2 state button (push down or push up)
134 // Buttons have properties of gadgets, plus bitmap information per state.
135
136 UIButtoncxx . . $ UIButton#::UIButtoncxx . . $ UIButton#UIButton(49f6e7a06ebc5aa8).() {
137 m_Itemscxx . . $ UIButton#m_Items.[UI_BTS_DISABLEDcxx . . $ `ui/ui.h:542:9`!] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
138 m_Itemscxx . . $ UIButton#m_Items.[UI_BTS_INACTIVEcxx . . $ `ui/ui.h:543:9`!] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
139 m_Itemscxx . . $ UIButton#m_Items.[UI_BTS_HILITEcxx . . $ `ui/ui.h:544:9`!] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
140 m_Itemscxx . . $ UIButton#m_Items.[UI_BTS_ACTIVATEDcxx . . $ `ui/ui.h:545:9`!] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
141 }
142
143 UIButtoncxx . . $ UIButton#::~cxx . . $ UIButton#`~UIButton`(ced63f7c635d850d).UIButtoncxx . . $ UIButton#() {}
144
145 // if text = NULL, no text printed out.
146 void UIButtoncxx . . $ UIButton#::Createcxx . . $ UIButton#Create(55c0967870198d96).(UIWindowcxx . . $ UIWindow# *parent, int id, UIItemcxx . . $ UIItem# *item, int x, int y, int w, int h, int flags) {
147 if (item) {
148 m_Itemscxx . . $ UIButton#m_Items.[UI_BTS_DISABLEDcxx . . $ `ui/ui.h:542:9`!] = item->CopyUIItemcxx . . $ UIItem#CopyUIItem(ff7db2a2e5605676).();
149 m_Itemscxx . . $ UIButton#m_Items.[UI_BTS_INACTIVEcxx . . $ `ui/ui.h:543:9`!] = item->CopyUIItemcxx . . $ UIItem#CopyUIItem(ff7db2a2e5605676).();
150 m_Itemscxx . . $ UIButton#m_Items.[UI_BTS_HILITEcxx . . $ `ui/ui.h:544:9`!] = item->CopyUIItemcxx . . $ UIItem#CopyUIItem(ff7db2a2e5605676).();
151 m_Itemscxx . . $ UIButton#m_Items.[UI_BTS_ACTIVATEDcxx . . $ `ui/ui.h:545:9`!] = item->CopyUIItemcxx . . $ UIItem#CopyUIItem(ff7db2a2e5605676).();
152 }
153
154 SetColorcxx . . $ UIButton#SetColor(c8dafc4a64bf4a1c).(UI_BTS_DISABLEDcxx . . $ `ui/ui.h:542:9`!, GR_DARKGRAYcxx . . $ GR_DARKGRAY.);
155 SetColorcxx . . $ UIButton#SetColor(c8dafc4a64bf4a1c).(UI_BTS_INACTIVEcxx . . $ `ui/ui.h:543:9`!, GR_DARKGRAYcxx . . $ GR_DARKGRAY.);
156 SetColorcxx . . $ UIButton#SetColor(c8dafc4a64bf4a1c).(UI_BTS_HILITEcxx . . $ `ui/ui.h:544:9`!, GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(128, 128, 128));
157 SetColorcxx . . $ UIButton#SetColor(c8dafc4a64bf4a1c).(UI_BTS_ACTIVATEDcxx . . $ `ui/ui.h:545:9`!, GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(128, 128, 128));
158
159 m_Statecxx . . $ UIButton#m_State. = UI_BTS_INACTIVEcxx . . $ `ui/ui.h:543:9`!; // current state of button.
160
161 UIGadgetcxx . . $ UIGadget#::Createcxx . . $ UIGadget#Create(43707b8add2f137d).(parent, id, x, y, w, h, flags);
162 }
163
164 // sets the background bitmap for a specified button state
165 void UIButtoncxx . . $ UIButton#::SetStateItemcxx . . $ UIButton#SetStateItem(be8be563f9cef951).(int state, UIItemcxx . . $ UIItem# *item) {
166 ASSERTcxx . . $ `misc/pserror.h:246:9`!(state < UI_BTS_NUMcxx . . $ `ui/ui.h:541:9`!);
167 if (m_Itemscxx . . $ UIButton#m_Items.[state]) {
168 delete m_Itemscxx . . $ UIButton#m_Items.[state];
169 m_Itemscxx . . $ UIButton#m_Items.[state] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
170 }
171 if (item)
172 m_Itemscxx . . $ UIButton#m_Items.[state] = item->CopyUIItemcxx . . $ UIItem#CopyUIItem(ff7db2a2e5605676).();
173 }
174
175 // sets the background color for a specified button state
176 void UIButtoncxx . . $ UIButton#::SetColorcxx . . $ UIButton#SetColor(c8dafc4a64bf4a1c).(int state, ddgr_colorcxx . . $ ddgr_color# col) {
177 ASSERTcxx . . $ `misc/pserror.h:246:9`!(state < UI_BTS_NUMcxx . . $ `ui/ui.h:541:9`!);
178
179 m_Colorscxx . . $ UIButton#m_Colors.[state] = col;
180 }
181
182 // sets text for all states.
183 void UIButtoncxx . . $ UIButton#::SetAllStatescxx . . $ UIButton#SetAllStates(52afca12b6cce14a).(UIItemcxx . . $ UIItem# *item) {
184 for (int i = 0; i < UI_BTS_NUMcxx . . $ `ui/ui.h:541:9`!; i++)
185 SetStateItemcxx . . $ UIButton#SetStateItem(be8be563f9cef951).(i, item);
186 }
187
188 // Inheritable operations
189
190 // override: behavior when gadget is destroyed.
191 void UIButtoncxx . . $ UIButton#::OnDestroycxx . . $ UIButton#OnDestroy(49f6e7a06ebc5aa8).() {
192 UIGadgetcxx . . $ UIGadget#::OnDestroycxx . . $ UIGadget#OnDestroy(49f6e7a06ebc5aa8).();
193
194 SetStateItemcxx . . $ UIButton#SetStateItem(be8be563f9cef951).(UI_BTS_DISABLEDcxx . . $ `ui/ui.h:542:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
195 SetStateItemcxx . . $ UIButton#SetStateItem(be8be563f9cef951).(UI_BTS_INACTIVEcxx . . $ `ui/ui.h:543:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
196 SetStateItemcxx . . $ UIButton#SetStateItem(be8be563f9cef951).(UI_BTS_HILITEcxx . . $ `ui/ui.h:544:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
197 SetStateItemcxx . . $ UIButton#SetStateItem(be8be563f9cef951).(UI_BTS_ACTIVATEDcxx . . $ `ui/ui.h:545:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
198 }
199
200 // behavior when gadget loses input focus.
201 void UIButtoncxx . . $ UIButton#::OnLostFocuscxx . . $ UIButton#OnLostFocus(49f6e7a06ebc5aa8).() {
202 if (m_Statecxx . . $ UIButton#m_State. == UI_BTS_HILITEcxx . . $ `ui/ui.h:544:9`!)
203 m_Statecxx . . $ UIButton#m_State. = UI_BTS_INACTIVEcxx . . $ `ui/ui.h:543:9`!;
204 }
205
206 // behavior when gadget gains input focus.
207 void UIButtoncxx . . $ UIButton#::OnGainFocuscxx . . $ UIButton#OnGainFocus(49f6e7a06ebc5aa8).() {
208 if (m_Statecxx . . $ UIButton#m_State. != UI_BTS_ACTIVATEDcxx . . $ `ui/ui.h:545:9`!)
209 m_Statecxx . . $ UIButton#m_State. = UI_BTS_HILITEcxx . . $ `ui/ui.h:544:9`!;
210 }
211
212 // override: called when resized or before drawing.
213 void UIButtoncxx . . $ UIButton#::OnFormatcxx . . $ UIButton#OnFormat(49f6e7a06ebc5aa8).() {
214 if (m_Flagscxx . . $ UIGadget#m_Flags. & UIF_FITcxx . . $ `ui/ui.h:343:9`!) {
215 m_Wcxx . . $ UIObject#m_W. = m_Itemscxx . . $ UIButton#m_Items.[m_Statecxx . . $ UIButton#m_State.]->widthcxx . . $ UIItem#width(b126dc7c1de90089).() + 20;
216 m_Hcxx . . $ UIObject#m_H. = m_Itemscxx . . $ UIButton#m_Items.[m_Statecxx . . $ UIButton#m_State.]->heightcxx . . $ UIItem#height(b126dc7c1de90089).() + 8;
217 }
218
219 UIGadgetcxx . . $ UIGadget#::OnFormatcxx . . $ UIGadget#OnFormat(49f6e7a06ebc5aa8).();
220 }
221
222 // behavior when gadget is being drawn.
223 void UIButtoncxx . . $ UIButton#::OnDrawcxx . . $ UIButton#OnDraw(49f6e7a06ebc5aa8).() {
224 // do state based drawing
225 // determine colors here.
226 if (IsDisabledcxx . . $ UIGadget#IsDisabled(c9857a73d68e59ba).())
227 m_Statecxx . . $ UIButton#m_State. = UI_BTS_DISABLEDcxx . . $ `ui/ui.h:542:9`!;
228
229 switch (m_Statecxx . . $ UIButton#m_State.) {
230 case UI_BTS_ACTIVATEDcxx . . $ `ui/ui.h:545:9`!:
231 case UI_BTS_HILITEcxx . . $ `ui/ui.h:544:9`!:
232 ui_DrawLTBoxcxx . . $ ui_DrawLTBox(c7c2c8c9daee4a15).(GR_BLACKcxx . . $ GR_BLACK., GR_LIGHTGRAYcxx . . $ GR_LIGHTGRAY., 0, 0, m_Wcxx . . $ UIObject#m_W., m_Hcxx . . $ UIObject#m_H.);
233 break;
234
235 case UI_BTS_INACTIVEcxx . . $ `ui/ui.h:543:9`!:
236 ui_DrawLTBoxcxx . . $ ui_DrawLTBox(c7c2c8c9daee4a15).(GR_LIGHTGRAYcxx . . $ GR_LIGHTGRAY., GR_BLACKcxx . . $ GR_BLACK., 0, 0, m_Wcxx . . $ UIObject#m_W., m_Hcxx . . $ UIObject#m_H.);
237 break;
238
239 case UI_BTS_DISABLEDcxx . . $ `ui/ui.h:542:9`!:
240 ui_DrawLTBoxcxx . . $ ui_DrawLTBox(c7c2c8c9daee4a15).(GR_DARKGRAYcxx . . $ GR_DARKGRAY., GR_DARKGRAYcxx . . $ GR_DARKGRAY., 0, 0, m_Wcxx . . $ UIObject#m_W., m_Hcxx . . $ UIObject#m_H.);
241 break;
242
243 default:
244 Int3cxx . . $ `misc/pserror.h:247:9`!();
245 }
246
247 ui_DrawRectcxx . . $ ui_DrawRect(fe09a4b73d8d396f).(m_Colorscxx . . $ UIButton#m_Colors.[m_Statecxx . . $ UIButton#m_State.], 1, 1, m_Wcxx . . $ UIObject#m_W. - 1, m_Hcxx . . $ UIObject#m_H. - 1);
248
249 if (m_Itemscxx . . $ UIButton#m_Items.[m_Statecxx . . $ UIButton#m_State.]) {
250 int x = (m_Wcxx . . $ UIObject#m_W. / 2 - m_Itemscxx . . $ UIButton#m_Items.[m_Statecxx . . $ UIButton#m_State.]->widthcxx . . $ UIItem#width(b126dc7c1de90089).() / 2);
251 int y = (m_Hcxx . . $ UIObject#m_H. / 2 - m_Itemscxx . . $ UIButton#m_Items.[m_Statecxx . . $ UIButton#m_State.]->heightcxx . . $ UIItem#height(b126dc7c1de90089).() / 2);
252 m_Itemscxx . . $ UIButton#m_Items.[m_Statecxx . . $ UIButton#m_State.]->drawcxx . . $ UIItem#draw(84329bcd07240ccf).(x, y, IsDisabledcxx . . $ UIGadget#IsDisabled(c9857a73d68e59ba).() ? uiDrawFadedcxx . . $ uiDrawFaded. : uiDrawNormalcxx . . $ uiDrawNormal.);
253 }
254 }
255
256 // behavior when key is pressed.
257 void UIButtoncxx . . $ UIButton#::OnKeyDowncxx . . $ UIButton#OnKeyDown(d4f767463ce0a6b3).(int key) {}
258
259 // behavior when key is released.
260 void UIButtoncxx . . $ UIButton#::OnKeyUpcxx . . $ UIButton#OnKeyUp(d4f767463ce0a6b3).(int key) {}
261
262 // behavior when mouse button is pressed.
263 void UIButtoncxx . . $ UIButton#::OnMouseBtnDowncxx . . $ UIButton#OnMouseBtnDown(d4f767463ce0a6b3).(int btn) {
264 if (btn == UILMSEBTNcxx . . $ `ui/uisys.h:36:9`!) {
265 if (m_Statecxx . . $ UIButton#m_State. != UI_BTS_ACTIVATEDcxx . . $ `ui/ui.h:545:9`! && PT_IN_GADGETcxx . . $ PT_IN_GADGET(55d2799d541f12b5).(m_Wndcxx . . $ UIGadget#m_Wnd., this, UI_inputcxx . . $ UI_input..mxcxx . . $ tUIInput#mx., UI_inputcxx . . $ UI_input..mycxx . . $ tUIInput#my.)) {
266 m_Statecxx . . $ UIButton#m_State. = UI_BTS_ACTIVATEDcxx . . $ `ui/ui.h:545:9`!;
267 LOCK_FOCUScxx . . $ `ui/uisys.h:107:9`!(this);
268 // mprintf(0, "Mouse down, locking gadget.\n");
269 } else if (m_Statecxx . . $ UIButton#m_State. == UI_BTS_ACTIVATEDcxx . . $ `ui/ui.h:545:9`! && !PT_IN_GADGETcxx . . $ PT_IN_GADGET(55d2799d541f12b5).(m_Wndcxx . . $ UIGadget#m_Wnd., this, UI_inputcxx . . $ UI_input..mxcxx . . $ tUIInput#mx., UI_inputcxx . . $ UI_input..mycxx . . $ tUIInput#my.)) {
270 m_Statecxx . . $ UIButton#m_State. = UI_BTS_HILITEcxx . . $ `ui/ui.h:544:9`!;
271 }
272 }
273 }
274
275 // behavior when mouse button is released.
276 void UIButtoncxx . . $ UIButton#::OnMouseBtnUpcxx . . $ UIButton#OnMouseBtnUp(d4f767463ce0a6b3).(int btn) {
277 if (btn == UILMSEBTNcxx . . $ `ui/uisys.h:36:9`!) {
278 if (m_Statecxx . . $ UIButton#m_State. == UI_BTS_ACTIVATEDcxx . . $ `ui/ui.h:545:9`!) {
279 if (PT_IN_GADGETcxx . . $ PT_IN_GADGET(55d2799d541f12b5).(UIGadgetcxx . . $ UIGadget#::m_Wndcxx . . $ UIGadget#m_Wnd., this, UI_inputcxx . . $ UI_input..mxcxx . . $ tUIInput#mx., UI_inputcxx . . $ UI_input..mycxx . . $ tUIInput#my.)) {
280 OnSelectcxx . . $ UIGadget#OnSelect(49f6e7a06ebc5aa8).();
281 }
282 m_Statecxx . . $ UIButton#m_State. = UI_BTS_HILITEcxx . . $ `ui/ui.h:544:9`!;
283 }
284 // mprintf(0, "Mouse up, unlocking gadget.\n");
285 UNLOCK_FOCUScxx . . $ `ui/uisys.h:109:9`!(this);
286 }
287 }
288
289 // this adds to the gadget equivalent
290 void UIButtoncxx . . $ UIButton#::Disablecxx . . $ UIButton#Disable(49f6e7a06ebc5aa8).() {
291 UIGadgetcxx . . $ UIGadget#::Disablecxx . . $ UIGadget#Disable(49f6e7a06ebc5aa8).();
292 m_Statecxx . . $ UIButton#m_State. = UI_BTS_DISABLEDcxx . . $ `ui/ui.h:542:9`!;
293 }
294
295 // this adds to the gadget equivalent
296 void UIButtoncxx . . $ UIButton#::Enablecxx . . $ UIButton#Enable(49f6e7a06ebc5aa8).() {
297 UIGadgetcxx . . $ UIGadget#::Enablecxx . . $ UIGadget#Enable(49f6e7a06ebc5aa8).();
298
299 if (HasFocuscxx . . $ UIGadget#HasFocus(50ce9a9e25b4a850).()) {
300 m_Statecxx . . $ UIButton#m_State. = UI_BTS_HILITEcxx . . $ `ui/ui.h:544:9`!;
301 } else {
302 m_Statecxx . . $ UIButton#m_State. = UI_BTS_INACTIVEcxx . . $ `ui/ui.h:543:9`!;
303 }
304 }
305
306 // UIRadioButton
307 // This is a simple 2 state button (push down or push up)
308 // Buttons have properties of gadgets, plus bitmap information per state.
309
310 UIRadioButtoncxx . . $ UIRadioButton#::UIRadioButtoncxx . . $ UIRadioButton#UIRadioButton(49f6e7a06ebc5aa8).() { m_PrevRBcxx . . $ UIRadioButton#m_PrevRB. = m_NextRBcxx . . $ UIRadioButton#m_NextRB. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; }
311
312 void UIRadioButtoncxx . . $ UIRadioButton#::Createcxx . . $ UIRadioButton#Create(2c6e3f78865b93cb).(UIWindowcxx . . $ UIWindow# *parent, UIRadioButtoncxx . . $ UIRadioButton# *prev_rb, int id, UIItemcxx . . $ UIItem# *title, int x, int y, int w, int h,
313 int flags) {
314 UIButtoncxx . . $ UIButton#::Createcxx . . $ UIButton#Create(55c0967870198d96).(parent, id, title, x, y, w, h, flags);
315
316 // create link in radio button chain.
317 m_PrevRBcxx . . $ UIRadioButton#m_PrevRB. = prev_rb;
318 m_NextRBcxx . . $ UIRadioButton#m_NextRB. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
319 if (m_PrevRBcxx . . $ UIRadioButton#m_PrevRB.) {
320 m_NextRBcxx . . $ UIRadioButton#m_NextRB. = m_PrevRBcxx . . $ UIRadioButton#m_PrevRB.->m_NextRBcxx . . $ UIRadioButton#m_NextRB.;
321 if (m_NextRBcxx . . $ UIRadioButton#m_NextRB.) {
322 m_NextRBcxx . . $ UIRadioButton#m_NextRB.->m_PrevRBcxx . . $ UIRadioButton#m_PrevRB. = this;
323 }
324 m_PrevRBcxx . . $ UIRadioButton#m_PrevRB.->m_NextRBcxx . . $ UIRadioButton#m_NextRB. = this;
325 }
326
327 if (!m_PrevRBcxx . . $ UIRadioButton#m_PrevRB.) {
328 UIGadgetcxx . . $ UIGadget#::SetFlagcxx . . $ UIGadget#SetFlag(d4f767463ce0a6b3).(UIF_GROUP_STARTcxx . . $ `ui/ui.h:349:9`!);
329 } else {
330 m_PrevRBcxx . . $ UIRadioButton#m_PrevRB.->ClearFlagcxx . . $ UIGadget#ClearFlag(d4f767463ce0a6b3).(UIF_GROUP_ENDcxx . . $ `ui/ui.h:350:9`!);
331 }
332 if (!m_NextRBcxx . . $ UIRadioButton#m_NextRB.) {
333 UIGadgetcxx . . $ UIGadget#::SetFlagcxx . . $ UIGadget#SetFlag(d4f767463ce0a6b3).(UIF_GROUP_ENDcxx . . $ `ui/ui.h:350:9`!);
334 }
335
336 // THIS PROBLEM IS PROBABLY DUE TO THE CALLER'S FAULT!
337 ASSERTcxx . . $ `misc/pserror.h:246:9`!(m_PrevRB != this);
338 }
339
340 // turns on button, turns off others in group.
341 void UIRadioButtoncxx . . $ UIRadioButton#::Activatecxx . . $ UIRadioButton#Activate(49f6e7a06ebc5aa8).() { ActivateButtoncxx . . $ UIRadioButton#ActivateButton(49f6e7a06ebc5aa8).(); }
342
343 // behavior when gadget is being drawn.
344 void UIRadioButtoncxx . . $ UIRadioButton#::OnDrawcxx . . $ UIRadioButton#OnDraw(49f6e7a06ebc5aa8).() {
345 char btnstr[3];
346 int iterations = 0;
347
348 if (IsDisabledcxx . . $ UIGadget#IsDisabled(c9857a73d68e59ba).())
349 m_Statecxx . . $ UIButton#m_State. = UI_BTS_DISABLEDcxx . . $ `ui/ui.h:542:9`!;
350
351 switch (m_Statecxx . . $ UIButton#m_State.) {
352 case UI_BTS_HILITEcxx . . $ `ui/ui.h:544:9`!:
353 iterations = 1;
354 case UI_BTS_INACTIVEcxx . . $ `ui/ui.h:543:9`!:
355 case UI_BTS_DISABLEDcxx . . $ `ui/ui.h:542:9`!:
356 if (m_Flagscxx . . $ UIGadget#m_Flags. & UIRB_NOBUTTONcxx . . $ `ui/ui.h:359:9`!)
357 strcpy(btnstr, " ");
358 else
359 snprintf(btnstr, sizeof(btnstr), "%c ", UI_RADIO_OFF_CHARcxx . . $ `ui/UIlib.h:101:9`!);
360 break;
361 case UI_BTS_ACTIVATEDcxx . . $ `ui/ui.h:545:9`!:
362 iterations = 1;
363 if (m_Flagscxx . . $ UIGadget#m_Flags. & UIRB_NOBUTTONcxx . . $ `ui/ui.h:359:9`!)
364 strcpy(btnstr, " ");
365 else
366 snprintf(btnstr, sizeof(btnstr), "%c ", UI_RADIO_ON_CHARcxx . . $ `ui/UIlib.h:102:9`!);
367 break;
368
369 default:
370 btnstr[0] = 0;
371 }
372
373 UITextItemcxx . . $ UITextItem# btncxx . . $ UITextItem#UITextItem(5f8aa4f2725849c4).(btnstr, GetStateItemcxx . . $ UIButton#GetStateItem(6e2eddbf98f33a4f).(m_Statecxx . . $ UIButton#m_State.)->get_colorcxx . . $ UIItem#get_color(ddd8539a2fcdd4ce).(), GetStateItemcxx . . $ UIButton#GetStateItem(6e2eddbf98f33a4f).(m_Statecxx . . $ UIButton#m_State.)->get_alphacxx . . $ UIItem#get_alpha(bd807b21b9713a30).());
374
375 btn.drawcxx . . $ UITextItem#draw(84329bcd07240ccf).(0, 0, IsDisabledcxx . . $ UIGadget#IsDisabled(c9857a73d68e59ba).() ? uiDrawFadedcxx . . $ uiDrawFaded. : uiDrawNormalcxx . . $ uiDrawNormal.);
376 GetStateItemcxx . . $ UIButton#GetStateItem(6e2eddbf98f33a4f).(m_Statecxx . . $ UIButton#m_State.)->drawcxx . . $ UIItem#draw(84329bcd07240ccf).(ui_GetTextWidthcxx . . $ ui_GetTextWidth(5c4306d8553b3696).(btnstr), 0, IsDisabledcxx . . $ UIGadget#IsDisabled(c9857a73d68e59ba).() ? uiDrawFadedcxx . . $ uiDrawFaded. : uiDrawNormalcxx . . $ uiDrawNormal.);
377
378 while (iterations--) {
379 btn.drawcxx . . $ UITextItem#draw(84329bcd07240ccf).(0, 0, uiDrawAlphaSaturatecxx . . $ uiDrawAlphaSaturate.);
380 GetStateItemcxx . . $ UIButton#GetStateItem(6e2eddbf98f33a4f).(m_Statecxx . . $ UIButton#m_State.)->drawcxx . . $ UIItem#draw(84329bcd07240ccf).(ui_GetTextWidthcxx . . $ ui_GetTextWidth(5c4306d8553b3696).(btnstr), 0, uiDrawAlphaSaturatecxx . . $ uiDrawAlphaSaturate.);
381 }
382 }
383
384 // override: called when resized or before drawing.
385 void UIRadioButtoncxx . . $ UIRadioButton#::OnFormatcxx . . $ UIRadioButton#OnFormat(49f6e7a06ebc5aa8).() {
386 if (m_Flagscxx . . $ UIGadget#m_Flags. & UIF_FITcxx . . $ `ui/ui.h:343:9`!) {
387 char btnstr[3];
388 if (m_Flagscxx . . $ UIGadget#m_Flags. & UIRB_NOBUTTONcxx . . $ `ui/ui.h:359:9`!)
389 strcpy(btnstr, " ");
390 else
391 snprintf(btnstr, sizeof(btnstr), "%c ", UI_RADIO_OFF_CHARcxx . . $ `ui/UIlib.h:101:9`!);
392
393 UITextItemcxx . . $ UITextItem# btncxx . . $ UITextItem#UITextItem(5f8aa4f2725849c4).(btnstr, GetStateItemcxx . . $ UIButton#GetStateItem(6e2eddbf98f33a4f).(m_Statecxx . . $ UIButton#m_State.)->get_colorcxx . . $ UIItem#get_color(ddd8539a2fcdd4ce).(), GetStateItemcxx . . $ UIButton#GetStateItem(6e2eddbf98f33a4f).(m_Statecxx . . $ UIButton#m_State.)->get_alphacxx . . $ UIItem#get_alpha(bd807b21b9713a30).());
394
395 m_Wcxx . . $ UIObject#m_W. = GetStateItemcxx . . $ UIButton#GetStateItem(6e2eddbf98f33a4f).(m_Statecxx . . $ UIButton#m_State.)->widthcxx . . $ UIItem#width(b126dc7c1de90089).() + btn.widthcxx . . $ UITextItem#width(b126dc7c1de90089).();
396 m_Hcxx . . $ UIObject#m_H. = GetStateItemcxx . . $ UIButton#GetStateItem(6e2eddbf98f33a4f).(m_Statecxx . . $ UIButton#m_State.)->heightcxx . . $ UIItem#height(b126dc7c1de90089).() + 8;
397 }
398
399 UIGadgetcxx . . $ UIGadget#::OnFormatcxx . . $ UIGadget#OnFormat(49f6e7a06ebc5aa8).();
400 }
401
402 // behavior when gadget loses input focus.
403 void UIRadioButtoncxx . . $ UIRadioButton#::OnLostFocuscxx . . $ UIRadioButton#OnLostFocus(49f6e7a06ebc5aa8).() {}
404
405 // behavior when gadget gains input focus.
406 void UIRadioButtoncxx . . $ UIRadioButton#::OnGainFocuscxx . . $ UIRadioButton#OnGainFocus(49f6e7a06ebc5aa8).() {}
407
408 // behavior when key is pressed.
409 void UIRadioButtoncxx . . $ UIRadioButton#::OnKeyDowncxx . . $ UIRadioButton#OnKeyDown(d4f767463ce0a6b3).(int key) {
410 if (key == KEY_SPACEBARcxx . . $ `ddio/ddio_common.h:271:9`! || key == KEY_ENTERcxx . . $ `ddio/ddio_common.h:268:9`!)
411 ActivateButtoncxx . . $ UIRadioButton#ActivateButton(49f6e7a06ebc5aa8).();
412 }
413
414 // behavior when key is released.
415 void UIRadioButtoncxx . . $ UIRadioButton#::OnKeyUpcxx . . $ UIRadioButton#OnKeyUp(d4f767463ce0a6b3).(int key) {}
416
417 // behavior when mouse button is pressed.
418 void UIRadioButtoncxx . . $ UIRadioButton#::OnMouseBtnDowncxx . . $ UIRadioButton#OnMouseBtnDown(d4f767463ce0a6b3).(int btn) {
419 if (btn == UILMSEBTNcxx . . $ `ui/uisys.h:36:9`! && !this->IsLockedcxx . . $ UIGadget#IsLocked(50ce9a9e25b4a850).()) {
420 if (PT_IN_GADGETcxx . . $ PT_IN_GADGET(55d2799d541f12b5).(m_Wndcxx . . $ UIGadget#m_Wnd., this, UI_inputcxx . . $ UI_input..mxcxx . . $ tUIInput#mx., UI_inputcxx . . $ UI_input..mycxx . . $ tUIInput#my.)) {
421 ActivateButtoncxx . . $ UIRadioButton#ActivateButton(49f6e7a06ebc5aa8).();
422 LOCK_FOCUScxx . . $ `ui/uisys.h:107:9`!(this);
423 }
424 }
425 }
426
427 // behavior when mouse button is released.
428 void UIRadioButtoncxx . . $ UIRadioButton#::OnMouseBtnUpcxx . . $ UIRadioButton#OnMouseBtnUp(d4f767463ce0a6b3).(int btn) {
429 if (btn == UILMSEBTNcxx . . $ `ui/uisys.h:36:9`!) {
430 UNLOCK_FOCUScxx . . $ `ui/uisys.h:109:9`!(this);
431 }
432 }
433
434 // activates this button, deactivating all others.
435 void UIRadioButtoncxx . . $ UIRadioButton#::ActivateButtoncxx . . $ UIRadioButton#ActivateButton(49f6e7a06ebc5aa8).() {
436 // okay, start through list
437 UIRadioButtoncxx . . $ UIRadioButton# *radiolist = this;
438
439 while (radiolist->m_PrevRBcxx . . $ UIRadioButton#m_PrevRB.)
440 radiolist = radiolist->m_PrevRBcxx . . $ UIRadioButton#m_PrevRB.;
441
442 // deactivate all buttons until we hit the current button, then activate it.
443 while (radiolist) {
444 if (radiolist == this) {
445 radiolist->m_Statecxx . . $ UIButton#m_State. = UI_BTS_ACTIVATEDcxx . . $ `ui/ui.h:545:9`!;
446 OnSelectcxx . . $ UIGadget#OnSelect(49f6e7a06ebc5aa8).();
447 } else {
448 radiolist->m_Statecxx . . $ UIButton#m_State. = UI_BTS_INACTIVEcxx . . $ `ui/ui.h:543:9`!;
449 }
450
451 radiolist = radiolist->m_NextRBcxx . . $ UIRadioButton#m_NextRB.;
452 }
453 }
454
455 //////////////////////////////////////////////////////////////////////////////
456 // UICheckBox
457 // This is a simple 2 state button (push down or push up)
458 // Buttons have properties of gadgets, plus bitmap information per state.
459
460 UICheckBoxcxx . . $ UICheckBox#::UICheckBoxcxx . . $ UICheckBox#UICheckBox(49f6e7a06ebc5aa8).() {}
461
462 void UICheckBoxcxx . . $ UICheckBox#::Createcxx . . $ UICheckBox#Create(55c0967870198d96).(UIWindowcxx . . $ UIWindow# *parent, int id, UIItemcxx . . $ UIItem# *title, int x, int y, int w, int h, int flags) {
463 UIButtoncxx . . $ UIButton#::Createcxx . . $ UIButton#Create(55c0967870198d96).(parent, id, title, x, y, w, h, flags);
464 SetCheckcxx . . $ UICheckBox#SetCheck(b45ddcbc8423892c).(false);
465 }
466
467 // turns on button, turns off others in group.
468 void UICheckBoxcxx . . $ UICheckBox#::SetCheckcxx . . $ UICheckBox#SetCheck(b45ddcbc8423892c).(bool state) {
469 if (state) {
470 m_Statecxx . . $ UIButton#m_State. = UI_BTS_ACTIVATEDcxx . . $ `ui/ui.h:545:9`!;
471 } else {
472 m_Statecxx . . $ UIButton#m_State. = UI_BTS_INACTIVEcxx . . $ `ui/ui.h:543:9`!;
473 }
474 }
475
476 // behavior when gadget is being drawn.
477 void UICheckBoxcxx . . $ UICheckBox#::OnDrawcxx . . $ UICheckBox#OnDraw(49f6e7a06ebc5aa8).() {
478 char btnstr[3];
479 int iterations = 1;
480
481 ui_DrawSetTextTypecxx . . $ ui_DrawSetTextType(d4f767463ce0a6b3).(UI_TEXTTYPE_SATURATEcxx . . $ `ui/uidraw.h:52:9`!);
482
483 if (IsDisabledcxx . . $ UIGadget#IsDisabled(c9857a73d68e59ba).())
484 m_Statecxx . . $ UIButton#m_State. = UI_BTS_DISABLEDcxx . . $ `ui/ui.h:542:9`!;
485
486 switch (m_Statecxx . . $ UIButton#m_State.) {
487 case UI_BTS_HILITEcxx . . $ `ui/ui.h:544:9`!:
488 iterations = 2;
489 case UI_BTS_INACTIVEcxx . . $ `ui/ui.h:543:9`!:
490 case UI_BTS_DISABLEDcxx . . $ `ui/ui.h:542:9`!:
491 snprintf(btnstr, sizeof(btnstr), "%c ", UI_CHECKBOX_OFF_CHARcxx . . $ `ui/UIlib.h:99:9`!);
492 break;
493 case UI_BTS_ACTIVATEDcxx . . $ `ui/ui.h:545:9`!:
494 iterations = 2;
495 snprintf(btnstr, sizeof(btnstr), "%c ", UI_CHECKBOX_ON_CHARcxx . . $ `ui/UIlib.h:100:9`!);
496 break;
497
498 default:
499 btnstr[0] = 0;
500 }
501
502 UITextItemcxx . . $ UITextItem# btncxx . . $ UITextItem#UITextItem(5f8aa4f2725849c4).(btnstr, GetStateItemcxx . . $ UIButton#GetStateItem(6e2eddbf98f33a4f).(m_Statecxx . . $ UIButton#m_State.)->get_colorcxx . . $ UIItem#get_color(ddd8539a2fcdd4ce).(), GetStateItemcxx . . $ UIButton#GetStateItem(6e2eddbf98f33a4f).(m_Statecxx . . $ UIButton#m_State.)->get_alphacxx . . $ UIItem#get_alpha(bd807b21b9713a30).());
503
504 while (iterations--) {
505 btn.drawcxx . . $ UITextItem#draw(84329bcd07240ccf).(0, 0);
506 GetStateItemcxx . . $ UIButton#GetStateItem(6e2eddbf98f33a4f).(m_Statecxx . . $ UIButton#m_State.)->drawcxx . . $ UIItem#draw(84329bcd07240ccf).(ui_GetTextWidthcxx . . $ ui_GetTextWidth(5c4306d8553b3696).(btnstr), 0, IsDisabledcxx . . $ UIGadget#IsDisabled(c9857a73d68e59ba).() ? uiDrawFadedcxx . . $ uiDrawFaded. : uiDrawNormalcxx . . $ uiDrawNormal.);
507 }
508
509 ui_DrawSetTextTypecxx . . $ ui_DrawSetTextType(d4f767463ce0a6b3).(0);
510 }
511
512 // override: called when resized or before drawing.
513 void UICheckBoxcxx . . $ UICheckBox#::OnFormatcxx . . $ UICheckBox#OnFormat(49f6e7a06ebc5aa8).() {
514 if (m_Flagscxx . . $ UIGadget#m_Flags. & UIF_FITcxx . . $ `ui/ui.h:343:9`!) {
515 char btnstr[3];
516 snprintf(btnstr, sizeof(btnstr), "%c ", UI_CHECKBOX_OFF_CHARcxx . . $ `ui/UIlib.h:99:9`!);
517
518 UITextItemcxx . . $ UITextItem# btncxx . . $ UITextItem#UITextItem(5f8aa4f2725849c4).(btnstr, GetStateItemcxx . . $ UIButton#GetStateItem(6e2eddbf98f33a4f).(m_Statecxx . . $ UIButton#m_State.)->get_colorcxx . . $ UIItem#get_color(ddd8539a2fcdd4ce).(), GetStateItemcxx . . $ UIButton#GetStateItem(6e2eddbf98f33a4f).(m_Statecxx . . $ UIButton#m_State.)->get_alphacxx . . $ UIItem#get_alpha(bd807b21b9713a30).());
519
520 m_Wcxx . . $ UIObject#m_W. = GetStateItemcxx . . $ UIButton#GetStateItem(6e2eddbf98f33a4f).(m_Statecxx . . $ UIButton#m_State.)->widthcxx . . $ UIItem#width(b126dc7c1de90089).() + btn.widthcxx . . $ UITextItem#width(b126dc7c1de90089).();
521 m_Hcxx . . $ UIObject#m_H. = GetStateItemcxx . . $ UIButton#GetStateItem(6e2eddbf98f33a4f).(m_Statecxx . . $ UIButton#m_State.)->heightcxx . . $ UIItem#height(b126dc7c1de90089).() + 8;
522 }
523
524 UIGadgetcxx . . $ UIGadget#::OnFormatcxx . . $ UIGadget#OnFormat(49f6e7a06ebc5aa8).();
525 }
526
527 // behavior when gadget loses input focus.
528 void UICheckBoxcxx . . $ UICheckBox#::OnLostFocuscxx . . $ UICheckBox#OnLostFocus(49f6e7a06ebc5aa8).() {}
529
530 // behavior when gadget gains input focus.
531 void UICheckBoxcxx . . $ UICheckBox#::OnGainFocuscxx . . $ UICheckBox#OnGainFocus(49f6e7a06ebc5aa8).() {}
532
533 // behavior when key is pressed.
534 void UICheckBoxcxx . . $ UICheckBox#::OnKeyDowncxx . . $ UICheckBox#OnKeyDown(d4f767463ce0a6b3).(int key) {
535 if (key == KEY_SPACEBARcxx . . $ `ddio/ddio_common.h:271:9`! || key == KEY_ENTERcxx . . $ `ddio/ddio_common.h:268:9`!) {
536 SetCheckcxx . . $ UICheckBox#SetCheck(b45ddcbc8423892c).((m_Statecxx . . $ UIButton#m_State. == UI_BTS_ACTIVATEDcxx . . $ `ui/ui.h:545:9`!) ? false : true);
537 OnSelectcxx . . $ UIGadget#OnSelect(49f6e7a06ebc5aa8).();
538 }
539 }
540
541 // behavior when key is released.
542 void UICheckBoxcxx . . $ UICheckBox#::OnKeyUpcxx . . $ UICheckBox#OnKeyUp(d4f767463ce0a6b3).(int key) {}
543
544 // behavior when mouse button is pressed.
545 void UICheckBoxcxx . . $ UICheckBox#::OnMouseBtnDowncxx . . $ UICheckBox#OnMouseBtnDown(d4f767463ce0a6b3).(int btn) {
546 if (btn == UILMSEBTNcxx . . $ `ui/uisys.h:36:9`! && !this->IsLockedcxx . . $ UIGadget#IsLocked(50ce9a9e25b4a850).()) {
547 if (PT_IN_GADGETcxx . . $ PT_IN_GADGET(55d2799d541f12b5).(m_Wndcxx . . $ UIGadget#m_Wnd., this, UI_inputcxx . . $ UI_input..mxcxx . . $ tUIInput#mx., UI_inputcxx . . $ UI_input..mycxx . . $ tUIInput#my.)) {
548 SetCheckcxx . . $ UICheckBox#SetCheck(b45ddcbc8423892c).((m_Statecxx . . $ UIButton#m_State. == UI_BTS_ACTIVATEDcxx . . $ `ui/ui.h:545:9`!) ? false : true);
549 OnSelectcxx . . $ UIGadget#OnSelect(49f6e7a06ebc5aa8).();
550 LOCK_FOCUScxx . . $ `ui/uisys.h:107:9`!(this);
551 }
552 }
553 }
554
555 // behavior when mouse button is released.
556 void UICheckBoxcxx . . $ UICheckBox#::OnMouseBtnUpcxx . . $ UICheckBox#OnMouseBtnUp(d4f767463ce0a6b3).(int btn) {
557 if (btn == UILMSEBTNcxx . . $ `ui/uisys.h:36:9`!) {
558 UNLOCK_FOCUScxx . . $ `ui/uisys.h:109:9`!(this);
559 }
560 }