DisplayString.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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: DisplayString.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: DisplayString.h
  36. //
  37. // Created: Colin Day, July 2001
  38. //
  39. // Desc: Contstuct for holding double byte game string data and being
  40. // able to draw that text to the screen.
  41. //
  42. //-----------------------------------------------------------------------------
  43. ///////////////////////////////////////////////////////////////////////////////
  44. #pragma once
  45. #ifndef __DISPLAYSTRING_H_
  46. #define __DISPLAYSTRING_H_
  47. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  48. // USER INCLUDES //////////////////////////////////////////////////////////////
  49. #include "Lib/BaseType.h"
  50. #include "GameClient/GameFont.h"
  51. #include "GameClient/Color.h"
  52. #include "Common/AsciiString.h"
  53. #include "Common/UnicodeString.h"
  54. #include "Common/GameMemory.h"
  55. // FORWARD REFERENCES /////////////////////////////////////////////////////////
  56. class DisplayStringManager;
  57. // TYPE DEFINES ///////////////////////////////////////////////////////////////
  58. // DisplayString --------------------------------------------------------------
  59. /** String representation that can also has additional information and
  60. * methods for drawing to the screen */
  61. //-----------------------------------------------------------------------------
  62. class DisplayString : public MemoryPoolObject
  63. {
  64. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( DisplayString, "DisplayString" )
  65. public:
  66. friend DisplayStringManager;
  67. DisplayString( void );
  68. // virtual ~DisplayString( void ); // destructor defined by memory pool
  69. virtual void setText( UnicodeString text ); ///< set text for this string
  70. virtual UnicodeString getText( void ); ///< get text for this string
  71. virtual Int getTextLength( void ); ///< return number of chars in string
  72. virtual void notifyTextChanged( void ); ///< called when text has changed
  73. virtual void reset( void ); ///< reset all contents of string
  74. virtual void setFont( GameFont *font ); ///< set a font for display
  75. virtual GameFont *getFont( void ); ///< return font in string
  76. virtual void setWordWrap( Int wordWrap ) = 0; ///< Set the width that we want to start wrapping text
  77. virtual void setWordWrapCentered( Bool isCentered ) = 0; ///< If this is set to true, the text on a new line is centered
  78. virtual void draw( Int x, Int y, Color color, Color dropColor ) = 0; ///< render text
  79. virtual void draw( Int x, Int y, Color color, Color dropColor, Int xDrop, Int yDrop ) = 0; ///< render text with the drop shadow being at the offsets passed in
  80. virtual void getSize( Int *width, Int *height ) = 0; ///< get render size
  81. virtual Int getWidth( Int charPos = -1 ) = 0; ///< get text with up to charPos characters, 1- = all characters
  82. virtual void setUseHotkey( Bool useHotkey, Color hotKeyColor ) = 0;
  83. virtual void setClipRegion( IRegion2D *region ); ///< clip text in this region
  84. virtual void removeLastChar( void ); ///< remove the last character
  85. virtual void appendChar( WideChar c ); ///< append character to end
  86. DisplayString *next( void ); ///< return next string
  87. protected:
  88. UnicodeString m_textString;
  89. GameFont *m_font; ///< font to display this string with
  90. DisplayString *m_next; ///< for the display string factory list ONLY
  91. DisplayString *m_prev; ///< for the display string factory list ONLY
  92. }; // end DisplayString
  93. ///////////////////////////////////////////////////////////////////////////////
  94. // INLINING ///////////////////////////////////////////////////////////////////
  95. ///////////////////////////////////////////////////////////////////////////////
  96. inline UnicodeString DisplayString::getText( void ) { return m_textString; }
  97. inline Int DisplayString::getTextLength( void ) { return m_textString.getLength(); }
  98. inline void DisplayString::setFont( GameFont *font ) { m_font = font; }
  99. inline GameFont *DisplayString::getFont( void ) { return m_font; }
  100. inline void DisplayString::setClipRegion( IRegion2D *region ) {}
  101. inline void DisplayString::notifyTextChanged( void ) {}
  102. inline DisplayString *DisplayString::next( void ) { return m_next; }
  103. // EXTERNALS //////////////////////////////////////////////////////////////////
  104. #endif // __DISPLAYSTRING_H_