COLRLIST.CPP 14 KB

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