Unicodified fontdlg.

This commit is contained in:
Jacek Caban 2004-12-22 17:17:06 +00:00 committed by Alexandre Julliard
parent 4fa1d6bba7
commit 417fde8d42
3 changed files with 326 additions and 252 deletions

View File

@ -199,26 +199,25 @@ typedef struct
{
HWND hWnd1;
HWND hWnd2;
LPCHOOSEFONTA lpcf32a;
LPCHOOSEFONTW lpcf32w;
int added;
} CFn_ENUMSTRUCT, *LPCFn_ENUMSTRUCT;
INT AddFontFamily(const ENUMLOGFONTEXA *lpElfex, const NEWTEXTMETRICEXA *lpNTM,
UINT nFontType, LPCHOOSEFONTA lpcf, HWND hwnd,
INT AddFontFamily(const ENUMLOGFONTEXW *lpElfex, const NEWTEXTMETRICEXW *lpNTM,
UINT nFontType, LPCHOOSEFONTW lpcf, HWND hwnd,
LPCFn_ENUMSTRUCT e);
INT AddFontStyle(const ENUMLOGFONTEXA *lpElfex, const NEWTEXTMETRICEXA *metrics,
UINT nFontType, LPCHOOSEFONTA lpcf, HWND hcmb2, HWND hcmb3,
INT AddFontStyle(const ENUMLOGFONTEXW *lpElfex, const NEWTEXTMETRICEXW *metrics,
UINT nFontType, LPCHOOSEFONTW lpcf, HWND hcmb2, HWND hcmb3,
HWND hDlg, BOOL iswin16);
void _dump_cf_flags(DWORD cflags);
LRESULT CFn_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam,
LPCHOOSEFONTA lpcf);
LPCHOOSEFONTW lpcf);
LRESULT CFn_WMMeasureItem(HWND hDlg, WPARAM wParam, LPARAM lParam);
LRESULT CFn_WMDrawItem(HWND hDlg, WPARAM wParam, LPARAM lParam);
LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam,
LPCHOOSEFONTA lpcf);
LPCHOOSEFONTW lpcf);
LRESULT CFn_WMPaint(HWND hDlg, WPARAM wParam, LPARAM lParam,
LPCHOOSEFONTA lpcf);
LRESULT CFn_WMDestroy(HWND hwnd, WPARAM wParam, LPARAM lParam);
LPCHOOSEFONTW lpcf);
#endif /* _WINE_DLL_CDLG_H */

View File

@ -36,7 +36,10 @@
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
#define WINE_FONTDATA "__WINE_FONTDLGDATA"
static const WCHAR strWineFontData[] = {'_','_','W','I','N','E','_','F','O','N','T','D','L','G','D','A','T','A',0};
static const WCHAR strWineFontData_a[] =
{'_','_','W','I','N','E','_','F','O','N','T','D','L','G','D','A','T','A','_','A',0};
static const WCHAR chooseFontW[] = {'C','H','O','O','S','E','_','F','O','N','T',0};
#include "cdlg.h"
@ -44,11 +47,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
static HIMAGELIST himlTT = 0;
#define TTBITMAP_XSIZE 20 /* x-size of the bitmaps */
INT_PTR CALLBACK FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam);
INT_PTR CALLBACK FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam);
INT_PTR CALLBACK FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
/* There is a table here of all charsets, and the sample text for each.
* There is a second table that translates a charset into an index into
@ -168,8 +168,7 @@ BOOL WINAPI ChooseFontW(LPCHOOSEFONTW lpChFont)
HINSTANCE hDlginst;
HGLOBAL hDlgTmpl;
static const WCHAR chooseFontW[] = {'C','H','O','O','S','E','_',
'F','O','N','T',0};
TRACE("(%p)\n", lpChFont);
if ( (lpChFont->Flags&CF_ENABLETEMPLATEHANDLE)!=0 )
{
@ -221,6 +220,8 @@ BOOL WINAPI ChooseFontA(LPCHOOSEFONTA lpChFont)
HINSTANCE hDlginst;
HGLOBAL hDlgTmpl;
TRACE("(%p)\n", lpChFont);
if ( (lpChFont->Flags&CF_ENABLETEMPLATEHANDLE)!=0 )
{
template=(LPCVOID)lpChFont->hInstance;
@ -238,7 +239,7 @@ BOOL WINAPI ChooseFontA(LPCHOOSEFONTA lpChFont)
} else
{
hDlginst=COMDLG32_hInstance;
if (!(hResInfo = FindResourceA(hDlginst, "CHOOSE_FONT", (LPSTR)RT_DIALOG)))
if (!(hResInfo = FindResourceW(hDlginst, chooseFontW, (LPWSTR)RT_DIALOG)))
{
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
return FALSE;
@ -253,7 +254,6 @@ BOOL WINAPI ChooseFontA(LPCHOOSEFONTA lpChFont)
}
if (TRACE_ON(commdlg))
_dump_cf_flags(lpChFont->Flags);
if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS ))
FIXME(": unimplemented flag (ignored)\n");
@ -261,7 +261,6 @@ BOOL WINAPI ChooseFontA(LPCHOOSEFONTA lpChFont)
lpChFont->hwndOwner, FormatCharDlgProcA, (LPARAM)lpChFont );
}
#define TEXT_EXTRAS 4
#define TEXT_COLORS 16
@ -276,7 +275,7 @@ static const COLORREF textcolors[TEXT_COLORS]=
/***********************************************************************
* CFn_HookCallChk32 [internal]
*/
static BOOL CFn_HookCallChk32(LPCHOOSEFONTA lpcf)
static BOOL CFn_HookCallChk32(LPCHOOSEFONTW lpcf)
{
if (lpcf)
if(lpcf->Flags & CF_ENABLEHOOK)
@ -288,14 +287,14 @@ static BOOL CFn_HookCallChk32(LPCHOOSEFONTA lpcf)
/*************************************************************************
* AddFontFamily [internal]
*/
INT AddFontFamily(const ENUMLOGFONTEXA *lpElfex, const NEWTEXTMETRICEXA *lpNTM,
UINT nFontType, LPCHOOSEFONTA lpcf, HWND hwnd, LPCFn_ENUMSTRUCT e)
INT AddFontFamily(const ENUMLOGFONTEXW *lpElfex, const NEWTEXTMETRICEXW *lpNTM,
UINT nFontType, LPCHOOSEFONTW lpcf, HWND hwnd, LPCFn_ENUMSTRUCT e)
{
int i;
WORD w;
const LOGFONTA *lplf = &(lpElfex->elfLogFont);
const LOGFONTW *lplf = &(lpElfex->elfLogFont);
TRACE("font=%s (nFontType=%d)\n", lplf->lfFaceName,nFontType);
TRACE("font=%s (nFontType=%d)\n", debugstr_w(lplf->lfFaceName), nFontType);
if (lpcf->Flags & CF_FIXEDPITCHONLY)
if (!(lplf->lfPitchAndFamily & FIXED_PITCH))
@ -309,14 +308,14 @@ INT AddFontFamily(const ENUMLOGFONTEXA *lpElfex, const NEWTEXTMETRICEXA *lpNTM,
if (e) e->added++;
i=SendMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)lplf->lfFaceName);
i=SendMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)lplf->lfFaceName);
if (i == CB_ERR) {
i = SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)lplf->lfFaceName);
i = SendMessageW(hwnd, CB_ADDSTRING, 0, (LPARAM)lplf->lfFaceName);
if( i != CB_ERR) {
/* store some important font information */
w = (lplf->lfPitchAndFamily) << 8 |
(HIWORD(lpNTM->ntmTm.ntmFlags) & 0xff);
SendMessageA(hwnd, CB_SETITEMDATA, i, MAKELONG(nFontType,w));
SendMessageW(hwnd, CB_SETITEMDATA, i, MAKELONG(nFontType,w));
}
}
return 1;
@ -325,13 +324,13 @@ INT AddFontFamily(const ENUMLOGFONTEXA *lpElfex, const NEWTEXTMETRICEXA *lpNTM,
/*************************************************************************
* FontFamilyEnumProc32 [internal]
*/
static INT WINAPI FontFamilyEnumProc(const ENUMLOGFONTEXA *lpElfex,
const TEXTMETRICA *metrics, DWORD dwFontType, LPARAM lParam)
static INT WINAPI FontFamilyEnumProc(const ENUMLOGFONTEXW *lpElfex,
const TEXTMETRICW *metrics, DWORD dwFontType, LPARAM lParam)
{
LPCFn_ENUMSTRUCT e;
e=(LPCFn_ENUMSTRUCT)lParam;
return AddFontFamily( lpElfex, (NEWTEXTMETRICEXA *) metrics,
dwFontType, e->lpcf32a, e->hWnd1, e);
return AddFontFamily( lpElfex, (NEWTEXTMETRICEXW *) metrics,
dwFontType, e->lpcf32w, e->hWnd1, e);
}
/*************************************************************************
@ -339,42 +338,48 @@ static INT WINAPI FontFamilyEnumProc(const ENUMLOGFONTEXA *lpElfex,
*
* Fill font style information into combobox (without using font.c directly)
*/
static int SetFontStylesToCombo2(HWND hwnd, HDC hdc, const LOGFONTA *lplf)
static int SetFontStylesToCombo2(HWND hwnd, HDC hdc, const LOGFONTW *lplf)
{
#define FSTYLES 4
struct FONTSTYLE
{
int italic;
int weight;
const char *stname;
const WCHAR *stname;
};
static const WCHAR strRegular[] = {'R','e','g','u','l','a','r',0};
static const WCHAR strItalic[] = {'I','t','a','l','i','c',0};
static const WCHAR strBold[] = {'B','o','l','d',0};
static const WCHAR strBoldItalic[] = {'B','o','l','d',' ','I','t','a','l','i','c',0};
static const struct FONTSTYLE fontstyles[FSTYLES]={
{ 0,FW_NORMAL,"Regular"}, { 1,FW_NORMAL,"Italic"},
{ 0,FW_BOLD,"Bold"}, { 1,FW_BOLD,"Bold Italic"}
{ 0, FW_NORMAL, strRegular },
{ 1, FW_NORMAL, strItalic },
{ 0, FW_BOLD, strBold },
{ 1, FW_BOLD, strBoldItalic }
};
HFONT hf;
TEXTMETRICA tm;
TEXTMETRICW tm;
int i,j;
LOGFONTA lf;
LOGFONTW lf;
memcpy(&lf, lplf, sizeof(LOGFONTA));
memcpy(&lf, lplf, sizeof(LOGFONTW));
for (i=0;i<FSTYLES;i++)
{
lf.lfItalic=fontstyles[i].italic;
lf.lfWeight=fontstyles[i].weight;
hf=CreateFontIndirectA(&lf);
hf=CreateFontIndirectW(&lf);
hf=SelectObject(hdc,hf);
GetTextMetricsA(hdc,&tm);
GetTextMetricsW(hdc,&tm);
hf=SelectObject(hdc,hf);
DeleteObject(hf);
/* font successful created ? */
if (tm.tmWeight==fontstyles[i].weight &&
((tm.tmItalic != 0)==fontstyles[i].italic))
{
j=SendMessageA(hwnd,CB_ADDSTRING,0,(LPARAM)fontstyles[i].stname );
j=SendMessageW(hwnd,CB_ADDSTRING,0,(LPARAM)fontstyles[i].stname );
if (j==CB_ERR) return 1;
j=SendMessageA(hwnd, CB_SETITEMDATA, j,
j=SendMessageW(hwnd, CB_SETITEMDATA, j,
MAKELONG(fontstyles[i].weight,fontstyles[i].italic));
if (j==CB_ERR) return 1;
}
@ -385,7 +390,7 @@ static int SetFontStylesToCombo2(HWND hwnd, HDC hdc, const LOGFONTA *lplf)
/*************************************************************************
* AddFontSizeToCombo3 [internal]
*/
static int AddFontSizeToCombo3(HWND hwnd, UINT h, LPCHOOSEFONTA lpcf)
static int AddFontSizeToCombo3(HWND hwnd, UINT h, LPCHOOSEFONTW lpcf)
{
int j;
char buffer[20];
@ -398,7 +403,7 @@ static int AddFontSizeToCombo3(HWND hwnd, UINT h, LPCHOOSEFONTA lpcf)
if (j==CB_ERR)
{
j=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)buffer);
if (j!=CB_ERR) j = SendMessageA(hwnd, CB_SETITEMDATA, j, h);
if (j!=CB_ERR) j = SendMessageW(hwnd, CB_SETITEMDATA, j, h);
if (j==CB_ERR) return 1;
}
}
@ -408,9 +413,9 @@ static int AddFontSizeToCombo3(HWND hwnd, UINT h, LPCHOOSEFONTA lpcf)
/*************************************************************************
* SetFontSizesToCombo3 [internal]
*/
static int SetFontSizesToCombo3(HWND hwnd, LPCHOOSEFONTA lpcf)
static int SetFontSizesToCombo3(HWND hwnd, LPCHOOSEFONTW lpcf)
{
static const char sizes[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
static const BYTE sizes[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
int i;
for (i = 0; i < sizeof(sizes)/sizeof(sizes[0]); i++)
@ -421,7 +426,7 @@ static int SetFontSizesToCombo3(HWND hwnd, LPCHOOSEFONTA lpcf)
/*************************************************************************
* CFn_GetDC [internal]
*/
inline HDC CFn_GetDC(LPCHOOSEFONTA lpcf)
inline HDC CFn_GetDC(LPCHOOSEFONTW lpcf)
{
HDC ret = ((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC) ?
lpcf->hDC :
@ -433,7 +438,7 @@ inline HDC CFn_GetDC(LPCHOOSEFONTA lpcf)
/*************************************************************************
* CFn_ReleaseDC [internal]
*/
inline void CFn_ReleaseDC(LPCHOOSEFONTA lpcf, HDC hdc)
inline void CFn_ReleaseDC(LPCHOOSEFONTW lpcf, HDC hdc)
{
if(!((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC))
ReleaseDC(0, hdc);
@ -442,19 +447,19 @@ inline void CFn_ReleaseDC(LPCHOOSEFONTA lpcf, HDC hdc)
/***********************************************************************
* AddFontStyle [internal]
*/
INT AddFontStyle( const ENUMLOGFONTEXA *lpElfex, const NEWTEXTMETRICEXA *lpNTM,
UINT nFontType, LPCHOOSEFONTA lpcf, HWND hcmb2, HWND hcmb3,
INT AddFontStyle( const ENUMLOGFONTEXW *lpElfex, const NEWTEXTMETRICEXW *lpNTM,
UINT nFontType, LPCHOOSEFONTW lpcf, HWND hcmb2, HWND hcmb3,
HWND hDlg, BOOL iswin16)
{
int i;
const LOGFONTA *lplf = &(lpElfex->elfLogFont);
const LOGFONTW *lplf = &(lpElfex->elfLogFont);
HWND hcmb5;
HDC hdc;
TRACE("(nFontType=%d)\n",nFontType);
TRACE(" %s h=%ld w=%ld e=%ld o=%ld wg=%ld i=%d u=%d s=%d"
" ch=%d op=%d cp=%d q=%d pf=%xh\n",
lplf->lfFaceName,lplf->lfHeight,lplf->lfWidth,
debugstr_w(lplf->lfFaceName),lplf->lfHeight,lplf->lfWidth,
lplf->lfEscapement,lplf->lfOrientation,
lplf->lfWeight,lplf->lfItalic,lplf->lfUnderline,
lplf->lfStrikeOut,lplf->lfCharSet, lplf->lfOutPrecision,
@ -467,10 +472,10 @@ INT AddFontStyle( const ENUMLOGFONTEXA *lpElfex, const NEWTEXTMETRICEXA *lpNTM,
72, GetDeviceCaps(hdc, LOGPIXELSY));
CFn_ReleaseDC(lpcf, hdc);
i = AddFontSizeToCombo3(hcmb3, points, lpcf);
if( i) return 0;
if(i) return 0;
} else if (SetFontSizesToCombo3(hcmb3, lpcf)) return 0;
if (!SendMessageA(hcmb2, CB_GETCOUNT, 0, 0))
if (!SendMessageW(hcmb2, CB_GETCOUNT, 0, 0))
{
if(!(hdc = CFn_GetDC(lpcf))) return 0;
i=SetFontStylesToCombo2(hcmb2,hdc,lplf);
@ -479,13 +484,13 @@ INT AddFontStyle( const ENUMLOGFONTEXA *lpElfex, const NEWTEXTMETRICEXA *lpNTM,
return 0;
}
if( iswin16 || !( hcmb5 = GetDlgItem(hDlg, cmb5))) return 1;
i = SendMessageA( hcmb5, CB_FINDSTRINGEXACT, 0,
i = SendMessageW( hcmb5, CB_FINDSTRINGEXACT, 0,
(LPARAM)lpElfex->elfScript);
if( i == CB_ERR) {
i = SendMessageA( hcmb5, CB_ADDSTRING, 0,
i = SendMessageW( hcmb5, CB_ADDSTRING, 0,
(LPARAM)lpElfex->elfScript);
if( i != CB_ERR)
SendMessageA( hcmb5, CB_SETITEMDATA, i, lplf->lfCharSet);
SendMessageW( hcmb5, CB_SETITEMDATA, i, lplf->lfCharSet);
}
return 1 ;
}
@ -495,14 +500,14 @@ static INT CFn_FitFontSize( HWND hDlg, int points)
int i,n;
int ret = 0;
/* look for fitting font size in combobox3 */
n=SendDlgItemMessageA(hDlg, cmb3, CB_GETCOUNT, 0, 0);
n=SendDlgItemMessageW(hDlg, cmb3, CB_GETCOUNT, 0, 0);
for (i=0;i<n;i++)
{
if (points == (int)SendDlgItemMessageA
if (points == (int)SendDlgItemMessageW
(hDlg,cmb3, CB_GETITEMDATA,i,0))
{
SendDlgItemMessageA(hDlg,cmb3,CB_SETCURSEL,i,0);
SendMessageA(hDlg, WM_COMMAND,
SendDlgItemMessageW(hDlg,cmb3,CB_SETCURSEL,i,0);
SendMessageW(hDlg, WM_COMMAND,
MAKEWPARAM(cmb3, CBN_SELCHANGE),
(LPARAM)GetDlgItem(hDlg,cmb3));
ret = 1;
@ -519,11 +524,11 @@ static INT CFn_FitFontStyle( HWND hDlg, LONG packedstyle )
/* look for fitting font style in combobox2 */
for (i=0;i<TEXT_EXTRAS;i++)
{
id =SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0);
id = SendDlgItemMessageW(hDlg, cmb2, CB_GETITEMDATA, i, 0);
if (packedstyle == id)
{
SendDlgItemMessageA(hDlg, cmb2, CB_SETCURSEL, i, 0);
SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb2, CBN_SELCHANGE),
SendDlgItemMessageW(hDlg, cmb2, CB_SETCURSEL, i, 0);
SendMessageW(hDlg, WM_COMMAND, MAKEWPARAM(cmb2, CBN_SELCHANGE),
(LPARAM)GetDlgItem(hDlg,cmb2));
ret = 1;
break;
@ -537,21 +542,21 @@ static INT CFn_FitCharSet( HWND hDlg, int charset )
{
int i,n,cs;
/* look for fitting char set in combobox5 */
n=SendDlgItemMessageA(hDlg, cmb5, CB_GETCOUNT, 0, 0);
n=SendDlgItemMessageW(hDlg, cmb5, CB_GETCOUNT, 0, 0);
for (i=0;i<n;i++)
{
cs =SendDlgItemMessageA(hDlg, cmb5, CB_GETITEMDATA, i, 0);
cs =SendDlgItemMessageW(hDlg, cmb5, CB_GETITEMDATA, i, 0);
if (charset == cs)
{
SendDlgItemMessageA(hDlg, cmb5, CB_SETCURSEL, i, 0);
SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb5, CBN_SELCHANGE),
SendDlgItemMessageW(hDlg, cmb5, CB_SETCURSEL, i, 0);
SendMessageW(hDlg, WM_COMMAND, MAKEWPARAM(cmb5, CBN_SELCHANGE),
(LPARAM)GetDlgItem(hDlg,cmb2));
return 1;
}
}
/* no charset fits: select the first one in the list */
SendDlgItemMessageA(hDlg, cmb5, CB_SETCURSEL, 0, 0);
SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb5, CBN_SELCHANGE),
SendDlgItemMessageW(hDlg, cmb5, CB_SETCURSEL, 0, 0);
SendMessageW(hDlg, WM_COMMAND, MAKEWPARAM(cmb5, CBN_SELCHANGE),
(LPARAM)GetDlgItem(hDlg,cmb2));
return 0;
}
@ -559,42 +564,43 @@ static INT CFn_FitCharSet( HWND hDlg, int charset )
/***********************************************************************
* FontStyleEnumProc32 [internal]
*/
static INT WINAPI FontStyleEnumProc( const ENUMLOGFONTEXA *lpElfex,
const TEXTMETRICA *metrics, DWORD dwFontType, LPARAM lParam )
static INT WINAPI FontStyleEnumProc( const ENUMLOGFONTEXW *lpElfex,
const TEXTMETRICW *metrics, DWORD dwFontType, LPARAM lParam )
{
LPCFn_ENUMSTRUCT s=(LPCFn_ENUMSTRUCT)lParam;
HWND hcmb2=s->hWnd1;
HWND hcmb3=s->hWnd2;
HWND hDlg=GetParent(hcmb3);
return AddFontStyle( lpElfex, (const NEWTEXTMETRICEXA *) metrics,
dwFontType, s->lpcf32a, hcmb2, hcmb3, hDlg, FALSE);
return AddFontStyle( lpElfex, (const NEWTEXTMETRICEXW *) metrics,
dwFontType, s->lpcf32w, hcmb2, hcmb3, hDlg, FALSE);
}
/***********************************************************************
* CFn_WMInitDialog [internal]
*/
LRESULT CFn_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam,
LPCHOOSEFONTA lpcf)
LPCHOOSEFONTW lpcf)
{
HDC hdc;
int i,j,init=0;
long pstyle;
CFn_ENUMSTRUCT s;
LPLOGFONTA lpxx;
HCURSOR hcursor=SetCursor(LoadCursorA(0,(LPSTR)IDC_WAIT));
LPLOGFONTW lpxx;
HCURSOR hcursor=SetCursor(LoadCursorW(0,(LPWSTR)IDC_WAIT));
static const WCHAR strColorName[] = {'[','c','o','l','o','r',' ','n','a','m','e',']',0};
SetPropA(hDlg, WINE_FONTDATA, (HANDLE)lParam);
SetPropW(hDlg, strWineFontData, (HANDLE)lParam);
lpxx=lpcf->lpLogFont;
TRACE("WM_INITDIALOG lParam=%08lX\n", lParam);
if (lpcf->lStructSize != sizeof(CHOOSEFONTA))
if (lpcf->lStructSize != sizeof(CHOOSEFONTW))
{
ERR("structure size failure !!!\n");
EndDialog (hDlg, 0);
return FALSE;
}
if (!himlTT)
himlTT = ImageList_LoadImageA( COMDLG32_hInstance, MAKEINTRESOURCEA(38),
himlTT = ImageList_LoadImageW( COMDLG32_hInstance, MAKEINTRESOURCEW(38),
TTBITMAP_XSIZE, 0, CLR_DEFAULT, IMAGE_BITMAP, 0);
if (!(lpcf->Flags & CF_SHOWHELP) || !IsWindow(lpcf->hwndOwner))
@ -605,18 +611,18 @@ LRESULT CFn_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam,
{
for (i=0;i<TEXT_COLORS;i++)
{
char name[30];
WCHAR name[30];
if( LoadStringA(COMDLG32_hInstance, IDS_COLOR_BLACK+i, name,
if( LoadStringW(COMDLG32_hInstance, IDS_COLOR_BLACK+i, name,
sizeof(name)/sizeof(*name) )==0 )
{
strcpy( name, "[color name]" );
memcpy(name, strColorName, sizeof(strColorName));
}
j=SendDlgItemMessageA(hDlg, cmb4, CB_ADDSTRING, 0, (LPARAM)name);
SendDlgItemMessageA(hDlg, cmb4, CB_SETITEMDATA, j, textcolors[j]);
j=SendDlgItemMessageW(hDlg, cmb4, CB_ADDSTRING, 0, (LPARAM)name);
SendDlgItemMessageW(hDlg, cmb4, CB_SETITEMDATA, j, textcolors[j]);
/* look for a fitting value in color combobox */
if (textcolors[j]==lpcf->rgbColors)
SendDlgItemMessageA(hDlg,cmb4, CB_SETCURSEL,j,0);
SendDlgItemMessageW(hDlg,cmb4, CB_SETCURSEL,j,0);
}
}
else
@ -633,14 +639,14 @@ LRESULT CFn_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam,
return FALSE;
}
s.hWnd1=GetDlgItem(hDlg,cmb1);
s.lpcf32a=lpcf;
s.lpcf32w=lpcf;
do {
LOGFONTA elf;
LOGFONTW elf;
s.added = 0;
elf.lfCharSet = DEFAULT_CHARSET; /* enum all charsets */
elf.lfPitchAndFamily = 0;
elf.lfFaceName[0] = '\0'; /* enum all fonts */
if (!EnumFontFamiliesExA(hdc, &elf, (FONTENUMPROCA)FontFamilyEnumProc, (LPARAM)&s, 0))
if (!EnumFontFamiliesExW(hdc, &elf, (FONTENUMPROCW)FontFamilyEnumProc, (LPARAM)&s, 0))
{
TRACE("EnumFontFamiliesEx returns 0\n");
break;
@ -663,7 +669,7 @@ LRESULT CFn_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam,
if (lpcf->Flags & CF_INITTOLOGFONTSTRUCT)
{
/* look for fitting font name in combobox1 */
j=SendDlgItemMessageA(hDlg,cmb1,CB_FINDSTRING,-1,(LONG)lpxx->lfFaceName);
j=SendDlgItemMessageW(hDlg,cmb1,CB_FINDSTRING,-1,(LONG)lpxx->lfFaceName);
if (j!=CB_ERR)
{
INT height = lpxx->lfHeight < 0 ? -lpxx->lfHeight :
@ -673,8 +679,8 @@ LRESULT CFn_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam,
points = MulDiv( height, 72, GetDeviceCaps(hdc, LOGPIXELSY));
pstyle = MAKELONG(lpxx->lfWeight > FW_MEDIUM ? FW_BOLD:
FW_NORMAL,lpxx->lfItalic !=0);
SendDlgItemMessageA(hDlg, cmb1, CB_SETCURSEL, j, 0);
SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
SendDlgItemMessageW(hDlg, cmb1, CB_SETCURSEL, j, 0);
SendMessageW(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
(LPARAM)GetDlgItem(hDlg,cmb1));
init=1;
/* look for fitting font style in combobox2 */
@ -686,17 +692,17 @@ LRESULT CFn_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam,
}
if (!init)
{
SendDlgItemMessageA(hDlg,cmb1,CB_SETCURSEL,0,0);
SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
SendDlgItemMessageW(hDlg,cmb1,CB_SETCURSEL,0,0);
SendMessageW(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
(LPARAM)GetDlgItem(hDlg,cmb1));
}
if (lpcf->Flags & CF_USESTYLE && lpcf->lpszStyle)
{
j=SendDlgItemMessageA(hDlg,cmb2,CB_FINDSTRING,-1,(LONG)lpcf->lpszStyle);
j=SendDlgItemMessageW(hDlg,cmb2,CB_FINDSTRING,-1,(LONG)lpcf->lpszStyle);
if (j!=CB_ERR)
{
j=SendDlgItemMessageA(hDlg,cmb2,CB_SETCURSEL,j,0);
SendMessageA(hDlg,WM_COMMAND,cmb2,
j=SendDlgItemMessageW(hDlg,cmb2,CB_SETCURSEL,j,0);
SendMessageW(hDlg,WM_COMMAND,cmb2,
MAKELONG(HWND_16(GetDlgItem(hDlg,cmb2)),CBN_SELCHANGE));
}
}
@ -716,18 +722,18 @@ LRESULT CFn_WMMeasureItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
TEXTMETRICW tm;
LPMEASUREITEMSTRUCT lpmi=(LPMEASUREITEMSTRUCT)lParam;
if (!himlTT)
himlTT = ImageList_LoadImageA( COMDLG32_hInstance, MAKEINTRESOURCEA(38),
himlTT = ImageList_LoadImageW( COMDLG32_hInstance, MAKEINTRESOURCEW(38),
TTBITMAP_XSIZE, 0, CLR_DEFAULT, IMAGE_BITMAP, 0);
ImageList_GetIconSize( himlTT, 0, &lpmi->itemHeight);
lpmi->itemHeight += 2;
/* use MAX of bitmap height and tm.tmHeight .*/
hdc=GetDC( hDlg);
hdc=GetDC(hDlg);
if(!hdc) return 0;
hfontprev = SelectObject( hdc, GetStockObject( SYSTEM_FONT));
GetTextMetricsW( hdc, &tm);
GetTextMetricsW(hdc, &tm);
if( tm.tmHeight > lpmi->itemHeight) lpmi->itemHeight = tm.tmHeight;
SelectObject( hdc, hfontprev);
ReleaseDC( hDlg, hdc);
SelectObject(hdc, hfontprev);
ReleaseDC(hDlg, hdc);
return 0;
}
@ -738,7 +744,7 @@ LRESULT CFn_WMMeasureItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
LRESULT CFn_WMDrawItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
{
HBRUSH hBrush;
char buffer[40];
WCHAR buffer[40];
COLORREF cr, oldText=0, oldBk=0;
RECT rect;
int nFontType;
@ -771,11 +777,11 @@ LRESULT CFn_WMDrawItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
{
case cmb1:
/* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
SendMessageW(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
(LPARAM)buffer);
TextOutA(lpdi->hDC, lpdi->rcItem.left + TTBITMAP_XSIZE + 10,
lpdi->rcItem.top, buffer, strlen(buffer));
nFontType = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
TextOutW(lpdi->hDC, lpdi->rcItem.left + TTBITMAP_XSIZE + 10,
lpdi->rcItem.top, buffer, lstrlenW(buffer));
nFontType = SendMessageW(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
idx = -1;
if (nFontType & TRUETYPE_FONTTYPE) {
idx = 0; /* picture: TT */
@ -795,19 +801,19 @@ LRESULT CFn_WMDrawItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
case cmb3:
/* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
case cmb5:
SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
SendMessageW(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
(LPARAM)buffer);
TextOutA(lpdi->hDC, lpdi->rcItem.left,
lpdi->rcItem.top, buffer, strlen(buffer));
TextOutW(lpdi->hDC, lpdi->rcItem.left,
lpdi->rcItem.top, buffer, lstrlenW(buffer));
break;
case cmb4:
/* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
SendMessageW(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
(LPARAM)buffer);
TextOutA(lpdi->hDC, lpdi->rcItem.left + 25+5,
lpdi->rcItem.top, buffer, strlen(buffer));
cr = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
TextOutW(lpdi->hDC, lpdi->rcItem.left + 25+5,
lpdi->rcItem.top, buffer, lstrlenW(buffer));
cr = SendMessageW(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
hBrush = CreateSolidBrush(cr);
if (hBrush)
{
@ -840,12 +846,12 @@ LRESULT CFn_WMDrawItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
* CFn_WMCommand [internal]
*/
LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam,
LPCHOOSEFONTA lpcf)
LPCHOOSEFONTW lpcf)
{
int i;
long l;
HDC hdc;
LPLOGFONTA lpxx=lpcf->lpLogFont;
LPLOGFONTW lpxx=lpcf->lpLogFont;
TRACE("WM_COMMAND wParam=%08lX lParam=%08lX\n", (LONG)wParam, lParam);
switch (LOWORD(wParam))
@ -862,33 +868,33 @@ LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam,
EndDialog (hDlg, 0);
return TRUE;
}
idx = SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
pointsize = (int)SendDlgItemMessageA( hDlg, cmb3, CB_GETITEMDATA,
idx = SendDlgItemMessageW(hDlg, cmb3, CB_GETCURSEL, 0, 0);
pointsize = (int)SendDlgItemMessageW( hDlg, cmb3, CB_GETITEMDATA,
idx, 0);
idx = SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
pstyle = SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, idx, 0);
idx = SendDlgItemMessageA(hDlg, cmb5, CB_GETCURSEL, 0, 0);
charset = SendDlgItemMessageA(hDlg, cmb5, CB_GETITEMDATA, idx, 0);
idx = SendDlgItemMessageW(hDlg, cmb2, CB_GETCURSEL, 0, 0);
pstyle = SendDlgItemMessageW(hDlg, cmb2, CB_GETITEMDATA, idx, 0);
idx = SendDlgItemMessageW(hDlg, cmb5, CB_GETCURSEL, 0, 0);
charset = SendDlgItemMessageW(hDlg, cmb5, CB_GETITEMDATA, idx, 0);
SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT, 0, 0);
SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT, 0, 0);
SendDlgItemMessageA(hDlg, cmb5, CB_RESETCONTENT, 0, 0);
i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL, 0, 0);
SendDlgItemMessageW(hDlg, cmb2, CB_RESETCONTENT, 0, 0);
SendDlgItemMessageW(hDlg, cmb3, CB_RESETCONTENT, 0, 0);
SendDlgItemMessageW(hDlg, cmb5, CB_RESETCONTENT, 0, 0);
i=SendDlgItemMessageW(hDlg, cmb1, CB_GETCURSEL, 0, 0);
if (i!=CB_ERR)
{
HCURSOR hcursor=SetCursor(LoadCursorA(0,(LPSTR)IDC_WAIT));
HCURSOR hcursor=SetCursor(LoadCursorW(0,(LPWSTR)IDC_WAIT));
CFn_ENUMSTRUCT s;
LOGFONTA enumlf;
SendDlgItemMessageA(hDlg, cmb1, CB_GETLBTEXT, i,
LOGFONTW enumlf;
SendDlgItemMessageW(hDlg, cmb1, CB_GETLBTEXT, i,
(LPARAM)enumlf.lfFaceName);
TRACE("WM_COMMAND/cmb1 =>%s\n",enumlf.lfFaceName);
TRACE("WM_COMMAND/cmb1 =>%s\n", debugstr_w(enumlf.lfFaceName));
s.hWnd1=GetDlgItem(hDlg, cmb2);
s.hWnd2=GetDlgItem(hDlg, cmb3);
s.lpcf32a=lpcf;
s.lpcf32w=lpcf;
enumlf.lfCharSet = DEFAULT_CHARSET; /* enum all charsets */
enumlf.lfPitchAndFamily = 0;
EnumFontFamiliesExA(hdc, &enumlf,
(FONTENUMPROCA)FontStyleEnumProc, (LPARAM)&s, 0);
EnumFontFamiliesExW(hdc, &enumlf,
(FONTENUMPROCW)FontStyleEnumProc, (LPARAM)&s, 0);
CFn_FitFontStyle(hDlg, pstyle);
if( pointsize != CB_ERR) CFn_FitFontSize(hDlg, pointsize);
if( charset != CB_ERR) CFn_FitCharSet( hDlg, charset );
@ -903,37 +909,37 @@ LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam,
case cmb5:
if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED )
{
char str[256];
WCHAR str[256];
WINDOWINFO wininfo;
TRACE("WM_COMMAND/cmb2,3 =%08lX\n", lParam);
i=SendDlgItemMessageA(hDlg,cmb1,CB_GETCURSEL,0,0);
i=SendDlgItemMessageW(hDlg,cmb1,CB_GETCURSEL,0,0);
if (i==CB_ERR)
i=GetDlgItemTextA( hDlg, cmb1, str, 256 );
i=GetDlgItemTextW( hDlg, cmb1, str, 256 );
else
{
SendDlgItemMessageA(hDlg,cmb1,CB_GETLBTEXT,i,
SendDlgItemMessageW(hDlg,cmb1,CB_GETLBTEXT,i,
(LPARAM)str);
l=SendDlgItemMessageA(hDlg,cmb1,CB_GETITEMDATA,i,0);
l=SendDlgItemMessageW(hDlg,cmb1,CB_GETITEMDATA,i,0);
lpcf->nFontType = LOWORD(l);
/* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
/* same value reported to the EnumFonts
call back with the extra FONTTYPE_... bits added */
lpxx->lfPitchAndFamily = HIWORD(l) >> 8;
}
strcpy(lpxx->lfFaceName,str);
i=SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
lstrcpyW(lpxx->lfFaceName,str);
i=SendDlgItemMessageW(hDlg, cmb2, CB_GETCURSEL, 0, 0);
if (i!=CB_ERR)
{
l=SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0);
l=SendDlgItemMessageW(hDlg, cmb2, CB_GETITEMDATA, i, 0);
if (0!=(lpxx->lfItalic=HIWORD(l)))
lpcf->nFontType |= ITALIC_FONTTYPE;
if ((lpxx->lfWeight=LOWORD(l)) > FW_MEDIUM)
lpcf->nFontType |= BOLD_FONTTYPE;
}
i=SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0);
i=SendDlgItemMessageW(hDlg, cmb3, CB_GETCURSEL, 0, 0);
if( i != CB_ERR)
lpcf->iPointSize = 10 * LOWORD(SendDlgItemMessageA(hDlg, cmb3,
lpcf->iPointSize = 10 * LOWORD(SendDlgItemMessageW(hDlg, cmb3,
CB_GETITEMDATA , i, 0));
else
lpcf->iPointSize = 100;
@ -945,9 +951,9 @@ LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam,
CFn_ReleaseDC(lpcf, hdc);
} else
lpxx->lfHeight = -lpcf->iPointSize / 10;
i=SendDlgItemMessageA(hDlg, cmb5, CB_GETCURSEL, 0, 0);
i=SendDlgItemMessageW(hDlg, cmb5, CB_GETCURSEL, 0, 0);
if (i!=CB_ERR)
lpxx->lfCharSet=SendDlgItemMessageA(hDlg, cmb5, CB_GETITEMDATA, i, 0);
lpxx->lfCharSet=SendDlgItemMessageW(hDlg, cmb5, CB_GETITEMDATA, i, 0);
else
lpxx->lfCharSet = DEFAULT_CHARSET;
lpxx->lfStrikeOut=IsDlgButtonChecked(hDlg,chx1);
@ -968,7 +974,7 @@ LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam,
break;
case cmb4:
i=SendDlgItemMessageA(hDlg, cmb4, CB_GETCURSEL, 0, 0);
i=SendDlgItemMessageW(hDlg, cmb4, CB_GETCURSEL, 0, 0);
if (i!=CB_ERR)
{
WINDOWINFO wininfo;
@ -985,9 +991,9 @@ LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam,
break;
case psh15:
i=RegisterWindowMessageA( HELPMSGSTRINGA );
i=RegisterWindowMessageW( HELPMSGSTRINGW );
if (lpcf->hwndOwner)
SendMessageA(lpcf->hwndOwner, i, 0, (LPARAM)GetPropA(hDlg, WINE_FONTDATA));
SendMessageW(lpcf->hwndOwner, i, 0, (LPARAM)GetPropW(hDlg, strWineFontData));
/* if (CFn_HookCallChk(lpcf))
CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
break;
@ -1013,18 +1019,45 @@ LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam,
return(FALSE);
}
LRESULT CFn_WMDestroy(HWND hwnd, WPARAM wParam, LPARAM lParam)
LRESULT CFn_WMDestroy(HWND hwnd, WPARAM wParam, LPARAM lParam, LPCHOOSEFONTW lpcfw)
{
LPCHOOSEFONTA lpcfa;
LPCSTR lpTemplateName;
LPSTR lpszStyle;
LPLOGFONTA lpLogFonta;
int len;
lpcfa = GetPropW(hwnd, strWineFontData_a);
lpLogFonta = lpcfa->lpLogFont;
lpTemplateName = lpcfa->lpTemplateName;
lpszStyle = lpcfa->lpszStyle;
memcpy(lpcfa, lpcfw, sizeof(CHOOSEFONTA));
lpcfa->lpLogFont = lpLogFonta;
lpcfa->lpTemplateName = lpTemplateName;
lpcfa->lpszStyle = lpszStyle;
memcpy(lpcfa->lpLogFont, lpcfw->lpLogFont, sizeof(LOGFONTA));
WideCharToMultiByte(CP_ACP, 0, lpcfw->lpLogFont->lfFaceName,
LF_FACESIZE, lpcfa->lpLogFont->lfFaceName, LF_FACESIZE, 0, 0);
if(lpcfw->lpszStyle) {
len = WideCharToMultiByte(CP_ACP, 0, lpcfw->lpszStyle, -1, NULL, -1, 0, 0);
WideCharToMultiByte(CP_ACP, 0, lpcfw->lpszStyle, -1, lpcfa->lpszStyle, len, 0, 0);
HeapFree(GetProcessHeap(), 0, lpcfw->lpszStyle);
}
if(lpcfw->lpTemplateName)
HeapFree(GetProcessHeap(), 0, (LPBYTE)lpcfw->lpTemplateName);
HeapFree(GetProcessHeap(), 0, lpcfw->lpLogFont);
HeapFree(GetProcessHeap(), 0, lpcfw);
return TRUE;
}
LRESULT CFn_WMPaint(HWND hDlg, WPARAM wParam, LPARAM lParam,
LPCHOOSEFONTA lpcf )
LRESULT CFn_WMPaint(HWND hDlg, WPARAM wParam, LPARAM lParam, LPCHOOSEFONTW lpcf)
{
WINDOWINFO info;
info.cbSize=sizeof(info);
if( GetWindowInfo( GetDlgItem( hDlg, stc5), &info ) )
{
PAINTSTRUCT ps;
@ -1032,7 +1065,7 @@ LRESULT CFn_WMPaint(HWND hDlg, WPARAM wParam, LPARAM lParam,
HPEN hOrigPen;
HFONT hOrigFont;
COLORREF rgbPrev;
LOGFONTA lf = *(lpcf->lpLogFont);
LOGFONTW lf = *(lpcf->lpLogFont);
MapWindowPoints( 0, hDlg, (LPPOINT) &info.rcWindow, 2);
hdc = BeginPaint( hDlg, &ps );
@ -1058,7 +1091,7 @@ LRESULT CFn_WMPaint(HWND hDlg, WPARAM wParam, LPARAM lParam,
info.rcWindow.bottom--;
info.rcWindow.top++;
info.rcWindow.left++;
hOrigFont = SelectObject( hdc, CreateFontIndirectA( &lf ) );
hOrigFont = SelectObject( hdc, CreateFontIndirectW( &lf ) );
rgbPrev=SetTextColor( hdc, lpcf->rgbColors );
DrawTextW( hdc,
@ -1077,29 +1110,50 @@ LRESULT CFn_WMPaint(HWND hDlg, WPARAM wParam, LPARAM lParam,
INT_PTR CALLBACK FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
LPCHOOSEFONTA lpcf;
LPCHOOSEFONTW lpcfw;
LPCHOOSEFONTA lpcfa;
INT_PTR res = FALSE;
int len;
if (uMsg!=WM_INITDIALOG)
{
lpcf=(LPCHOOSEFONTA)GetPropA(hDlg, WINE_FONTDATA);
if (!lpcf && uMsg != WM_MEASUREITEM)
if (uMsg!=WM_INITDIALOG) {
lpcfw = (LPCHOOSEFONTW)GetPropW(hDlg, strWineFontData);
if (!lpcfw)
return FALSE;
if (CFn_HookCallChk32(lpcf))
res=CallWindowProcA((WNDPROC)lpcf->lpfnHook, hDlg, uMsg, wParam, lParam);
if (CFn_HookCallChk32(lpcfw))
res=CallWindowProcA((WNDPROC)lpcfw->lpfnHook, hDlg, uMsg, wParam, lParam);
if (res)
return res;
} else {
lpcfa=(LPCHOOSEFONTA)lParam;
SetPropW(hDlg, strWineFontData_a, (HANDLE)lParam);
lpcfw = HeapAlloc(GetProcessHeap(), 0, sizeof(CHOOSEFONTW));
memcpy(lpcfw, lpcfa, sizeof(CHOOSEFONTA));
lpcfw->lpLogFont = HeapAlloc(GetProcessHeap(), 0, sizeof(LOGFONTW));
memcpy(lpcfw->lpLogFont, lpcfa->lpLogFont, sizeof(LOGFONTA));
MultiByteToWideChar(CP_ACP, 0, lpcfa->lpLogFont->lfFaceName,
LF_FACESIZE, lpcfw->lpLogFont->lfFaceName, LF_FACESIZE);
if(lpcfa->lpszStyle) {
len = MultiByteToWideChar(CP_ACP, 0, lpcfa->lpszStyle, -1, NULL, 0);
lpcfw->lpszStyle = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, lpcfa->lpszStyle, -1, lpcfw->lpszStyle, len);
}
else
{
lpcf=(LPCHOOSEFONTA)lParam;
if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf))
if(lpcfa->lpTemplateName) {
len = MultiByteToWideChar(CP_ACP, 0, lpcfa->lpTemplateName, -1, NULL, 0);
lpcfw->lpTemplateName = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, lpcfa->lpTemplateName,
-1, (LPWSTR)lpcfw->lpTemplateName, len);
}
if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcfw))
{
TRACE("CFn_WMInitDialog returned FALSE\n");
return FALSE;
}
if (CFn_HookCallChk32(lpcf))
return CallWindowProcA((WNDPROC)lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
if (CFn_HookCallChk32(lpcfw))
return CallWindowProcA((WNDPROC)lpcfa->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
}
switch (uMsg)
{
@ -1108,16 +1162,15 @@ INT_PTR CALLBACK FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
case WM_DRAWITEM:
return CFn_WMDrawItem(hDlg, wParam, lParam);
case WM_COMMAND:
return CFn_WMCommand(hDlg, wParam, lParam, lpcf);
return CFn_WMCommand(hDlg, wParam, lParam, lpcfw);
case WM_DESTROY:
return CFn_WMDestroy(hDlg, wParam, lParam);
return CFn_WMDestroy(hDlg, wParam, lParam, lpcfw);
case WM_CHOOSEFONT_GETLOGFONT:
TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
lParam);
TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n", lParam);
FIXME("current logfont back to caller\n");
break;
case WM_PAINT:
return CFn_WMPaint(hDlg, wParam, lParam, lpcf);
return CFn_WMPaint(hDlg, wParam, lParam, lpcfw);
}
return res;
}
@ -1128,29 +1181,29 @@ INT_PTR CALLBACK FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
INT_PTR CALLBACK FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
LPCHOOSEFONTW lpcf32w;
LPCHOOSEFONTW lpcf;
INT_PTR res = FALSE;
if (uMsg!=WM_INITDIALOG)
{
lpcf32w=(LPCHOOSEFONTW)GetPropA(hDlg, WINE_FONTDATA);
if (!lpcf32w)
lpcf=(LPCHOOSEFONTW)GetPropW(hDlg, strWineFontData);
if (!lpcf)
return FALSE;
if (CFn_HookCallChk32((LPCHOOSEFONTA)lpcf32w))
res=CallWindowProcW((WNDPROC)lpcf32w->lpfnHook, hDlg, uMsg, wParam, lParam);
if (CFn_HookCallChk32(lpcf))
res=CallWindowProcW((WNDPROC)lpcf->lpfnHook, hDlg, uMsg, wParam, lParam);
if (res)
return res;
}
else
{
lpcf32w=(LPCHOOSEFONTW)lParam;
if (!CFn_WMInitDialog(hDlg, wParam, lParam, (LPCHOOSEFONTA)lpcf32w))
lpcf=(LPCHOOSEFONTW)lParam;
if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf))
{
TRACE("CFn_WMInitDialog returned FALSE\n");
return FALSE;
}
if (CFn_HookCallChk32((LPCHOOSEFONTA)lpcf32w))
return CallWindowProcW((WNDPROC)lpcf32w->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
if (CFn_HookCallChk32(lpcf))
return CallWindowProcW((WNDPROC)lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
}
switch (uMsg)
{
@ -1159,14 +1212,15 @@ INT_PTR CALLBACK FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
case WM_DRAWITEM:
return CFn_WMDrawItem(hDlg, wParam, lParam);
case WM_COMMAND:
return CFn_WMCommand(hDlg, wParam, lParam, (LPCHOOSEFONTW)lpcf32w);
return CFn_WMCommand(hDlg, wParam, lParam, lpcf);
case WM_DESTROY:
return CFn_WMDestroy(hDlg, wParam, lParam);
return TRUE;
case WM_CHOOSEFONT_GETLOGFONT:
TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
lParam);
TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n", lParam);
FIXME("current logfont back to caller\n");
break;
case WM_PAINT:
return CFn_WMPaint(hDlg, wParam, lParam, lpcf);
}
return res;
}

View File

@ -41,7 +41,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
#include "cdlg.h"
#include "cdlg16.h"
static void FONT_LogFont16To32A( const LPLOGFONT16 font16, LPLOGFONTA font32 )
static void FONT_LogFont16To32W( const LPLOGFONT16 font16, LPLOGFONTW font32 )
{
font32->lfHeight = font16->lfHeight;
font32->lfWidth = font16->lfWidth;
@ -56,35 +56,50 @@ static void FONT_LogFont16To32A( const LPLOGFONT16 font16, LPLOGFONTA font32 )
font32->lfClipPrecision = font16->lfClipPrecision;
font32->lfQuality = font16->lfQuality;
font32->lfPitchAndFamily = font16->lfPitchAndFamily;
lstrcpynA( font32->lfFaceName, font16->lfFaceName, LF_FACESIZE );
MultiByteToWideChar(CP_ACP, 0, font16->lfFaceName,
LF_FACESIZE, font32->lfFaceName, LF_FACESIZE);
};
static void FONT_Metrics16To32A( const TEXTMETRIC16 *pm16,
NEWTEXTMETRICEXA *pnm32a)
static void FONT_Metrics16To32W( const TEXTMETRIC16 *pm16,
NEWTEXTMETRICEXW *pnm32w)
{
ZeroMemory( pnm32a, sizeof(NEWTEXTMETRICEXA));
ZeroMemory( pnm32w, sizeof(NEWTEXTMETRICEXW));
/* NOTE: only the fields used by AddFontStyle() are filled in */
pnm32a->ntmTm.tmHeight = pm16->tmHeight;
pnm32a->ntmTm.tmExternalLeading = pm16->tmExternalLeading;
pnm32w->ntmTm.tmHeight = pm16->tmHeight;
pnm32w->ntmTm.tmExternalLeading = pm16->tmExternalLeading;
};
static void CFn_CHOOSEFONT16to32A(LPCHOOSEFONT16 chf16, LPCHOOSEFONTA chf32a)
static void CFn_CHOOSEFONT16to32W(LPCHOOSEFONT16 chf16, LPCHOOSEFONTW chf32w)
{
chf32a->lStructSize=sizeof(CHOOSEFONTA);
chf32a->hwndOwner=HWND_32(chf16->hwndOwner);
chf32a->hDC=HDC_32(chf16->hDC);
chf32a->iPointSize=chf16->iPointSize;
chf32a->Flags=chf16->Flags;
chf32a->rgbColors=chf16->rgbColors;
chf32a->lCustData=chf16->lCustData;
chf32a->lpfnHook=NULL;
chf32a->lpTemplateName=MapSL(chf16->lpTemplateName);
chf32a->hInstance=HINSTANCE_32(chf16->hInstance);
chf32a->lpszStyle=MapSL(chf16->lpszStyle);
chf32a->nFontType=chf16->nFontType;
chf32a->nSizeMax=chf16->nSizeMax;
chf32a->nSizeMin=chf16->nSizeMin;
FONT_LogFont16To32A(MapSL(chf16->lpLogFont), chf32a->lpLogFont);
int len;
if(chf16->lpTemplateName)
{
len = MultiByteToWideChar(CP_ACP, 0, (LPBYTE)chf16->lpTemplateName, -1, NULL, 0);
chf32w->lpTemplateName = HeapAlloc(GetProcessHeap(), 0,len*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, (LPSTR)MapSL(chf16->lpTemplateName),
-1, (LPWSTR)chf32w->lpTemplateName, len);
}
if(chf16->lpszStyle)
{
len = MultiByteToWideChar(CP_ACP, 0, (LPBYTE)chf16->lpszStyle, -1, NULL, 0);
chf32w->lpszStyle = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, (LPSTR)MapSL(chf16->lpTemplateName),
-1, chf32w->lpszStyle, len);
}
chf32w->lStructSize=sizeof(CHOOSEFONTW);
chf32w->hwndOwner=HWND_32(chf16->hwndOwner);
chf32w->hDC=HDC_32(chf16->hDC);
chf32w->iPointSize=chf16->iPointSize;
chf32w->Flags=chf16->Flags;
chf32w->rgbColors=chf16->rgbColors;
chf32w->lCustData=chf16->lCustData;
chf32w->lpfnHook=NULL;
chf32w->hInstance=HINSTANCE_32(chf16->hInstance);
chf32w->lpszStyle=MapSL(chf16->lpszStyle);
chf32w->nFontType=chf16->nFontType;
chf32w->nSizeMax=chf16->nSizeMax;
chf32w->nSizeMin=chf16->nSizeMin;
FONT_LogFont16To32W(MapSL(chf16->lpLogFont), chf32w->lpLogFont);
};
/***********************************************************************
@ -110,12 +125,12 @@ INT16 WINAPI FontFamilyEnumProc16( SEGPTR logfont, SEGPTR metrics,
LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
LOGFONT16 *lplf = MapSL( logfont );
TEXTMETRIC16 *lpmtrx16 = MapSL(metrics);
ENUMLOGFONTEXA elf32a;
NEWTEXTMETRICEXA nmtrx32a;
FONT_LogFont16To32A(lplf, &(elf32a.elfLogFont));
FONT_Metrics16To32A(lpmtrx16, &nmtrx32a);
return AddFontFamily(&elf32a, &nmtrx32a, nFontType,
(LPCHOOSEFONTA)lpcf->lpTemplateName, hwnd,NULL);
ENUMLOGFONTEXW elf32w;
NEWTEXTMETRICEXW nmtrx32w;
FONT_LogFont16To32W(lplf, &(elf32w.elfLogFont));
FONT_Metrics16To32W(lpmtrx16, &nmtrx32w);
return AddFontFamily(&elf32w, &nmtrx32w, nFontType,
(LPCHOOSEFONTW)lpcf->lpTemplateName, hwnd,NULL);
}
/***********************************************************************
@ -130,12 +145,12 @@ INT16 WINAPI FontStyleEnumProc16( SEGPTR logfont, SEGPTR metrics,
LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
LOGFONT16 *lplf = MapSL(logfont);
TEXTMETRIC16 *lpmtrx16 = MapSL(metrics);
ENUMLOGFONTEXA elf32a;
NEWTEXTMETRICEXA nmtrx32a;
FONT_LogFont16To32A(lplf, &(elf32a.elfLogFont));
FONT_Metrics16To32A(lpmtrx16, &nmtrx32a);
return AddFontStyle(&elf32a, &nmtrx32a, nFontType,
(LPCHOOSEFONTA)lpcf->lpTemplateName, hcmb2, hcmb3, hDlg, TRUE);
ENUMLOGFONTEXW elf32w;
NEWTEXTMETRICEXW nmtrx32w;
FONT_LogFont16To32W(lplf, &(elf32w.elfLogFont));
FONT_Metrics16To32W(lpmtrx16, &nmtrx32w);
return AddFontStyle(&elf32w, &nmtrx32w, nFontType,
(LPCHOOSEFONTW)lpcf->lpTemplateName, hcmb2, hcmb3, hDlg, TRUE);
}
/***********************************************************************
@ -149,13 +164,13 @@ BOOL16 WINAPI ChooseFont16(LPCHOOSEFONT16 lpChFont)
BOOL16 bRet = FALSE;
LPCVOID template;
FARPROC16 ptr;
CHOOSEFONTA cf32a;
LOGFONTA lf32a;
CHOOSEFONTW cf32w;
LOGFONTW lf32w;
LOGFONT16 *font16;
SEGPTR lpTemplateName;
cf32a.lpLogFont=&lf32a;
CFn_CHOOSEFONT16to32A(lpChFont, &cf32a);
cf32w.lpLogFont=&lf32w;
CFn_CHOOSEFONT16to32W(lpChFont, &cf32w);
TRACE("ChooseFont\n");
if (!lpChFont) return FALSE;
@ -228,7 +243,7 @@ BOOL16 WINAPI ChooseFont16(LPCHOOSEFONT16 lpChFont)
/* lpTemplateName is not used in the dialog */
lpTemplateName=lpChFont->lpTemplateName;
lpChFont->lpTemplateName=(SEGPTR)&cf32a;
lpChFont->lpTemplateName=(SEGPTR)&cf32w;
ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 16);
hInst = GetWindowLongPtrA(HWND_32(lpChFont->hwndOwner), GWLP_HINSTANCE);
@ -242,27 +257,34 @@ BOOL16 WINAPI ChooseFont16(LPCHOOSEFONT16 lpChFont)
}
lpChFont->lpTemplateName=lpTemplateName;
lpChFont->iPointSize = cf32a.iPointSize;
lpChFont->Flags = cf32a.Flags;
lpChFont->rgbColors = cf32a.rgbColors;
lpChFont->lCustData = cf32a.lCustData;
lpChFont->nFontType = cf32a.nFontType;
lpChFont->iPointSize = cf32w.iPointSize;
lpChFont->Flags = cf32w.Flags;
lpChFont->rgbColors = cf32w.rgbColors;
lpChFont->lCustData = cf32w.lCustData;
lpChFont->nFontType = cf32w.nFontType;
font16 = MapSL(lpChFont->lpLogFont);
font16->lfHeight = cf32a.lpLogFont->lfHeight;
font16->lfWidth = cf32a.lpLogFont->lfWidth;
font16->lfEscapement = cf32a.lpLogFont->lfEscapement;
font16->lfOrientation = cf32a.lpLogFont->lfOrientation;
font16->lfWeight = cf32a.lpLogFont->lfWeight;
font16->lfItalic = cf32a.lpLogFont->lfItalic;
font16->lfUnderline = cf32a.lpLogFont->lfUnderline;
font16->lfStrikeOut = cf32a.lpLogFont->lfStrikeOut;
font16->lfCharSet = cf32a.lpLogFont->lfCharSet;
font16->lfOutPrecision = cf32a.lpLogFont->lfOutPrecision;
font16->lfClipPrecision = cf32a.lpLogFont->lfClipPrecision;
font16->lfQuality = cf32a.lpLogFont->lfQuality;
font16->lfPitchAndFamily = cf32a.lpLogFont->lfPitchAndFamily;
lstrcpynA( font16->lfFaceName, cf32a.lpLogFont->lfFaceName, LF_FACESIZE );
font16->lfHeight = cf32w.lpLogFont->lfHeight;
font16->lfWidth = cf32w.lpLogFont->lfWidth;
font16->lfEscapement = cf32w.lpLogFont->lfEscapement;
font16->lfOrientation = cf32w.lpLogFont->lfOrientation;
font16->lfWeight = cf32w.lpLogFont->lfWeight;
font16->lfItalic = cf32w.lpLogFont->lfItalic;
font16->lfUnderline = cf32w.lpLogFont->lfUnderline;
font16->lfStrikeOut = cf32w.lpLogFont->lfStrikeOut;
font16->lfCharSet = cf32w.lpLogFont->lfCharSet;
font16->lfOutPrecision = cf32w.lpLogFont->lfOutPrecision;
font16->lfClipPrecision = cf32w.lpLogFont->lfClipPrecision;
font16->lfQuality = cf32w.lpLogFont->lfQuality;
font16->lfPitchAndFamily = cf32w.lpLogFont->lfPitchAndFamily;
WideCharToMultiByte(CP_ACP, 0, cf32w.lpLogFont->lfFaceName,
LF_FACESIZE, font16->lfFaceName, LF_FACESIZE, 0, 0);
if(cf32w.lpTemplateName)
HeapFree(GetProcessHeap(), 0, (LPBYTE)cf32w.lpTemplateName);
if(cf32w.lpszStyle)
HeapFree(GetProcessHeap(), 0, cf32w.lpszStyle);
return bRet;
}
@ -291,7 +313,7 @@ BOOL16 CALLBACK FormatCharDlgProc16(HWND16 hDlg16, UINT16 message,
else
{
lpcf=(LPCHOOSEFONT16)lParam;
if (!CFn_WMInitDialog(hDlg, wParam, lParam, (LPCHOOSEFONTA)lpcf->lpTemplateName))
if (!CFn_WMInitDialog(hDlg, wParam, lParam, (LPCHOOSEFONTW)lpcf->lpTemplateName))
{
TRACE("CFn_WMInitDialog returned FALSE\n");
return FALSE;
@ -337,17 +359,16 @@ BOOL16 CALLBACK FormatCharDlgProc16(HWND16 hDlg16, UINT16 message,
break;
case WM_COMMAND:
res=CFn_WMCommand(hDlg, MAKEWPARAM( wParam, HIWORD(lParam) ), LOWORD(lParam),
(LPCHOOSEFONTA)lpcf->lpTemplateName);
(LPCHOOSEFONTW)lpcf->lpTemplateName);
break;
case WM_DESTROY:
res=CFn_WMDestroy(hDlg, wParam, lParam);
break;
return TRUE;
case WM_CHOOSEFONT_GETLOGFONT:
TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n", lParam);
FIXME("current logfont back to caller\n");
break;
case WM_PAINT:
res= CFn_WMPaint(hDlg, wParam, lParam, (LPCHOOSEFONTA)lpcf->lpTemplateName);
res= CFn_WMPaint(hDlg, wParam, lParam, (LPCHOOSEFONTW)lpcf->lpTemplateName);
break;
}
return res;