This repository has been archived by the owner on Feb 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy pathCHEKLIST.CPP
168 lines (154 loc) · 8.62 KB
/
CHEKLIST.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
** Command & Conquer(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Header: F:\projects\c&c\vcs\code\cheklist.cpv 2.18 16 Oct 1995 16:48:36 JOE_BOSTIC $ */
/***************************************************************************
** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
***************************************************************************
* *
* Project Name : Command & Conquer *
* *
* File Name : CHEKLIST.CPP *
* *
* Programmer : Bill Randolph *
* *
* Start Date : February 16, 1995 *
* *
* Last Update : February 16, 1995 [BR] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* CheckListClass::Action -- action function for this class *
* CheckListClass::CheckListClass -- constructor *
* CheckListClass::Check_Item -- [un]checks an items *
* CheckListClass::~CheckListClass -- destructor *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "function.h"
/***************************************************************************
* CheckListClass::CheckListClass -- constructor *
* *
* INPUT: *
* id control ID for this list box *
* x x-coord *
* y y-coord *
* w width *
* h height *
* flags mouse event flags *
* up ptr to Up-arrow shape *
* down ptr to Down-arrow shape *
* *
* OUTPUT: *
* none. *
* *
* WARNINGS: *
* none. *
* *
* HISTORY: *
* 02/16/1995 BR : Created. *
*=========================================================================*/
CheckListClass::CheckListClass(int id, int x, int y, int w, int h, TextPrintType flags,
void const * up, void const * down) :
ListClass (id, x, y, w, h, flags, up, down)
{
IsReadOnly = false;
}
/***************************************************************************
* CheckListClass::Check_Item -- [un]checks an items *
* *
* INPUT: *
* index index of item to check or uncheck *
* checked 0 = uncheck, non-zero = check *
* *
* OUTPUT: *
* none. *
* *
* WARNINGS: *
* none. *
* *
* HISTORY: *
* 02/16/1995 BR : Created. *
*=========================================================================*/
void CheckListClass::Check_Item(int index, int checked)
{
if (List[index]) {
((char &)List[index][0]) = checked ? CHECK_CHAR : UNCHECK_CHAR;
}
}
/***************************************************************************
* CheckListClass::Is_Checked -- returns checked state of an item *
* *
* INPUT: *
* index index of item to query *
* *
* OUTPUT: *
* 0 = item is unchecked, 1 = item is checked *
* *
* WARNINGS: *
* none. *
* *
* HISTORY: *
* 02/16/1995 BR : Created. *
*=========================================================================*/
int CheckListClass::Is_Checked(int index) const
{
if (List[index]) {
return(List[index][0] == CHECK_CHAR);
}
return(false);
}
/***************************************************************************
* CheckListClass::Action -- action function for this class *
* *
* INPUT: *
* flags the reason we're being called *
* key the KN_number that was pressed *
* *
* OUTPUT: *
* true = event was processed, false = event not processed *
* *
* WARNINGS: *
* none. *
* *
* HISTORY: *
* 02/16/1995 BR : Created. *
*=========================================================================*/
int CheckListClass::Action(unsigned flags, KeyNumType &key)
{
int rc;
/*
** If this is a read-only list, it's a display-only device
*/
if (IsReadOnly) {
return(false);
}
/*
** Invoke parents Action first, so it can set the SelectedIndex if needed.
*/
rc = ListClass::Action(flags, key);
/*
** Now, if this event was a left-press, toggle the checked state of the
** current item.
*/
if (flags & LEFTPRESS) {
if (Is_Checked(SelectedIndex)) {
Check_Item(SelectedIndex,0);
} else {
Check_Item(SelectedIndex,1);
}
}
return(rc);
}