comboboxctrl.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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/comboboxctrl.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/09/02 4:07p $*
  29. * *
  30. * $Revision:: 22 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __COMBOBOX_CTRL_H
  39. #define __COMBOBOX_CTRL_H
  40. #include "dialogcontrol.h"
  41. #include "vector3.h"
  42. #include "render2dsentence.h"
  43. #include "bittype.h"
  44. #include "dropdownctrl.h"
  45. #include "EditCtrl.h"
  46. ////////////////////////////////////////////////////////////////
  47. //
  48. // ComboBoxCtrlClass
  49. //
  50. ////////////////////////////////////////////////////////////////
  51. class ComboBoxCtrlClass : public DialogControlClass
  52. {
  53. public:
  54. ////////////////////////////////////////////////////////////////
  55. // Public friends
  56. ////////////////////////////////////////////////////////////////
  57. friend class DropDownCtrlClass;
  58. ////////////////////////////////////////////////////////////////
  59. // Public constructors/destructors
  60. ////////////////////////////////////////////////////////////////
  61. ComboBoxCtrlClass (void);
  62. virtual ~ComboBoxCtrlClass (void);
  63. ////////////////////////////////////////////////////////////////
  64. // Public methods
  65. ////////////////////////////////////////////////////////////////
  66. //
  67. // From DialogControlClass
  68. //
  69. const WCHAR * Get_Text (void) const;
  70. void Set_Text (const WCHAR *title);
  71. void Set_Window_Pos (const Vector2 &pos);
  72. void Render (void);
  73. void Set_Style(DWORD style);
  74. //
  75. // Content control
  76. //
  77. int Add_String (const WCHAR* string) { return DropDownCtrl.Add_String (string); }
  78. void Delete_String (int index);
  79. int Find_String (const WCHAR* string) { return DropDownCtrl.Find_String (string); }
  80. int Select_String (const WCHAR* string);
  81. void Set_Item_Data (int index, uint32 data) { DropDownCtrl.Set_Item_Data (index, data); Set_Dirty();}
  82. uint32 Get_Item_Data (int index) { return DropDownCtrl.Get_Item_Data (index); }
  83. void Reset_Content (void) { DropDownCtrl.Reset_Content (); }
  84. bool Get_String (int index, WideStringClass &string) { return DropDownCtrl.Get_String (index, string); }
  85. int Get_Item_Count(void) {return DropDownCtrl.Get_Count();}
  86. //
  87. // Selection management
  88. //
  89. void Set_Curr_Sel (int index);
  90. int Get_Curr_Sel (void) const { return CurrSel; }
  91. protected:
  92. ////////////////////////////////////////////////////////////////
  93. // Protected methods
  94. ////////////////////////////////////////////////////////////////
  95. void Set_Sel (int index, bool notify);
  96. void On_LButton_Down (const Vector2 &mouse_pos);
  97. void On_LButton_Up (const Vector2 &mouse_pos);
  98. void On_Mouse_Move (const Vector2 &mouse_pos);
  99. void On_Set_Cursor (const Vector2 &mouse_pos);
  100. void On_Set_Focus (void);
  101. void On_Kill_Focus (DialogControlClass *focus);
  102. void On_Mouse_Wheel (int direction);
  103. bool On_Key_Down (uint32 key_id, uint32 key_data);
  104. void On_Create (void);
  105. void On_Destroy (void);
  106. void Update_Client_Rect (void);
  107. void Create_Control_Renderers (void);
  108. void Create_Text_Renderers (void);
  109. void Display_Drop_Down (bool onoff);
  110. //
  111. // Notifications
  112. //
  113. void On_Drop_Down_End (int curr_sel);
  114. void On_EditCtrl_Change(EditCtrlClass* edit_ctrl, int ctrl_id);
  115. bool On_EditCtrl_Key_Down(EditCtrlClass* edit_ctrl, uint32 key_id, uint32 key_data);
  116. ////////////////////////////////////////////////////////////////
  117. // Protected member data
  118. ////////////////////////////////////////////////////////////////
  119. Render2DSentenceClass TextRenderer;
  120. Render2DClass ControlRenderer;
  121. Render2DClass HilightRenderer;
  122. bool IsDropDownDisplayed;
  123. int CurrState;
  124. RectClass ButtonRect;
  125. RectClass TextRect;
  126. RectClass FullRect;
  127. Vector2 DropDownSize;
  128. bool WasButtonPressedOnMe;
  129. bool IsInitialized;
  130. DropDownCtrlClass DropDownCtrl;
  131. int LastDropDownDisplayChange;
  132. int CurrSel;
  133. EditCtrlClass EditControl;
  134. };
  135. #endif //__COMBOBOX_CTRL_H