ltguifont.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // LTGUIFont.h: interface for the CLTGUIFont class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_LTGUIFONT_H__30D313E1_736B_11D2_BDBE_0060971BDC6D__INCLUDED_)
  5. #define AFX_LTGUIFONT_H__30D313E1_736B_11D2_BDBE_0060971BDC6D__INCLUDED_
  6. #if _MSC_VER >= 1000
  7. #pragma once
  8. #endif // _MSC_VER >= 1000
  9. #include "lithfontdefs.h"
  10. // Defines...
  11. #define LGFT_NONE 0 // font types
  12. #define LGFT_BITMAP 1
  13. #define LGFT_ENGINE 2
  14. #define LGFT_ARRAY 3
  15. #define LGFT_MENU 4
  16. #define LGFI_NORMAL 0 // font indices
  17. #define LGFI_SELECTED 1
  18. #define LGFI_DISABLED 2
  19. #define LGF_MAX_FONTS 16 // font maximums
  20. #define LGF_MAX_LENGTH 128
  21. // Duel purpose font class. It can either be inited to use an english bitmap font
  22. // or use an engine font for other languages.
  23. class CLTGUIFont
  24. {
  25. public:
  26. CLTGUIFont();
  27. virtual ~CLTGUIFont();
  28. // Initialize a bitmap font
  29. LTBOOL Init(ILTClient *pClientDE, LITHFONTCREATESTRUCT *lfCS); // ALM(7/12/99)
  30. // Termination
  31. void Term();
  32. // Drawing functions. Note that engine fonts are always solid. Calling Draw or DrawFormat
  33. // on an engine font will just draw the text white.
  34. void Draw(HSTRING hString, HSURFACE hDest, int x, int y, int justify, HLTCOLOR color = LTNULL);
  35. void Draw(char *szString, HSURFACE hDest, int x, int y, int justify, HLTCOLOR color = LTNULL);
  36. void DrawFormat(HSTRING hString, HSURFACE hDest, int x, int y, int nWidth, HLTCOLOR color = LTNULL);
  37. void DrawFormat(char *szString, HSURFACE hDest, int x, int y, int nWidth, HLTCOLOR color = LTNULL);
  38. void Draw(HSTRING hString, HSURFACE hDest, LITHFONTDRAWDATA *lfDD, int x, int y, LITHFONTSAVEDATA *lfSD = LTNULL);
  39. void Draw(char *szString, HSURFACE hDest, LITHFONTDRAWDATA *lfDD, int x, int y, LITHFONTSAVEDATA *lfSD = LTNULL);
  40. // Returns the height and width of a text string
  41. LTIntPt GetTextExtents(HSTRING hString);
  42. LTIntPt GetTextExtentsFormat(HSTRING hString, int nWidth);
  43. LTIntPt GetPositionFromIndex(HSTRING hString, int nIndex, int nWidth = -1);
  44. int GetIndexFromPosition(HSTRING hString, int x, int y);
  45. // Returns the height of the font
  46. int GetHeight();
  47. LTBOOL IsChromaKeyed();
  48. LTBOOL IsSystemFont();
  49. // Sets the wrapping method between using spaces and non-space based wrapping (Japanese)
  50. // Note that non-space based wrapping only works with engine fonts.
  51. static void SetWrapMethod(LTBOOL bUseSpaces) { s_bWrapUseSpaces=bUseSpaces; }
  52. protected:
  53. ILTClient *m_pClientDE; // Pointer to the client interface
  54. LithFont *m_pLithFont; // Pointer to the bitmap font (2)
  55. int m_nFontHeight; // The height passed in when creating an engine font.
  56. static LTBOOL s_bWrapUseSpaces; // TRUE if the wrapping method is to use a space as a word separator
  57. };
  58. #endif // !defined(AFX_LTGUIFONT_H__30D313E1_736B_11D2_BDBE_0060971BDC6D__INCLUDED_)