Updated.
[wine/multimedia.git] / dlls / commdlg / fontdlg.c
bloba473ba4030ac485f028d75baefd70b4ac99bd081
1 /*
2 * COMMDLG - Font Dialog
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <ctype.h>
23 #include <stdlib.h>
24 #include <stdarg.h>
25 #include <stdio.h>
26 #include <string.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winnls.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "wine/winbase16.h"
33 #include "wine/winuser16.h"
34 #include "heap.h"
35 #include "commdlg.h"
36 #include "dlgs.h"
37 #include "wine/debug.h"
38 #include "cderr.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
42 #include "cdlg.h"
43 #include "fontdlg.h"
45 static HBITMAP hBitmapTT = 0;
48 INT_PTR CALLBACK FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
49 LPARAM lParam);
50 INT_PTR CALLBACK FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
51 LPARAM lParam);
52 BOOL16 CALLBACK FormatCharDlgProc16(HWND16 hDlg, UINT16 message, WPARAM16 wParam,
53 LPARAM lParam);
55 /* There is a table here of all charsets, and the sample text for each.
56 * There is a second table that translates a charset into an index into
57 * the first table.
60 #define CI(cs) ((IDS_CHARSET_##cs)-IDS_CHARSET_ANSI)
63 static const WCHAR stWestern[]={'A','a','B','b','Y','y','Z','z',0}; /* Western and default */
64 static const WCHAR stSymbol[]={'S','y','m','b','o','l',0}; /* Symbol */
65 static const WCHAR stShiftJis[]={'A','a',0x3042,0x3041,0x30a2,0x30a1,0x4e9c,0x5b87,0}; /* Shift JIS */
66 static const WCHAR stHangul[]={0xac00,0xb098,0xb2e4,'A','a','B','Y','y','Z','z',0}; /* Hangul */
67 static const WCHAR stGB2312[]={0x5fae,0x8f6f,0x4e2d,0x6587,0x8f6f,0x4ef6,0}; /* GB2312 */
68 static const WCHAR stBIG5[]={0x4e2d,0x6587,0x5b57,0x578b,0x7bc4,0x4f8b,0}; /* BIG5 */
69 static const WCHAR stGreek[]={'A','a','B','b',0x0391,0x03b1,0x0392,0x03b2,0}; /* Greek */
70 static const WCHAR stTurkish[]={'A','a','B','b',0x011e,0x011f,0x015e,0x015f,0}; /* Turkish */
71 static const WCHAR stHebrew[]={'A','a','B','b',0x05e0,0x05e1,0x05e9,0x05ea,0}; /* Hebrew */
72 static const WCHAR stArabic[]={'A','a','B','b',0x0627,0x0628,0x062c,0x062f,0x0647,0x0648,0x0632,0};/* Arabic */
73 static const WCHAR stBaltic[]={'A','a','B','b','Y','y','Z','z',0}; /* Baltic */
74 static const WCHAR stVietname[]={'A','a','B','b',0x01a0,0x01a1,0x01af,0x01b0,0}; /* Vietnamese */
75 static const WCHAR stCyrillic[]={'A','a','B','b',0x0411,0x0431,0x0424,0x0444,0}; /* Cyrillic */
76 static const WCHAR stEastEur[]={'A','a','B','b',0xc1,0xe1,0xd4,0xf4,0}; /* East European */
77 static const WCHAR stThai[]={'A','a','B','b',0x0e2d,0x0e31,0x0e01,0x0e29,0x0e23,0x0e44,0x0e17,0x0e22,0}; /* Thai */
78 static const WCHAR stJohab[]={0xac00,0xb098,0xb2e4,'A','a','B','Y','y','Z','z',0}; /* Johab */
79 static const WCHAR stMac[]={'A','a','B','b','Y','y','Z','z',0}; /* Mac */
80 static const WCHAR stOEM[]={'A','a','B','b',0xf8,0xf1,0xfd,0}; /* OEM */
81 /* the following character sets actually behave different (Win2K observation):
82 * the sample string is 'sticky': it uses the sample string of the previous
83 * selected character set. That behaviour looks like some default, which is
84 * not (yet) implemented. */
85 static const WCHAR stVISCII[]={'A','a','B','b',0}; /* VISCII */
86 static const WCHAR stTCVN[]={'A','a','B','b',0}; /* TCVN */
87 static const WCHAR stKOI8[]={'A','a','B','b',0}; /* KOI-8 */
88 static const WCHAR stIso88593[]={'A','a','B','b',0}; /* ISO-8859-3 */
89 static const WCHAR stIso88594[]={'A','a','B','b',0}; /* ISO-8859-4 */
90 static const WCHAR stIso885910[]={'A','a','B','b',0}; /* ISO-8859-10 */
91 static const WCHAR stCeltic[]={'A','a','B','b',0};/* Celtic */
93 static const WCHAR *sample_lang_text[]={
94 stWestern,stSymbol,stShiftJis,stHangul,stGB2312,
95 stBIG5,stGreek,stTurkish,stHebrew,stArabic,
96 stBaltic,stVietname,stCyrillic,stEastEur,stThai,
97 stJohab,stMac,stOEM,stVISCII,stTCVN,
98 stKOI8,stIso88593,stIso88594,stIso885910,stCeltic};
101 static const int CHARSET_ORDER[256]={
102 CI(ANSI), 0, CI(SYMBOL), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
103 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
104 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
105 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
106 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CI(MAC), 0, 0,
107 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
108 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
109 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
110 CI(JIS), CI(HANGUL), CI(JOHAB), 0, 0, 0, CI(GB2312), 0, CI(BIG5), 0, 0, 0, 0, 0, 0, 0,
111 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
112 0, CI(GREEK), CI(TURKISH), CI(VIETNAMESE), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
113 0, CI(HEBREW), CI(ARABIC), 0, 0, 0, 0, 0, 0, 0, CI(BALTIC), 0, 0, 0, 0, 0,
114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CI(RUSSIAN), 0, 0, 0,
115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CI(THAI), 0,
116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CI(EE), 0,
117 CI(VISCII), CI(TCVN), CI(KOI8), CI(ISO3), CI(ISO4), CI(ISO10), CI(CELTIC), 0, 0, 0, 0, 0, 0, 0, 0, CI(OEM),
120 struct {
121 int mask;
122 char *name;
123 } cfflags[] = {
124 #define XX(x) { x, #x },
125 XX(CF_SCREENFONTS)
126 XX(CF_PRINTERFONTS)
127 XX(CF_SHOWHELP)
128 XX(CF_ENABLEHOOK)
129 XX(CF_ENABLETEMPLATE)
130 XX(CF_ENABLETEMPLATEHANDLE)
131 XX(CF_INITTOLOGFONTSTRUCT)
132 XX(CF_USESTYLE)
133 XX(CF_EFFECTS)
134 XX(CF_APPLY)
135 XX(CF_ANSIONLY)
136 XX(CF_NOVECTORFONTS)
137 XX(CF_NOSIMULATIONS)
138 XX(CF_LIMITSIZE)
139 XX(CF_FIXEDPITCHONLY)
140 XX(CF_WYSIWYG)
141 XX(CF_FORCEFONTEXIST)
142 XX(CF_SCALABLEONLY)
143 XX(CF_TTONLY)
144 XX(CF_NOFACESEL)
145 XX(CF_NOSTYLESEL)
146 XX(CF_NOSIZESEL)
147 XX(CF_SELECTSCRIPT)
148 XX(CF_NOSCRIPTSEL)
149 XX(CF_NOVERTFONTS)
150 #undef XX
151 {0,NULL},
154 void _dump_cf_flags(DWORD cflags)
156 int i;
158 for (i=0;cfflags[i].name;i++)
159 if (cfflags[i].mask & cflags)
160 MESSAGE("%s|",cfflags[i].name);
161 MESSAGE("\n");
164 /***********************************************************************
165 * ChooseFontA (COMDLG32.@)
167 BOOL WINAPI ChooseFontA(LPCHOOSEFONTA lpChFont)
169 LPCVOID template;
170 HRSRC hResInfo;
171 HINSTANCE hDlginst;
172 HGLOBAL hDlgTmpl;
174 if ( (lpChFont->Flags&CF_ENABLETEMPLATEHANDLE)!=0 )
176 template=(LPCVOID)lpChFont->hInstance;
177 } else
179 if ( (lpChFont->Flags&CF_ENABLETEMPLATE)!=0 )
181 hDlginst=lpChFont->hInstance;
182 if( !(hResInfo = FindResourceA(hDlginst, lpChFont->lpTemplateName,
183 (LPSTR)RT_DIALOG)))
185 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
186 return FALSE;
188 } else
190 hDlginst=COMDLG32_hInstance;
191 if (!(hResInfo = FindResourceA(hDlginst, "CHOOSE_FONT", (LPSTR)RT_DIALOG)))
193 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
194 return FALSE;
197 if (!(hDlgTmpl = LoadResource(hDlginst, hResInfo )) ||
198 !(template = LockResource( hDlgTmpl )))
200 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
201 return FALSE;
204 if (TRACE_ON(commdlg))
205 _dump_cf_flags(lpChFont->Flags);
207 if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS ))
208 FIXME(": unimplemented flag (ignored)\n");
210 return DialogBoxIndirectParamA(COMDLG32_hInstance, template,
211 lpChFont->hwndOwner, FormatCharDlgProcA, (LPARAM)lpChFont );
214 /***********************************************************************
215 * ChooseFontW (COMDLG32.@)
217 * NOTES:
219 * The LOGFONT conversion functions will break if the structure ever
220 * grows beyond the lfFaceName element.
222 * The CHOOSEFONT conversion functions assume that both versions of
223 * lpLogFont and lpszStyle (if used) point to pre-allocated objects.
225 * The ASCII version of lpTemplateName is created by ChooseFontAtoW
226 * and freed by ChooseFontWtoA.
228 inline static VOID LogFontWtoA(const LOGFONTW *lfw, LOGFONTA *lfa)
230 memcpy(lfa, lfw, sizeof(LOGFONTA));
231 WideCharToMultiByte(CP_ACP, 0, lfw->lfFaceName, -1, lfa->lfFaceName,
232 LF_FACESIZE, NULL, NULL);
233 lfa->lfFaceName[LF_FACESIZE - 1] = '\0';
236 inline static VOID LogFontAtoW(const LOGFONTA *lfa, LOGFONTW *lfw)
238 memcpy(lfw, lfa, sizeof(LOGFONTA));
239 MultiByteToWideChar(CP_ACP, 0, lfa->lfFaceName, -1, lfw->lfFaceName,
240 LF_FACESIZE);
241 lfw->lfFaceName[LF_FACESIZE - 1] = 0;
244 static BOOL ChooseFontWtoA(const CHOOSEFONTW *cfw, CHOOSEFONTA *cfa)
246 LOGFONTA *lpLogFont = cfa->lpLogFont;
247 LPSTR lpszStyle = cfa->lpszStyle;
249 memcpy(cfa, cfw, sizeof(CHOOSEFONTA));
250 cfa->lpLogFont = lpLogFont;
251 cfa->lpszStyle = lpszStyle;
253 LogFontWtoA(cfw->lpLogFont, lpLogFont);
255 if ((cfw->Flags&CF_ENABLETEMPLATE)!=0 && HIWORD(cfw->lpTemplateName)!=0)
257 cfa->lpTemplateName = HEAP_strdupWtoA(GetProcessHeap(), 0,
258 cfw->lpTemplateName);
259 if (cfa->lpTemplateName == NULL)
260 return FALSE;
263 if ((cfw->Flags & CF_USESTYLE) != 0 && cfw->lpszStyle != NULL)
265 WideCharToMultiByte(CP_ACP, 0, cfw->lpszStyle, -1, cfa->lpszStyle,
266 LF_FACESIZE, NULL, NULL);
267 cfa->lpszStyle[LF_FACESIZE - 1] = '\0';
270 return TRUE;
273 static VOID ChooseFontAtoW(const CHOOSEFONTA *cfa, CHOOSEFONTW *cfw)
275 LOGFONTW *lpLogFont = cfw->lpLogFont;
276 LPWSTR lpszStyle = cfw->lpszStyle;
277 LPCWSTR lpTemplateName = cfw->lpTemplateName;
279 memcpy(cfw, cfa, sizeof(CHOOSEFONTA));
280 cfw->lpLogFont = lpLogFont;
281 cfw->lpszStyle = lpszStyle;
282 cfw->lpTemplateName = lpTemplateName;
284 LogFontAtoW(cfa->lpLogFont, lpLogFont);
286 if ((cfa->Flags&CF_ENABLETEMPLATE)!=0 && HIWORD(cfa->lpTemplateName) != 0)
287 HeapFree(GetProcessHeap(), 0, (LPSTR)(cfa->lpTemplateName));
289 if ((cfa->Flags & CF_USESTYLE) != 0 && cfa->lpszStyle != NULL)
291 MultiByteToWideChar(CP_ACP, 0, cfa->lpszStyle, -1, cfw->lpszStyle,
292 LF_FACESIZE);
293 cfw->lpszStyle[LF_FACESIZE - 1] = 0;
297 BOOL WINAPI ChooseFontW(LPCHOOSEFONTW lpChFont)
299 CHOOSEFONTA cf_a;
300 LOGFONTA lf_a;
301 CHAR style_a[LF_FACESIZE];
303 cf_a.lpLogFont = &lf_a;
304 cf_a.lpszStyle = style_a;
306 if (ChooseFontWtoA(lpChFont, &cf_a) == FALSE)
308 COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
309 return FALSE;
312 if (ChooseFontA(&cf_a) == FALSE)
314 if (cf_a.lpTemplateName != NULL)
315 HeapFree(GetProcessHeap(), 0, (LPSTR)(cf_a.lpTemplateName));
316 return FALSE;
319 ChooseFontAtoW(&cf_a, lpChFont);
321 return TRUE;
324 #if 0
325 /***********************************************************************
326 * ChooseFontW (COMDLG32.@)
328 BOOL WINAPI ChooseFontW(LPCHOOSEFONTW lpChFont)
330 BOOL bRet=FALSE;
331 CHOOSEFONTA cf32a;
332 LOGFONTA lf32a;
333 LPCVOID template;
334 HANDLE hResInfo, hDlgTmpl;
336 if (TRACE_ON(commdlg))
337 _dump_cf_flags(lpChFont->Flags);
339 if (!(hResInfo = FindResourceA(COMDLG32_hInstance, "CHOOSE_FONT", (LPSTR)RT_DIALOG)))
341 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
342 return FALSE;
344 if (!(hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo )) ||
345 !(template = LockResource( hDlgTmpl )))
347 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
348 return FALSE;
351 if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS | CF_ENABLETEMPLATE |
352 CF_ENABLETEMPLATEHANDLE)) FIXME(": unimplemented flag (ignored)\n");
353 memcpy(&cf32a, lpChFont, sizeof(cf32a));
354 memcpy(&lf32a, lpChFont->lpLogFont, sizeof(LOGFONTA));
356 WideCharToMultiByte( CP_ACP, 0, lpChFont->lpLogFont->lfFaceName, -1,
357 lf32a.lfFaceName, LF_FACESIZE, NULL, NULL );
358 lf32a.lfFaceName[LF_FACESIZE-1] = 0;
359 cf32a.lpLogFont=&lf32a;
360 cf32a.lpszStyle=HEAP_strdupWtoA(GetProcessHeap(), 0, lpChFont->lpszStyle);
361 lpChFont->lpTemplateName=(LPWSTR)&cf32a;
362 bRet = DialogBoxIndirectParamW(COMDLG32_hInstance, template,
363 lpChFont->hwndOwner, FormatCharDlgProcW, (LPARAM)lpChFont );
364 HeapFree(GetProcessHeap(), 0, cf32a.lpszStyle);
365 lpChFont->lpTemplateName=(LPWSTR)cf32a.lpTemplateName;
366 memcpy(lpChFont->lpLogFont, &lf32a, sizeof(CHOOSEFONTA));
367 MultiByteToWideChar( CP_ACP, 0, lf32a.lfFaceName, -1,
368 lpChFont->lpLogFont->lfFaceName, LF_FACESIZE );
369 lpChFont->lpLogFont->lfFaceName[LF_FACESIZE-1] = 0;
370 return bRet;
372 #endif
374 #define TEXT_EXTRAS 4
375 #define TEXT_COLORS 16
377 static const COLORREF textcolors[TEXT_COLORS]=
379 0x00000000L,0x00000080L,0x00008000L,0x00008080L,
380 0x00800000L,0x00800080L,0x00808000L,0x00808080L,
381 0x00c0c0c0L,0x000000ffL,0x0000ff00L,0x0000ffffL,
382 0x00ff0000L,0x00ff00ffL,0x00ffff00L,0x00FFFFFFL
385 /***********************************************************************
386 * CFn_HookCallChk32 [internal]
388 static BOOL CFn_HookCallChk32(LPCHOOSEFONTA lpcf)
390 if (lpcf)
391 if(lpcf->Flags & CF_ENABLEHOOK)
392 if (lpcf->lpfnHook)
393 return TRUE;
394 return FALSE;
397 /*************************************************************************
398 * AddFontFamily [internal]
400 INT AddFontFamily(const LOGFONTA *lplf, UINT nFontType,
401 LPCHOOSEFONTA lpcf, HWND hwnd, LPCFn_ENUMSTRUCT e)
403 int i;
404 WORD w;
406 TRACE("font=%s (nFontType=%d)\n", lplf->lfFaceName,nFontType);
408 if (lpcf->Flags & CF_FIXEDPITCHONLY)
409 if (!(lplf->lfPitchAndFamily & FIXED_PITCH))
410 return 1;
411 if (lpcf->Flags & CF_ANSIONLY)
412 if (lplf->lfCharSet != ANSI_CHARSET)
413 return 1;
414 if (lpcf->Flags & CF_TTONLY)
415 if (!(nFontType & TRUETYPE_FONTTYPE))
416 return 1;
418 if (e) e->added++;
420 i=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)lplf->lfFaceName);
421 if (i!=CB_ERR)
423 w=(lplf->lfCharSet << 8) | lplf->lfPitchAndFamily;
424 SendMessageA(hwnd, CB_SETITEMDATA, i, MAKELONG(nFontType,w));
425 return 1 ; /* store some important font information */
427 else
428 return 0;
431 /*************************************************************************
432 * FontFamilyEnumProc32 [internal]
434 static INT WINAPI FontFamilyEnumProc(const LOGFONTA *lpLogFont,
435 const TEXTMETRICA *metrics, DWORD dwFontType, LPARAM lParam)
437 LPCFn_ENUMSTRUCT e;
438 e=(LPCFn_ENUMSTRUCT)lParam;
439 return AddFontFamily(lpLogFont, dwFontType, e->lpcf32a, e->hWnd1, e);
442 /*************************************************************************
443 * SetFontStylesToCombo2 [internal]
445 * Fill font style information into combobox (without using font.c directly)
447 static int SetFontStylesToCombo2(HWND hwnd, HDC hdc, const LOGFONTA *lplf)
449 #define FSTYLES 4
450 struct FONTSTYLE
452 int italic;
453 int weight;
454 char stname[20];
456 static struct FONTSTYLE fontstyles[FSTYLES]={
457 { 0,FW_NORMAL,"Regular"}, { 1,FW_NORMAL,"Italic"},
458 { 0,FW_BOLD,"Bold"}, { 1,FW_BOLD,"Bold Italic"}
460 HFONT hf;
461 TEXTMETRICA tm;
462 int i,j;
463 LOGFONTA lf;
465 memcpy(&lf, lplf, sizeof(LOGFONTA));
467 for (i=0;i<FSTYLES;i++)
469 lf.lfItalic=fontstyles[i].italic;
470 lf.lfWeight=fontstyles[i].weight;
471 hf=CreateFontIndirectA(&lf);
472 hf=SelectObject(hdc,hf);
473 GetTextMetricsA(hdc,&tm);
474 hf=SelectObject(hdc,hf);
475 DeleteObject(hf);
476 /* font successful created ? */
477 if (tm.tmWeight==fontstyles[i].weight &&
478 ((tm.tmItalic != 0)==fontstyles[i].italic))
480 j=SendMessageA(hwnd,CB_ADDSTRING,0,(LPARAM)fontstyles[i].stname );
481 if (j==CB_ERR) return 1;
482 j=SendMessageA(hwnd, CB_SETITEMDATA, j,
483 MAKELONG(fontstyles[i].weight,fontstyles[i].italic));
484 if (j==CB_ERR) return 1;
487 return 0;
490 /*************************************************************************
491 * AddFontSizeToCombo3 [internal]
493 static int AddFontSizeToCombo3(HWND hwnd, UINT h, LPCHOOSEFONTA lpcf)
495 int j;
496 char buffer[20];
498 if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
499 ((lpcf->Flags & CF_LIMITSIZE) && (h >= lpcf->nSizeMin) && (h <= lpcf->nSizeMax)))
501 sprintf(buffer, "%2d", h);
502 j=SendMessageA(hwnd, CB_FINDSTRINGEXACT, -1, (LPARAM)buffer);
503 if (j==CB_ERR)
505 j=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)buffer);
506 if (j!=CB_ERR) j = SendMessageA(hwnd, CB_SETITEMDATA, j, h);
507 if (j==CB_ERR) return 1;
510 return 0;
513 /*************************************************************************
514 * SetFontSizesToCombo3 [internal]
516 static int SetFontSizesToCombo3(HWND hwnd, LPCHOOSEFONTA lpcf)
518 static const int sizes[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
519 int i;
521 for (i=0; sizes[i]; i++)
522 if (AddFontSizeToCombo3(hwnd, sizes[i], lpcf)) return 1;
523 return 0;
526 /***********************************************************************
527 * AddFontStyle [internal]
529 INT AddFontStyle(const LOGFONTA *lplf, UINT nFontType,
530 LPCHOOSEFONTA lpcf, HWND hcmb2, HWND hcmb3, HWND hDlg)
532 int i;
534 TRACE("(nFontType=%d)\n",nFontType);
535 TRACE(" %s h=%ld w=%ld e=%ld o=%ld wg=%ld i=%d u=%d s=%d"
536 " ch=%d op=%d cp=%d q=%d pf=%xh\n",
537 lplf->lfFaceName,lplf->lfHeight,lplf->lfWidth,
538 lplf->lfEscapement,lplf->lfOrientation,
539 lplf->lfWeight,lplf->lfItalic,lplf->lfUnderline,
540 lplf->lfStrikeOut,lplf->lfCharSet, lplf->lfOutPrecision,
541 lplf->lfClipPrecision,lplf->lfQuality, lplf->lfPitchAndFamily);
542 if (nFontType & RASTER_FONTTYPE)
544 if (AddFontSizeToCombo3(hcmb3, lplf->lfHeight, lpcf)) return 0;
545 } else if (SetFontSizesToCombo3(hcmb3, lpcf)) return 0;
547 if (!SendMessageA(hcmb2, CB_GETCOUNT, 0, 0))
549 HDC hdc= ((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
550 i=SetFontStylesToCombo2(hcmb2,hdc,lplf);
551 if (!((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC))
552 ReleaseDC(hDlg,hdc);
553 if (i)
554 return 0;
556 return 1 ;
559 static INT CFn_FitFontSize( HWND hDlg, int points)
561 int i,n;
562 int ret = 0;
563 /* look for fitting font size in combobox3 */
564 n=SendDlgItemMessageA(hDlg, cmb3, CB_GETCOUNT, 0, 0);
565 for (i=0;i<n;i++)
567 if (points == (int)SendDlgItemMessageA
568 (hDlg,cmb3, CB_GETITEMDATA,i,0))
570 SendDlgItemMessageA(hDlg,cmb3,CB_SETCURSEL,i,0);
571 SendMessageA(hDlg, WM_COMMAND,
572 MAKEWPARAM(cmb3, CBN_SELCHANGE),
573 (LPARAM)GetDlgItem(hDlg,cmb3));
574 ret = 1;
575 break;
578 return ret;
581 static INT CFn_FitFontStyle( HWND hDlg, LONG packedstyle )
583 LONG id;
584 int i, ret = 0;
585 /* look for fitting font style in combobox2 */
586 for (i=0;i<TEXT_EXTRAS;i++)
588 id =SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0);
589 if (packedstyle == id)
591 SendDlgItemMessageA(hDlg, cmb2, CB_SETCURSEL, i, 0);
592 SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb2, CBN_SELCHANGE),
593 (LPARAM)GetDlgItem(hDlg,cmb2));
594 ret = 1;
595 break;
598 return ret;
601 /***********************************************************************
602 * FontStyleEnumProc32 [internal]
604 static INT WINAPI FontStyleEnumProc( const LOGFONTA *lpFont,
605 const TEXTMETRICA *metrics, DWORD dwFontType, LPARAM lParam )
607 LPCFn_ENUMSTRUCT s=(LPCFn_ENUMSTRUCT)lParam;
608 HWND hcmb2=s->hWnd1;
609 HWND hcmb3=s->hWnd2;
610 HWND hDlg=GetParent(hcmb3);
611 return AddFontStyle(lpFont, dwFontType, s->lpcf32a, hcmb2,
612 hcmb3, hDlg);
615 /***********************************************************************
616 * CFn_WMInitDialog [internal]
618 LRESULT CFn_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam,
619 LPCHOOSEFONTA lpcf)
621 HDC hdc;
622 int i,j,init=0;
623 long pstyle;
624 LPLOGFONTA lpxx;
625 HCURSOR hcursor=SetCursor(LoadCursorA(0,(LPSTR)IDC_WAIT));
627 SetWindowLongA(hDlg, DWL_USER, lParam);
628 lpxx=lpcf->lpLogFont;
629 TRACE("WM_INITDIALOG lParam=%08lX\n", lParam);
631 if (lpcf->lStructSize != sizeof(CHOOSEFONTA))
633 ERR("structure size failure !!!\n");
634 EndDialog (hDlg, 0);
635 return FALSE;
637 if (!hBitmapTT)
638 hBitmapTT = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_TRTYPE));
640 if (!(lpcf->Flags & CF_SHOWHELP) || !IsWindow(lpcf->hwndOwner))
641 ShowWindow(GetDlgItem(hDlg,pshHelp),SW_HIDE);
642 if (!(lpcf->Flags & CF_APPLY))
643 ShowWindow(GetDlgItem(hDlg,psh3),SW_HIDE);
644 if (lpcf->Flags & CF_EFFECTS)
646 for (i=0;i<TEXT_COLORS;i++)
648 char name[30];
650 if( LoadStringA(COMDLG32_hInstance, IDS_COLOR_BLACK+i, name,
651 sizeof(name)/sizeof(*name) )==0 )
653 strcpy( name, "[color name]" );
655 j=SendDlgItemMessageA(hDlg, cmb4, CB_ADDSTRING, 0, (LPARAM)name);
656 SendDlgItemMessageA(hDlg, cmb4, CB_SETITEMDATA16, j, textcolors[j]);
657 /* look for a fitting value in color combobox */
658 if (textcolors[j]==lpcf->rgbColors)
659 SendDlgItemMessageA(hDlg,cmb4, CB_SETCURSEL,j,0);
662 else
664 ShowWindow(GetDlgItem(hDlg,cmb4),SW_HIDE);
665 ShowWindow(GetDlgItem(hDlg,chx1),SW_HIDE);
666 ShowWindow(GetDlgItem(hDlg,chx2),SW_HIDE);
667 ShowWindow(GetDlgItem(hDlg,grp1),SW_HIDE);
668 ShowWindow(GetDlgItem(hDlg,stc4),SW_HIDE);
670 hdc= ((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
671 if (hdc)
673 CFn_ENUMSTRUCT s;
674 s.hWnd1=GetDlgItem(hDlg,cmb1);
675 s.lpcf32a=lpcf;
676 do {
677 s.added = 0;
678 if (!EnumFontFamiliesA(hdc, NULL, FontFamilyEnumProc, (LPARAM)&s)) {
679 TRACE("EnumFontFamilies returns 0\n");
680 break;
682 if (s.added) break;
683 if (lpcf->Flags & CF_FIXEDPITCHONLY) {
684 FIXME("No font found with fixed pitch only, dropping flag.\n");
685 lpcf->Flags &= ~CF_FIXEDPITCHONLY;
686 continue;
688 if (lpcf->Flags & CF_TTONLY) {
689 FIXME("No font found with truetype only, dropping flag.\n");
690 lpcf->Flags &= ~CF_TTONLY;
691 continue;
693 break;
694 } while (1);
697 if (lpcf->Flags & CF_INITTOLOGFONTSTRUCT)
699 /* look for fitting font name in combobox1 */
700 j=SendDlgItemMessageA(hDlg,cmb1,CB_FINDSTRING,-1,(LONG)lpxx->lfFaceName);
701 if (j!=CB_ERR)
703 INT height = (lpcf->iPointSize + 5) / 10;
704 pstyle=MAKELONG(lpxx->lfWeight > FW_MEDIUM ? FW_BOLD:FW_NORMAL,lpxx->lfItalic !=0);
705 SendDlgItemMessageA(hDlg, cmb1, CB_SETCURSEL, j, 0);
706 SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
707 (LPARAM)GetDlgItem(hDlg,cmb1));
708 init=1;
709 /* look for fitting font style in combobox2 */
710 CFn_FitFontStyle(hDlg, pstyle);
711 /* look for fitting font size in combobox3 */
712 CFn_FitFontSize(hDlg, height);
715 if (!init)
717 SendDlgItemMessageA(hDlg,cmb1,CB_SETCURSEL,0,0);
718 SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
719 (LPARAM)GetDlgItem(hDlg,cmb1));
721 if (lpcf->Flags & CF_USESTYLE && lpcf->lpszStyle)
723 j=SendDlgItemMessageA(hDlg,cmb2,CB_FINDSTRING,-1,(LONG)lpcf->lpszStyle);
724 if (j!=CB_ERR)
726 j=SendDlgItemMessageA(hDlg,cmb2,CB_SETCURSEL,j,0);
727 SendMessageA(hDlg,WM_COMMAND,cmb2,
728 MAKELONG(HWND_16(GetDlgItem(hDlg,cmb2)),CBN_SELCHANGE));
732 else
734 WARN("HDC failure !!!\n");
735 EndDialog (hDlg, 0);
736 return FALSE;
739 if (!((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC))
740 ReleaseDC(hDlg,hdc);
741 SetCursor(hcursor);
742 return TRUE;
746 /***********************************************************************
747 * CFn_WMMeasureItem [internal]
749 LRESULT CFn_WMMeasureItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
751 BITMAP bm;
752 LPMEASUREITEMSTRUCT lpmi=(LPMEASUREITEMSTRUCT)lParam;
753 if (!hBitmapTT)
754 hBitmapTT = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_TRTYPE));
755 GetObjectA( hBitmapTT, sizeof(bm), &bm );
756 lpmi->itemHeight=bm.bmHeight;
757 /* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
758 return 0;
762 /***********************************************************************
763 * CFn_WMDrawItem [internal]
765 LRESULT CFn_WMDrawItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
767 HBRUSH hBrush;
768 char buffer[40];
769 BITMAP bm;
770 COLORREF cr, oldText=0, oldBk=0;
771 RECT rect;
772 #if 0
773 HDC hMemDC;
774 int nFontType;
775 HBITMAP hBitmap; /* for later TT usage */
776 #endif
777 LPDRAWITEMSTRUCT lpdi = (LPDRAWITEMSTRUCT)lParam;
779 if (lpdi->itemID == (UINT)-1) /* got no items */
780 DrawFocusRect(lpdi->hDC, &lpdi->rcItem);
781 else
783 if (lpdi->CtlType == ODT_COMBOBOX)
785 if (lpdi->itemState ==ODS_SELECTED)
787 hBrush=GetSysColorBrush(COLOR_HIGHLIGHT);
788 oldText=SetTextColor(lpdi->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
789 oldBk=SetBkColor(lpdi->hDC, GetSysColor(COLOR_HIGHLIGHT));
790 } else
792 hBrush = SelectObject(lpdi->hDC, GetStockObject(LTGRAY_BRUSH));
793 SelectObject(lpdi->hDC, hBrush);
795 FillRect(lpdi->hDC, &lpdi->rcItem, hBrush);
797 else
798 return TRUE; /* this should never happen */
800 rect=lpdi->rcItem;
801 switch (lpdi->CtlID)
803 case cmb1:
804 /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
805 SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
806 (LPARAM)buffer);
807 GetObjectA( hBitmapTT, sizeof(bm), &bm );
808 TextOutA(lpdi->hDC, lpdi->rcItem.left + bm.bmWidth + 10,
809 lpdi->rcItem.top, buffer, strlen(buffer));
810 #if 0
811 nFontType = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
812 /* FIXME: draw bitmap if truetype usage */
813 if (nFontType&TRUETYPE_FONTTYPE)
815 hMemDC = CreateCompatibleDC(lpdi->hDC);
816 hBitmap = SelectObject(hMemDC, hBitmapTT);
817 BitBlt(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top,
818 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
819 SelectObject(hMemDC, hBitmap);
820 DeleteDC(hMemDC);
822 #endif
823 break;
824 case cmb2:
825 case cmb3:
826 /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
827 SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
828 (LPARAM)buffer);
829 TextOutA(lpdi->hDC, lpdi->rcItem.left,
830 lpdi->rcItem.top, buffer, strlen(buffer));
831 break;
833 case cmb4:
834 /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
835 SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
836 (LPARAM)buffer);
837 TextOutA(lpdi->hDC, lpdi->rcItem.left + 25+5,
838 lpdi->rcItem.top, buffer, strlen(buffer));
839 cr = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
840 hBrush = CreateSolidBrush(cr);
841 if (hBrush)
843 hBrush = SelectObject (lpdi->hDC, hBrush) ;
844 rect.right=rect.left+25;
845 rect.top++;
846 rect.left+=5;
847 rect.bottom--;
848 Rectangle( lpdi->hDC, rect.left, rect.top,
849 rect.right, rect.bottom );
850 DeleteObject( SelectObject (lpdi->hDC, hBrush)) ;
852 rect=lpdi->rcItem;
853 rect.left+=25+5;
854 break;
856 default:
857 return TRUE; /* this should never happen */
859 if (lpdi->itemState == ODS_SELECTED)
861 SetTextColor(lpdi->hDC, oldText);
862 SetBkColor(lpdi->hDC, oldBk);
865 return TRUE;
868 /***********************************************************************
869 * CFn_WMCommand [internal]
871 LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam,
872 LPCHOOSEFONTA lpcf)
874 int i,j;
875 long l;
876 HDC hdc;
877 LPLOGFONTA lpxx=lpcf->lpLogFont;
879 TRACE("WM_COMMAND wParam=%08lX lParam=%08lX\n", (LONG)wParam, lParam);
880 switch (LOWORD(wParam))
882 case cmb1:
883 if (HIWORD(wParam)==CBN_SELCHANGE)
885 hdc=((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
886 if (hdc)
888 INT pointsize; /* save current pointsize */
889 LONG pstyle; /* save current style */
890 int idx2, idx3;
891 idx3 = SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
892 pointsize = (int)SendDlgItemMessageA( hDlg, cmb3, CB_GETITEMDATA,
893 idx3, 0);
894 idx2 = SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
895 pstyle = SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, idx2, 0);
897 SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT, 0, 0);
898 SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT, 0, 0);
899 i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL, 0, 0);
900 if (i!=CB_ERR)
902 HCURSOR hcursor=SetCursor(LoadCursorA(0,(LPSTR)IDC_WAIT));
903 CFn_ENUMSTRUCT s;
904 char str[256];
905 SendDlgItemMessageA(hDlg, cmb1, CB_GETLBTEXT, i,
906 (LPARAM)str);
907 TRACE("WM_COMMAND/cmb1 =>%s\n",str);
908 s.hWnd1=GetDlgItem(hDlg, cmb2);
909 s.hWnd2=GetDlgItem(hDlg, cmb3);
910 s.lpcf32a=lpcf;
911 EnumFontFamiliesA(hdc, str, FontStyleEnumProc, (LPARAM)&s);
912 CFn_FitFontStyle(hDlg, pstyle);
913 CFn_FitFontSize(hDlg, pointsize);
914 SetCursor(hcursor);
916 if (!((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC))
917 ReleaseDC(hDlg,hdc);
919 else
921 WARN("HDC failure !!!\n");
922 EndDialog (hDlg, 0);
923 return TRUE;
926 case chx1:
927 case chx2:
928 case cmb2:
929 case cmb3:
930 if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED )
932 char str[256];
933 WINDOWINFO wininfo;
935 TRACE("WM_COMMAND/cmb2,3 =%08lX\n", lParam);
936 i=SendDlgItemMessageA(hDlg,cmb1,CB_GETCURSEL,0,0);
937 if (i==CB_ERR)
938 i=GetDlgItemTextA( hDlg, cmb1, str, 256 );
939 else
941 SendDlgItemMessageA(hDlg,cmb1,CB_GETLBTEXT,i,
942 (LPARAM)str);
943 l=SendDlgItemMessageA(hDlg,cmb1,CB_GETITEMDATA,i,0);
944 j=HIWORD(l);
945 lpcf->nFontType = LOWORD(l);
946 /* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
947 /* same value reported to the EnumFonts
948 call back with the extra FONTTYPE_... bits added */
949 lpxx->lfPitchAndFamily=j&0xff;
950 lpxx->lfCharSet=j>>8;
952 strcpy(lpxx->lfFaceName,str);
953 i=SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
954 if (i!=CB_ERR)
956 l=SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0);
957 if (0!=(lpxx->lfItalic=HIWORD(l)))
958 lpcf->nFontType |= ITALIC_FONTTYPE;
959 if ((lpxx->lfWeight=LOWORD(l)) > FW_MEDIUM)
960 lpcf->nFontType |= BOLD_FONTTYPE;
962 i=SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
963 if (i!=CB_ERR)
964 lpxx->lfHeight=-LOWORD(SendDlgItemMessageA(hDlg, cmb3, CB_GETITEMDATA, i, 0));
965 else
966 lpxx->lfHeight=0;
967 lpxx->lfStrikeOut=IsDlgButtonChecked(hDlg,chx1);
968 lpxx->lfUnderline=IsDlgButtonChecked(hDlg,chx2);
969 lpxx->lfWidth=lpxx->lfOrientation=lpxx->lfEscapement=0;
970 lpxx->lfOutPrecision=OUT_DEFAULT_PRECIS;
971 lpxx->lfClipPrecision=CLIP_DEFAULT_PRECIS;
972 lpxx->lfQuality=DEFAULT_QUALITY;
973 lpcf->iPointSize= -10*lpxx->lfHeight;
975 wininfo.cbSize=sizeof(wininfo);
977 if( GetWindowInfo( GetDlgItem( hDlg, stc5), &wininfo ) )
979 MapWindowPoints( 0, hDlg, (LPPOINT) &wininfo.rcWindow, 2);
980 InvalidateRect( hDlg, &wininfo.rcWindow, TRUE );
983 break;
985 case cmb4:
986 i=SendDlgItemMessageA(hDlg, cmb4, CB_GETCURSEL, 0, 0);
987 if (i!=CB_ERR)
989 WINDOWINFO wininfo;
991 lpcf->rgbColors=textcolors[i];
992 wininfo.cbSize=sizeof(wininfo);
994 if( GetWindowInfo( GetDlgItem( hDlg, stc5), &wininfo ) )
996 MapWindowPoints( 0, hDlg, (LPPOINT) &wininfo.rcWindow, 2);
997 InvalidateRect( hDlg, &wininfo.rcWindow, TRUE );
1000 break;
1002 case psh15:
1003 i=RegisterWindowMessageA( HELPMSGSTRINGA );
1004 if (lpcf->hwndOwner)
1005 SendMessageA(lpcf->hwndOwner, i, 0, (LPARAM)GetWindowLongA(hDlg, DWL_USER));
1006 /* if (CFn_HookCallChk(lpcf))
1007 CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
1008 break;
1010 case IDOK:
1011 if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
1012 ( (lpcf->Flags & CF_LIMITSIZE) &&
1013 (-lpxx->lfHeight >= lpcf->nSizeMin) &&
1014 (-lpxx->lfHeight <= lpcf->nSizeMax)))
1015 EndDialog(hDlg, TRUE);
1016 else
1018 char buffer[80];
1019 sprintf(buffer,"Select a font size between %d and %d points.",
1020 lpcf->nSizeMin,lpcf->nSizeMax);
1021 MessageBoxA(hDlg, buffer, NULL, MB_OK);
1023 return(TRUE);
1024 case IDCANCEL:
1025 EndDialog(hDlg, FALSE);
1026 return(TRUE);
1028 return(FALSE);
1031 LRESULT CFn_WMDestroy(HWND hwnd, WPARAM wParam, LPARAM lParam)
1033 return TRUE;
1036 static LRESULT CFn_WMPaint(HWND hDlg, WPARAM wParam, LPARAM lParam,
1037 LPCHOOSEFONTA lpcf )
1039 WINDOWINFO info;
1041 info.cbSize=sizeof(info);
1043 if( GetWindowInfo( GetDlgItem( hDlg, stc5), &info ) )
1045 PAINTSTRUCT ps;
1046 HDC hdc;
1047 HPEN hOrigPen;
1048 HFONT hOrigFont;
1049 COLORREF rgbPrev;
1050 LOGFONTA lf = *(lpcf->lpLogFont);
1052 MapWindowPoints( 0, hDlg, (LPPOINT) &info.rcWindow, 2);
1053 hdc=BeginPaint( hDlg, &ps );
1055 /* Paint frame */
1056 MoveToEx( hdc, info.rcWindow.left, info.rcWindow.bottom, NULL );
1057 hOrigPen=SelectObject( hdc, CreatePen( PS_SOLID, 2,
1058 GetSysColor( COLOR_3DSHADOW ) ));
1059 LineTo( hdc, info.rcWindow.left, info.rcWindow.top );
1060 LineTo( hdc, info.rcWindow.right, info.rcWindow.top );
1061 DeleteObject(SelectObject( hdc, CreatePen( PS_SOLID, 2,
1062 GetSysColor( COLOR_3DLIGHT ) )));
1063 LineTo( hdc, info.rcWindow.right, info.rcWindow.bottom );
1064 LineTo( hdc, info.rcWindow.left, info.rcWindow.bottom );
1065 DeleteObject(SelectObject( hdc, hOrigPen ));
1067 /* Draw the sample text itself */
1068 info.rcWindow.right--;
1069 info.rcWindow.bottom--;
1070 info.rcWindow.top++;
1071 info.rcWindow.left++;
1072 lf.lfHeight = MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
1073 hOrigFont = SelectObject( hdc, CreateFontIndirectA( &lf ) );
1074 rgbPrev=SetTextColor( hdc, lpcf->rgbColors );
1076 DrawTextW( hdc,
1077 sample_lang_text[CHARSET_ORDER[lpcf->lpLogFont->lfCharSet]],
1078 -1, &info.rcWindow, DT_CENTER|DT_VCENTER|DT_SINGLELINE );
1080 EndPaint( hDlg, &ps );
1083 return FALSE;
1086 /***********************************************************************
1087 * FormatCharDlgProcA [internal]
1089 INT_PTR CALLBACK FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
1090 LPARAM lParam)
1092 LPCHOOSEFONTA lpcf;
1093 INT_PTR res = FALSE;
1094 if (uMsg!=WM_INITDIALOG)
1096 lpcf=(LPCHOOSEFONTA)GetWindowLongA(hDlg, DWL_USER);
1097 if (!lpcf)
1098 return FALSE;
1099 if (CFn_HookCallChk32(lpcf))
1100 res=CallWindowProcA((WNDPROC)lpcf->lpfnHook, hDlg, uMsg, wParam, lParam);
1101 if (res)
1102 return res;
1104 else
1106 lpcf=(LPCHOOSEFONTA)lParam;
1107 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf))
1109 TRACE("CFn_WMInitDialog returned FALSE\n");
1110 return FALSE;
1112 if (CFn_HookCallChk32(lpcf))
1113 return CallWindowProcA((WNDPROC)lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
1115 switch (uMsg)
1117 case WM_MEASUREITEM:
1118 return CFn_WMMeasureItem(hDlg, wParam, lParam);
1119 case WM_DRAWITEM:
1120 return CFn_WMDrawItem(hDlg, wParam, lParam);
1121 case WM_COMMAND:
1122 return CFn_WMCommand(hDlg, wParam, lParam, lpcf);
1123 case WM_DESTROY:
1124 return CFn_WMDestroy(hDlg, wParam, lParam);
1125 case WM_CHOOSEFONT_GETLOGFONT:
1126 TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
1127 lParam);
1128 FIXME("current logfont back to caller\n");
1129 break;
1130 case WM_PAINT:
1131 return CFn_WMPaint(hDlg, wParam, lParam, lpcf);
1133 return res;
1136 /***********************************************************************
1137 * FormatCharDlgProcW [internal]
1139 INT_PTR CALLBACK FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
1140 LPARAM lParam)
1142 LPCHOOSEFONTW lpcf32w;
1143 LPCHOOSEFONTA lpcf32a;
1144 INT_PTR res = FALSE;
1145 if (uMsg!=WM_INITDIALOG)
1147 lpcf32w=(LPCHOOSEFONTW)GetWindowLongA(hDlg, DWL_USER);
1148 if (!lpcf32w)
1149 return FALSE;
1150 if (CFn_HookCallChk32((LPCHOOSEFONTA)lpcf32w))
1151 res=CallWindowProcW((WNDPROC)lpcf32w->lpfnHook, hDlg, uMsg, wParam, lParam);
1152 if (res)
1153 return res;
1155 else
1157 lpcf32w=(LPCHOOSEFONTW)lParam;
1158 lpcf32a=(LPCHOOSEFONTA)lpcf32w->lpTemplateName;
1159 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
1161 TRACE("CFn_WMInitDialog returned FALSE\n");
1162 return FALSE;
1164 if (CFn_HookCallChk32((LPCHOOSEFONTA)lpcf32w))
1165 return CallWindowProcW((WNDPROC)lpcf32w->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
1167 lpcf32a=(LPCHOOSEFONTA)lpcf32w->lpTemplateName;
1168 switch (uMsg)
1170 case WM_MEASUREITEM:
1171 return CFn_WMMeasureItem(hDlg, wParam, lParam);
1172 case WM_DRAWITEM:
1173 return CFn_WMDrawItem(hDlg, wParam, lParam);
1174 case WM_COMMAND:
1175 return CFn_WMCommand(hDlg, wParam, lParam, lpcf32a);
1176 case WM_DESTROY:
1177 return CFn_WMDestroy(hDlg, wParam, lParam);
1178 case WM_CHOOSEFONT_GETLOGFONT:
1179 TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
1180 lParam);
1181 FIXME("current logfont back to caller\n");
1182 break;
1184 return res;