ICONLIST.H 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. #ifdef WOLAPI_INTEGRATION
  19. /***************************************************************************
  20. * IconListClass -- Exactly like ListClass, but displays an icon as well
  21. * (actually a 'shape' image), left-aligned, covering
  22. * any text that happens to be there...
  23. * Also, I've added the option of making this class
  24. * responsible for the mem alloc. of the strings, and
  25. * an automatic limiting of entries to a set maximum.
  26. * *
  27. * HISTORY: 07/07/1998 ajw : Created, largely in hack mode. *
  28. *=========================================================================*/
  29. #ifndef ICONLIST_H
  30. #define ICONLIST_H
  31. #include "function.h"
  32. #include "vector.h"
  33. enum ICONKIND
  34. {
  35. ICON_SHAPE = 0, // pIcon points to a shape.
  36. ICON_DIB // pIcon points to DIBitmap data.
  37. };
  38. struct FIXEDICON // For putting icons in list entries at a specific fixed offset.
  39. {
  40. void* pIcon;
  41. ICONKIND IconKind;
  42. int xOffset;
  43. int yOffset;
  44. int iWidth;
  45. };
  46. struct IconList_ItemExtras
  47. {
  48. IconList_ItemExtras() : bMultiSelected( false ), szHelp( NULL ), szExtraData( NULL ), pvExtraData( NULL )
  49. {
  50. pIcon[0] = NULL;
  51. pIcon[1] = NULL;
  52. pIcon[2] = NULL;
  53. }
  54. virtual ~IconList_ItemExtras()
  55. {
  56. delete [] szHelp;
  57. delete [] szExtraData;
  58. }
  59. bool bMultiSelected; // True if selected when bMultiSelect is on.
  60. void* pIcon[3]; // Icon that appears before an item.
  61. ICONKIND IconKind[3]; // Specifies what kind of image data pIcon points to.
  62. char* szHelp; // Tooltip help string that can be associated with item. Allocated and deleted here.
  63. char* szExtraData; // Extra string that can be associated with item. Allocated and deleted here.
  64. void* pvExtraData; // Hidden pointer that can be associated with item.
  65. RemapControlType* pColorRemap; // Pointer to a color remap, or null for default colored text.
  66. FIXEDICON FixedIcon;
  67. };
  68. class IconListClass : public ListClass
  69. {
  70. public:
  71. IconListClass( int id, int x, int y, int w, int h, TextPrintType flags, void const * up, void const * down, bool bResponsibleForStringAlloc = FALSE, int iSelectionType = 1, int iMaxItemsSaved = 0 );
  72. // IconListClass( const IconListClass& list );
  73. virtual ~IconListClass( void );
  74. virtual int Add_Item( char const * text );
  75. virtual int Add_Item( const char* text, const char* szHelp,
  76. void* pIcon0, ICONKIND IconKind0, const char* szExtraDataString = NULL,
  77. void* pvExtraDataPtr = NULL, RemapControlType* pColorRemap = NULL,
  78. void* pIcon1 = NULL, ICONKIND IconKind1 = ICON_SHAPE,
  79. void* pIcon2 = NULL, ICONKIND IconKind2 = ICON_SHAPE,
  80. void* pFixedIcon = NULL, ICONKIND FixedIconKind = ICON_SHAPE, int iXFixedIcon = 0, int iYFixedIcon = 0, int iFixedIconWidth = -1 );
  81. virtual int Add_Item( int text );
  82. virtual int Add_Item( int text, const char* szHelp,
  83. void* pIcon0, ICONKIND IconKind0, const char* szExtraDataString = NULL,
  84. void* pvExtraDataPtr = NULL, RemapControlType* pColorRemap = NULL,
  85. void* pIcon1 = NULL, ICONKIND IconKind1 = ICON_SHAPE,
  86. void* pIcon2 = NULL, ICONKIND IconKind2 = ICON_SHAPE,
  87. void* pFixedIcon = NULL, ICONKIND FixedIconKind = ICON_SHAPE, int iXFixedIcon = 0, int iYFixedIcon = 0, int iFixedIconWidth = -1 );
  88. // virtual int Add_Scroll_Bar(void);
  89. // virtual void Bump(int up);
  90. // virtual int Count(void) const {return List.Count();};
  91. // virtual int Current_Index(void) const;
  92. // virtual char const * Current_Item(void) const;
  93. // virtual int Draw_Me(int forced);
  94. // virtual char const * Get_Item(int index) const;
  95. // virtual int Step_Selected_Index(int forward);
  96. // virtual void Flag_To_Redraw(void);
  97. // virtual void Peer_To_Peer(unsigned flags, KeyNumType & key, ControlClass & whom);
  98. virtual void Remove_Item( char const * text );
  99. virtual void Remove_Item( int );
  100. // virtual int Remove_Scroll_Bar(void);
  101. // virtual void Set_Selected_Index(int index);
  102. // virtual void Set_Selected_Index(char const * text);
  103. // virtual void Set_Tabs(int const * tabs);
  104. // virtual int Set_View_Index(int index);
  105. // virtual void Step(int up);
  106. // virtual void Set_Position(int x, int y);
  107. /*
  108. ** These overloaded list routines handle adding/removing the scroll bar
  109. ** automatically when the list box is added or removed.
  110. */
  111. // virtual LinkClass & Add(LinkClass & object);
  112. // virtual LinkClass & Add_Tail(LinkClass & object);
  113. // virtual LinkClass & Add_Head(LinkClass & object);
  114. // virtual GadgetClass * Remove(void);
  115. virtual void Show_Last_Item();
  116. virtual bool bItemIsMultiSelected( int index ) const;
  117. virtual void MultiSelect( int index, bool bSelect );
  118. virtual const char* Get_Item_ExtraDataString( int index ) const;
  119. virtual void Set_Item_ExtraDataString( int index, const char* szNewString );
  120. virtual void* Get_Item_ExtraDataPtr( int index ) const;
  121. virtual void Set_Item_ExtraDataPtr( int index, void* pNewValue );
  122. const char* Get_Item_Help( int index ) const;
  123. virtual RemapControlType* Get_Item_Color( int index );
  124. virtual void Set_Item_Color( int index, RemapControlType* pColorRemap );
  125. virtual const IconList_ItemExtras* Get_ItemExtras( int index ) const;
  126. virtual void Clear();
  127. virtual int Get_View_Index() { return CurrentTopIndex; }
  128. bool bScrollBeingDragged()
  129. {
  130. // Returns true if the scroll bar of the list is being dragged by the user.
  131. return ( GadgetClass::StuckOn == &ScrollGadget );
  132. }
  133. virtual int Find( const char* szItemToFind );
  134. virtual int FindColor( RemapControlType* pColorRemap );
  135. virtual bool Set_Item( unsigned int index, const char* szText );
  136. virtual bool Set_Icon( unsigned int index, unsigned int iIconNumber, void* pIcon, ICONKIND IconKind );
  137. virtual int GetRealWidth();
  138. virtual void Resize( int x, int y, int w, int h );
  139. virtual int IndexUnderMouse();
  140. virtual int OffsetToIndex( int iIndex, int y );
  141. virtual int SetSelectType( int iSelectTypeNew )
  142. {
  143. // Provided to enable horrible hacks, mainly involved with dealing with ListClass's inability
  144. // to have no item selected...
  145. int iSelectTypeOld = iSelectType;
  146. iSelectType = iSelectTypeNew;
  147. return iSelectTypeOld;
  148. }
  149. protected:
  150. virtual int Action(unsigned flags, KeyNumType &key);
  151. virtual void Draw_Entry( int index, int x, int y, int width, int selected );
  152. virtual int Add_Item_Detail( const char* szToken, const char* szHelp,
  153. void* pIcon0, ICONKIND IconKind0, const char* szExtraDataString,
  154. void* pvExtraData, RemapControlType* pColorRemap,
  155. void* pIcon1, ICONKIND IconKind1, void* pIcon2, ICONKIND IconKind2,
  156. void* pFixedIcon, ICONKIND FixedIconKind, int iXFixedIcon, int iYFixedIcon, int iFixedIconWidth );
  157. // The list of Icons.
  158. //DynamicVectorClass<void*> IconList;
  159. //DynamicVectorClass< IconList_ItemExtras* > ExtrasList; ajw: creates hellacious linking problems
  160. DynamicVectorClass< void* > ExtrasList;
  161. bool bDoAlloc; // True if I am responsible for mem. allocation/deletion of strings.
  162. // bool bMultiSelect; // True if we are using the multiple item selection feature.
  163. int iSelectType; // 0 for no selection shown, 1 for normal ListClass selection, 2 for n multiple selections
  164. int iMaxItems; // Number of items to limit list to, if bDoAlloc is true.
  165. };
  166. #endif
  167. #endif