| 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/UIGadget.cpp $ |
| 21 | * $Revision: 28 $ |
| 22 | * $Date: 10/21/99 3:31p $ |
| 23 | * $Author: Kevin $ |
| 24 | * |
| 25 | * Gadget code |
| 26 | * |
| 27 | * $Log: /DescentIII/Main/ui/UIGadget.cpp $ |
| 28 | * |
| 29 | * 28 10/21/99 3:31p Kevin |
| 30 | * mac merge & fix for slider |
| 31 | * |
| 32 | * 27 4/14/99 1:52a Jeff |
| 33 | * fixed case mismatched #includes |
| 34 | * |
| 35 | * 26 3/23/99 9:02p Samir |
| 36 | * always null hotkey when creating gadget! |
| 37 | * |
| 38 | * 25 3/01/99 7:29p Samir |
| 39 | * fixed an issue with slaves getting freed after their master was |
| 40 | * destroyed for sliders. |
| 41 | * |
| 42 | * 24 2/22/99 8:13p Samir |
| 43 | * added slave gadget system that only uses mouse input from window, but |
| 44 | * defers keys to its master. |
| 45 | * |
| 46 | * 23 2/21/99 6:36p Samir |
| 47 | * focusing changes and key input changes to ui., |
| 48 | * |
| 49 | * 22 2/17/99 8:32p Samir |
| 50 | * fixed bugs in remove gadget, added callbacks for attaching and |
| 51 | * detaching gadgets. |
| 52 | * |
| 53 | * 21 2/16/99 11:58a Samir |
| 54 | * small fixes and added gadget notification. |
| 55 | * |
| 56 | * 20 10/19/98 12:18p Samir |
| 57 | * made tabbing between edit controls possible. |
| 58 | * |
| 59 | * 19 10/13/98 8:23p Samir |
| 60 | * communication between gadget and window and edit system to work |
| 61 | * together. |
| 62 | * |
| 63 | * 18 8/26/98 12:25p Samir |
| 64 | * fixed the whole editbox, keyboard access mess. |
| 65 | * |
| 66 | * 17 8/25/98 7:08p Samir |
| 67 | * select how keys are sent to a gadget. |
| 68 | * |
| 69 | * 16 6/22/98 7:30p Samir |
| 70 | * set focus on gadget when calling LockFocus. |
| 71 | * |
| 72 | * 15 6/05/98 5:35p Samir |
| 73 | * massive improvement in UI keyboard interface. |
| 74 | * |
| 75 | * 14 5/25/98 8:18p Samir |
| 76 | * Enter keys are passed to gadgets too. |
| 77 | * |
| 78 | * 13 4/24/98 2:43a Samir |
| 79 | * added IsLocked function. |
| 80 | * |
| 81 | * 12 3/24/98 4:26p Samir |
| 82 | * fixed minor bug in TrapKey. |
| 83 | * |
| 84 | * 11 3/10/98 7:24p Samir |
| 85 | * Save original width and height. |
| 86 | * |
| 87 | * 10 3/09/98 2:57p Samir |
| 88 | * Remove gadget from window called from gadget destroy. |
| 89 | * |
| 90 | * 9 2/15/98 7:07p Samir |
| 91 | * Revamped way keys like up and down are handled in window system. |
| 92 | * |
| 93 | * 8 2/13/98 6:35p Samir |
| 94 | * Fixed some gadget creation/destruction inconsistancies |
| 95 | * |
| 96 | * 7 1/30/98 7:05p Samir |
| 97 | * Each gadget now has their own coordinate system. |
| 98 | * |
| 99 | * 6 1/23/98 5:34p Samir |
| 100 | * Allow for nonpersistant UIItems. |
| 101 | * |
| 102 | * 5 1/18/98 4:22p Samir |
| 103 | * Implemented new UIItem system. |
| 104 | * |
| 105 | * 4 1/13/98 4:27p Samir |
| 106 | * Keyboard timing delay stored UIGadget. Moved from UIEdit. |
| 107 | * |
| 108 | * 3 1/05/98 4:36p Samir |
| 109 | * Moved centering and fittext control flags to UIGadget class. |
| 110 | * |
| 111 | * 2 1/02/98 12:43p Samir |
| 112 | * Gadget processing functional. |
| 113 | * |
| 114 | * 1 12/30/97 4:36p Samir |
| 115 | * Initial revision |
| 116 | * |
| 117 | * $NoKeywords: $ |
| 118 | */ |
| 119 | |
| 120 | #include <cstring> |
| 121 | |
| 122 | #include "UIlib.h"cxx . . $ `<file>/ui/UIlib.h`/ |
| 123 | #include "Macros.h"cxx . . $ `<file>/lib/Macros.h`/ |
| 124 | |
| 125 | int UIGadgetcxx . . $ UIGadget#::m_LastKeycxx . . $ UIGadget#m_LastKey. = 0; |
| 126 | int UIGadgetcxx . . $ UIGadget#::m_LastKeyCountcxx . . $ UIGadget#m_LastKeyCount. = 0; |
| 127 | float UIGadgetcxx . . $ UIGadget#::m_LastKeyTimecxx . . $ UIGadget#m_LastKeyTime. = 0.0f; |
| 128 | |
| 129 | UIGadgetcxx . . $ UIGadget#::UIGadgetcxx . . $ UIGadget#UIGadget(49f6e7a06ebc5aa8).() : UIObjectcxx . . $ UIObject#UIObject(49f6e7a06ebc5aa8).() { |
| 130 | m_IDcxx . . $ UIGadget#m_ID. = 0; |
| 131 | m_Wndcxx . . $ UIGadget#m_Wnd. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 132 | m_Prevcxx . . $ UIGadget#m_Prev. = m_PrevSlavecxx . . $ UIGadget#m_PrevSlave. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 133 | m_Nextcxx . . $ UIGadget#m_Next. = m_NextSlavecxx . . $ UIGadget#m_NextSlave. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 134 | m_MasterGadgetcxx . . $ UIGadget#m_MasterGadget. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 135 | m_SlaveGadgetscxx . . $ UIGadget#m_SlaveGadgets. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 136 | m_CurrentSlavecxx . . $ UIGadget#m_CurrentSlave. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 137 | m_infocuscxx . . $ UIGadget#m_infocus. = false; |
| 138 | } |
| 139 | |
| 140 | UIGadgetcxx . . $ UIGadget#::~cxx . . $ UIGadget#`~UIGadget`(ced63f7c635d850d).UIGadgetcxx . . $ UIGadget#() {} |
| 141 | |
| 142 | // ALL Gadgets must have a parent. |
| 143 | void UIGadgetcxx . . $ UIGadget#::Createcxx . . $ UIGadget#Create(43707b8add2f137d).(UIWindowcxx . . $ UIWindow# *wnd, int id, int x, int y, int w, int h, int flags) { |
| 144 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(!IsCreated()); |
| 145 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(wnd); |
| 146 | |
| 147 | m_IDcxx . . $ UIGadget#m_ID. = id; |
| 148 | m_Wndcxx . . $ UIGadget#m_Wnd. = wnd; |
| 149 | |
| 150 | m_Disabledcxx . . $ UIGadget#m_Disabled. = false; |
| 151 | m_Flagscxx . . $ UIGadget#m_Flags. = flags; |
| 152 | m_infocuscxx . . $ UIGadget#m_infocus. = false; |
| 153 | |
| 154 | // add to interface's list. |
| 155 | UIObjectcxx . . $ UIObject#::Createcxx . . $ UIObject#Create(748afa4755bc9595).(x, y, w, h); |
| 156 | |
| 157 | // save original width and height |
| 158 | m_SavedWcxx . . $ UIGadget#m_SavedW. = m_Wcxx . . $ UIObject#m_W.; |
| 159 | m_SavedHcxx . . $ UIGadget#m_SavedH. = m_Hcxx . . $ UIObject#m_H.; |
| 160 | m_Hotkeycxx . . $ UIGadget#m_Hotkey. = 0; |
| 161 | |
| 162 | // handle formatting issues. |
| 163 | OnFormatcxx . . $ UIGadget#OnFormat(49f6e7a06ebc5aa8).(); |
| 164 | m_MasterGadgetcxx . . $ UIGadget#m_MasterGadget. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 165 | m_SlaveGadgetscxx . . $ UIGadget#m_SlaveGadgets. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 166 | m_CurrentSlavecxx . . $ UIGadget#m_CurrentSlave. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 167 | m_NextSlavecxx . . $ UIGadget#m_NextSlave. = m_PrevSlavecxx . . $ UIGadget#m_PrevSlave. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 168 | m_Datumcxx . . $ UIGadget#m_Datum. = 0; |
| 169 | |
| 170 | m_Wndcxx . . $ UIGadget#m_Wnd.->AddGadgetcxx . . $ UIWindow#AddGadget(627f6e6cf27f18b7).(this); |
| 171 | } |
| 172 | |
| 173 | void UIGadgetcxx . . $ UIGadget#::Destroycxx . . $ UIGadget#Destroy(49f6e7a06ebc5aa8).() { |
| 174 | // slaves are freed or destroyed by now. |
| 175 | m_SlaveGadgetscxx . . $ UIGadget#m_SlaveGadgets. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 176 | |
| 177 | // remove gadget from windw list. |
| 178 | if (m_Wndcxx . . $ UIGadget#m_Wnd.) { |
| 179 | m_Wndcxx . . $ UIGadget#m_Wnd.->RemoveGadgetcxx . . $ UIWindow#RemoveGadget(627f6e6cf27f18b7).(this); |
| 180 | } |
| 181 | OnDestroycxx . . $ UIGadget#OnDestroy(49f6e7a06ebc5aa8).(); |
| 182 | UIObjectcxx . . $ UIObject#::Destroycxx . . $ UIObject#Destroy(49f6e7a06ebc5aa8).(); |
| 183 | } |
| 184 | |
| 185 | // sets hotkey for gadget |
| 186 | void UIGadgetcxx . . $ UIGadget#::SetHotkeycxx . . $ UIGadget#SetHotkey(d4f767463ce0a6b3).(int key) { m_Hotkeycxx . . $ UIGadget#m_Hotkey. = key; } |
| 187 | |
| 188 | void UIGadgetcxx . . $ UIGadget#::SetFlagcxx . . $ UIGadget#SetFlag(d4f767463ce0a6b3).(int flag) { m_Flagscxx . . $ UIGadget#m_Flags. |= flag; } |
| 189 | |
| 190 | void UIGadgetcxx . . $ UIGadget#::ClearFlagcxx . . $ UIGadget#ClearFlag(d4f767463ce0a6b3).(int flag) { m_Flagscxx . . $ UIGadget#m_Flags. &= (~flag); } |
| 191 | |
| 192 | // locks input on this gadget |
| 193 | void UIGadgetcxx . . $ UIGadget#::LockFocuscxx . . $ UIGadget#LockFocus(49f6e7a06ebc5aa8).() { |
| 194 | // m_Wnd->SetFocusOnGadget(this); |
| 195 | m_Wndcxx . . $ UIGadget#m_Wnd.->LockFocusOnGadgetcxx . . $ UIWindow#LockFocusOnGadget(627f6e6cf27f18b7).(this); |
| 196 | } |
| 197 | |
| 198 | void UIGadgetcxx . . $ UIGadget#::UnlockFocuscxx . . $ UIGadget#UnlockFocus(49f6e7a06ebc5aa8).() { m_Wndcxx . . $ UIGadget#m_Wnd.->UnlockFocusOnGadgetcxx . . $ UIWindow#UnlockFocusOnGadget(49f6e7a06ebc5aa8).(); } |
| 199 | |
| 200 | // called before drawing usually. sets x,y,w,h optionally. |
| 201 | void UIGadgetcxx . . $ UIGadget#::OnFormatcxx . . $ UIGadget#OnFormat(49f6e7a06ebc5aa8).() { |
| 202 | if (m_Flagscxx . . $ UIGadget#m_Flags. & UIF_CENTERcxx . . $ `ui/ui.h:342:9`!) |
| 203 | m_Xcxx . . $ UIObject#m_X. = m_Wndcxx . . $ UIGadget#m_Wnd.->Wcxx . . $ UIObject#W(455f465bc33b4cdf).() / 2 - m_Wcxx . . $ UIObject#m_W. / 2; |
| 204 | } |
| 205 | |
| 206 | // interprets input on this gadget. this gadget is in focus. |
| 207 | void UIGadgetcxx . . $ UIGadget#::Processcxx . . $ UIGadget#Process(9e113dd3a0d25c95).(bool do_keys, bool do_mouse, bool do_user) { |
| 208 | // do mouse processing on this gadget if and only if no slave processing was done. |
| 209 | if (UI_inputcxx . . $ UI_input..b1_statuscxx . . $ tUIInput#b1_status. == UIMSEBTN_PRESSEDcxx . . $ `ui/uisys.h:27:9`! && do_mouse) { |
| 210 | OnMouseBtnDowncxx . . $ UIGadget#OnMouseBtnDown(d4f767463ce0a6b3).(UILMSEBTNcxx . . $ `ui/uisys.h:36:9`!); |
| 211 | UI_inputcxx . . $ UI_input..b1_last_statuscxx . . $ tUIInput#b1_last_status. = UIMSEBTN_PRESSEDcxx . . $ `ui/uisys.h:27:9`!; // DAJ use to latch the UI mouse button |
| 212 | } else if (UI_inputcxx . . $ UI_input..b1_statuscxx . . $ tUIInput#b1_status. == UIMSEBTN_RELEASEDcxx . . $ `ui/uisys.h:28:9`! && do_mouse) { |
| 213 | OnMouseBtnUpcxx . . $ UIGadget#OnMouseBtnUp(d4f767463ce0a6b3).(UILMSEBTNcxx . . $ `ui/uisys.h:36:9`!); |
| 214 | UI_inputcxx . . $ UI_input..b1_last_statuscxx . . $ tUIInput#b1_last_status. = UIMSEBTN_RELEASEDcxx . . $ `ui/uisys.h:28:9`!; // DAJ use to latch the UI mouse button |
| 215 | } else if (UI_inputcxx . . $ UI_input..b1_statuscxx . . $ tUIInput#b1_status. == UIMSEBTN_CLICKEDcxx . . $ `ui/uisys.h:29:9`! && do_mouse) { |
| 216 | OnMouseBtnDowncxx . . $ UIGadget#OnMouseBtnDown(d4f767463ce0a6b3).(UILMSEBTNcxx . . $ `ui/uisys.h:36:9`!); |
| 217 | OnMouseBtnUpcxx . . $ UIGadget#OnMouseBtnUp(d4f767463ce0a6b3).(UILMSEBTNcxx . . $ `ui/uisys.h:36:9`!); |
| 218 | } else if (do_keys) { |
| 219 | // keyboard processing. |
| 220 | switch (UI_inputcxx . . $ UI_input..keycxx . . $ tUIInput#key.) { |
| 221 | case KEY_ENTERcxx . . $ `ddio/ddio_common.h:268:9`!: |
| 222 | if ((UI_inputcxx . . $ UI_input..key_statuscxx . . $ tUIInput#key_status. == UIKEY_PRESSEDcxx . . $ `ui/uisys.h:31:9`!) || (UI_inputcxx . . $ UI_input..key_statuscxx . . $ tUIInput#key_status. == UIKEY_CLICKEDcxx . . $ `ui/uisys.h:33:9`!)) { |
| 223 | OnSelectcxx . . $ UIGadget#OnSelect(49f6e7a06ebc5aa8).(); |
| 224 | } |
| 225 | break; |
| 226 | } |
| 227 | |
| 228 | if (UI_inputcxx . . $ UI_input..key_statuscxx . . $ tUIInput#key_status. == UIKEY_PRESSEDcxx . . $ `ui/uisys.h:31:9`!) { |
| 229 | if (TrapKeycxx . . $ UIGadget#TrapKey(83c267b20bac841a).(UI_inputcxx . . $ UI_input..keycxx . . $ tUIInput#key.)) |
| 230 | OnKeyDowncxx . . $ UIGadget#OnKeyDown(d4f767463ce0a6b3).(UI_inputcxx . . $ UI_input..keycxx . . $ tUIInput#key.); |
| 231 | } else if (UI_inputcxx . . $ UI_input..key_statuscxx . . $ tUIInput#key_status. == UIKEY_RELEASEDcxx . . $ `ui/uisys.h:32:9`!) { |
| 232 | UntrapKeycxx . . $ UIGadget#UntrapKey(d4f767463ce0a6b3).(UI_inputcxx . . $ UI_input..keycxx . . $ tUIInput#key.); |
| 233 | OnKeyUpcxx . . $ UIGadget#OnKeyUp(d4f767463ce0a6b3).(UI_inputcxx . . $ UI_input..keycxx . . $ tUIInput#key.); |
| 234 | } else if (UI_inputcxx . . $ UI_input..key_statuscxx . . $ tUIInput#key_status. == UIKEY_CLICKEDcxx . . $ `ui/uisys.h:33:9`!) { |
| 235 | if (TrapKeycxx . . $ UIGadget#TrapKey(83c267b20bac841a).(UI_inputcxx . . $ UI_input..keycxx . . $ tUIInput#key.)) |
| 236 | OnKeyDowncxx . . $ UIGadget#OnKeyDown(d4f767463ce0a6b3).(UI_inputcxx . . $ UI_input..keycxx . . $ tUIInput#key.); |
| 237 | UntrapKeycxx . . $ UIGadget#UntrapKey(d4f767463ce0a6b3).(UI_inputcxx . . $ UI_input..keycxx . . $ tUIInput#key.); |
| 238 | OnKeyUpcxx . . $ UIGadget#OnKeyUp(d4f767463ce0a6b3).(UI_inputcxx . . $ UI_input..keycxx . . $ tUIInput#key.); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | // run gadget's user process |
| 243 | if (do_user) { |
| 244 | OnUserProcesscxx . . $ UIGadget#OnUserProcess(49f6e7a06ebc5aa8).(); |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | // when gadget is selected, this function will AT LEAST be called. |
| 249 | // typically this function is called by a child class when we want |
| 250 | // to tell the caller that this gadget was selected for something. |
| 251 | void UIGadgetcxx . . $ UIGadget#::OnSelectcxx . . $ UIGadget#OnSelect(49f6e7a06ebc5aa8).() { |
| 252 | if (m_MasterGadgetcxx . . $ UIGadget#m_MasterGadget. && CHECK_FLAGcxx . . $ `lib/Macros.h:63:9`!(m_Flags, UIF_NOTIFYMASTERSELcxx . . $ `ui/ui.h:346:9`!)) { |
| 253 | m_MasterGadgetcxx . . $ UIGadget#m_MasterGadget.->OnNotifySelectcxx . . $ UIGadget#OnNotifySelect(627f6e6cf27f18b7).(this); |
| 254 | } else { |
| 255 | UI_outputcxx . . $ UI_output..idcxx . . $ tUIOutput#id. = m_IDcxx . . $ UIGadget#m_ID.; |
| 256 | UI_outputcxx . . $ UI_output..gadgetcxx . . $ tUIOutput#gadget. = this; |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | void UIGadgetcxx . . $ UIGadget#::AttachSlaveGadgetcxx . . $ UIGadget#AttachSlaveGadget(627f6e6cf27f18b7).(UIGadgetcxx . . $ UIGadget# *gadget) { |
| 261 | // attach to list. |
| 262 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(gadget); |
| 263 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(!m_MasterGadget); // slaves can't own each other (sorry, been reading Uncle Tom's Cabin in class) |
| 264 | |
| 265 | gadget->m_Flagscxx . . $ UIGadget#m_Flags. |= UIF_SLAVEcxx . . $ `ui/ui.h:345:9`!; |
| 266 | gadget->m_MasterGadgetcxx . . $ UIGadget#m_MasterGadget. = this; |
| 267 | if (m_SlaveGadgetscxx . . $ UIGadget#m_SlaveGadgets.) { |
| 268 | m_SlaveGadgetscxx . . $ UIGadget#m_SlaveGadgets.->m_NextSlavecxx . . $ UIGadget#m_NextSlave. = gadget; |
| 269 | } |
| 270 | gadget->m_PrevSlavecxx . . $ UIGadget#m_PrevSlave. = m_SlaveGadgetscxx . . $ UIGadget#m_SlaveGadgets.; |
| 271 | gadget->m_NextSlavecxx . . $ UIGadget#m_NextSlave. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 272 | m_SlaveGadgetscxx . . $ UIGadget#m_SlaveGadgets. = gadget; |
| 273 | } |
| 274 | |
| 275 | void UIGadgetcxx . . $ UIGadget#::DetachSlaveGadgetcxx . . $ UIGadget#DetachSlaveGadget(627f6e6cf27f18b7).(UIGadgetcxx . . $ UIGadget# *gadget) { |
| 276 | if (!gadget) { |
| 277 | return; |
| 278 | } |
| 279 | |
| 280 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(gadget->m_MasterGadget == this); |
| 281 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(!m_MasterGadget); // slaves can't own each other (sorry, been reading Uncle Tom's Cabin in class) |
| 282 | |
| 283 | if (gadget == m_SlaveGadgetscxx . . $ UIGadget#m_SlaveGadgets.) { |
| 284 | m_SlaveGadgetscxx . . $ UIGadget#m_SlaveGadgets. = gadget->m_PrevSlavecxx . . $ UIGadget#m_PrevSlave.; |
| 285 | } |
| 286 | if (gadget == m_CurrentSlavecxx . . $ UIGadget#m_CurrentSlave.) { |
| 287 | m_CurrentSlavecxx . . $ UIGadget#m_CurrentSlave.->LostFocuscxx . . $ UIGadget#LostFocus(49f6e7a06ebc5aa8).(); |
| 288 | m_CurrentSlavecxx . . $ UIGadget#m_CurrentSlave. = gadget->m_PrevSlavecxx . . $ UIGadget#m_PrevSlave. ? gadget->m_PrevSlavecxx . . $ UIGadget#m_PrevSlave. : gadget->m_NextSlavecxx . . $ UIGadget#m_NextSlave.; |
| 289 | } |
| 290 | if (gadget->m_PrevSlavecxx . . $ UIGadget#m_PrevSlave.) { |
| 291 | gadget->m_PrevSlavecxx . . $ UIGadget#m_PrevSlave.->m_NextSlavecxx . . $ UIGadget#m_NextSlave. = gadget->m_NextSlavecxx . . $ UIGadget#m_NextSlave.; |
| 292 | } |
| 293 | if (gadget->m_NextSlavecxx . . $ UIGadget#m_NextSlave.) { |
| 294 | gadget->m_NextSlavecxx . . $ UIGadget#m_NextSlave.->m_PrevSlavecxx . . $ UIGadget#m_PrevSlave. = gadget->m_PrevSlavecxx . . $ UIGadget#m_PrevSlave.; |
| 295 | } |
| 296 | |
| 297 | gadget->m_MasterGadgetcxx . . $ UIGadget#m_MasterGadget. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 298 | gadget->m_Flagscxx . . $ UIGadget#m_Flags. &= (~UIF_SLAVEcxx . . $ `ui/ui.h:345:9`!); |
| 299 | } |
| 300 | |
| 301 | /////////////////////////////////////////////////////////////////////////////// |
| 302 | // PRIVATE FUNCTIONS |
| 303 | |
| 304 | // called by window system |
| 305 | void UIGadgetcxx . . $ UIGadget#::LostFocuscxx . . $ UIGadget#LostFocus(49f6e7a06ebc5aa8).() { |
| 306 | this->OnLostFocuscxx . . $ UIGadget#OnLostFocus(49f6e7a06ebc5aa8).(); // should invoke gadget's OnLostFocus function |
| 307 | if (m_CurrentSlavecxx . . $ UIGadget#m_CurrentSlave.) { |
| 308 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(m_SlaveGadgets); |
| 309 | m_CurrentSlavecxx . . $ UIGadget#m_CurrentSlave.->LostFocuscxx . . $ UIGadget#LostFocus(49f6e7a06ebc5aa8).(); |
| 310 | m_CurrentSlavecxx . . $ UIGadget#m_CurrentSlave. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 311 | } |
| 312 | m_infocuscxx . . $ UIGadget#m_infocus. = false; |
| 313 | } |
| 314 | |
| 315 | // called by window system |
| 316 | void UIGadgetcxx . . $ UIGadget#::GainFocuscxx . . $ UIGadget#GainFocus(49f6e7a06ebc5aa8).() { |
| 317 | // m_LastKey = 0; |
| 318 | // m_LastKeyTime = 0.0f; |
| 319 | |
| 320 | m_infocuscxx . . $ UIGadget#m_infocus. = true; |
| 321 | m_CurrentSlavecxx . . $ UIGadget#m_CurrentSlave. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 322 | this->OnGainFocuscxx . . $ UIGadget#OnGainFocus(49f6e7a06ebc5aa8).(); // should invoke gadget's OnGainFocus function |
| 323 | } |
| 324 | |
| 325 | void UIGadgetcxx . . $ UIGadget#::CheckFocusOnSlavescxx . . $ UIGadget#CheckFocusOnSlaves(3e454b8ccf442868).(int mx, int my) { |
| 326 | UIGadgetcxx . . $ UIGadget# *slave = m_SlaveGadgetscxx . . $ UIGadget#m_SlaveGadgets.; |
| 327 | |
| 328 | if (CHECK_FLAGcxx . . $ `lib/Macros.h:63:9`!(m_Flags, UIF_SLAVEcxx . . $ `ui/ui.h:345:9`!)) |
| 329 | return; |
| 330 | |
| 331 | while (slave) { |
| 332 | if (PT_IN_GADGETcxx . . $ PT_IN_GADGET(55d2799d541f12b5).(m_Wndcxx . . $ UIGadget#m_Wnd., slave, mx, my)) { |
| 333 | if (m_CurrentSlavecxx . . $ UIGadget#m_CurrentSlave.) { |
| 334 | m_CurrentSlavecxx . . $ UIGadget#m_CurrentSlave.->LostFocuscxx . . $ UIGadget#LostFocus(49f6e7a06ebc5aa8).(); |
| 335 | } |
| 336 | m_CurrentSlavecxx . . $ UIGadget#m_CurrentSlave. = slave; |
| 337 | m_CurrentSlavecxx . . $ UIGadget#m_CurrentSlave.->GainFocuscxx . . $ UIGadget#GainFocus(49f6e7a06ebc5aa8).(); |
| 338 | break; |
| 339 | } |
| 340 | slave = slave->m_PrevSlavecxx . . $ UIGadget#m_PrevSlave.; |
| 341 | } |
| 342 | |
| 343 | if (!slave) { |
| 344 | if (m_CurrentSlavecxx . . $ UIGadget#m_CurrentSlave.) { |
| 345 | m_CurrentSlavecxx . . $ UIGadget#m_CurrentSlave.->LostFocuscxx . . $ UIGadget#LostFocus(49f6e7a06ebc5aa8).(); |
| 346 | m_CurrentSlavecxx . . $ UIGadget#m_CurrentSlave. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 347 | } |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | // used to manage keypresses so repeating isn't quick. |
| 352 | bool UIGadgetcxx . . $ UIGadget#::TrapKeycxx . . $ UIGadget#TrapKey(83c267b20bac841a).(int key) { |
| 353 | float time; |
| 354 | time = timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!(); |
| 355 | |
| 356 | // take care of multiple keypresses and key down repeats. handle timing |
| 357 | // so it feels 'natural' |
| 358 | if (m_LastKeycxx . . $ UIGadget#m_LastKey. && m_LastKeycxx . . $ UIGadget#m_LastKey. == key) { |
| 359 | if (m_LastKeyCountcxx . . $ UIGadget#m_LastKeyCount. == 1) { |
| 360 | if ((time - m_LastKeyTimecxx . . $ UIGadget#m_LastKeyTime.) < KEYDOWN_FIRST_DELAYcxx . . $ `ui/ui.h:753:9`!) |
| 361 | return false; |
| 362 | } else if ((time - m_LastKeyTimecxx . . $ UIGadget#m_LastKeyTime.) < KEYDOWN_REPEAT_DELAYcxx . . $ `ui/ui.h:754:9`!) { |
| 363 | return false; |
| 364 | } |
| 365 | m_LastKeyCountcxx . . $ UIGadget#m_LastKeyCount.++; |
| 366 | } else { |
| 367 | m_LastKeyCountcxx . . $ UIGadget#m_LastKeyCount. = 1; |
| 368 | } |
| 369 | |
| 370 | m_LastKeycxx . . $ UIGadget#m_LastKey. = key; |
| 371 | m_LastKeyTimecxx . . $ UIGadget#m_LastKeyTime. = time; |
| 372 | |
| 373 | return true; |
| 374 | } |
| 375 | |
| 376 | void UIGadgetcxx . . $ UIGadget#::UntrapKeycxx . . $ UIGadget#UntrapKey(d4f767463ce0a6b3).(int key) { |
| 377 | // if the key previously pressed went up, then |
| 378 | // turn off key repeat management. |
| 379 | if (key == m_LastKeycxx . . $ UIGadget#m_LastKey.) { |
| 380 | m_LastKeyCountcxx . . $ UIGadget#m_LastKeyCount. = 0; |
| 381 | m_LastKeycxx . . $ UIGadget#m_LastKey. = 0; |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | // is this gadget's focus locked? |
| 386 | bool UIGadgetcxx . . $ UIGadget#::IsLockedcxx . . $ UIGadget#IsLocked(50ce9a9e25b4a850).() const { |
| 387 | if (m_Wndcxx . . $ UIGadget#m_Wnd.->m_LockedGadgetcxx . . $ UIWindow#m_LockedGadget. == this) |
| 388 | return true; |
| 389 | else |
| 390 | return false; |
| 391 | } |
| 392 | |
| 393 | UIGadgetcxx . . $ UIGadget# *UIGadgetcxx . . $ UIGadget#::GetPrevUsableGadgetcxx . . $ UIGadget#GetPrevUsableGadget(42baa2535cd0f5f7).() { |
| 394 | UIGadgetcxx . . $ UIGadget# *gadget = this; |
| 395 | UIGadgetcxx . . $ UIGadget# *next_gadget = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 396 | |
| 397 | while (gadget->m_Prevcxx . . $ UIGadget#m_Prev.) { |
| 398 | gadget = gadget->m_Prevcxx . . $ UIGadget#m_Prev.; |
| 399 | if (!gadget->IsDisabledcxx . . $ UIGadget#IsDisabled(c9857a73d68e59ba).()) { |
| 400 | next_gadget = gadget; |
| 401 | break; |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | return next_gadget; |
| 406 | } |
| 407 | |
| 408 | UIGadgetcxx . . $ UIGadget# *UIGadgetcxx . . $ UIGadget#::GetNextUsableGadgetcxx . . $ UIGadget#GetNextUsableGadget(42baa2535cd0f5f7).() { |
| 409 | UIGadgetcxx . . $ UIGadget# *gadget = this; |
| 410 | UIGadgetcxx . . $ UIGadget# *next_gadget = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 411 | |
| 412 | while (gadget->m_Nextcxx . . $ UIGadget#m_Next.) { |
| 413 | gadget = gadget->m_Nextcxx . . $ UIGadget#m_Next.; |
| 414 | if (!gadget->IsDisabledcxx . . $ UIGadget#IsDisabled(c9857a73d68e59ba).()) { |
| 415 | next_gadget = gadget; |
| 416 | break; |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | return next_gadget; |
| 421 | } |