LIST.H 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. ** Command & Conquer(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: F:\projects\c&c\vcs\code\list.h_v 2.17 16 Oct 1995 16:46:24 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 : LIST.H *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : 01/15/95 *
  30. * *
  31. * Last Update : January 15, 1995 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef LIST_H
  37. #define LIST_H
  38. #include "control.h"
  39. #include "shapebtn.h"
  40. #include "slider.h"
  41. /***************************************************************************
  42. * ListClass -- Like a Windows ListBox structure *
  43. * *
  44. * INPUT: int x -- x position of gadget *
  45. * int y -- y position of gadget *
  46. * int w -- width of gadget *
  47. * int h -- height of gadget *
  48. * UWORD flags -- see enumeration choices *
  49. * *
  50. * OUTPUT: none. *
  51. * WARNINGS: *
  52. * HISTORY: 01/03/1995 MML : Created. *
  53. *=========================================================================*/
  54. class ListClass : public ControlClass
  55. {
  56. public:
  57. ListClass(int id, int x, int y, int w, int h, TextPrintType flags, void const * up, void const * down);
  58. virtual ~ListClass(void);
  59. // static ListClass * Create_One_Of(int id, int x, int y, int w, int h, TextPrintType flags, void const * up, void const * down);
  60. virtual int Add_Item(char const * text);
  61. virtual int Add_Item(int text);
  62. virtual int Add_Scroll_Bar(void);
  63. virtual void Bump(int up);
  64. virtual int Count(void) {return List.Count();};
  65. virtual int Current_Index(void);
  66. virtual char const * Current_Item(void);
  67. virtual int Draw_Me(int forced);
  68. virtual char const * Get_Item(int index) const;
  69. virtual int Step_Selected_Index(int forward);
  70. virtual void Peer_To_Peer(unsigned flags, KeyNumType & key, ControlClass & whom);
  71. virtual void Remove_Item(char const * text);
  72. virtual int Remove_Scroll_Bar(void);
  73. virtual void Set_Selected_Index(int index);
  74. virtual void Set_Tabs(int const * tabs);
  75. virtual int Set_View_Index(int index);
  76. virtual void Step(int up);
  77. /*
  78. ** These overloaded list routines handle adding/removing the scroll bar
  79. ** automatically when the list box is added or removed.
  80. */
  81. virtual LinkClass & Add(LinkClass & object);
  82. virtual LinkClass & Add_Tail(LinkClass & object);
  83. virtual LinkClass & Add_Head(LinkClass & object);
  84. virtual GadgetClass * Remove(void);
  85. protected:
  86. virtual int Action(unsigned flags, KeyNumType &key);
  87. virtual void Draw_Entry(int index, int x, int y, int width, int selected);
  88. /*
  89. ** This controls what the text looks like. It uses the basic TPF_ flags that
  90. ** are used to control Fancy_Text_Print().
  91. */
  92. TextPrintType TextFlags;
  93. /*
  94. ** This is a series of tabstop pixel positions to use when processing any
  95. ** <TAB> characters found in a list box string. The tabs are a series of
  96. ** pixel offsets from the starting pixel position of the text.
  97. */
  98. int const *Tabs;
  99. /*
  100. ** The actual list of text pointers is maintained by this list manager. The pointers
  101. ** are stored in EMS. The text that is pointed to may also be in EMS.
  102. */
  103. DynamicVectorClass<char const *> List;
  104. //EMSListOf<char const *> List;
  105. /*
  106. ** This is the total pixel height of a standar line of text. This is greatly
  107. ** influenced by the TextFlags value.
  108. */
  109. int LineHeight;
  110. /*
  111. ** This is the number of text lines that can fit within the list box.
  112. */
  113. int LineCount;
  114. /*
  115. ** If the slider bar has been created, these point to the respective gadgets
  116. ** that it is composed of.
  117. */
  118. unsigned IsScrollActive:1;
  119. ShapeButtonClass UpGadget;
  120. ShapeButtonClass DownGadget;
  121. SliderClass ScrollGadget;
  122. /*
  123. ** This is the currently selected index. It is highlighted.
  124. */
  125. int SelectedIndex;
  126. /*
  127. ** This specifies the line (index) that is at the top of the list box.
  128. */
  129. int CurrentTopIndex;
  130. };
  131. #endif