Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.7 KiB

  1. //=========== Copyright Valve Corporation, All rights reserved. ===============//
  2. //
  3. // Purpose:
  4. //=============================================================================//
  5. #ifndef IUITEXTLAYOUT_H
  6. #define IUITEXTLAYOUT_H
  7. #ifdef _WIN32
  8. #pragma once
  9. #endif
  10. #include "mathlib/mathlib.h"
  11. #include "mathlib/vector2d.h"
  12. #include "tier1/utlvector.h"
  13. #include "panorama/panoramatypes.h"
  14. namespace panorama
  15. {
  16. //
  17. // Interface that needs to be implemented for text layout on all platforms
  18. //
  19. class IUITextLayout
  20. {
  21. public:
  22. virtual ~IUITextLayout() {}
  23. // Set formatting for character ranges
  24. virtual void SetFontName( uint32 unCharStartIndex, uint32 unCharEndIndex, const char *pchFontName ) = 0;
  25. virtual void SetFontSize( uint32 unCharStartIndex, uint32 unCharEndIndex, float flFontSize ) = 0;
  26. virtual void SetFontStyle( uint32 unCharStartIndex, uint32 unCharEndIndex, EFontStyle eFontStyle ) = 0;
  27. virtual void SetFontWeight( uint32 unCharStartIndex, uint32 unCharEndIndex, EFontWeight eFontWeight ) = 0;
  28. virtual void SetUnderline( uint32 unCharStartIndex, uint32 unCharEndIndex, bool bUnderline ) = 0;
  29. virtual void SetStrikethrough( uint32 unCharStartIndex, uint32 unCharEndIndex, bool bStrikethrough ) = 0;
  30. virtual void SetInlineObject( uint32 unCharIndex, float flWidth, float flHeight ) = 0;
  31. virtual void MarkColorRangeForMeasurement( uint32 unCharStartIndex, uint32 unCharEndIndex ) = 0;
  32. // Gets the size required to fully draw the text layout
  33. virtual void GetRequiredSize( float &flWidth, float &flHeight ) = 0;
  34. // Hit tests a point against the text layout.
  35. // unHitRunLength returns the character index hit
  36. // bIsTrailingHit indicates whether the hit is on the leading or trailing side of the char
  37. // bInside is true if the hit is within the text region, when false the position closest the point is returned as
  38. // the character hit offset
  39. virtual void HitTestPoint( Vector2D point, uint32 &unFirstHitOffset, bool &bIsTrailingHit, bool &bIsInsideString ) = 0;
  40. // Struct used in some calls below
  41. struct HitTestRegionRect_t
  42. {
  43. Vector2D topLeft;
  44. Vector2D bottomRight;
  45. uint32 unCharStart;
  46. uint32 unCharEnd;
  47. bool bIsText;
  48. bool bIsTrimmed;
  49. };
  50. // Determines the layout coordinates for a given character offset, coordinates are relative to top left of text layout
  51. virtual void GetCharacterCoordinates( uint32 unCharIndex, HitTestRegionRect_t &charRegionRect ) = 0;
  52. // Determines a vector of rects enclosing a range of text, normally used for getting selection highlight regions
  53. virtual void GetCharacterRangeCoordinates( uint32 unCharStartIndex, uint32 unCharEndIndex, CUtlVector<HitTestRegionRect_t> &vecRangeRegionRects ) = 0;
  54. };
  55. } // namespace panorama
  56. #endif // IUITEXTLAYOUT_H