WinInstanceData.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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: WinInstanceData.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: WinInstanceData.h
  36. //
  37. // Created: Colin Day, July 2001
  38. //
  39. // Desc: The game window instance dat
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. #pragma once
  44. #ifndef __WININSTANCEDATA_H_
  45. #define __WININSTANCEDATA_H_
  46. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  47. // USER INCLUDES //////////////////////////////////////////////////////////////
  48. #include "GameClient/DisplayString.h"
  49. #include "GameClient/GameFont.h"
  50. #include "GameClient/Image.h"
  51. // FORWARD REFERENCES /////////////////////////////////////////////////////////
  52. class GameWindow;
  53. class VideoBuffer;
  54. // TYPE DEFINES ///////////////////////////////////////////////////////////////
  55. #define WIN_STATE_HILITED 0x00000002 // Mouse is over window or has focus
  56. #define WIN_STATE_SELECTED 0x00000004 // Window has been selected
  57. enum
  58. {
  59. MAX_WINDOW_NAME_LEN = 64,
  60. /** how many elements there are for each of the draw states for the inst
  61. * data of a window, note if you increase this you must update the parsing
  62. * tables make sure you can parse the new fields from the window scrip
  63. * files */
  64. MAX_DRAW_DATA = 9,
  65. MAX_TEXT_LABEL = 128 ///< max length of text label
  66. };
  67. // WinDrawData ----------------------------------------------------------------
  68. //-----------------------------------------------------------------------------
  69. struct WinDrawData
  70. {
  71. const Image *image;
  72. Color color;
  73. Color borderColor;
  74. };
  75. // TextDrawData ---------------------------------------------------------------
  76. //-----------------------------------------------------------------------------
  77. struct TextDrawData
  78. {
  79. Color color; ///< the text color
  80. Color borderColor; ///< outline color
  81. };
  82. // WinInstanceData ------------------------------------------------------------
  83. // NOTE if you add data to this make sure you update winSetInstanceData()
  84. // NOTE if you add data to this make sure you update winSetInstanceData()
  85. // NOTE if you add data to this make sure you update winSetInstanceData()
  86. //-----------------------------------------------------------------------------
  87. class WinInstanceData
  88. {
  89. public:
  90. WinInstanceData( void ); ///< constructor automatically runs init()
  91. virtual ~WinInstanceData( void );
  92. void init( void ); ///< initialize default values if desired
  93. // setting text
  94. void setTooltipText( UnicodeString tip ); ///< set tooltip text
  95. void setText( UnicodeString text ); ///< set instance text text
  96. // a couple of nice access methods
  97. UnicodeString getTooltipText( void ); ///< get tooltip text
  98. UnicodeString getText( void ); ///< get instance text
  99. Int getTextLength( void ); ///< get number of chars in instance text
  100. Int getTooltipTextLength( void ); ///< get number of chars in tooltip text
  101. UnsignedInt getStyle( void ); ///< return window style
  102. UnsignedInt getStatus( void ); ///< return widnow status
  103. UnsignedInt getState( void ); ///< return window state
  104. GameWindow *getOwner( void ); ///< return window owner
  105. GameFont *getFont( void ); ///< return window font
  106. DisplayString *getTextDisplayString( void ); ///< return the text display string
  107. DisplayString *getTooltipDisplayString( void ); ///< return the tooltip display string
  108. void setVideoBuffer( VideoBuffer * videoBuffer ); ///< set the videobuffer to display a video frame
  109. // NOTE if you add data to this make sure you update winSetInstanceData()
  110. // NOTE if you add data to this make sure you update winSetInstanceData()
  111. // NOTE if you add data to this make sure you update winSetInstanceData()
  112. /** @todo you may want to make these data members protected, they are public
  113. because of the legacy of porting all this code in from Nox, but they
  114. really should be protected and have the rest of the code use access
  115. functions to edit them */
  116. Int m_id; // Id of the window (used mainly for scripts)
  117. Int m_state; // Flags indicating state of window
  118. UnsignedInt m_style; // Flags indicating style of window
  119. UnsignedInt m_status; // Status bits for this window (mirrored in GameWindow)
  120. GameWindow *m_owner;
  121. WinDrawData m_enabledDrawData[ MAX_DRAW_DATA ]; ///< image/color info for enabled state
  122. WinDrawData m_disabledDrawData[ MAX_DRAW_DATA ]; ///< image/color info for disabled state
  123. WinDrawData m_hiliteDrawData[ MAX_DRAW_DATA ]; ///< image/color info for hilite state
  124. TextDrawData m_enabledText; ///< enabled text colors
  125. TextDrawData m_disabledText; ///< disabled text colors
  126. TextDrawData m_hiliteText; ///< hilite text colors
  127. TextDrawData m_imeCompositeText;///< IME composite text colors
  128. ICoord2D m_imageOffset; // dx, dy for blitting bkgnd images
  129. GameFont *m_font; // font which this window should use
  130. AsciiString m_textLabelString; ///< text label from window file if present
  131. AsciiString m_decoratedNameString; ///< window text name from GUIEdit
  132. AsciiString m_tooltipString; ///< tooltip Label from window file if present
  133. AsciiString m_headerTemplateName; ///< name of the template we're going to base our font off of.
  134. Int m_tooltipDelay; ///< desired delay before showing tooltip
  135. DisplayString *m_text; ///< generic text for any window to display
  136. DisplayString *m_tooltip; ///< tooltip for display
  137. //NOTE Video Buffer cannot be transfered to another window.
  138. VideoBuffer *m_videoBuffer; ///< Each window can be made to play a video in it.
  139. // NOTE if you add data to this make sure you update winSetInstanceData()
  140. // NOTE if you add data to this make sure you update winSetInstanceData()
  141. // NOTE if you add data to this make sure you update winSetInstanceData()
  142. protected:
  143. };
  144. ///////////////////////////////////////////////////////////////////////////////
  145. // INLINING ///////////////////////////////////////////////////////////////////
  146. ///////////////////////////////////////////////////////////////////////////////
  147. inline UnsignedInt WinInstanceData::getStyle( void ) { return m_style; }
  148. inline UnsignedInt WinInstanceData::getStatus( void ) { return m_status; }
  149. inline UnsignedInt WinInstanceData::getState( void ) { return m_state; }
  150. inline GameWindow *WinInstanceData::getOwner( void ) { return m_owner; }
  151. inline GameFont *WinInstanceData::getFont( void ) { return m_font; }
  152. inline DisplayString *WinInstanceData::getTextDisplayString( void ) { return m_text; }
  153. inline DisplayString *WinInstanceData::getTooltipDisplayString( void ) { return m_tooltip; }
  154. inline UnicodeString WinInstanceData::getTooltipText( void )
  155. {
  156. if( m_tooltip )
  157. return m_tooltip->getText();
  158. return UnicodeString::TheEmptyString;
  159. }
  160. inline UnicodeString WinInstanceData::getText( void )
  161. {
  162. if( m_text )
  163. return m_text->getText();
  164. return UnicodeString::TheEmptyString;
  165. }
  166. inline Int WinInstanceData::getTextLength( void )
  167. {
  168. if( m_text )
  169. return m_text->getTextLength();
  170. return 0;
  171. }
  172. inline Int WinInstanceData::getTooltipTextLength( void )
  173. {
  174. if( m_tooltip )
  175. return m_tooltip->getTextLength();
  176. return 0;
  177. }
  178. // EXTERNALS //////////////////////////////////////////////////////////////////
  179. #endif // __WININSTANCEDATA_H_