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.

458 lines
8.7 KiB

  1. /*++
  2. Copyright (c) 1990-1998, Microsoft Corporation All rights reserved.
  3. Module Name:
  4. font.h
  5. Abstract:
  6. This module contains the header information for the Win32 font dialogs.
  7. Revision History:
  8. --*/
  9. //
  10. // Include Files.
  11. //
  12. #include <help.h>
  13. //
  14. // Constant Declarations.
  15. //
  16. // Finnish needs 17 chars (18 w/ NULL) -- let's give them 20.
  17. #define CCHCOLORNAMEMAX 20 // max length of color name text
  18. #define CCHCOLORS 16 // max # of pure colors in color combo
  19. #define POINTS_PER_INCH 72
  20. #define FFMASK 0xf0 // pitch and family mask
  21. #define CCHSTDSTRING 12 // max length of sample text string
  22. #define FONTPROP (LPCTSTR) 0xA000L
  23. #define CBN_MYEDITUPDATE (WM_USER + 501)
  24. #define KEY_FONT_SUBS TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes")
  25. #define DEF_POINT_SIZE 10
  26. //If you add a bitmaps to the font bitmap you should modify this constant.
  27. #define NUM_OF_BITMAP 5
  28. #define DX_BITMAP 20
  29. #define DY_BITMAP 12
  30. #define FONT_INVALID_CHARSET 0x100
  31. //
  32. // Typedef Declarations.
  33. //
  34. typedef struct {
  35. UINT ApiType;
  36. LPCHOOSEFONT pCF;
  37. UINT iCharset;
  38. RECT rcText;
  39. DWORD nLastFontType;
  40. DWORD ProcessVersion;
  41. #ifdef UNICODE
  42. LPCHOOSEFONTA pCFA;
  43. PUNICODE_STRING pusStyle;
  44. PANSI_STRING pasStyle;
  45. #endif
  46. } FONTINFO;
  47. typedef FONTINFO *PFONTINFO;
  48. typedef struct {
  49. HWND hwndFamily;
  50. HWND hwndStyle;
  51. HWND hwndSizes;
  52. HWND hwndScript;
  53. UINT iCharset; // returned for enumerating scripts
  54. UINT cfdCharset; // ChooseFontData charset passed in here
  55. HDC hDC;
  56. DWORD dwFlags;
  57. DWORD nFontType;
  58. BOOL bFillSize;
  59. BOOL bPrinterFont;
  60. LPCHOOSEFONT lpcf;
  61. } ENUM_FONT_DATA, *LPENUM_FONT_DATA;
  62. typedef struct _ITEMDATA {
  63. PLOGFONT pLogFont;
  64. DWORD nFontType;
  65. } ITEMDATA, *LPITEMDATA;
  66. //
  67. // Chinese font numbers (zihao).
  68. //
  69. typedef struct {
  70. TCHAR name[5];
  71. int size;
  72. int sizeFr;
  73. } ZIHAO;
  74. #define NUM_ZIHAO 16
  75. #ifdef UNICODE
  76. ZIHAO stZihao[NUM_ZIHAO] =
  77. {
  78. { L"\x516b\x53f7", 5, 0 }, { L"\x4e03\x53f7", 5, 5 },
  79. { L"\x5c0f\x516d", 6, 5 }, { L"\x516d\x53f7", 7, 5 },
  80. { L"\x5c0f\x4e94", 9, 0 }, { L"\x4e94\x53f7", 10, 5 },
  81. { L"\x5c0f\x56db", 12, 0 }, { L"\x56db\x53f7", 14, 0 },
  82. { L"\x5c0f\x4e09", 15, 0 }, { L"\x4e09\x53f7", 16, 0 },
  83. { L"\x5c0f\x4e8c", 18, 0 }, { L"\x4e8c\x53f7", 22, 0 },
  84. { L"\x5c0f\x4e00", 24, 0 }, { L"\x4e00\x53f7", 26, 0 },
  85. { L"\x5c0f\x521d", 36, 0 }, { L"\x521d\x53f7", 42, 0 }
  86. };
  87. #else
  88. ZIHAO stZihao[NUM_ZIHAO] =
  89. {
  90. { "\xb0\xcb\xba\xc5", 5, 0 }, { "\xc6\xdf\xba\xc5", 5, 5 },
  91. { "\xd0\xa1\xc1\xf9", 6, 5 }, { "\xc1\xf9\xba\xc5", 7, 5 },
  92. { "\xd0\xa1\xce\xe5", 9, 0 }, { "\xce\xe5\xba\xc5", 10, 5 },
  93. { "\xd0\xa1\xcb\xc4", 12, 0 }, { "\xcb\xc4\xba\xc5", 14, 0 },
  94. { "\xd0\xa1\xc8\xfd", 15, 0 }, { "\xc8\xfd\xba\xc5", 16, 0 },
  95. { "\xd0\xa1\xb6\xfe", 18, 0 }, { "\xb6\xfe\xba\xc5", 22, 0 },
  96. { "\xd0\xa1\xd2\xbb", 24, 0 }, { "\xd2\xbb\xba\xc5", 26, 0 },
  97. { "\xd0\xa1\xb3\xf5", 36, 0 }, { "\xb3\xf5\xba\xc5", 42, 0 }
  98. };
  99. #endif
  100. //
  101. // Global Variables.
  102. //
  103. UINT msgWOWLFCHANGE;
  104. UINT msgWOWCHOOSEFONT_GETLOGFONT;
  105. //
  106. // Color tables for color combo box.
  107. // Order of values must match names in sz.src.
  108. //
  109. DWORD rgbColors[CCHCOLORS] =
  110. {
  111. RGB( 0, 0, 0), // Black
  112. RGB(128, 0, 0), // Dark red
  113. RGB( 0, 128, 0), // Dark green
  114. RGB(128, 128, 0), // Dark yellow
  115. RGB( 0, 0, 128), // Dark blue
  116. RGB(128, 0, 128), // Dark purple
  117. RGB( 0, 128, 128), // Dark aqua
  118. RGB(128, 128, 128), // Dark grey
  119. RGB(192, 192, 192), // Light grey
  120. RGB(255, 0, 0), // Light red
  121. RGB( 0, 255, 0), // Light green
  122. RGB(255, 255, 0), // Light yellow
  123. RGB( 0, 0, 255), // Light blue
  124. RGB(255, 0, 255), // Light purple
  125. RGB( 0, 255, 255), // Light aqua
  126. RGB(255, 255, 255), // White
  127. };
  128. HBITMAP hbmFont = NULL;
  129. HFONT hDlgFont = NULL;
  130. UINT DefaultCharset;
  131. TCHAR szRegular[CCHSTYLE];
  132. TCHAR szBold[CCHSTYLE];
  133. TCHAR szItalic[CCHSTYLE];
  134. TCHAR szBoldItalic[CCHSTYLE];
  135. TCHAR szPtFormat[] = TEXT("%d");
  136. TCHAR c_szRegular[] = TEXT("Regular");
  137. TCHAR c_szBold[] = TEXT("Bold");
  138. TCHAR c_szItalic[] = TEXT("Italic");
  139. TCHAR c_szBoldItalic[] = TEXT("Bold Italic");
  140. LPCFHOOKPROC glpfnFontHook = 0;
  141. BOOL g_bIsSimplifiedChineseUI = FALSE;
  142. //
  143. // Context Help IDs.
  144. //
  145. const static DWORD aFontHelpIDs[] = // Context Help IDs
  146. {
  147. stc1, IDH_FONT_FONT,
  148. cmb1, IDH_FONT_FONT,
  149. stc2, IDH_FONT_STYLE,
  150. cmb2, IDH_FONT_STYLE,
  151. stc3, IDH_FONT_SIZE,
  152. cmb3, IDH_FONT_SIZE,
  153. psh3, IDH_COMM_APPLYNOW,
  154. grp1, IDH_FONT_EFFECTS,
  155. chx1, IDH_FONT_EFFECTS,
  156. chx2, IDH_FONT_EFFECTS,
  157. stc4, IDH_FONT_COLOR,
  158. cmb4, IDH_FONT_COLOR,
  159. grp2, IDH_FONT_SAMPLE,
  160. stc5, IDH_FONT_SAMPLE,
  161. stc6, NO_HELP,
  162. stc7, IDH_FONT_SCRIPT,
  163. cmb5, IDH_FONT_SCRIPT,
  164. 0, 0
  165. };
  166. //
  167. // Function Prototypes.
  168. //
  169. BOOL
  170. ChooseFontX(
  171. PFONTINFO pFI);
  172. VOID
  173. SetStyleSelection(
  174. HWND hDlg,
  175. LPCHOOSEFONT lpcf,
  176. BOOL bInit);
  177. VOID
  178. HideDlgItem(
  179. HWND hDlg,
  180. int id);
  181. VOID
  182. FixComboHeights(
  183. HWND hDlg);
  184. BOOL_PTR CALLBACK
  185. FormatCharDlgProc(
  186. HWND hDlg,
  187. UINT wMsg,
  188. WPARAM wParam,
  189. LPARAM lParam);
  190. void
  191. SelectStyleFromLF(
  192. HWND hwnd,
  193. LPLOGFONT lplf);
  194. int
  195. CBSetTextFromSel(
  196. HWND hwnd);
  197. int
  198. CBSetSelFromText(
  199. HWND hwnd,
  200. LPTSTR lpszString);
  201. int
  202. CBGetTextAndData(
  203. HWND hwnd,
  204. LPTSTR lpszString,
  205. int iSize,
  206. PULONG_PTR lpdw);
  207. int
  208. CBFindString(
  209. HWND hwnd,
  210. LPTSTR lpszString);
  211. BOOL
  212. GetPointSizeInRange(
  213. HWND hDlg,
  214. LPCHOOSEFONT lpcf,
  215. LPINT pts,
  216. WORD wFlags);
  217. BOOL
  218. ResetSampleFromScript(
  219. HWND hdlg,
  220. HWND hwndScript,
  221. PFONTINFO pFI);
  222. BOOL ProcessDlgCtrlCommand(HWND hDlg, PFONTINFO pFI, WORD wId, WORD wCmd, HWND hwnd);
  223. int
  224. CmpFontType(
  225. DWORD ft1,
  226. DWORD ft2);
  227. int
  228. FontFamilyEnumProc(
  229. LPENUMLOGFONTEX lplf,
  230. LPNEWTEXTMETRIC lptm,
  231. DWORD nFontType,
  232. LPENUM_FONT_DATA lpData);
  233. BOOL
  234. GetFontFamily(
  235. HWND hDlg,
  236. HDC hDC,
  237. DWORD dwEnumCode,
  238. UINT iCharset);
  239. VOID
  240. CBAddSize(
  241. HWND hwnd,
  242. int pts,
  243. LPCHOOSEFONT lpcf);
  244. int
  245. InsertStyleSorted(
  246. HWND hwnd,
  247. LPTSTR lpszStyle,
  248. LPLOGFONT lplf);
  249. PLOGFONT
  250. CBAddStyle(
  251. HWND hwnd,
  252. LPTSTR lpszStyle,
  253. DWORD nFontType,
  254. LPLOGFONT lplf);
  255. int
  256. CBAddScript(
  257. HWND hwnd,
  258. LPTSTR lpszScript,
  259. UINT iCharset);
  260. VOID
  261. FillInMissingStyles(
  262. HWND hwnd);
  263. VOID
  264. FillScalableSizes(
  265. HWND hwnd,
  266. LPCHOOSEFONT lpcf);
  267. int
  268. FontStyleEnumProc(
  269. LPENUMLOGFONTEX lplf,
  270. LPNEWTEXTMETRIC lptm,
  271. DWORD nFontType,
  272. LPENUM_FONT_DATA lpData);
  273. VOID
  274. FreeFonts(
  275. HWND hwnd);
  276. VOID
  277. FreeAllItemData(
  278. HWND hDlg,
  279. PFONTINFO pFI);
  280. VOID
  281. InitLF(
  282. LPLOGFONT lplf);
  283. int
  284. FontScriptEnumProc(
  285. LPENUMLOGFONTEX lplf,
  286. LPNEWTEXTMETRIC lptm,
  287. DWORD nFontType,
  288. LPENUM_FONT_DATA lpData);
  289. BOOL
  290. GetFontStylesAndSizes(
  291. HWND hDlg,
  292. PFONTINFO pFI,
  293. LPCHOOSEFONT lpcf,
  294. BOOL bForceSizeFill);
  295. VOID
  296. FillColorCombo(
  297. HWND hDlg);
  298. BOOL
  299. DrawSizeComboItem(
  300. LPDRAWITEMSTRUCT lpdis);
  301. BOOL
  302. DrawFamilyComboItem(
  303. LPDRAWITEMSTRUCT lpdis);
  304. BOOL
  305. DrawColorComboItem(
  306. LPDRAWITEMSTRUCT lpdis);
  307. VOID
  308. DrawSampleText(
  309. HWND hDlg,
  310. PFONTINFO pFI,
  311. LPCHOOSEFONT lpcf,
  312. HDC hDC);
  313. BOOL
  314. FillInFont(
  315. HWND hDlg,
  316. PFONTINFO pFI,
  317. LPCHOOSEFONT lpcf,
  318. LPLOGFONT lplf,
  319. BOOL bSetBits);
  320. BOOL
  321. SetLogFont(
  322. HWND hDlg,
  323. LPCHOOSEFONT lpcf,
  324. LPLOGFONT lplf);
  325. VOID
  326. TermFont();
  327. int
  328. GetPointString(
  329. LPTSTR buf,
  330. UINT cch,
  331. HDC hDC,
  332. int height);
  333. DWORD
  334. FlipColor(
  335. DWORD rgb);
  336. HBITMAP
  337. LoadBitmaps(
  338. int id);
  339. BOOL LookUpFontSubs(LPCTSTR lpSubFontName, LPTSTR lpRealFontName, UINT cch);
  340. BOOL GetUnicodeSampleText(HDC hdc, LPTSTR lpString, int nMaxCount);
  341. #ifdef UNICODE
  342. void
  343. ThunkChooseFontA2W(
  344. PFONTINFO pFI);
  345. void
  346. ThunkChooseFontW2A(
  347. PFONTINFO pFI);
  348. VOID
  349. ThunkLogFontA2W(
  350. LPLOGFONTA lpLFA,
  351. LPLOGFONTW lpLFW);
  352. VOID
  353. ThunkLogFontW2A(
  354. LPLOGFONTW lpLFW,
  355. LPLOGFONTA lpLFA);
  356. #endif