CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

ICONLIST.H (8242B)


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