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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 LPCHOOSEFONTW lpcf32w
;
30 } CFn_ENUMSTRUCT
, *LPCFn_ENUMSTRUCT
;
33 static const WCHAR strWineFontData
[] = {'_','_','W','I','N','E','_','F','O','N','T','D','L','G','D','A','T','A',0};
34 static const WCHAR strWineFontData_a
[] =
35 {'_','_','W','I','N','E','_','F','O','N','T','D','L','G','D','A','T','A','_','A',0};
36 static const WCHAR chooseFontW
[] = {'C','H','O','O','S','E','_','F','O','N','T',0};
38 /* image list with TrueType bitmaps and more */
39 static HIMAGELIST himlTT
= 0;
40 #define TTBITMAP_XSIZE 20 /* x-size of the bitmaps */
42 static INT_PTR CALLBACK
FormatCharDlgProcA(HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
43 static INT_PTR CALLBACK
FormatCharDlgProcW(HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
45 /* There is a table here of all charsets, and the sample text for each.
46 * There is a second table that translates a charset into an index into
50 #define CI(cs) ((IDS_CHARSET_##cs)-IDS_CHARSET_ANSI)
53 static const WCHAR stWestern
[]={'A','a','B','b','Y','y','Z','z',0}; /* Western and default */
54 static const WCHAR stSymbol
[]={'S','y','m','b','o','l',0}; /* Symbol */
55 static const WCHAR stShiftJis
[]={'A','a',0x3042,0x3041,0x30a2,0x30a1,0x4e9c,0x5b87,0}; /* Shift JIS */
56 static const WCHAR stHangul
[]={0xac00,0xb098,0xb2e4,'A','a','B','Y','y','Z','z',0}; /* Hangul */
57 static const WCHAR stGB2312
[]={0x5fae,0x8f6f,0x4e2d,0x6587,0x8f6f,0x4ef6,0}; /* GB2312 */
58 static const WCHAR stBIG5
[]={0x4e2d,0x6587,0x5b57,0x578b,0x7bc4,0x4f8b,0}; /* BIG5 */
59 static const WCHAR stGreek
[]={'A','a','B','b',0x0391,0x03b1,0x0392,0x03b2,0}; /* Greek */
60 static const WCHAR stTurkish
[]={'A','a','B','b',0x011e,0x011f,0x015e,0x015f,0}; /* Turkish */
61 static const WCHAR stHebrew
[]={'A','a','B','b',0x05e0,0x05e1,0x05e9,0x05ea,0}; /* Hebrew */
62 static const WCHAR stArabic
[]={'A','a','B','b',0x0627,0x0628,0x062c,0x062f,0x0647,0x0648,0x0632,0};/* Arabic */
63 static const WCHAR stBaltic
[]={'A','a','B','b','Y','y','Z','z',0}; /* Baltic */
64 static const WCHAR stVietname
[]={'A','a','B','b',0x01a0,0x01a1,0x01af,0x01b0,0}; /* Vietnamese */
65 static const WCHAR stCyrillic
[]={'A','a','B','b',0x0411,0x0431,0x0424,0x0444,0}; /* Cyrillic */
66 static const WCHAR stEastEur
[]={'A','a','B','b',0xc1,0xe1,0xd4,0xf4,0}; /* East European */
67 static const WCHAR stThai
[]={'A','a','B','b',0x0e2d,0x0e31,0x0e01,0x0e29,0x0e23,0x0e44,0x0e17,0x0e22,0}; /* Thai */
68 static const WCHAR stJohab
[]={0xac00,0xb098,0xb2e4,'A','a','B','Y','y','Z','z',0}; /* Johab */
69 static const WCHAR stMac
[]={'A','a','B','b','Y','y','Z','z',0}; /* Mac */
70 static const WCHAR stOEM
[]={'A','a','B','b',0xf8,0xf1,0xfd,0}; /* OEM */
71 /* the following character sets actually behave different (Win2K observation):
72 * the sample string is 'sticky': it uses the sample string of the previous
73 * selected character set. That behaviour looks like some default, which is
74 * not (yet) implemented. */
75 static const WCHAR stVISCII
[]={'A','a','B','b',0}; /* VISCII */
76 static const WCHAR stTCVN
[]={'A','a','B','b',0}; /* TCVN */
77 static const WCHAR stKOI8
[]={'A','a','B','b',0}; /* KOI-8 */
78 static const WCHAR stIso88593
[]={'A','a','B','b',0}; /* ISO-8859-3 */
79 static const WCHAR stIso88594
[]={'A','a','B','b',0}; /* ISO-8859-4 */
80 static const WCHAR stIso885910
[]={'A','a','B','b',0}; /* ISO-8859-10 */
81 static const WCHAR stCeltic
[]={'A','a','B','b',0};/* Celtic */
83 static const WCHAR
* const sample_lang_text
[]={
84 stWestern
,stSymbol
,stShiftJis
,stHangul
,stGB2312
,
85 stBIG5
,stGreek
,stTurkish
,stHebrew
,stArabic
,
86 stBaltic
,stVietname
,stCyrillic
,stEastEur
,stThai
,
87 stJohab
,stMac
,stOEM
,stVISCII
,stTCVN
,
88 stKOI8
,stIso88593
,stIso88594
,stIso885910
,stCeltic
};
91 static const BYTE CHARSET_ORDER
[256]={
92 CI(ANSI
), 0, CI(SYMBOL
), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
93 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
94 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
95 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
96 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CI(MAC
), 0, 0,
97 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
98 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
99 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
100 CI(JIS
), CI(HANGUL
), CI(JOHAB
), 0, 0, 0, CI(GB2312
), 0, CI(BIG5
), 0, 0, 0, 0, 0, 0, 0,
101 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
102 0, CI(GREEK
), CI(TURKISH
), CI(VIETNAMESE
), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
103 0, CI(HEBREW
), CI(ARABIC
), 0, 0, 0, 0, 0, 0, 0, CI(BALTIC
), 0, 0, 0, 0, 0,
104 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CI(RUSSIAN
), 0, 0, 0,
105 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CI(THAI
), 0,
106 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CI(EE
), 0,
107 CI(VISCII
), CI(TCVN
), CI(KOI8
), CI(ISO3
), CI(ISO4
), CI(ISO10
), CI(CELTIC
), 0, 0, 0, 0, 0, 0, 0, 0, CI(OEM
),
110 static const struct {
114 #define XX(x) { x, #x },
119 XX(CF_ENABLETEMPLATE
)
120 XX(CF_ENABLETEMPLATEHANDLE
)
121 XX(CF_INITTOLOGFONTSTRUCT
)
129 XX(CF_FIXEDPITCHONLY
)
131 XX(CF_FORCEFONTEXIST
)
143 static void _dump_cf_flags(DWORD cflags
)
147 for (i
= 0; i
< sizeof(cfflags
)/sizeof(cfflags
[0]); i
++)
148 if (cfflags
[i
].mask
& cflags
)
149 TRACE("%s|",cfflags
[i
].name
);
153 /***********************************************************************
154 * ChooseFontW (COMDLG32.@)
156 * Create a font dialog box.
159 * lpChFont [I/O] in: information to initialize the dialog box.
160 * out: User's color selection
163 * TRUE: Ok button clicked.
164 * FALSE: Cancel button clicked, or error.
166 BOOL WINAPI
ChooseFontW(LPCHOOSEFONTW lpChFont
)
173 TRACE("(%p)\n", lpChFont
);
175 if ( (lpChFont
->Flags
&CF_ENABLETEMPLATEHANDLE
)!=0 )
177 template=lpChFont
->hInstance
;
180 if ( (lpChFont
->Flags
&CF_ENABLETEMPLATE
)!=0 )
182 hDlginst
=lpChFont
->hInstance
;
183 if( !(hResInfo
= FindResourceW(hDlginst
, lpChFont
->lpTemplateName
,
186 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
191 hDlginst
=COMDLG32_hInstance
;
192 if (!(hResInfo
= FindResourceW(hDlginst
, chooseFontW
, (LPWSTR
)RT_DIALOG
)))
194 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
198 if (!(hDlgTmpl
= LoadResource(hDlginst
, hResInfo
)) ||
199 !(template = LockResource( hDlgTmpl
)))
201 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
205 if (TRACE_ON(commdlg
))
206 _dump_cf_flags(lpChFont
->Flags
);
208 if (lpChFont
->Flags
& CF_SELECTSCRIPT
)
209 FIXME(": unimplemented flag (ignored)\n");
211 return DialogBoxIndirectParamW(COMDLG32_hInstance
, template,
212 lpChFont
->hwndOwner
, FormatCharDlgProcW
, (LPARAM
)lpChFont
);
215 /***********************************************************************
216 * ChooseFontA (COMDLG32.@)
220 BOOL WINAPI
ChooseFontA(LPCHOOSEFONTA lpChFont
)
227 TRACE("(%p)\n", lpChFont
);
229 if ( (lpChFont
->Flags
&CF_ENABLETEMPLATEHANDLE
)!=0 )
231 template=lpChFont
->hInstance
;
234 if ( (lpChFont
->Flags
&CF_ENABLETEMPLATE
)!=0 )
236 hDlginst
=lpChFont
->hInstance
;
237 if( !(hResInfo
= FindResourceA(hDlginst
, lpChFont
->lpTemplateName
,
240 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
245 hDlginst
=COMDLG32_hInstance
;
246 if (!(hResInfo
= FindResourceW(hDlginst
, chooseFontW
, (LPWSTR
)RT_DIALOG
)))
248 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
252 if (!(hDlgTmpl
= LoadResource(hDlginst
, hResInfo
)) ||
253 !(template = LockResource( hDlgTmpl
)))
255 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
259 if (TRACE_ON(commdlg
))
260 _dump_cf_flags(lpChFont
->Flags
);
261 if (lpChFont
->Flags
& CF_SELECTSCRIPT
)
262 FIXME(": unimplemented flag (ignored)\n");
264 return DialogBoxIndirectParamA(COMDLG32_hInstance
, template,
265 lpChFont
->hwndOwner
, FormatCharDlgProcA
, (LPARAM
)lpChFont
);
268 #define TEXT_EXTRAS 4
269 #define TEXT_COLORS 16
271 static const COLORREF textcolors
[TEXT_COLORS
]=
273 0x00000000L
,0x00000080L
,0x00008000L
,0x00008080L
,
274 0x00800000L
,0x00800080L
,0x00808000L
,0x00808080L
,
275 0x00c0c0c0L
,0x000000ffL
,0x0000ff00L
,0x0000ffffL
,
276 0x00ff0000L
,0x00ff00ffL
,0x00ffff00L
,0x00FFFFFFL
279 /***********************************************************************
280 * CFn_HookCallChk32 [internal]
282 static BOOL
CFn_HookCallChk32(const CHOOSEFONTW
*lpcf
)
285 if(lpcf
->Flags
& CF_ENABLEHOOK
)
291 /*************************************************************************
292 * AddFontFamily [internal]
294 static INT
AddFontFamily(const ENUMLOGFONTEXW
*lpElfex
, const NEWTEXTMETRICEXW
*lpNTM
,
295 UINT nFontType
, const CHOOSEFONTW
*lpcf
, HWND hwnd
, LPCFn_ENUMSTRUCT e
)
299 const LOGFONTW
*lplf
= &(lpElfex
->elfLogFont
);
301 TRACE("font=%s (nFontType=%d)\n", debugstr_w(lplf
->lfFaceName
), nFontType
);
303 if (lpcf
->Flags
& CF_FIXEDPITCHONLY
)
304 if (!(lplf
->lfPitchAndFamily
& FIXED_PITCH
))
306 if (lpcf
->Flags
& CF_ANSIONLY
)
307 if (lplf
->lfCharSet
!= ANSI_CHARSET
)
309 if (lpcf
->Flags
& CF_TTONLY
)
310 if (!(nFontType
& TRUETYPE_FONTTYPE
))
312 if (lpcf
->Flags
& CF_NOVERTFONTS
)
313 if (lplf
->lfFaceName
[0] == '@')
318 i
=SendMessageW(hwnd
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)lplf
->lfFaceName
);
320 i
= SendMessageW(hwnd
, CB_ADDSTRING
, 0, (LPARAM
)lplf
->lfFaceName
);
322 /* store some important font information */
323 w
= (lplf
->lfPitchAndFamily
) << 8 |
324 (HIWORD(lpNTM
->ntmTm
.ntmFlags
) & 0xff);
325 SendMessageW(hwnd
, CB_SETITEMDATA
, i
, MAKELONG(nFontType
,w
));
331 /*************************************************************************
332 * FontFamilyEnumProc32 [internal]
334 static INT WINAPI
FontFamilyEnumProc(const ENUMLOGFONTEXW
*lpElfex
,
335 const TEXTMETRICW
*metrics
, DWORD dwFontType
, LPARAM lParam
)
338 e
=(LPCFn_ENUMSTRUCT
)lParam
;
339 return AddFontFamily( lpElfex
, (const NEWTEXTMETRICEXW
*) metrics
,
340 dwFontType
, e
->lpcf32w
, e
->hWnd1
, e
);
343 /*************************************************************************
344 * SetFontStylesToCombo2 [internal]
346 * Fill font style information into combobox (without using font.c directly)
348 static int SetFontStylesToCombo2(HWND hwnd
, HDC hdc
, const LOGFONTW
*lplf
)
357 static const struct FONTSTYLE fontstyles
[FSTYLES
]={
358 { 0, FW_NORMAL
, IDS_FONT_REGULAR
},
359 { 1, FW_NORMAL
, IDS_FONT_ITALIC
},
360 { 0, FW_BOLD
, IDS_FONT_BOLD
},
361 { 1, FW_BOLD
, IDS_FONT_BOLD_ITALIC
}
370 for (i
=0;i
<FSTYLES
;i
++)
372 lf
.lfItalic
=fontstyles
[i
].italic
;
373 lf
.lfWeight
=fontstyles
[i
].weight
;
374 hf
=CreateFontIndirectW(&lf
);
375 hf
=SelectObject(hdc
,hf
);
376 GetTextMetricsW(hdc
,&tm
);
377 hf
=SelectObject(hdc
,hf
);
379 /* font successful created ? */
380 if (((fontstyles
[i
].weight
== FW_NORMAL
&& tm
.tmWeight
<= FW_MEDIUM
) ||
381 (fontstyles
[i
].weight
== FW_BOLD
&& tm
.tmWeight
> FW_MEDIUM
)) &&
382 ((tm
.tmItalic
!= 0)==fontstyles
[i
].italic
))
385 LoadStringW(COMDLG32_hInstance
, fontstyles
[i
].resId
, name
, 64);
386 j
=SendMessageW(hwnd
,CB_ADDSTRING
,0,(LPARAM
)name
);
387 if (j
==CB_ERR
) return 1;
388 j
=SendMessageW(hwnd
, CB_SETITEMDATA
, j
,
389 MAKELONG(tm
.tmWeight
,fontstyles
[i
].italic
));
390 if (j
==CB_ERR
) return 1;
396 /*************************************************************************
397 * AddFontSizeToCombo3 [internal]
399 static int AddFontSizeToCombo3(HWND hwnd
, UINT h
, const CHOOSEFONTW
*lpcf
)
403 static const WCHAR strFormat
[] = {'%','2','d',0};
405 if ( (!(lpcf
->Flags
& CF_LIMITSIZE
)) ||
406 ((lpcf
->Flags
& CF_LIMITSIZE
) && (h
>= lpcf
->nSizeMin
) && (h
<= lpcf
->nSizeMax
)))
408 wsprintfW(buffer
, strFormat
, h
);
409 j
=SendMessageW(hwnd
, CB_FINDSTRINGEXACT
, -1, (LPARAM
)buffer
);
412 j
=SendMessageW(hwnd
, CB_ADDSTRING
, 0, (LPARAM
)buffer
);
413 if (j
!=CB_ERR
) j
= SendMessageW(hwnd
, CB_SETITEMDATA
, j
, h
);
414 if (j
==CB_ERR
) return 1;
420 /*************************************************************************
421 * SetFontSizesToCombo3 [internal]
423 static int SetFontSizesToCombo3(HWND hwnd
, const CHOOSEFONTW
*lpcf
)
425 static const BYTE sizes
[]={6,7,8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
428 for (i
= 0; i
< sizeof(sizes
)/sizeof(sizes
[0]); i
++)
429 if (AddFontSizeToCombo3(hwnd
, sizes
[i
], lpcf
)) return 1;
433 /*************************************************************************
434 * CFn_GetDC [internal]
436 static inline HDC
CFn_GetDC(const CHOOSEFONTW
*lpcf
)
438 HDC ret
= ((lpcf
->Flags
& CF_PRINTERFONTS
) && lpcf
->hDC
) ?
441 if(!ret
) ERR("HDC failure!!!\n");
445 /*************************************************************************
446 * GetScreenDPI [internal]
448 static inline int GetScreenDPI(void)
454 result
= GetDeviceCaps(hdc
, LOGPIXELSY
);
460 /*************************************************************************
461 * CFn_ReleaseDC [internal]
463 static inline void CFn_ReleaseDC(const CHOOSEFONTW
*lpcf
, HDC hdc
)
465 if(!((lpcf
->Flags
& CF_PRINTERFONTS
) && lpcf
->hDC
))
469 /***********************************************************************
470 * AddFontStyle [internal]
472 static INT
AddFontStyle( const ENUMLOGFONTEXW
*lpElfex
, const NEWTEXTMETRICEXW
*lpNTM
,
473 UINT nFontType
, const CHOOSEFONTW
*lpcf
, HWND hcmb2
, HWND hcmb3
, HWND hDlg
)
476 const LOGFONTW
*lplf
= &(lpElfex
->elfLogFont
);
480 TRACE("(nFontType=%d)\n",nFontType
);
481 TRACE(" %s h=%d w=%d e=%d o=%d wg=%d i=%d u=%d s=%d"
482 " ch=%d op=%d cp=%d q=%d pf=%xh\n",
483 debugstr_w(lplf
->lfFaceName
),lplf
->lfHeight
,lplf
->lfWidth
,
484 lplf
->lfEscapement
,lplf
->lfOrientation
,
485 lplf
->lfWeight
,lplf
->lfItalic
,lplf
->lfUnderline
,
486 lplf
->lfStrikeOut
,lplf
->lfCharSet
, lplf
->lfOutPrecision
,
487 lplf
->lfClipPrecision
,lplf
->lfQuality
, lplf
->lfPitchAndFamily
);
488 if (nFontType
& RASTER_FONTTYPE
)
491 points
= MulDiv( lpNTM
->ntmTm
.tmHeight
- lpNTM
->ntmTm
.tmInternalLeading
,
493 i
= AddFontSizeToCombo3(hcmb3
, points
, lpcf
);
495 } else if (SetFontSizesToCombo3(hcmb3
, lpcf
)) return 0;
497 if (!SendMessageW(hcmb2
, CB_GETCOUNT
, 0, 0))
499 if(!(hdc
= CFn_GetDC(lpcf
))) return 0;
500 i
=SetFontStylesToCombo2(hcmb2
,hdc
,lplf
);
501 CFn_ReleaseDC(lpcf
, hdc
);
505 if (!( hcmb5
= GetDlgItem(hDlg
, cmb5
))) return 1;
506 i
= SendMessageW( hcmb5
, CB_FINDSTRINGEXACT
, 0,
507 (LPARAM
)lpElfex
->elfScript
);
509 i
= SendMessageW( hcmb5
, CB_ADDSTRING
, 0,
510 (LPARAM
)lpElfex
->elfScript
);
512 SendMessageW( hcmb5
, CB_SETITEMDATA
, i
, lplf
->lfCharSet
);
517 static INT
CFn_FitFontSize( HWND hDlg
, int points
)
521 /* look for fitting font size in combobox3 */
522 n
=SendDlgItemMessageW(hDlg
, cmb3
, CB_GETCOUNT
, 0, 0);
525 if (points
== (int)SendDlgItemMessageW
526 (hDlg
,cmb3
, CB_GETITEMDATA
,i
,0))
528 SendDlgItemMessageW(hDlg
,cmb3
,CB_SETCURSEL
,i
,0);
529 SendMessageW(hDlg
, WM_COMMAND
,
530 MAKEWPARAM(cmb3
, CBN_SELCHANGE
),
531 (LPARAM
)GetDlgItem(hDlg
,cmb3
));
539 static INT
CFn_FitFontStyle( HWND hDlg
, LONG packedstyle
)
543 /* look for fitting font style in combobox2 */
544 for (i
=0;i
<TEXT_EXTRAS
;i
++)
546 id
= SendDlgItemMessageW(hDlg
, cmb2
, CB_GETITEMDATA
, i
, 0);
547 if (packedstyle
== id
)
549 SendDlgItemMessageW(hDlg
, cmb2
, CB_SETCURSEL
, i
, 0);
550 SendMessageW(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb2
, CBN_SELCHANGE
),
551 (LPARAM
)GetDlgItem(hDlg
,cmb2
));
560 static INT
CFn_FitCharSet( HWND hDlg
, int charset
)
563 /* look for fitting char set in combobox5 */
564 n
=SendDlgItemMessageW(hDlg
, cmb5
, CB_GETCOUNT
, 0, 0);
567 cs
=SendDlgItemMessageW(hDlg
, cmb5
, CB_GETITEMDATA
, i
, 0);
570 SendDlgItemMessageW(hDlg
, cmb5
, CB_SETCURSEL
, i
, 0);
571 SendMessageW(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb5
, CBN_SELCHANGE
),
572 (LPARAM
)GetDlgItem(hDlg
,cmb2
));
576 /* no charset fits: select the first one in the list */
577 SendDlgItemMessageW(hDlg
, cmb5
, CB_SETCURSEL
, 0, 0);
578 SendMessageW(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb5
, CBN_SELCHANGE
),
579 (LPARAM
)GetDlgItem(hDlg
,cmb2
));
583 /***********************************************************************
584 * FontStyleEnumProc32 [internal]
586 static INT WINAPI
FontStyleEnumProc( const ENUMLOGFONTEXW
*lpElfex
,
587 const TEXTMETRICW
*metrics
, DWORD dwFontType
, LPARAM lParam
)
589 LPCFn_ENUMSTRUCT s
=(LPCFn_ENUMSTRUCT
)lParam
;
592 HWND hDlg
=GetParent(hcmb3
);
593 return AddFontStyle( lpElfex
, (const NEWTEXTMETRICEXW
*) metrics
,
594 dwFontType
, s
->lpcf32w
, hcmb2
, hcmb3
, hDlg
);
597 /***********************************************************************
598 * CFn_WMInitDialog [internal]
600 static LRESULT
CFn_WMInitDialog(HWND hDlg
, LPARAM lParam
, LPCHOOSEFONTW lpcf
)
607 HCURSOR hcursor
=SetCursor(LoadCursorW(0,(LPWSTR
)IDC_WAIT
));
608 static const WCHAR strColorName
[] = {'[','c','o','l','o','r',' ','n','a','m','e',']',0};
610 SetPropW(hDlg
, strWineFontData
, lpcf
);
611 lpxx
=lpcf
->lpLogFont
;
612 TRACE("WM_INITDIALOG lParam=%08lX\n", lParam
);
614 if (lpcf
->lStructSize
!= sizeof(CHOOSEFONTW
))
616 ERR("structure size failure !!!\n");
621 himlTT
= ImageList_LoadImageW( COMDLG32_hInstance
, MAKEINTRESOURCEW(38),
622 TTBITMAP_XSIZE
, 0, CLR_DEFAULT
, IMAGE_BITMAP
, 0);
624 /* Set effect flags */
625 if((lpcf
->Flags
& CF_EFFECTS
) && (lpcf
->Flags
& CF_INITTOLOGFONTSTRUCT
))
627 if(lpxx
->lfUnderline
)
628 CheckDlgButton(hDlg
, chx2
, TRUE
);
629 if(lpxx
->lfStrikeOut
)
630 CheckDlgButton(hDlg
, chx1
, TRUE
);
633 if (!(lpcf
->Flags
& CF_SHOWHELP
) || !IsWindow(lpcf
->hwndOwner
))
634 ShowWindow(GetDlgItem(hDlg
,pshHelp
),SW_HIDE
);
635 if (!(lpcf
->Flags
& CF_APPLY
))
636 ShowWindow(GetDlgItem(hDlg
,psh3
),SW_HIDE
);
637 if (lpcf
->Flags
& CF_NOSCRIPTSEL
)
638 EnableWindow(GetDlgItem(hDlg
,cmb5
),FALSE
);
639 if (lpcf
->Flags
& CF_EFFECTS
)
641 for (i
=0;i
<TEXT_COLORS
;i
++)
645 if( LoadStringW(COMDLG32_hInstance
, IDS_COLOR_BLACK
+i
, name
,
646 sizeof(name
)/sizeof(*name
) )==0 )
648 memcpy(name
, strColorName
, sizeof(strColorName
));
650 j
=SendDlgItemMessageW(hDlg
, cmb4
, CB_ADDSTRING
, 0, (LPARAM
)name
);
651 SendDlgItemMessageW(hDlg
, cmb4
, CB_SETITEMDATA
, j
, textcolors
[i
]);
652 /* look for a fitting value in color combobox */
653 if (textcolors
[i
]==lpcf
->rgbColors
)
654 SendDlgItemMessageW(hDlg
,cmb4
, CB_SETCURSEL
,j
,0);
659 ShowWindow(GetDlgItem(hDlg
,cmb4
),SW_HIDE
);
660 ShowWindow(GetDlgItem(hDlg
,chx1
),SW_HIDE
);
661 ShowWindow(GetDlgItem(hDlg
,chx2
),SW_HIDE
);
662 ShowWindow(GetDlgItem(hDlg
,grp1
),SW_HIDE
);
663 ShowWindow(GetDlgItem(hDlg
,stc4
),SW_HIDE
);
665 if(!(hdc
= CFn_GetDC(lpcf
)))
670 s
.hWnd1
=GetDlgItem(hDlg
,cmb1
);
675 elf
.lfCharSet
= DEFAULT_CHARSET
; /* enum all charsets */
676 elf
.lfPitchAndFamily
= 0;
677 elf
.lfFaceName
[0] = '\0'; /* enum all fonts */
678 if (!EnumFontFamiliesExW(hdc
, &elf
, (FONTENUMPROCW
)FontFamilyEnumProc
, (LPARAM
)&s
, 0))
680 TRACE("EnumFontFamiliesEx returns 0\n");
684 if (lpcf
->Flags
& CF_FIXEDPITCHONLY
) {
685 FIXME("No font found with fixed pitch only, dropping flag.\n");
686 lpcf
->Flags
&= ~CF_FIXEDPITCHONLY
;
689 if (lpcf
->Flags
& CF_TTONLY
) {
690 FIXME("No font found with truetype only, dropping flag.\n");
691 lpcf
->Flags
&= ~CF_TTONLY
;
698 if (lpcf
->Flags
& CF_INITTOLOGFONTSTRUCT
)
700 /* look for fitting font name in combobox1 */
701 j
=SendDlgItemMessageW(hDlg
,cmb1
,CB_FINDSTRING
,-1,(LPARAM
)lpxx
->lfFaceName
);
704 INT height
= lpxx
->lfHeight
< 0 ? -lpxx
->lfHeight
:
707 int charset
= lpxx
->lfCharSet
;
708 points
= MulDiv( height
, 72, GetScreenDPI());
709 pstyle
= MAKELONG(lpxx
->lfWeight
> FW_MEDIUM
? FW_BOLD
:
710 FW_NORMAL
,lpxx
->lfItalic
!=0);
711 SendDlgItemMessageW(hDlg
, cmb1
, CB_SETCURSEL
, j
, 0);
712 SendMessageW(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb1
, CBN_SELCHANGE
),
713 (LPARAM
)GetDlgItem(hDlg
,cmb1
));
715 /* look for fitting font style in combobox2 */
716 CFn_FitFontStyle(hDlg
, pstyle
);
717 /* look for fitting font size in combobox3 */
718 CFn_FitFontSize(hDlg
, points
);
719 CFn_FitCharSet( hDlg
, charset
);
724 SendDlgItemMessageW(hDlg
,cmb1
,CB_SETCURSEL
,0,0);
725 SendMessageW(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb1
, CBN_SELCHANGE
),
726 (LPARAM
)GetDlgItem(hDlg
,cmb1
));
727 SendDlgItemMessageW(hDlg
,cmb2
,CB_SETCURSEL
,0,0);
728 SendMessageW(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb2
, CBN_SELCHANGE
),
729 (LPARAM
)GetDlgItem(hDlg
,cmb1
));
730 SendDlgItemMessageW(hDlg
,cmb3
,CB_SETCURSEL
,0,0);
731 SendMessageW(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb3
, CBN_SELCHANGE
),
732 (LPARAM
)GetDlgItem(hDlg
,cmb3
));
733 SendDlgItemMessageW(hDlg
,cmb5
,CB_SETCURSEL
,0,0);
734 SendMessageW(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb5
, CBN_SELCHANGE
),
735 (LPARAM
)GetDlgItem(hDlg
,cmb5
));
737 if ((lpcf
->Flags
& CF_USESTYLE
) && lpcf
->lpszStyle
)
739 j
=SendDlgItemMessageW(hDlg
,cmb2
,CB_FINDSTRING
,-1,(LPARAM
)lpcf
->lpszStyle
);
742 j
=SendDlgItemMessageW(hDlg
,cmb2
,CB_SETCURSEL
,j
,0);
743 SendMessageW(hDlg
,WM_COMMAND
,cmb2
,
744 MAKELONG(LOWORD(GetDlgItem(hDlg
,cmb2
)),CBN_SELCHANGE
));
747 CFn_ReleaseDC(lpcf
, hdc
);
753 /***********************************************************************
754 * CFn_WMMeasureItem [internal]
756 static LRESULT
CFn_WMMeasureItem(HWND hDlg
, LPARAM lParam
)
761 LPMEASUREITEMSTRUCT lpmi
=(LPMEASUREITEMSTRUCT
)lParam
;
765 himlTT
= ImageList_LoadImageW( COMDLG32_hInstance
, MAKEINTRESOURCEW(38),
766 TTBITMAP_XSIZE
, 0, CLR_DEFAULT
, IMAGE_BITMAP
, 0);
767 ImageList_GetIconSize( himlTT
, &cx
, &height
);
768 lpmi
->itemHeight
= height
+ 2;
769 /* use MAX of bitmap height and tm.tmHeight .*/
772 hfontprev
= SelectObject( hdc
, (HFONT
)SendMessageW( hDlg
, WM_GETFONT
, 0, 0 ));
773 GetTextMetricsW(hdc
, &tm
);
774 if( tm
.tmHeight
> lpmi
->itemHeight
) lpmi
->itemHeight
= tm
.tmHeight
;
775 SelectObject(hdc
, hfontprev
);
776 ReleaseDC(hDlg
, hdc
);
781 /***********************************************************************
782 * CFn_WMDrawItem [internal]
784 static LRESULT
CFn_WMDrawItem(LPARAM lParam
)
788 COLORREF cr
, oldText
=0, oldBk
=0;
792 LPDRAWITEMSTRUCT lpdi
= (LPDRAWITEMSTRUCT
)lParam
;
794 if (lpdi
->itemID
== (UINT
)-1) /* got no items */
795 DrawFocusRect(lpdi
->hDC
, &lpdi
->rcItem
);
798 if (lpdi
->CtlType
== ODT_COMBOBOX
)
800 if (lpdi
->itemState
& ODS_SELECTED
)
802 hBrush
=GetSysColorBrush(COLOR_HIGHLIGHT
);
803 oldText
=SetTextColor(lpdi
->hDC
, GetSysColor(COLOR_HIGHLIGHTTEXT
));
804 oldBk
=SetBkColor(lpdi
->hDC
, GetSysColor(COLOR_HIGHLIGHT
));
807 hBrush
= SelectObject(lpdi
->hDC
, GetStockObject(LTGRAY_BRUSH
));
808 SelectObject(lpdi
->hDC
, hBrush
);
810 FillRect(lpdi
->hDC
, &lpdi
->rcItem
, hBrush
);
813 return TRUE
; /* this should never happen */
819 /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
820 ImageList_GetIconSize( himlTT
, &cx
, &cy
);
821 SendMessageW(lpdi
->hwndItem
, CB_GETLBTEXT
, lpdi
->itemID
,
823 TextOutW(lpdi
->hDC
, lpdi
->rcItem
.left
+ cx
+ 4,
824 lpdi
->rcItem
.top
, buffer
, lstrlenW(buffer
));
825 nFontType
= SendMessageW(lpdi
->hwndItem
, CB_GETITEMDATA
, lpdi
->itemID
,0L);
827 if (nFontType
& TRUETYPE_FONTTYPE
) {
828 idx
= 0; /* picture: TT */
829 if( nFontType
& NTM_TT_OPENTYPE
)
830 idx
= 2; /* picture: O */
831 } else if( nFontType
& NTM_PS_OPENTYPE
)
832 idx
= 3; /* picture: O+ps */
833 else if( nFontType
& NTM_TYPE1
)
834 idx
= 4; /* picture: a */
835 else if( nFontType
& DEVICE_FONTTYPE
)
836 idx
= 1; /* picture: printer */
838 ImageList_Draw( himlTT
, idx
, lpdi
->hDC
, lpdi
->rcItem
.left
,
839 (lpdi
->rcItem
.top
+ lpdi
->rcItem
.bottom
- cy
) / 2, ILD_TRANSPARENT
);
843 /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
845 SendMessageW(lpdi
->hwndItem
, CB_GETLBTEXT
, lpdi
->itemID
,
847 TextOutW(lpdi
->hDC
, lpdi
->rcItem
.left
,
848 lpdi
->rcItem
.top
, buffer
, lstrlenW(buffer
));
852 /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
853 SendMessageW(lpdi
->hwndItem
, CB_GETLBTEXT
, lpdi
->itemID
,
855 TextOutW(lpdi
->hDC
, lpdi
->rcItem
.left
+ 25+5,
856 lpdi
->rcItem
.top
, buffer
, lstrlenW(buffer
));
857 cr
= SendMessageW(lpdi
->hwndItem
, CB_GETITEMDATA
, lpdi
->itemID
,0L);
858 hBrush
= CreateSolidBrush(cr
);
861 hBrush
= SelectObject (lpdi
->hDC
, hBrush
) ;
862 rect
.right
=rect
.left
+25;
866 Rectangle( lpdi
->hDC
, rect
.left
, rect
.top
,
867 rect
.right
, rect
.bottom
);
868 DeleteObject( SelectObject (lpdi
->hDC
, hBrush
)) ;
875 return TRUE
; /* this should never happen */
877 if (lpdi
->itemState
& ODS_SELECTED
)
879 SetTextColor(lpdi
->hDC
, oldText
);
880 SetBkColor(lpdi
->hDC
, oldBk
);
886 /***********************************************************************
887 * CFn_WMCommand [internal]
889 static LRESULT
CFn_WMCommand(HWND hDlg
, WPARAM wParam
, LPARAM lParam
, LPCHOOSEFONTW lpcf
)
895 if (!lpcf
) return FALSE
;
897 TRACE("WM_COMMAND wParam=%08X lParam=%08lX\n", (LONG
)wParam
, lParam
);
898 switch (LOWORD(wParam
))
901 if (HIWORD(wParam
)==CBN_SELCHANGE
)
903 INT pointsize
; /* save current pointsize */
904 LONG pstyle
; /* save current style */
907 if(!(hdc
= CFn_GetDC(lpcf
)))
912 idx
= SendDlgItemMessageW(hDlg
, cmb3
, CB_GETCURSEL
, 0, 0);
913 pointsize
= (int)SendDlgItemMessageW( hDlg
, cmb3
, CB_GETITEMDATA
,
915 idx
= SendDlgItemMessageW(hDlg
, cmb2
, CB_GETCURSEL
, 0, 0);
916 pstyle
= SendDlgItemMessageW(hDlg
, cmb2
, CB_GETITEMDATA
, idx
, 0);
917 idx
= SendDlgItemMessageW(hDlg
, cmb5
, CB_GETCURSEL
, 0, 0);
918 charset
= SendDlgItemMessageW(hDlg
, cmb5
, CB_GETITEMDATA
, idx
, 0);
920 SendDlgItemMessageW(hDlg
, cmb2
, CB_RESETCONTENT
, 0, 0);
921 SendDlgItemMessageW(hDlg
, cmb3
, CB_RESETCONTENT
, 0, 0);
922 SendDlgItemMessageW(hDlg
, cmb5
, CB_RESETCONTENT
, 0, 0);
923 i
=SendDlgItemMessageW(hDlg
, cmb1
, CB_GETCURSEL
, 0, 0);
926 HCURSOR hcursor
=SetCursor(LoadCursorW(0,(LPWSTR
)IDC_WAIT
));
929 SendDlgItemMessageW(hDlg
, cmb1
, CB_GETLBTEXT
, i
,
930 (LPARAM
)enumlf
.lfFaceName
);
931 TRACE("WM_COMMAND/cmb1 =>%s\n", debugstr_w(enumlf
.lfFaceName
));
932 s
.hWnd1
=GetDlgItem(hDlg
, cmb2
);
933 s
.hWnd2
=GetDlgItem(hDlg
, cmb3
);
935 enumlf
.lfCharSet
= DEFAULT_CHARSET
; /* enum all charsets */
936 enumlf
.lfPitchAndFamily
= 0;
937 EnumFontFamiliesExW(hdc
, &enumlf
,
938 (FONTENUMPROCW
)FontStyleEnumProc
, (LPARAM
)&s
, 0);
939 CFn_FitFontStyle(hDlg
, pstyle
);
940 if( pointsize
!= CB_ERR
) CFn_FitFontSize(hDlg
, pointsize
);
941 if( charset
!= CB_ERR
) CFn_FitCharSet( hDlg
, charset
);
944 CFn_ReleaseDC(lpcf
, hdc
);
952 if (HIWORD(wParam
)==CBN_SELCHANGE
|| HIWORD(wParam
)== BN_CLICKED
)
956 LPLOGFONTW lpxx
=lpcf
->lpLogFont
;
958 TRACE("WM_COMMAND/cmb2,3 =%08lX\n", lParam
);
959 i
=SendDlgItemMessageW(hDlg
,cmb1
,CB_GETCURSEL
,0,0);
961 i
=GetDlgItemTextW( hDlg
, cmb1
, str
, 256 );
964 SendDlgItemMessageW(hDlg
,cmb1
,CB_GETLBTEXT
,i
,
966 l
=SendDlgItemMessageW(hDlg
,cmb1
,CB_GETITEMDATA
,i
,0);
967 lpcf
->nFontType
= LOWORD(l
);
968 /* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
969 /* same value reported to the EnumFonts
970 call back with the extra FONTTYPE_... bits added */
971 lpxx
->lfPitchAndFamily
= HIWORD(l
) >> 8;
973 lstrcpynW(lpxx
->lfFaceName
, str
, sizeof(lpxx
->lfFaceName
)/sizeof(lpxx
->lfFaceName
[0]));
974 i
=SendDlgItemMessageW(hDlg
, cmb2
, CB_GETCURSEL
, 0, 0);
977 l
=SendDlgItemMessageW(hDlg
, cmb2
, CB_GETITEMDATA
, i
, 0);
978 if (0!=(lpxx
->lfItalic
=HIWORD(l
)))
979 lpcf
->nFontType
|= ITALIC_FONTTYPE
;
980 if ((lpxx
->lfWeight
=LOWORD(l
)) > FW_MEDIUM
)
981 lpcf
->nFontType
|= BOLD_FONTTYPE
;
983 i
=SendDlgItemMessageW(hDlg
, cmb3
, CB_GETCURSEL
, 0, 0);
985 lpcf
->iPointSize
= 10 * LOWORD(SendDlgItemMessageW(hDlg
, cmb3
,
986 CB_GETITEMDATA
, i
, 0));
988 lpcf
->iPointSize
= 100;
989 lpxx
->lfHeight
= - MulDiv( lpcf
->iPointSize
,
990 GetScreenDPI(), 720);
991 i
=SendDlgItemMessageW(hDlg
, cmb5
, CB_GETCURSEL
, 0, 0);
993 lpxx
->lfCharSet
=SendDlgItemMessageW(hDlg
, cmb5
, CB_GETITEMDATA
, i
, 0);
995 lpxx
->lfCharSet
= DEFAULT_CHARSET
;
996 lpxx
->lfStrikeOut
=IsDlgButtonChecked(hDlg
,chx1
);
997 lpxx
->lfUnderline
=IsDlgButtonChecked(hDlg
,chx2
);
998 lpxx
->lfWidth
=lpxx
->lfOrientation
=lpxx
->lfEscapement
=0;
999 lpxx
->lfOutPrecision
=OUT_DEFAULT_PRECIS
;
1000 lpxx
->lfClipPrecision
=CLIP_DEFAULT_PRECIS
;
1001 lpxx
->lfQuality
=DEFAULT_QUALITY
;
1003 wininfo
.cbSize
=sizeof(wininfo
);
1005 if( GetWindowInfo( GetDlgItem( hDlg
, stc5
), &wininfo
) )
1007 MapWindowPoints( 0, hDlg
, (LPPOINT
) &wininfo
.rcWindow
, 2);
1008 InvalidateRect( hDlg
, &wininfo
.rcWindow
, TRUE
);
1014 i
=SendDlgItemMessageW(hDlg
, cmb4
, CB_GETCURSEL
, 0, 0);
1019 lpcf
->rgbColors
= SendDlgItemMessageW(hDlg
, cmb4
, CB_GETITEMDATA
, i
, 0);
1020 wininfo
.cbSize
=sizeof(wininfo
);
1022 if( GetWindowInfo( GetDlgItem( hDlg
, stc5
), &wininfo
) )
1024 MapWindowPoints( 0, hDlg
, (LPPOINT
) &wininfo
.rcWindow
, 2);
1025 InvalidateRect( hDlg
, &wininfo
.rcWindow
, TRUE
);
1031 i
=RegisterWindowMessageW( HELPMSGSTRINGW
);
1032 if (lpcf
->hwndOwner
)
1033 SendMessageW(lpcf
->hwndOwner
, i
, 0, (LPARAM
)GetPropW(hDlg
, strWineFontData
));
1037 if ( (!(lpcf
->Flags
& CF_LIMITSIZE
)) ||
1038 ( (lpcf
->Flags
& CF_LIMITSIZE
) &&
1039 (lpcf
->iPointSize
>= 10 * lpcf
->nSizeMin
) &&
1040 (lpcf
->iPointSize
<= 10 * lpcf
->nSizeMax
)))
1041 EndDialog(hDlg
, TRUE
);
1047 LoadStringW(COMDLG32_hInstance
, IDS_FONT_SIZE
, format
, sizeof(format
)/sizeof(WCHAR
));
1048 args
[0] = lpcf
->nSizeMin
;
1049 args
[1] = lpcf
->nSizeMax
;
1050 FormatMessageW(FORMAT_MESSAGE_FROM_STRING
|FORMAT_MESSAGE_ARGUMENT_ARRAY
,
1051 format
, 0, 0, buffer
, sizeof(buffer
)/sizeof(*buffer
),
1052 (__ms_va_list
*)args
);
1053 MessageBoxW(hDlg
, buffer
, NULL
, MB_OK
);
1057 EndDialog(hDlg
, FALSE
);
1063 static LRESULT
CFn_WMDestroy(HWND hwnd
, LPCHOOSEFONTW lpcfw
)
1065 LPCHOOSEFONTA lpcfa
;
1067 LPLOGFONTA lpLogFonta
;
1070 if (!lpcfw
) return FALSE
;
1072 lpcfa
= GetPropW(hwnd
, strWineFontData_a
);
1073 lpLogFonta
= lpcfa
->lpLogFont
;
1074 lpszStyle
= lpcfa
->lpszStyle
;
1075 memcpy(lpcfa
, lpcfw
, sizeof(CHOOSEFONTA
));
1076 lpcfa
->lpLogFont
= lpLogFonta
;
1077 lpcfa
->lpszStyle
= lpszStyle
;
1078 memcpy(lpcfa
->lpLogFont
, lpcfw
->lpLogFont
, sizeof(LOGFONTA
));
1079 WideCharToMultiByte(CP_ACP
, 0, lpcfw
->lpLogFont
->lfFaceName
,
1080 LF_FACESIZE
, lpcfa
->lpLogFont
->lfFaceName
, LF_FACESIZE
, 0, 0);
1082 if((lpcfw
->Flags
& CF_USESTYLE
) && lpcfw
->lpszStyle
) {
1083 len
= WideCharToMultiByte(CP_ACP
, 0, lpcfw
->lpszStyle
, -1, NULL
, 0, 0, 0);
1084 WideCharToMultiByte(CP_ACP
, 0, lpcfw
->lpszStyle
, -1, lpcfa
->lpszStyle
, len
, 0, 0);
1085 HeapFree(GetProcessHeap(), 0, lpcfw
->lpszStyle
);
1088 HeapFree(GetProcessHeap(), 0, lpcfw
->lpLogFont
);
1089 HeapFree(GetProcessHeap(), 0, lpcfw
);
1090 SetPropW(hwnd
, strWineFontData
, 0);
1095 static LRESULT
CFn_WMPaint(HWND hDlg
, WPARAM wParam
, LPARAM lParam
, const CHOOSEFONTW
*lpcf
)
1099 if (!lpcf
) return FALSE
;
1101 info
.cbSize
=sizeof(info
);
1102 if( GetWindowInfo( GetDlgItem( hDlg
, stc5
), &info
) )
1107 LOGFONTW lf
= *(lpcf
->lpLogFont
);
1109 MapWindowPoints( 0, hDlg
, (LPPOINT
) &info
.rcWindow
, 2);
1110 hdc
= BeginPaint( hDlg
, &ps
);
1112 TRACE("erase %d, rect=(%d,%d)-(%d,%d)\n", ps
.fErase
,
1113 ps
.rcPaint
.left
, ps
.rcPaint
.top
,
1114 ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
1117 DrawEdge( hdc
, &info
.rcWindow
, EDGE_SUNKEN
, BF_RECT
|BF_ADJUST
);
1119 /* Draw the sample text itself */
1120 hOrigFont
= SelectObject( hdc
, CreateFontIndirectW( &lf
) );
1121 SetTextColor( hdc
, lpcf
->rgbColors
);
1124 sample_lang_text
[CHARSET_ORDER
[lpcf
->lpLogFont
->lfCharSet
]],
1125 -1, &info
.rcWindow
, DT_CENTER
|DT_VCENTER
|DT_SINGLELINE
);
1127 DeleteObject(SelectObject( hdc
, hOrigFont
));
1128 EndPaint( hDlg
, &ps
);
1133 /***********************************************************************
1134 * FormatCharDlgProcA [internal]
1136 static INT_PTR CALLBACK
FormatCharDlgProcA(HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1138 LPCHOOSEFONTW lpcfw
;
1139 LPCHOOSEFONTA lpcfa
;
1140 INT_PTR res
= FALSE
;
1143 if (uMsg
!=WM_INITDIALOG
) {
1144 lpcfw
= GetPropW(hDlg
, strWineFontData
);
1145 if (lpcfw
&& CFn_HookCallChk32(lpcfw
))
1146 res
=CallWindowProcA((WNDPROC
)lpcfw
->lpfnHook
, hDlg
, uMsg
, wParam
, lParam
);
1150 lpcfa
=(LPCHOOSEFONTA
)lParam
;
1151 SetPropW(hDlg
, strWineFontData_a
, (HANDLE
)lParam
);
1153 lpcfw
= HeapAlloc(GetProcessHeap(), 0, sizeof(CHOOSEFONTW
));
1154 memcpy(lpcfw
, lpcfa
, sizeof(CHOOSEFONTA
));
1155 lpcfw
->lpLogFont
= HeapAlloc(GetProcessHeap(), 0, sizeof(LOGFONTW
));
1156 memcpy(lpcfw
->lpLogFont
, lpcfa
->lpLogFont
, sizeof(LOGFONTA
));
1157 MultiByteToWideChar(CP_ACP
, 0, lpcfa
->lpLogFont
->lfFaceName
,
1158 LF_FACESIZE
, lpcfw
->lpLogFont
->lfFaceName
, LF_FACESIZE
);
1160 if((lpcfa
->Flags
& CF_USESTYLE
) && lpcfa
->lpszStyle
) {
1161 len
= MultiByteToWideChar(CP_ACP
, 0, lpcfa
->lpszStyle
, -1, NULL
, 0);
1162 lpcfw
->lpszStyle
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
1163 MultiByteToWideChar(CP_ACP
, 0, lpcfa
->lpszStyle
, -1, lpcfw
->lpszStyle
, len
);
1166 if (!CFn_WMInitDialog(hDlg
, lParam
, lpcfw
))
1168 TRACE("CFn_WMInitDialog returned FALSE\n");
1171 if (CFn_HookCallChk32(lpcfw
))
1172 return CallWindowProcA((WNDPROC
)lpcfa
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
1176 case WM_MEASUREITEM
:
1177 return CFn_WMMeasureItem(hDlg
,lParam
);
1179 return CFn_WMDrawItem(lParam
);
1181 return CFn_WMCommand(hDlg
, wParam
, lParam
, lpcfw
);
1183 return CFn_WMDestroy(hDlg
, lpcfw
);
1184 case WM_CHOOSEFONT_GETLOGFONT
:
1186 LOGFONTA
*logfont
= (LOGFONTA
*)lParam
;
1187 TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n", lParam
);
1188 memcpy( logfont
, lpcfw
->lpLogFont
, FIELD_OFFSET( LOGFONTA
, lfFaceName
));
1189 WideCharToMultiByte( CP_ACP
, 0, lpcfw
->lpLogFont
->lfFaceName
, LF_FACESIZE
,
1190 logfont
->lfFaceName
, LF_FACESIZE
, NULL
, NULL
);
1194 return CFn_WMPaint(hDlg
, wParam
, lParam
, lpcfw
);
1199 /***********************************************************************
1200 * FormatCharDlgProcW [internal]
1202 static INT_PTR CALLBACK
FormatCharDlgProcW(HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1205 INT_PTR res
= FALSE
;
1207 if (uMsg
!=WM_INITDIALOG
)
1209 lpcf
= GetPropW(hDlg
, strWineFontData
);
1210 if (lpcf
&& CFn_HookCallChk32(lpcf
))
1211 res
=CallWindowProcW((WNDPROC
)lpcf
->lpfnHook
, hDlg
, uMsg
, wParam
, lParam
);
1217 lpcf
=(LPCHOOSEFONTW
)lParam
;
1218 if (!CFn_WMInitDialog(hDlg
, lParam
, lpcf
))
1220 TRACE("CFn_WMInitDialog returned FALSE\n");
1223 if (CFn_HookCallChk32(lpcf
))
1224 return CallWindowProcW((WNDPROC
)lpcf
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
1228 case WM_MEASUREITEM
:
1229 return CFn_WMMeasureItem(hDlg
, lParam
);
1231 return CFn_WMDrawItem(lParam
);
1233 return CFn_WMCommand(hDlg
, wParam
, lParam
, lpcf
);
1236 case WM_CHOOSEFONT_GETLOGFONT
:
1237 TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n", lParam
);
1238 memcpy( (LOGFONTW
*)lParam
, lpcf
->lpLogFont
, sizeof(LOGFONTW
) );
1241 return CFn_WMPaint(hDlg
, wParam
, lParam
, lpcf
);