dropdownctrl.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. ** Command & Conquer Renegade(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. *** 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 ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/wwui/dropdownctrl.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 10/16/01 10:27p $*
  29. * *
  30. * $Revision:: 10 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __DROPDOWN_CTRL_H
  39. #define __DROPDOWN_CTRL_H
  40. #include "dialogcontrol.h"
  41. #include "vector.h"
  42. #include "render2dsentence.h"
  43. #include "bittype.h"
  44. #include "scrollbarctrl.h"
  45. ////////////////////////////////////////////////////////////////
  46. // Forward declarations
  47. ////////////////////////////////////////////////////////////////
  48. class ComboBoxCtrlClass;
  49. ////////////////////////////////////////////////////////////////
  50. //
  51. // DropDownCtrlClass
  52. //
  53. ////////////////////////////////////////////////////////////////
  54. class DropDownCtrlClass : public DialogControlClass
  55. {
  56. public:
  57. ////////////////////////////////////////////////////////////////
  58. // Public constructors/destructors
  59. ////////////////////////////////////////////////////////////////
  60. DropDownCtrlClass (void);
  61. virtual ~DropDownCtrlClass (void);
  62. ////////////////////////////////////////////////////////////////
  63. // Public methods
  64. ////////////////////////////////////////////////////////////////
  65. //
  66. // From DialogControlClass
  67. //
  68. void Render (void);
  69. //
  70. // Content control
  71. //
  72. int Add_String (const WCHAR* string);
  73. void Delete_String (int index);
  74. int Find_String (const WCHAR* string);
  75. int Find_Closest_String(const WCHAR* string);
  76. void Set_Item_Data (int index, uint32 data);
  77. uint32 Get_Item_Data (int index);
  78. void Reset_Content (void);
  79. //
  80. // Information accessors
  81. //
  82. bool Get_String (int index, WideStringClass &string) const;
  83. const WCHAR * Get_String (int index) const;
  84. int Get_Count (void) { return EntryList.Count (); }
  85. //
  86. // Selection management
  87. //
  88. void Set_Curr_Sel (int index);
  89. int Get_Curr_Sel (void) const { return CurrSel; }
  90. //
  91. // Combobox access
  92. //
  93. ComboBoxCtrlClass * Get_Combo_Box (void) const { return ComboBox; }
  94. void Set_Combo_Box (ComboBoxCtrlClass *ctrl) { ComboBox = ctrl; }
  95. void Set_Full_Rect (const RectClass &rect) { FullRect = rect; }
  96. //
  97. // Advise-sink callbacks
  98. //
  99. void On_VScroll (ScrollBarCtrlClass *scrollbar, int ctrl_id, int new_position);
  100. protected:
  101. ////////////////////////////////////////////////////////////////
  102. // Protected methods
  103. ////////////////////////////////////////////////////////////////
  104. void On_LButton_Down (const Vector2 &mouse_pos);
  105. void On_LButton_Up (const Vector2 &mouse_pos);
  106. void On_Mouse_Move (const Vector2 &mouse_pos);
  107. void On_Set_Cursor (const Vector2 &mouse_pos);
  108. void On_Kill_Focus (DialogControlClass *focus);
  109. bool On_Key_Down (uint32 key_id, uint32 key_data);
  110. void On_Create (void);
  111. void On_Add_To_Dialog (void);
  112. void On_Remove_From_Dialog (void);
  113. void Update_Client_Rect (void);
  114. void Create_Control_Renderer (void);
  115. void Create_Text_Renderer (void);
  116. int Entry_From_Pos (const Vector2 &mouse_pos);
  117. void Update_Scroll_Pos (void);
  118. ////////////////////////////////////////////////////////////////
  119. // Protected data types
  120. ////////////////////////////////////////////////////////////////
  121. typedef struct _ENTRY
  122. {
  123. WideStringClass text;
  124. uint32 user_data;
  125. bool operator== (const _ENTRY &src) { return false; }
  126. bool operator!= (const _ENTRY &src) { return true; }
  127. _ENTRY (void) :
  128. user_data (0) {}
  129. _ENTRY (const WCHAR *_text, uint32 _data) :
  130. text (_text), user_data (_data) {}
  131. } ENTRY;
  132. typedef DynamicVectorClass<ENTRY> ENTRY_LIST;
  133. ////////////////////////////////////////////////////////////////
  134. // Protected member data
  135. ////////////////////////////////////////////////////////////////
  136. Render2DSentenceClass TextRenderer;
  137. Render2DClass ControlRenderer;
  138. Render2DClass HilightRenderer;
  139. ENTRY_LIST EntryList;
  140. ComboBoxCtrlClass * ComboBox;
  141. Vector2 CellSize;
  142. ScrollBarCtrlClass ScrollBarCtrl;
  143. RectClass FullRect;
  144. RectClass ScrollBarRect;
  145. int CurrSel;
  146. int ScrollPos;
  147. int CountPerPage;
  148. bool DisplayScrollBar;
  149. bool ButtonClickedOnMe;
  150. int DisplayTime;
  151. };
  152. #endif //__DROPDOWN_CTRL_H