COLRLIST.CPP (14754B)
1 // 2 // Copyright 2020 Electronic Arts Inc. 3 // 4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 5 // software: you can redistribute it and/or modify it under the terms of 6 // the GNU General Public License as published by the Free Software Foundation, 7 // either version 3 of the License, or (at your option) any later version. 8 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 /* $Header: /CounterStrike/COLRLIST.CPP 1 3/03/97 10:24a Joe_bostic $ */ 17 /*********************************************************************************************** 18 *** 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 *** 19 *********************************************************************************************** 20 * * 21 * Project Name : Command & Conquer * 22 * * 23 * File Name : COLRLIST.CPP * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : 01/15/95 * 28 * * 29 * Last Update : April 19, 1995 [BRR] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * ColorListClass::Add_Item -- Adds an item to the list * 34 * ColorListClass::ColorListClass -- Class constructor * 35 * ColorListClass::Draw_Entry -- Draws one text line * 36 * ColorListClass::Remove_Item -- Removes an item from the list * 37 * ColorListClass::Set_Selected_Style -- tells how to draw selected item * 38 * ColorListClass::~ColorListClass -- Class destructor * 39 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 40 41 #include "function.h" 42 43 44 /*************************************************************************** 45 * ColorListClass::ColorListClass -- class constructor * 46 * * 47 * INPUT: * 48 * id button ID * 49 * x,y upper-left corner, in pixels * 50 * w,h width, height, in pixels * 51 * list ptr to array of char strings to list * 52 * flags flags for mouse, style of listbox * 53 * up,down pointers to shapes for up/down buttons * 54 * * 55 * OUTPUT: * 56 * none. * 57 * * 58 * WARNINGS: * 59 * none. * 60 * * 61 * HISTORY: 01/05/1995 MML : Created. * 62 *=========================================================================*/ 63 ColorListClass::ColorListClass (int id, int x, int y, int w, int h, 64 TextPrintType flags, void const * up, void const * down) : 65 ListClass (id, x, y, w, h, flags, up, down), 66 Style(SELECT_HIGHLIGHT), 67 SelectColor(NULL) 68 { 69 } 70 71 72 /*************************************************************************** 73 * ColorListClass::~ColorListClass -- Class destructor * 74 * * 75 * INPUT: * 76 * none. * 77 * * 78 * OUTPUT: * 79 * none. * 80 * * 81 * WARNINGS: * 82 * none. * 83 * * 84 * HISTORY: * 85 * 04/19/1995 BRR : Created. * 86 *=========================================================================*/ 87 ColorListClass::~ColorListClass(void) 88 { 89 Colors.Clear(); 90 SelectColor = 0; 91 } 92 93 94 /*************************************************************************** 95 * ColorListClass::Add_Item -- Adds an item to the list * 96 * * 97 * INPUT: * 98 * text text to add to list * 99 * color color for item * 100 * * 101 * OUTPUT: * 102 * position of item in the list * 103 * * 104 * WARNINGS: * 105 * none. * 106 * * 107 * HISTORY: * 108 * 04/19/1995 BRR : Created. * 109 *=========================================================================*/ 110 int ColorListClass::Add_Item(char const * text, RemapControlType * color) 111 { 112 Colors.Add(color); 113 return(ListClass::Add_Item(text)); 114 } 115 116 117 /*************************************************************************** 118 * ColorListClass::Add_Item -- Adds an item to the list * 119 * * 120 * INPUT: * 121 * text text to add to list * 122 * color color for item * 123 * * 124 * OUTPUT: * 125 * position of item in the list * 126 * * 127 * WARNINGS: * 128 * none. * 129 * * 130 * HISTORY: * 131 * 04/19/1995 BRR : Created. * 132 *=========================================================================*/ 133 int ColorListClass::Add_Item(int text, RemapControlType * color) 134 { 135 Colors.Add(color); 136 return(ListClass::Add_Item(text)); 137 } 138 139 140 /*************************************************************************** 141 * ColorListClass::Remove_Item -- Removes an item from the list * 142 * * 143 * INPUT: * 144 * text ptr to item to remove * 145 * * 146 * OUTPUT: * 147 * none. * 148 * * 149 * WARNINGS: * 150 * * 151 * HISTORY: * 152 * 04/19/1995 BRR : Created. * 153 *=========================================================================*/ 154 void ColorListClass::Remove_Item(char const * text) 155 { 156 int index = List.ID(text); 157 if (index != -1) { 158 Colors.Delete(index); 159 ListClass::Remove_Item(text); 160 } 161 } 162 163 164 /*************************************************************************** 165 * ColorListClass::Set_Selected_Style -- tells how to draw selected item * 166 * * 167 * INPUT: * 168 * style style to draw * 169 * color color to draw the special style in; -1 = use item's color * 170 * * 171 * OUTPUT: * 172 * none. * 173 * * 174 * WARNINGS: * 175 * none. * 176 * * 177 * HISTORY: * 178 * 04/19/1995 BRR : Created. * 179 *=========================================================================*/ 180 void ColorListClass::Set_Selected_Style(SelectStyleType style, RemapControlType * color) 181 { 182 Style = style; 183 SelectColor = color; 184 } 185 186 187 /*************************************************************************** 188 * ColorListClass::Draw_Entry -- Draws one text line * 189 * * 190 * INPUT: * 191 * index index into List of item to draw * 192 * x,y x,y coords to draw at * 193 * width maximum width allowed for text * 194 * selected true = this item is selected * 195 * * 196 * OUTPUT: * 197 * none. * 198 * * 199 * WARNINGS: * 200 * none. * 201 * * 202 * HISTORY: * 203 * 04/19/1995 BRR : Created. * 204 *=========================================================================*/ 205 void ColorListClass::Draw_Entry(int index, int x, int y, int width, int selected) 206 { 207 RemapControlType * color; 208 209 /* 210 ** Draw a non-selected item in its color 211 */ 212 if (!selected) { 213 Conquer_Clip_Text_Print(List[index], x, y, Colors[index], TBLACK, TextFlags, width, Tabs); 214 return; 215 } 216 217 /* 218 ** For selected items, choose the right color & style: 219 */ 220 if (SelectColor == NULL) { 221 color = Colors[index]; 222 } else { 223 color = SelectColor; 224 } 225 226 switch (Style) { 227 /* 228 ** NONE: Just print the string in its native color 229 */ 230 case SELECT_NORMAL: 231 Conquer_Clip_Text_Print(List[index], x, y, Colors[index], TBLACK, 232 TextFlags, width, Tabs); 233 break; 234 235 /* 236 ** HIGHLIGHT: Draw the string in the highlight color (SelectColor must 237 ** be set) 238 */ 239 case SELECT_HIGHLIGHT: 240 if (TextFlags & TPF_6PT_GRAD) { 241 Conquer_Clip_Text_Print(List[index], x, y, color, TBLACK, TextFlags | TPF_BRIGHT_COLOR, width, Tabs); 242 } else { 243 Conquer_Clip_Text_Print(List[index], x, y, color, TBLACK, TextFlags, width, Tabs); 244 } 245 break; 246 247 /* 248 ** BOX: Draw a box around the item in the current select color 249 */ 250 case SELECT_BOX: 251 LogicPage->Draw_Rect (x, y, x + width - 2, y + LineHeight - 2, color->Color); 252 Conquer_Clip_Text_Print(List[index], x, y, Colors[index], TBLACK, TextFlags, width, Tabs); 253 break; 254 255 /* 256 ** BAR: draw a color bar under the text 257 */ 258 case SELECT_BAR: 259 if (TextFlags & TPF_6PT_GRAD) { 260 LogicPage->Fill_Rect(x, y, x + width - 1, y + LineHeight - 1, color->Color); 261 Conquer_Clip_Text_Print(List[index], x, y, Colors[index], TBLACK, TextFlags | TPF_BRIGHT_COLOR, width, Tabs); 262 } else { 263 LogicPage->Fill_Rect(x, y, x + width - 2, y + LineHeight - 2, color->Color); 264 Conquer_Clip_Text_Print(List[index], x, y, Colors[index], TBLACK, TextFlags, width, Tabs); 265 } 266 break; 267 268 /* 269 ** INVERT: Draw text as the background color on foreground color 270 */ 271 case SELECT_INVERT: 272 LogicPage->Fill_Rect (x, y, x + width - 1, y + LineHeight - 1, Colors[index]->Color); 273 break; 274 } 275 }