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.

357 lines
12 KiB

  1. /*
  2. * Microsoft Confidential
  3. * Copyright (C) Microsoft Corporation 1992,1993
  4. * All Rights Reserved.
  5. *
  6. *
  7. * PIFFNTP.H
  8. * Private PIFMGR include file
  9. *
  10. * History:
  11. * Created 22-Mar-1993 2:58pm by Jeff Parsons (from vmdosapp\fontutil.h)
  12. */
  13. #define PREVIEW_BORDER 1
  14. #define DY_TTBITMAP 12
  15. /*
  16. * These parameters control how fast the fdiCache should grow.
  17. */
  18. #define FDI_TABLE_START 20 /* Number of entries to start */
  19. #define FDI_TABLE_INC 10 /* Increment in number of slots */
  20. typedef struct tagDISPLAYPARAMETERS { /* dp */
  21. INT dpHorzSize;
  22. INT dpVertSize;
  23. INT dpHorzRes;
  24. INT dpVertRes;
  25. INT dpLogPixelsX;
  26. INT dpLogPixelsY;
  27. INT dpAspectX;
  28. INT dpAspectY;
  29. INT dpBitsPerPixel;
  30. TCHAR szTTFace[2][LF_FACESIZE];
  31. } DISPLAYPARAMETERS;
  32. //#define BACKGROUND 0x000000FF /* bright blue */
  33. //#define BACKGROUNDSEL 0x00FF00FF /* bright magenta */
  34. //#define BUTTONFACE 0x00C0C0C0 /* bright grey */
  35. //#define BUTTONSHADOW 0x00808080 /* dark grey */
  36. #define FNTFLAGSFROMID(id) ((id - IDC_RASTERFONTS + 1) << FNT_FONTMASKBITS)
  37. #define IDFROMFNTFLAGS(fl) (IDC_RASTERFONTS - 1 + (((fl) & FNT_FONTMASK) >> FNT_FONTMASKBITS))
  38. #if FNTFLAGSFROMID(IDC_RASTERFONTS) != FNT_RASTERFONTS || \
  39. IDFROMFNTFLAGS(FNT_RASTERFONTS) != IDC_RASTERFONTS || \
  40. FNTFLAGSFROMID(IDC_TTFONTS) != FNT_TTFONTS || \
  41. IDFROMFNTFLAGS(FNT_TTFONTS) != IDC_TTFONTS || \
  42. FNTFLAGSFROMID(IDC_BOTHFONTS) != FNT_BOTHFONTS || \
  43. IDFROMFNTFLAGS(FNT_BOTHFONTS) != IDC_BOTHFONTS
  44. #error Dialog control IDs and FNT flags values are not compatible
  45. #endif
  46. /*
  47. * IsDlgError
  48. *
  49. * To simplify error checking, we assume that all *_ERR values are -1
  50. * and all *_ERRSPACE values are -2.
  51. *
  52. * This also assumes a two's complement number system.
  53. *
  54. * Entry:
  55. *
  56. * A return code from a list box or combo box.
  57. *
  58. * Exit:
  59. *
  60. * Nonzero if the return code indicated an error of some sort.
  61. * Zero if the return code indiated no error.
  62. *
  63. */
  64. #define B_ERR (-1)
  65. #if LB_ERR != B_ERR || LB_ERRSPACE != -2 || \
  66. CB_ERR != B_ERR || CB_ERRSPACE != -2
  67. #error Problem with manifest constants.
  68. #endif
  69. #define IsDlgError(dw) ((DWORD)(dw) >= (DWORD)(-2))
  70. /*
  71. * Low-level macros
  72. *
  73. * BPFDIFROMREF(lParam)
  74. *
  75. * These three macros pack and unpack list box reference data.
  76. *
  77. * bpfdi = based pointer into segCache describing the list box entry
  78. * fTrueType = nonzero if the font is a TrueType font
  79. * lParam = the reference data
  80. *
  81. */
  82. #define BPFDIFROMREF(lParam) (BPFDI)(lParam)
  83. /*
  84. * High-level macros
  85. *
  86. * These macros handle the SendMessages that go to/from list boxes
  87. * and combo boxes.
  88. *
  89. * The "lcb" prefix stands for "list or combo box".
  90. *
  91. * Basically, we're providing mnemonic names for what would otherwise
  92. * look like a whole slew of confusing SendMessage's.
  93. *
  94. */
  95. #define lcbFindStringExact(hwnd, fListBox, lpsz) \
  96. (DWORD)SendMessage(hwnd, fListBox ? LB_FINDSTRINGEXACT : CB_FINDSTRINGEXACT, \
  97. (WPARAM)-1, (LPARAM)(LPTSTR)lpsz)
  98. #define lcbAddString(hwnd, fListBox, lpsz) \
  99. (DWORD)SendMessage(hwnd, fListBox ? LB_ADDSTRING : CB_ADDSTRING, \
  100. 0, (LPARAM)(LPTSTR)lpsz)
  101. #define lcbSetItemDataPair(hwnd, fListBox, w, bpfdi, fIsTrueType) \
  102. if (!IsSpecialBpfdi((BPFDI)bpfdi)) \
  103. ((BPFDI)bpfdi)->bTT = fIsTrueType; \
  104. (DWORD)SendMessage(hwnd, fListBox ? LB_SETITEMDATA : CB_SETITEMDATA, \
  105. (WPARAM)w, (LPARAM)bpfdi)
  106. #define lcbGetCount(hwnd, fListBox) \
  107. (DWORD)SendMessage(hwnd, fListBox ? LB_GETCOUNT : CB_GETCOUNT, (WPARAM)0, (LPARAM)0)
  108. #define lcbGetCurSel(hwnd, fListBox) \
  109. (DWORD)SendMessage(hwnd, fListBox ? LB_GETCURSEL : CB_GETCURSEL, (WPARAM)0, (LPARAM)0)
  110. #define lcbSetCurSel(hwnd, fListBox, w) \
  111. (DWORD)SendMessage(hwnd, fListBox ? LB_SETCURSEL : CB_SETCURSEL, (WPARAM)w, (LPARAM)0)
  112. #define lcbGetItemDataPair(hwnd, fListBox, w) \
  113. (DWORD_PTR)SendMessage(hwnd, fListBox ? LB_GETITEMDATA : CB_GETITEMDATA, (WPARAM)w, (LPARAM)0)
  114. #define lcbGetBpfdi(hwnd, fListBox, w) \
  115. BPFDIFROMREF(lcbGetItemDataPair(hwnd, fListBox, w))
  116. #define lcbInsertString(hwnd, fListBox, lpsz, i) \
  117. (DWORD)SendMessage(hwnd, fListBox ? LB_INSERTSTRING : CB_INSERTSTRING, \
  118. (WPARAM)i, (LPARAM)(LPTSTR)lpsz)
  119. /*
  120. * the listbox/combox strings are stored as follows. we use the tabs
  121. * to do TabbedTextOut(). The padding is used to keep the sorting right.
  122. * TT fonts are distinguished by the hiword of the item data
  123. *
  124. * String: \t%2d\tx\t%2d
  125. * wd ht
  126. *
  127. * The "Auto" entry is stored as...
  128. *
  129. * String: \1Auto
  130. *
  131. * The first character is \1 so that Auto sorts at the top of the list.
  132. * (The \1 is not actually displayed.)
  133. *
  134. */
  135. /*
  136. * FONTDIMENINFO
  137. *
  138. * The distinction between the requested and returned font dimensions is
  139. * important in the case of TrueType fonts, in which there is no guarantee
  140. * that what you ask for is what you will get.
  141. *
  142. * Note that the correspondence between "Requested" and "Actual" is broken
  143. * whenever the user changes his display driver, because GDI uses driver
  144. * parameters to control the font rasterization.
  145. *
  146. * The fdiHeightReq and fdiWidthReq fields are both zero if the font is
  147. * a raster font.
  148. *
  149. */
  150. typedef struct tagFONTDIMENINFO { /* fdi */
  151. UINT fdiWidthReq; /* Font width requested */
  152. UINT fdiHeightReq; /* Font height requested */
  153. UINT fdiWidthActual; /* Font width returned */
  154. UINT fdiHeightActual; /* Font height returned */
  155. BOOL bTT; /* Font is TT? */
  156. INT Index; /* Index into listbox */
  157. } FONTDIMENINFO, *LPFONTDIMENINFO, *LPFDI;
  158. typedef FONTDIMENINFO *BPFDI;
  159. typedef UINT CFDI;
  160. typedef UINT IFDI;
  161. // BILINGUAL stuff
  162. #define CLIP_DFA_OVERRIDE 0x40 /* Disable Font Association */
  163. extern CFDI cfdiCache[]; /* # used entries in fdi cache */
  164. extern CFDI cfdiCacheActual[]; /* Total # entries in fdi cache */
  165. /*
  166. * BPFDI_CANCEL must be 0xFFFF because that is what DialogBox returns on
  167. * failure.
  168. */
  169. #define BPFDI_CANCEL (BPFDI)(INT_PTR)(-1)
  170. #define BPFDI_AUTO (BPFDI)(INT_PTR)(-2)
  171. #define BPFDI_IGNORE (BPFDI)(INT_PTR)(-3)
  172. #define IsSpecialBpfdi(bpfdi) ((bpfdi) >= BPFDI_IGNORE)
  173. /* This is the maximum size font we will create. */
  174. #define MAX_FONT_HEIGHT 72 /* 72pt = 1inch */
  175. typedef INT PENALTY; /* pnl */
  176. /*
  177. * Penalty structures
  178. *
  179. * Do NOT change these structure definitions unless you know what you're
  180. * doing, because the relative order of the values is crucial for proper
  181. * reading and writing of the INI file in which they are stored.
  182. */
  183. typedef struct tagPENALTYPAIR { /* pnlp */
  184. PENALTY pnlInitial;
  185. PENALTY pnlScale;
  186. } PENALTYPAIR, *PPENALTYPAIR;
  187. typedef struct tagPENALTYLIST { /* pnll */
  188. PENALTYPAIR pnlpOvershoot;
  189. PENALTYPAIR pnlpShortfall;
  190. } PENALTYLIST, *PPENALTYLIST;
  191. #define MINPENALTY (-5000)
  192. #define MAXPENALTY 5000
  193. #define SENTINELPENALTY MAXLONG /* Must exceed any legitimate penalty */
  194. #define NUMPENALTIES (SIZEOF(rgpnlPenalties) / SIZEOF(INT))
  195. #define NUMINITIALTTHEIGHTS (SIZEOF(rgwInitialTtHeights) / SIZEOF(WORD))
  196. #define pnllX ((PPENALTYLIST)rgpnlPenalties)[0]
  197. #define pnllY ((PPENALTYLIST)rgpnlPenalties)[1]
  198. #define pnlTrueType (rgpnlPenalties[8])
  199. /*
  200. * These values for FindFontMatch's third argument are magical.
  201. * WindowInit uses the funky values (with the exception of FFM_PERFECT)
  202. */
  203. #define FFM_BOTHFONTS 0x00000000
  204. #define FFM_RESTRICTED 0x00000001
  205. #define FFM_RASTERFONTS 0x00000001
  206. #define FFM_TTFONTS 0x80000001
  207. #define FFM_PERFECT 0xFFFFFFFF
  208. /*
  209. * Last but not least, per-dialog data (aka roll-your-own DLL instance data)
  210. */
  211. typedef struct FNTINFO { /* fi */
  212. PPROPLINK ppl; // ppl must ALWAYS be the first field
  213. BPFDI bpfdi;
  214. PROPFNT fntProposed; // The properties to use if the user selects OK
  215. PROPWIN winOriginal; // For window preview and auto font selection
  216. HFONT hFontPreview; // Used in font preview window
  217. BOOL fMax; // Should window preview show as maximized?
  218. POINT ptCorner; // Upper-left corner of window
  219. UINT uDefaultCp; // System default code page
  220. } FNTINFO;
  221. typedef FNTINFO *PFNTINFO; /* pfi */
  222. /*
  223. * for Font Enumlation
  224. */
  225. typedef struct FNTENUMINFO {
  226. HWND hwndList;
  227. BOOL fListBox;
  228. INT CodePage;
  229. } FNTENUMINFO;
  230. typedef FNTENUMINFO *LPFNTENUMINFO;
  231. /*
  232. * Internal function prototypes
  233. */
  234. BOOL_PTR CALLBACK DlgFntProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  235. VOID InitFntDlg(HWND hDlg, PFNTINFO pfi);
  236. VOID ApplyFntDlg(HWND hDlg, PFNTINFO pfi);
  237. BOOL LoadGlobalFontData(void);
  238. BOOL LoadGlobalFontEditData(void);
  239. VOID FreeGlobalFontEditData(void);
  240. VOID CheckDisplayParameters(void);
  241. HBITMAP LoadBitmaps(INT id);
  242. DWORD GetFlippedSysColor(INT nDispElement);
  243. VOID PreviewInit(HWND hDlg, PFNTINFO pfi);
  244. VOID PreviewUpdate(HWND hwndList, PFNTINFO pfi);
  245. LRESULT WndPreviewWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  246. VOID WndPreviewPaint(HWND hDlg, HWND hwnd);
  247. LRESULT FontPreviewWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  248. INT WINAPI CreateFontList(HWND hwndList, BOOL fListBox, LPPROPFNT lpFnt);
  249. VOID WINAPI DrawItemFontList(BOOL fListBox, const LPDRAWITEMSTRUCT lpdis);
  250. BOOL WINAPI MatchCurrentFont(HWND hwndList, BOOL fListBox, LPPROPFNT lpFnt);
  251. LONG WINAPI MeasureItemFontList(LPMEASUREITEMSTRUCT lpmi);
  252. VOID WINAPI UpdateTTBitmap(void);
  253. BOOL AddRasterFontsToFontListA(HWND hwndList, BOOL fListBox,
  254. LPCSTR lpszRasterFaceName, INT CodePage);
  255. INT CALLBACK RasterFontEnum(ENUMLOGFONTA *lpelf,
  256. NEWTEXTMETRICA *lpntm,
  257. INT nFontType, LPARAM lParam);
  258. BPFDI AddToFontListCache(HWND hwndList,
  259. BOOL fListBox,
  260. UINT uHeightReq,
  261. UINT uWidthReq,
  262. UINT uHeightActual,
  263. UINT uWidthActual,
  264. UINT uCodePage);
  265. BOOL AddTrueTypeFontsToFontListA(HWND hwndList, BOOL fListBox,
  266. LPSTR lpszTTFaceName, INT CodePage);
  267. BPFDI AddOneNewTrueTypeFontToFontListA(HWND hwndList,
  268. BOOL fListBox,
  269. UINT uWidth, UINT uHeight,
  270. LPSTR lpszTTFaceName,
  271. INT CodePage);
  272. DWORD_PTR GetFont(HWND hwndList, BOOL fListBox, PFNTINFO pfi);
  273. void SetFont(LPPROPFNT lpFnt, BPFDI bpfdi);
  274. #define AspectScale(n1,n2,m) (UINT)(((UINT)n1*(UINT)m)/(UINT)n2)
  275. VOID AspectPoint(LPRECT lprectPreview, LPPOINT lppt);
  276. VOID AspectRect(LPRECT lprectPreview, LPRECT lprc);
  277. HFONT CreateFontFromBpfdi(BPFDI bpfdi, PFNTINFO pfi);
  278. void FontSelInit(void);
  279. BPFDI GetTrueTypeFontTrueDimensions(UINT dxWidth, UINT dyHeight, INT CodePage);
  280. BPFDI FindFontMatch(UINT dxWidth, UINT dyHeight, LPINT lpfl, INT CodePage);
  281. PENALTY ComputePenaltyFromPair(PPENALTYPAIR ppnlp, UINT dSmaller, UINT dLarger);
  282. PENALTY ComputePenaltyFromList(PPENALTYLIST ppnll, UINT dActual, UINT dDesired);
  283. PENALTY ComputePenalty(UINT cxCells, UINT cyCells,
  284. UINT dxClient, UINT dyClient,
  285. UINT dxFont, UINT dyFont);
  286. BPFDI ChooseBestFont(UINT cxCells, UINT cyCells, UINT dxClient, UINT dyClient, INT fl, INT CodePage);