Debian Codegraph @

ui/UIStatic.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/UIStatic.cpp $
21 * $Revision: 12 $
22 * $Date: 4/14/99 1:53a $
23 * $Author: Jeff $
24 *
25 * Static text
26 *
27 * $Log: /DescentIII/Main/ui/UIStatic.cpp $
28 *
29 * 12 4/14/99 1:53a Jeff
30 * fixed case mismatched #includes
31 *
32 * 11 1/02/99 6:46p Matt
33 * Fixed compile warning
34 *
35 * 10 12/30/98 12:16p Kevin
36 * Auto Mission Download system
37 *
38 * 9 10/01/98 12:57p Samir
39 * fixed hotspots so their width and height touch text, no outer border.
40 *
41 * 8 8/31/98 12:37p Samir
42 * disable all static controls.
43 *
44 * 7 6/05/98 5:36p Samir
45 * disable static items by default, so they don't mess up keyboard focus.
46 *
47 * 6 2/13/98 6:34p Samir
48 * Added UIStatic class.
49 *
50 * 5 1/30/98 7:07p Samir
51 * Changes to gadget system.
52 *
53 * 4 1/18/98 4:22p Samir
54 * Implemented new UIItem system.
55 *
56 * 3 1/08/98 12:18p Samir
57 * Static control size is always calculated.
58 *
59 * 2 1/05/98 4:36p Samir
60 * Moved centering and fittext control flags to UIGadget class.
61 *
62 * 1 1/02/98 12:49p Samir
63 * Initial revision.
64 *
65 *
66 * $NoKeywords: $
67 */
68
69 #include <cstring>
70
71 #include "UIlib.h"cxx . . $ `<file>/ui/UIlib.h`/
72
73 // ----------------------------------------------------------------------------
74 // UIText
75 // This is a simple text.
76
77 void UITextcxx . . $ UIText#::Createcxx . . $ UIText#Create(c90f152919fa414d).(UIWindowcxx . . $ UIWindow# *parent, UITextItemcxx . . $ UITextItem# *text, int x, int y, int flags) {
78 UIStaticcxx . . $ UIStatic#::Createcxx . . $ UIStatic#Create(8745842b033f01b8).(parent, text, x, y, 1, 1, flags);
79 }
80
81 // inheritable operations
82 // override: called when resized or before drawing.
83 void UITextcxx . . $ UIText#::OnFormatcxx . . $ UIText#OnFormat(49f6e7a06ebc5aa8).() {
84 m_Wcxx . . $ UIObject#m_W. = m_Titlecxx . . $ UIStatic#m_Title.->widthcxx . . $ UIItem#width(b126dc7c1de90089).();
85 m_Hcxx . . $ UIObject#m_H. = m_Titlecxx . . $ UIStatic#m_Title.->heightcxx . . $ UIItem#height(b126dc7c1de90089).();
86
87 UIGadgetcxx . . $ UIGadget#::OnFormatcxx . . $ UIGadget#OnFormat(49f6e7a06ebc5aa8).();
88 }
89
90 UIStaticcxx . . $ UIStatic#::UIStaticcxx . . $ UIStatic#UIStatic(49f6e7a06ebc5aa8).() {
91 m_Titlecxx . . $ UIStatic#m_Title. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
92 m_Backgroundcxx . . $ UIStatic#m_Background. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
93 }
94
95 UIStaticcxx . . $ UIStatic#::~cxx . . $ UIStatic#`~UIStatic`(ced63f7c635d850d).UIStaticcxx . . $ UIStatic#() {}
96
97 void UIStaticcxx . . $ UIStatic#::Createcxx . . $ UIStatic#Create(8745842b033f01b8).(UIWindowcxx . . $ UIWindow# *parent, UIItemcxx . . $ UIItem# *item, int x, int y, int w, int h, int flags) {
98 m_Backgroundcxx . . $ UIStatic#m_Background. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
99 if (item)
100 m_Titlecxx . . $ UIStatic#m_Title. = item->CopyUIItemcxx . . $ UIItem#CopyUIItem(ff7db2a2e5605676).();
101 else
102 m_Titlecxx . . $ UIStatic#m_Title. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
103 UIGadgetcxx . . $ UIGadget#::Createcxx . . $ UIGadget#Create(43707b8add2f137d).(parent, -1, x, y, w, h, flags);
104 UIGadgetcxx . . $ UIGadget#::Disablecxx . . $ UIGadget#Disable(49f6e7a06ebc5aa8).();
105 }
106
107 void UIStaticcxx . . $ UIStatic#::SetBackgroundcxx . . $ UIStatic#SetBackground(20452550650c07e7).(UIPrimativeItemcxx . . $ UIPrimativeItem# *item) {
108 if (m_Backgroundcxx . . $ UIStatic#m_Background.)
109 delete m_Backgroundcxx . . $ UIStatic#m_Background.;
110 m_Backgroundcxx . . $ UIStatic#m_Background. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
111 if (item)
112 m_Backgroundcxx . . $ UIStatic#m_Background. = (UIPrimativeItemcxx . . $ UIPrimativeItem# *)item->CopyUIItemcxx . . $ UIPrimativeItem#CopyUIItem(ff7db2a2e5605676).();
113 }
114
115 void UIStaticcxx . . $ UIStatic#::SetTitlecxx . . $ UIStatic#SetTitle(52afca12b6cce14a).(UIItemcxx . . $ UIItem# *item) {
116 if (m_Titlecxx . . $ UIStatic#m_Title.)
117 delete m_Titlecxx . . $ UIStatic#m_Title.;
118 m_Titlecxx . . $ UIStatic#m_Title. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
119 if (item)
120 m_Titlecxx . . $ UIStatic#m_Title. = (UIPrimativeItemcxx . . $ UIPrimativeItem# *)item->CopyUIItemcxx . . $ UIItem#CopyUIItem(ff7db2a2e5605676).();
121 }
122
123 void UIStaticcxx . . $ UIStatic#::OnDrawcxx . . $ UIStatic#OnDraw(49f6e7a06ebc5aa8).() {
124 if (m_Flagscxx . . $ UIGadget#m_Flags. & UIF_BORDERcxx . . $ `ui/ui.h:344:9`!)
125 ui_DrawBoxcxx . . $ ui_DrawBox(fe09a4b73d8d396f).(GR_WHITEcxx . . $ GR_WHITE., 0, 0, m_Wcxx . . $ UIObject#m_W., m_Hcxx . . $ UIObject#m_H.);
126
127 if (m_Backgroundcxx . . $ UIStatic#m_Background.)
128 m_Backgroundcxx . . $ UIStatic#m_Background.->drawcxx . . $ UIPrimativeItem#draw(a1642a0ee405ca20).(0, 0, m_Wcxx . . $ UIObject#m_W., m_Hcxx . . $ UIObject#m_H.);
129 if (m_Titlecxx . . $ UIStatic#m_Title.) {
130 // int y = (m_H/2 - m_Title->height()/2);
131 // int x = (m_W/2 - m_Title->width()/2);
132 m_Titlecxx . . $ UIStatic#m_Title.->drawcxx . . $ UIItem#draw(84329bcd07240ccf).(0, 0);
133 }
134 }
135
136 void UIStaticcxx . . $ UIStatic#::OnFormatcxx . . $ UIStatic#OnFormat(49f6e7a06ebc5aa8).() {
137 if (m_Flagscxx . . $ UIGadget#m_Flags. & UIF_FITcxx . . $ `ui/ui.h:343:9`!) {
138 if (m_Titlecxx . . $ UIStatic#m_Title.) {
139 m_Wcxx . . $ UIObject#m_W. = m_Titlecxx . . $ UIStatic#m_Title.->widthcxx . . $ UIItem#width(b126dc7c1de90089).();
140 m_Hcxx . . $ UIObject#m_H. = m_Titlecxx . . $ UIStatic#m_Title.->heightcxx . . $ UIItem#height(b126dc7c1de90089).();
141 } else {
142 m_Wcxx . . $ UIObject#m_W. = 10;
143 m_Hcxx . . $ UIObject#m_H. = 10;
144 }
145 }
146
147 UIGadgetcxx . . $ UIGadget#::OnFormatcxx . . $ UIGadget#OnFormat(49f6e7a06ebc5aa8).();
148 }
149
150 // called when gadget is being nuked.
151 void UIStaticcxx . . $ UIStatic#::OnDestroycxx . . $ UIStatic#OnDestroy(49f6e7a06ebc5aa8).() {
152 if (m_Titlecxx . . $ UIStatic#m_Title.)
153 delete m_Titlecxx . . $ UIStatic#m_Title.;
154 if (m_Backgroundcxx . . $ UIStatic#m_Background.)
155 delete m_Backgroundcxx . . $ UIStatic#m_Background.;
156
157 m_Titlecxx . . $ UIStatic#m_Title. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
158 m_Backgroundcxx . . $ UIStatic#m_Background. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
159 }
160
161 // ----------------------------------------------------------------------------
162 // UIProgress
163 // This is a simple text.
164
165 void UIProgresscxx . . $ UIProgress#::Createcxx . . $ UIProgress#Create(d616eeffcc609617).(UIWindowcxx . . $ UIWindow# *parent, int x, int y, int w, int h, int flags) {
166 m_Wcxx . . $ UIObject#m_W. = w;
167 m_Hcxx . . $ UIObject#m_H. = h;
168 m_ProgressWidthcxx . . $ UIProgress#m_ProgressWidth. = 0;
169 UIStaticcxx . . $ UIStatic#::Createcxx . . $ UIStatic#Create(8745842b033f01b8).(parent, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, x, y, w, h, flags);
170 }
171
172 // inheritable operations
173 // override: called when resized or before drawing.
174 void UIProgresscxx . . $ UIProgress#::OnFormatcxx . . $ UIProgress#OnFormat(49f6e7a06ebc5aa8).() { UIGadgetcxx . . $ UIGadget#::OnFormatcxx . . $ UIGadget#OnFormat(49f6e7a06ebc5aa8).(); }
175
176 void UIProgresscxx . . $ UIProgress#::Updatecxx . . $ UIProgress#Update(9364e6e7bff7660).(float progress) {
177 m_Progresscxx . . $ UIProgress#m_Progress. = progress;
178 m_ProgressWidthcxx . . $ UIProgress#m_ProgressWidth. = ((int)((m_Wcxx . . $ UIObject#m_W. - 2) * m_Progresscxx . . $ UIProgress#m_Progress.));
179 }
180
181 void UIProgresscxx . . $ UIProgress#::OnDrawcxx . . $ UIProgress#OnDraw(49f6e7a06ebc5aa8).() {
182 // Take the x & y & w/h & progress to draw the progress bar
183 ui_DrawBoxcxx . . $ ui_DrawBox(fe09a4b73d8d396f).(GR_WHITEcxx . . $ GR_WHITE., 0, 0, m_Wcxx . . $ UIObject#m_W., m_Hcxx . . $ UIObject#m_H.);
184 ui_DrawBoxcxx . . $ ui_DrawBox(fe09a4b73d8d396f).(GR_WHITEcxx . . $ GR_WHITE., 1, 1, m_Wcxx . . $ UIObject#m_W. - 1, m_Hcxx . . $ UIObject#m_H. - 1);
185 ui_DrawRectcxx . . $ ui_DrawRect(fe09a4b73d8d396f).(GR_LIGHTGRAYcxx . . $ GR_LIGHTGRAY., 2, 2, m_ProgressWidthcxx . . $ UIProgress#m_ProgressWidth., m_Hcxx . . $ UIObject#m_H. - 2);
186 }