Debian Codegraph @

ui/UIGroup.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/UIGroup.cpp $
21 * $Revision: 6 $
22 * $Date: 4/14/99 1:53a $
23 * $Author: Jeff $
24 *
25 * Group box
26 *
27 * $Log: /DescentIII/Main/ui/UIGroup.cpp $
28 *
29 * 6 4/14/99 1:53a Jeff
30 * fixed case mismatched #includes
31 *
32 * 5 10/20/98 12:14p Jeff
33 * added color to the UIGroup
34 *
35 * 4 10/16/98 1:42p Jeff
36 * updated UIGroup
37 *
38 * 3 10/12/98 11:30a Kevin
39 * More memory stuff
40 *
41 * 2 10/07/98 11:25a Jeff
42 * created UIGroup
43 *
44 * $NoKeywords: $
45 */
46
47 #include <cstdlib>
48 #include <cstring>
49
50 #include "UIlib.h"cxx . . $ `<file>/ui/UIlib.h`/
51 #include "mem.h"cxx . . $ `<file>/mem/mem.h`/
52
53 // ----------------------------------------------------------------------------
54 // UIGroup
55 // Draws a group box on to the window
56
57 UIGroupcxx . . $ UIGroup#::UIGroupcxx . . $ UIGroup#UIGroup(49f6e7a06ebc5aa8).() {
58 m_Labelcxx . . $ UIGroup#m_Label. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
59 m_bTextCreatedcxx . . $ UIGroup#m_bTextCreated. = false;
60 }
61
62 UIGroupcxx . . $ UIGroup#::~cxx . . $ UIGroup#`~UIGroup`(ced63f7c635d850d).UIGroupcxx . . $ UIGroup#() {}
63
64 void UIGroupcxx . . $ UIGroup#::Createcxx . . $ UIGroup#Create(33c6c9652d183a8e).(UIWindowcxx . . $ UIWindow# *parent, char *label, int x, int y, int w, int h, ddgr_colorcxx . . $ ddgr_color# label_color,
65 ddgr_colorcxx . . $ ddgr_color# box_color, int flags) {
66 ASSERTcxx . . $ `misc/pserror.h:246:9`!(parent);
67 ASSERTcxx . . $ `misc/pserror.h:246:9`!(label);
68
69 m_LabelColorcxx . . $ UIGroup#m_LabelColor. = label_color;
70 m_BoxColorcxx . . $ UIGroup#m_BoxColor. = box_color;
71
72 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);
73
74 int length = strlen(label);
75 if (length) {
76 m_Labelcxx . . $ UIGroup#m_Label. = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(length + 1);
77 strcpy(m_Labelcxx . . $ UIGroup#m_Label., label);
78 }
79 }
80
81 void UIGroupcxx . . $ UIGroup#::OnDrawcxx . . $ UIGroup#OnDraw(49f6e7a06ebc5aa8).() {
82 ui_DrawSetAlphacxx . . $ ui_DrawSetAlpha(ac50b47256ae7414).(255);
83
84 int text_height = 0;
85 int text_width = 0;
86
87 if (m_Labelcxx . . $ UIGroup#m_Label.) {
88 text_height = ui_GetTextHeightcxx . . $ ui_GetTextHeight(5c4306d8553b3696).("X") / 2;
89 text_width = ui_GetTextWidthcxx . . $ ui_GetTextWidth(5c4306d8553b3696).(m_Labelcxx . . $ UIGroup#m_Label.);
90 }
91
92 ui_DrawLinecxx . . $ ui_DrawLine(fe09a4b73d8d396f).(m_BoxColorcxx . . $ UIGroup#m_BoxColor., 0, text_height, 0, m_Hcxx . . $ UIObject#m_H. - 1); // left side
93 ui_DrawLinecxx . . $ ui_DrawLine(fe09a4b73d8d396f).(m_BoxColorcxx . . $ UIGroup#m_BoxColor., 0, m_Hcxx . . $ UIObject#m_H. - 1, m_Wcxx . . $ UIObject#m_W. - 1, m_Hcxx . . $ UIObject#m_H. - 1); // bottom
94 ui_DrawLinecxx . . $ ui_DrawLine(fe09a4b73d8d396f).(m_BoxColorcxx . . $ UIGroup#m_BoxColor., m_Wcxx . . $ UIObject#m_W. - 1, m_Hcxx . . $ UIObject#m_H. - 1, m_Wcxx . . $ UIObject#m_W. - 1, text_height); // right side
95
96 int top_edge_length = 0;
97
98 top_edge_length = (m_Wcxx . . $ UIObject#m_W. - text_width) / 2;
99 if (m_Labelcxx . . $ UIGroup#m_Label.)
100 top_edge_length -= 3;
101
102 if (top_edge_length < 0)
103 top_edge_length = 0;
104
105 ui_DrawLinecxx . . $ ui_DrawLine(fe09a4b73d8d396f).(m_BoxColorcxx . . $ UIGroup#m_BoxColor., 0, text_height, top_edge_length, text_height);
106 ui_DrawLinecxx . . $ ui_DrawLine(fe09a4b73d8d396f).(m_BoxColorcxx . . $ UIGroup#m_BoxColor., m_Wcxx . . $ UIObject#m_W., text_height, m_Wcxx . . $ UIObject#m_W. - top_edge_length, text_height);
107
108 if (!m_bTextCreatedcxx . . $ UIGroup#m_bTextCreated.) {
109 m_bTextCreatedcxx . . $ UIGroup#m_bTextCreated. = true;
110 UITextItemcxx . . $ UITextItem# itemcxx . . $ UITextItem#UITextItem(5f8aa4f2725849c4).{(m_Labelcxx . . $ UIGroup#m_Label.) ? m_Labelcxx . . $ UIGroup#m_Label. : "", m_LabelColorcxx . . $ UIGroup#m_LabelColor.};
111 m_tLabelcxx . . $ UIGroup#m_tLabel..Createcxx . . $ UIText#Create(c90f152919fa414d).(m_Wndcxx . . $ UIGadget#m_Wnd., &item, m_Xcxx . . $ UIObject#m_X. + top_edge_length + 3, m_Ycxx . . $ UIObject#m_Y.);
112 }
113 }
114
115 void UIGroupcxx . . $ UIGroup#::OnDestroycxx . . $ UIGroup#OnDestroy(49f6e7a06ebc5aa8).() {
116 if (m_Labelcxx . . $ UIGroup#m_Label.)
117 mem_freecxx . . $ `mem/mem.h:80:9`!(m_Label);
118 }