ICONLIST.H 8.0 KB

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