GadgetListBox.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. ** Command & Conquer Generals(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. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: GadgetListBox.h //////////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Westwood Studios Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2001 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // Project: RTS3
  34. //
  35. // File name: GadgetListBox.h
  36. //
  37. // Created: Colin Day, June 2001
  38. //
  39. // Desc: Helpful interface for ListBoxes
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. #pragma once
  44. #ifndef __GADGETLISTBOX_H_
  45. #define __GADGETLISTBOX_H_
  46. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  47. // USER INCLUDES //////////////////////////////////////////////////////////////
  48. #include "GameClient/Gadget.h"
  49. #include "GameClient/GameWindow.h"
  50. // FORWARD REFERENCES /////////////////////////////////////////////////////////
  51. // TYPE DEFINES ///////////////////////////////////////////////////////////////
  52. typedef struct _RightClickStruct
  53. {
  54. Int mouseX;
  55. Int mouseY;
  56. Int pos;
  57. } RightClickStruct;
  58. ///////////////////////////////////////////////////////////////////////////////
  59. // INLINING ///////////////////////////////////////////////////////////////////
  60. ///////////////////////////////////////////////////////////////////////////////
  61. extern Int GadgetListBoxGetEntryBasedOnXY( GameWindow *listbox, Int x, Int y, Int &row, Int &column);
  62. extern void GadgetListboxCreateScrollbar( GameWindow *listbox );
  63. extern void GadgetListBoxAddMultiSelect( GameWindow *listbox );
  64. extern void GadgetListBoxRemoveMultiSelect( GameWindow *listbox );
  65. extern void GadgetListBoxSetListLength( GameWindow *listbox, Int newLength );
  66. extern Int GadgetListBoxGetListLength( GameWindow *listbox );
  67. extern Int GadgetListBoxGetNumEntries( GameWindow *listbox );
  68. extern Int GadgetListBoxGetNumColumns( GameWindow *listbox );
  69. extern Int GadgetListBoxGetColumnWidth( GameWindow *listbox, Int column );
  70. extern void GadgetListBoxSetFont( GameWindow *listbox, GameFont *font );
  71. extern UnicodeString GadgetListBoxGetText( GameWindow *listbox, Int row, Int column = 0);
  72. extern UnicodeString GadgetListBoxGetTextAndColor( GameWindow *listbox, Color *color, Int row, Int column = 0);
  73. extern Int GadgetListBoxAddEntryText( GameWindow *listbox, UnicodeString text, Color color, Int row, Int column = -1, Bool overwrite = TRUE);
  74. extern Int GadgetListBoxAddEntryImage( GameWindow *listbox, const Image *image,
  75. Int row, Int column = -1,
  76. Bool overwrite = TRUE, Color color = 0xFFFFFFFF );
  77. extern Int GadgetListBoxAddEntryImage( GameWindow *listbox, const Image *image,
  78. Int row, Int column,
  79. Int hight, Int width,
  80. Bool overwrite = TRUE, Color color = 0xFFFFFFFF );
  81. extern void GadgetListBoxSetSelected( GameWindow *listbox, Int selectIndex );
  82. extern void GadgetListBoxSetSelected( GameWindow *listbox, const Int *selectList, Int selectCount = 1 );
  83. extern void GadgetListBoxGetSelected( GameWindow *listbox, Int *selectList );
  84. extern void GadgetListBoxReset( GameWindow *listbox );
  85. extern void GadgetListBoxSetItemData( GameWindow *listbox, void *data, Int row, Int column = 0);
  86. extern void *GadgetListBoxGetItemData( GameWindow *listbox, Int row, Int column = 0);
  87. extern bool GadgetListBoxIsFull(GameWindow *window);
  88. extern Int GadgetListBoxGetBottomVisibleEntry( GameWindow *window );
  89. extern void GadgetListBoxSetBottomVisibleEntry( GameWindow *window, Int newPos );
  90. extern Int GadgetListBoxGetTopVisibleEntry( GameWindow *window );
  91. extern void GadgetListBoxSetTopVisibleEntry( GameWindow *window, Int newPos );
  92. extern void GadgetListBoxSetAudioFeedback( GameWindow *listbox, Bool enable );
  93. //
  94. // you can use this to set the colors for the list box all at once, note that
  95. // it will also automatically change the colors for any attached slider
  96. // and those slider buttons and thumb
  97. //
  98. extern void GadgetListBoxSetColors( GameWindow *listbox,
  99. Color enabledColor,
  100. Color enabledBorderColor,
  101. Color enabledSelectedItemColor,
  102. Color enabledSelectedItemBorderColor,
  103. Color disabledColor,
  104. Color disabledBorderColor,
  105. Color disabledSelectedItemColor,
  106. Color disabledSelectedItemBorderColor,
  107. Color hiliteColor,
  108. Color hiliteBorderColor,
  109. Color hiliteSelectedItemColor,
  110. Color hiliteSelectedItemBorderColor );
  111. inline void GadgetListBoxSetEnabledImage( GameWindow *g, const Image *image ) { g->winSetEnabledImage( 0, image ); }
  112. inline void GadgetListBoxSetEnabledColor( GameWindow *g, Color color ) { g->winSetEnabledColor( 0, color ); }
  113. inline void GadgetListBoxSetEnabledBorderColor( GameWindow *g, Color color ) { g->winSetEnabledBorderColor( 0, color ); }
  114. inline void GadgetListBoxSetEnabledSelectedItemImageLeft( GameWindow *g, const Image *image ) { g->winSetEnabledImage( 1, image ); }
  115. inline void GadgetListBoxSetEnabledSelectedItemImageRight( GameWindow *g, const Image *image ) { g->winSetEnabledImage( 2, image ); }
  116. inline void GadgetListBoxSetEnabledSelectedItemImageCenter( GameWindow *g, const Image *image ) { g->winSetEnabledImage( 3, image ); }
  117. inline void GadgetListBoxSetEnabledSelectedItemImageSmallCenter( GameWindow *g, const Image *image ) { g->winSetEnabledImage( 4, image ); }
  118. inline void GadgetListBoxSetEnabledSelectedItemColor( GameWindow *g, Color color ) { g->winSetEnabledColor( 1, color ); }
  119. inline void GadgetListBoxSetEnabledSelectedItemBorderColor( GameWindow *g, Color color ) { g->winSetEnabledBorderColor( 1, color ); }
  120. inline const Image *GadgetListBoxGetEnabledImage( GameWindow *g ) { return g->winGetEnabledImage( 0 ); }
  121. inline Color GadgetListBoxGetEnabledColor( GameWindow *g ) { return g->winGetEnabledColor( 0 ); }
  122. inline Color GadgetListBoxGetEnabledBorderColor( GameWindow *g ) { return g->winGetEnabledBorderColor( 0 ); }
  123. inline const Image *GadgetListBoxGetEnabledSelectedItemImageLeft( GameWindow *g ) { return g->winGetEnabledImage( 1 ); }
  124. inline const Image *GadgetListBoxGetEnabledSelectedItemImageRight( GameWindow *g ) { return g->winGetEnabledImage( 2 ); }
  125. inline const Image *GadgetListBoxGetEnabledSelectedItemImageCenter( GameWindow *g ) { return g->winGetEnabledImage( 3 ); }
  126. inline const Image *GadgetListBoxGetEnabledSelectedItemImageSmallCenter( GameWindow *g ){ return g->winGetEnabledImage( 4 ); }
  127. inline Color GadgetListBoxGetEnabledSelectedItemColor( GameWindow *g ) { return g->winGetEnabledColor( 1 ); }
  128. inline Color GadgetListBoxGetEnabledSelectedItemBorderColor( GameWindow *g ) { return g->winGetEnabledBorderColor( 1 ); }
  129. inline void GadgetListBoxSetDisabledImage( GameWindow *g, const Image *image ) { g->winSetDisabledImage( 0, image ); }
  130. inline void GadgetListBoxSetDisabledColor( GameWindow *g, Color color ) { g->winSetDisabledColor( 0, color ); }
  131. inline void GadgetListBoxSetDisabledBorderColor( GameWindow *g, Color color ) { g->winSetDisabledBorderColor( 0, color ); }
  132. inline void GadgetListBoxSetDisabledSelectedItemImageLeft( GameWindow *g, const Image *image ) { g->winSetDisabledImage( 1, image ); }
  133. inline void GadgetListBoxSetDisabledSelectedItemImageRight( GameWindow *g, const Image *image ) { g->winSetDisabledImage( 2, image ); }
  134. inline void GadgetListBoxSetDisabledSelectedItemImageCenter( GameWindow *g, const Image *image ) { g->winSetDisabledImage( 3, image ); }
  135. inline void GadgetListBoxSetDisabledSelectedItemImageSmallCenter( GameWindow *g, const Image *image ) { g->winSetDisabledImage( 4, image ); }
  136. inline void GadgetListBoxSetDisabledSelectedItemColor( GameWindow *g, Color color ) { g->winSetDisabledColor( 1, color ); }
  137. inline void GadgetListBoxSetDisabledSelectedItemBorderColor( GameWindow *g, Color color ) { g->winSetDisabledBorderColor( 1, color ); }
  138. inline const Image *GadgetListBoxGetDisabledImage( GameWindow *g ) { return g->winGetDisabledImage( 0 ); }
  139. inline Color GadgetListBoxGetDisabledColor( GameWindow *g ) { return g->winGetDisabledColor( 0 ); }
  140. inline Color GadgetListBoxGetDisabledBorderColor( GameWindow *g ) { return g->winGetDisabledBorderColor( 0 ); }
  141. inline const Image *GadgetListBoxGetDisabledSelectedItemImageLeft( GameWindow *g ) { return g->winGetDisabledImage( 1 ); }
  142. inline const Image *GadgetListBoxGetDisabledSelectedItemImageRight( GameWindow *g ) { return g->winGetDisabledImage( 2 ); }
  143. inline const Image *GadgetListBoxGetDisabledSelectedItemImageCenter( GameWindow *g ) { return g->winGetDisabledImage( 3 ); }
  144. inline const Image *GadgetListBoxGetDisabledSelectedItemImageSmallCenter( GameWindow *g ) { return g->winGetDisabledImage( 4 ); }
  145. inline Color GadgetListBoxGetDisabledSelectedItemColor( GameWindow *g ) { return g->winGetDisabledColor( 1 ); }
  146. inline Color GadgetListBoxGetDisabledSelectedItemBorderColor( GameWindow *g ) { return g->winGetDisabledBorderColor( 1 ); }
  147. inline void GadgetListBoxSetHiliteImage( GameWindow *g, const Image *image ) { g->winSetHiliteImage( 0, image ); }
  148. inline void GadgetListBoxSetHiliteColor( GameWindow *g, Color color ) { g->winSetHiliteColor( 0, color ); }
  149. inline void GadgetListBoxSetHiliteBorderColor( GameWindow *g, Color color ) { g->winSetHiliteBorderColor( 0, color ); }
  150. inline void GadgetListBoxSetHiliteSelectedItemImageLeft( GameWindow *g, const Image *image ) { g->winSetHiliteImage( 1, image ); }
  151. inline void GadgetListBoxSetHiliteSelectedItemImageRight( GameWindow *g, const Image *image ) { g->winSetHiliteImage( 2, image ); }
  152. inline void GadgetListBoxSetHiliteSelectedItemImageCenter( GameWindow *g, const Image *image ) { g->winSetHiliteImage( 3, image ); }
  153. inline void GadgetListBoxSetHiliteSelectedItemImageSmallCenter( GameWindow *g, const Image *image ) { g->winSetHiliteImage( 4, image ); }
  154. inline void GadgetListBoxSetHiliteSelectedItemColor( GameWindow *g, Color color ) { g->winSetHiliteColor( 1, color ); }
  155. inline void GadgetListBoxSetHiliteSelectedItemBorderColor( GameWindow *g, Color color ) { g->winSetHiliteBorderColor( 1, color ); }
  156. inline const Image *GadgetListBoxGetHiliteImage( GameWindow *g ) { return g->winGetHiliteImage( 0 ); }
  157. inline Color GadgetListBoxGetHiliteColor( GameWindow *g ) { return g->winGetHiliteColor( 0 ); }
  158. inline Color GadgetListBoxGetHiliteBorderColor( GameWindow *g ) { return g->winGetHiliteBorderColor( 0 ); }
  159. inline const Image *GadgetListBoxGetHiliteSelectedItemImageLeft( GameWindow *g ) { return g->winGetHiliteImage( 1 ); }
  160. inline const Image *GadgetListBoxGetHiliteSelectedItemImageRight( GameWindow *g ) { return g->winGetHiliteImage( 2 ); }
  161. inline const Image *GadgetListBoxGetHiliteSelectedItemImageCenter( GameWindow *g ) { return g->winGetHiliteImage( 3 ); }
  162. inline const Image *GadgetListBoxGetHiliteSelectedItemImageSmallCenter( GameWindow *g ) { return g->winGetHiliteImage( 4 ); }
  163. inline Color GadgetListBoxGetHiliteSelectedItemColor( GameWindow *g ) { return g->winGetHiliteColor( 1 ); }
  164. inline Color GadgetListBoxGetHiliteSelectedItemBorderColor( GameWindow *g ) { return g->winGetHiliteBorderColor( 1 ); }
  165. inline GameWindow *GadgetListBoxGetSlider( GameWindow *g )
  166. {
  167. ListboxData *listData = (ListboxData *)g->winGetUserData();
  168. if( listData && listData->slider )
  169. return listData->slider;
  170. return NULL;
  171. }
  172. inline GameWindow *GadgetListBoxGetUpButton( GameWindow *g )
  173. {
  174. ListboxData *listData = (ListboxData *)g->winGetUserData();
  175. if( listData && listData->upButton )
  176. return listData->upButton;
  177. return NULL;
  178. }
  179. inline GameWindow *GadgetListBoxGetDownButton( GameWindow *g )
  180. {
  181. ListboxData *listData = (ListboxData *)g->winGetUserData();
  182. if( listData && listData->downButton )
  183. return listData->downButton;
  184. return NULL;
  185. }
  186. // EXTERNALS //////////////////////////////////////////////////////////////////
  187. #endif // __GADGETLISTBOX_H_