Leaked source code of windows server 2003
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.

207 lines
4.4 KiB

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