GdiPlusFontFamily.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. //Download by http://www.NewXing.com
  2. /**************************************************************************\
  3. *
  4. * Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved.
  5. *
  6. * Module Name:
  7. *
  8. * GdiplusFontFamily.h
  9. *
  10. * Abstract:
  11. *
  12. * GDI+ Font Family class
  13. *
  14. \**************************************************************************/
  15. #ifndef _GDIPLUS_FONT_FAMILY_H
  16. #define _GDIPLUS_FONT_FAMILY_H
  17. inline
  18. FontFamily::FontFamily() :
  19. nativeFamily (NULL),
  20. lastResult (Ok)
  21. {
  22. }
  23. inline
  24. FontFamily::FontFamily(
  25. IN const WCHAR* name,
  26. IN const FontCollection* fontCollection
  27. )
  28. {
  29. nativeFamily = NULL;
  30. lastResult = DllExports::GdipCreateFontFamilyFromName(
  31. name,
  32. fontCollection ? fontCollection->nativeFontCollection : NULL,
  33. &nativeFamily
  34. );
  35. }
  36. inline
  37. FontFamily::FontFamily(
  38. IN GpFontFamily *nativeOrig,
  39. IN Status status
  40. )
  41. {
  42. lastResult = status;
  43. nativeFamily = nativeOrig;
  44. }
  45. inline const FontFamily *
  46. FontFamily::GenericSansSerif()
  47. {
  48. if (GenericSansSerifFontFamily != NULL)
  49. {
  50. return GenericSansSerifFontFamily;
  51. }
  52. GenericSansSerifFontFamily =
  53. (FontFamily*) GenericSansSerifFontFamilyBuffer;
  54. GenericSansSerifFontFamily->lastResult =
  55. DllExports::GdipGetGenericFontFamilySansSerif(
  56. &(GenericSansSerifFontFamily->nativeFamily)
  57. );
  58. return GenericSansSerifFontFamily;
  59. }
  60. inline const FontFamily *
  61. FontFamily::GenericSerif()
  62. {
  63. if (GenericSerifFontFamily != NULL)
  64. {
  65. return GenericSerifFontFamily;
  66. }
  67. GenericSerifFontFamily =
  68. (FontFamily*) GenericSerifFontFamilyBuffer;
  69. GenericSerifFontFamily->lastResult =
  70. DllExports::GdipGetGenericFontFamilySerif(
  71. &(GenericSerifFontFamily->nativeFamily)
  72. );
  73. return GenericSerifFontFamily;
  74. }
  75. inline const FontFamily *
  76. FontFamily::GenericMonospace()
  77. {
  78. if (GenericMonospaceFontFamily != NULL)
  79. {
  80. return GenericMonospaceFontFamily;
  81. }
  82. GenericMonospaceFontFamily =
  83. (FontFamily*) GenericMonospaceFontFamilyBuffer;
  84. GenericMonospaceFontFamily->lastResult =
  85. DllExports::GdipGetGenericFontFamilyMonospace(
  86. &(GenericMonospaceFontFamily->nativeFamily)
  87. );
  88. return GenericMonospaceFontFamily;
  89. }
  90. inline FontFamily::~FontFamily()
  91. {
  92. DllExports::GdipDeleteFontFamily (nativeFamily);
  93. }
  94. inline FontFamily *
  95. FontFamily::Clone() const
  96. {
  97. GpFontFamily * clonedFamily = NULL;
  98. SetStatus(DllExports::GdipCloneFontFamily (nativeFamily, &clonedFamily));
  99. return new FontFamily(clonedFamily, lastResult);
  100. }
  101. inline Status
  102. FontFamily::GetFamilyName(
  103. IN WCHAR name[LF_FACESIZE],
  104. IN LANGID language
  105. ) const
  106. {
  107. return SetStatus(DllExports::GdipGetFamilyName(nativeFamily,
  108. name,
  109. language));
  110. }
  111. inline BOOL
  112. FontFamily::IsStyleAvailable(IN INT style) const
  113. {
  114. BOOL StyleAvailable;
  115. Status status;
  116. status = SetStatus(DllExports::GdipIsStyleAvailable(nativeFamily, style, &StyleAvailable));
  117. if (status != Ok)
  118. StyleAvailable = FALSE;
  119. return StyleAvailable;
  120. }
  121. inline UINT16
  122. FontFamily::GetEmHeight(IN INT style) const
  123. {
  124. UINT16 EmHeight;
  125. SetStatus(DllExports::GdipGetEmHeight(nativeFamily, style, &EmHeight));
  126. return EmHeight;
  127. }
  128. inline UINT16
  129. FontFamily::GetCellAscent(IN INT style) const
  130. {
  131. UINT16 CellAscent;
  132. SetStatus(DllExports::GdipGetCellAscent(nativeFamily, style, &CellAscent));
  133. return CellAscent;
  134. }
  135. inline UINT16
  136. FontFamily::GetCellDescent(IN INT style) const
  137. {
  138. UINT16 CellDescent;
  139. SetStatus(DllExports::GdipGetCellDescent(nativeFamily, style, &CellDescent));
  140. return CellDescent;
  141. }
  142. inline UINT16
  143. FontFamily::GetLineSpacing(IN INT style) const
  144. {
  145. UINT16 LineSpacing;
  146. SetStatus(DllExports::GdipGetLineSpacing(nativeFamily, style, &LineSpacing));
  147. return LineSpacing;
  148. }
  149. inline Status
  150. FontFamily::GetLastStatus() const
  151. {
  152. Status lastStatus = lastResult;
  153. lastResult = Ok;
  154. return lastStatus;
  155. }
  156. inline Status
  157. FontFamily::SetStatus(Status status) const
  158. {
  159. if (status != Ok)
  160. return (lastResult = status);
  161. else
  162. return status;
  163. }
  164. #endif