1999-02-28 21:05:11 +01:00
|
|
|
/*
|
|
|
|
* COMMDLG - Font Dialog
|
|
|
|
*
|
|
|
|
* Copyright 1994 Martin Ayotte
|
|
|
|
* Copyright 1996 Albrecht Kleine
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include <stdio.h>
|
1999-02-28 21:05:11 +01:00
|
|
|
#include <string.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "windef.h"
|
2000-11-28 23:40:56 +01:00
|
|
|
#include "winnls.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
#include "winbase.h"
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "wingdi.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
#include "wine/winbase16.h"
|
|
|
|
#include "wine/winuser16.h"
|
|
|
|
#include "heap.h"
|
|
|
|
#include "commdlg.h"
|
|
|
|
#include "dlgs.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-03-13 18:07:56 +01:00
|
|
|
#include "cderr.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-04-25 20:31:35 +02:00
|
|
|
#include "cdlg.h"
|
|
|
|
|
2002-11-22 00:55:10 +01:00
|
|
|
static HBITMAP hBitmapTT = 0;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
|
2002-10-31 02:04:39 +01:00
|
|
|
INT_PTR CALLBACK FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
|
2000-05-27 00:26:06 +02:00
|
|
|
LPARAM lParam);
|
2002-10-31 02:04:39 +01:00
|
|
|
INT_PTR CALLBACK FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
|
2000-05-27 00:26:06 +02:00
|
|
|
LPARAM lParam);
|
2002-10-31 02:04:39 +01:00
|
|
|
BOOL16 CALLBACK FormatCharDlgProc16(HWND16 hDlg, UINT16 message, WPARAM16 wParam,
|
2000-07-23 15:35:14 +02:00
|
|
|
LPARAM lParam);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-11-29 19:38:24 +01:00
|
|
|
static void FONT_LogFont16To32A( const LPLOGFONT16 font16, LPLOGFONTA font32 )
|
|
|
|
{
|
|
|
|
font32->lfHeight = font16->lfHeight;
|
|
|
|
font32->lfWidth = font16->lfWidth;
|
|
|
|
font32->lfEscapement = font16->lfEscapement;
|
|
|
|
font32->lfOrientation = font16->lfOrientation;
|
|
|
|
font32->lfWeight = font16->lfWeight;
|
|
|
|
font32->lfItalic = font16->lfItalic;
|
|
|
|
font32->lfUnderline = font16->lfUnderline;
|
|
|
|
font32->lfStrikeOut = font16->lfStrikeOut;
|
|
|
|
font32->lfCharSet = font16->lfCharSet;
|
|
|
|
font32->lfOutPrecision = font16->lfOutPrecision;
|
|
|
|
font32->lfClipPrecision = font16->lfClipPrecision;
|
|
|
|
font32->lfQuality = font16->lfQuality;
|
|
|
|
font32->lfPitchAndFamily = font16->lfPitchAndFamily;
|
|
|
|
lstrcpynA( font32->lfFaceName, font16->lfFaceName, LF_FACESIZE );
|
|
|
|
}
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
static void CFn_CHOOSEFONT16to32A(LPCHOOSEFONT16 chf16, LPCHOOSEFONTA chf32a)
|
|
|
|
{
|
|
|
|
chf32a->lStructSize=sizeof(CHOOSEFONTA);
|
2002-09-06 22:40:42 +02:00
|
|
|
chf32a->hwndOwner=HWND_32(chf16->hwndOwner);
|
2002-11-22 00:55:10 +01:00
|
|
|
chf32a->hDC=HDC_32(chf16->hDC);
|
1999-02-28 21:05:11 +01:00
|
|
|
chf32a->iPointSize=chf16->iPointSize;
|
|
|
|
chf32a->Flags=chf16->Flags;
|
|
|
|
chf32a->rgbColors=chf16->rgbColors;
|
|
|
|
chf32a->lCustData=chf16->lCustData;
|
|
|
|
chf32a->lpfnHook=NULL;
|
2000-12-13 21:20:09 +01:00
|
|
|
chf32a->lpTemplateName=MapSL(chf16->lpTemplateName);
|
2002-11-22 00:55:10 +01:00
|
|
|
chf32a->hInstance=HINSTANCE_32(chf16->hInstance);
|
2000-12-13 21:20:09 +01:00
|
|
|
chf32a->lpszStyle=MapSL(chf16->lpszStyle);
|
1999-02-28 21:05:11 +01:00
|
|
|
chf32a->nFontType=chf16->nFontType;
|
|
|
|
chf32a->nSizeMax=chf16->nSizeMax;
|
|
|
|
chf32a->nSizeMin=chf16->nSizeMin;
|
2000-12-13 21:20:09 +01:00
|
|
|
FONT_LogFont16To32A(MapSL(chf16->lpLogFont), chf32a->lpLogFont);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
2001-05-05 02:42:54 +02:00
|
|
|
struct {
|
|
|
|
int mask;
|
|
|
|
char *name;
|
|
|
|
} cfflags[] = {
|
|
|
|
#define XX(x) { x, #x },
|
|
|
|
XX(CF_SCREENFONTS)
|
|
|
|
XX(CF_PRINTERFONTS)
|
|
|
|
XX(CF_SHOWHELP)
|
|
|
|
XX(CF_ENABLEHOOK)
|
|
|
|
XX(CF_ENABLETEMPLATE)
|
|
|
|
XX(CF_ENABLETEMPLATEHANDLE)
|
|
|
|
XX(CF_INITTOLOGFONTSTRUCT)
|
|
|
|
XX(CF_USESTYLE)
|
|
|
|
XX(CF_EFFECTS)
|
|
|
|
XX(CF_APPLY)
|
|
|
|
XX(CF_ANSIONLY)
|
|
|
|
XX(CF_NOVECTORFONTS)
|
|
|
|
XX(CF_NOSIMULATIONS)
|
|
|
|
XX(CF_LIMITSIZE)
|
|
|
|
XX(CF_FIXEDPITCHONLY)
|
|
|
|
XX(CF_WYSIWYG)
|
|
|
|
XX(CF_FORCEFONTEXIST)
|
|
|
|
XX(CF_SCALABLEONLY)
|
|
|
|
XX(CF_TTONLY)
|
|
|
|
XX(CF_NOFACESEL)
|
|
|
|
XX(CF_NOSTYLESEL)
|
|
|
|
XX(CF_NOSIZESEL)
|
|
|
|
XX(CF_SELECTSCRIPT)
|
|
|
|
XX(CF_NOSCRIPTSEL)
|
|
|
|
XX(CF_NOVERTFONTS)
|
|
|
|
#undef XX
|
|
|
|
{0,NULL},
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
_dump_cf_flags(DWORD cflags) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0;cfflags[i].name;i++)
|
|
|
|
if (cfflags[i].mask & cflags)
|
|
|
|
MESSAGE("%s|",cfflags[i].name);
|
|
|
|
MESSAGE("\n");
|
|
|
|
}
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
2002-06-01 01:06:46 +02:00
|
|
|
* ChooseFont (COMMDLG.15)
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
|
|
|
BOOL16 WINAPI ChooseFont16(LPCHOOSEFONT16 lpChFont)
|
|
|
|
{
|
|
|
|
HINSTANCE16 hInst;
|
2000-07-23 15:35:14 +02:00
|
|
|
HANDLE16 hDlgTmpl16 = 0, hResource16 = 0;
|
|
|
|
HGLOBAL16 hGlobal16 = 0;
|
|
|
|
BOOL16 bRet = FALSE;
|
1999-02-28 21:05:11 +01:00
|
|
|
LPCVOID template;
|
2000-07-23 15:35:14 +02:00
|
|
|
FARPROC16 ptr;
|
1999-02-28 21:05:11 +01:00
|
|
|
CHOOSEFONTA cf32a;
|
|
|
|
LOGFONTA lf32a;
|
2000-11-29 19:38:24 +01:00
|
|
|
LOGFONT16 *font16;
|
1999-02-28 21:05:11 +01:00
|
|
|
SEGPTR lpTemplateName;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
cf32a.lpLogFont=&lf32a;
|
|
|
|
CFn_CHOOSEFONT16to32A(lpChFont, &cf32a);
|
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("ChooseFont\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
if (!lpChFont) return FALSE;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2001-05-05 02:42:54 +02:00
|
|
|
if (TRACE_ON(commdlg))
|
|
|
|
_dump_cf_flags(lpChFont->Flags);
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
if (lpChFont->Flags & CF_ENABLETEMPLATEHANDLE)
|
|
|
|
{
|
|
|
|
if (!(template = LockResource16( lpChFont->hInstance )))
|
|
|
|
{
|
1999-03-15 16:16:54 +01:00
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
1999-02-28 21:05:11 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (lpChFont->Flags & CF_ENABLETEMPLATE)
|
|
|
|
{
|
|
|
|
HANDLE16 hResInfo;
|
|
|
|
if (!(hResInfo = FindResource16( lpChFont->hInstance,
|
2000-12-13 21:20:09 +01:00
|
|
|
MapSL(lpChFont->lpTemplateName),
|
2000-11-27 22:54:01 +01:00
|
|
|
RT_DIALOGA)))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
1999-03-15 16:16:54 +01:00
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
1999-02-28 21:05:11 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
2000-07-23 15:35:14 +02:00
|
|
|
if (!(hDlgTmpl16 = LoadResource16( lpChFont->hInstance, hResInfo )) ||
|
|
|
|
!(template = LockResource16( hDlgTmpl16 )))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
1999-03-15 16:16:54 +01:00
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
1999-02-28 21:05:11 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-17 00:47:05 +02:00
|
|
|
HRSRC hResInfo;
|
|
|
|
HGLOBAL hDlgTmpl32;
|
2000-07-23 15:35:14 +02:00
|
|
|
LPCVOID template32;
|
|
|
|
DWORD size;
|
|
|
|
if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_FONT", RT_DIALOGA)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo)) ||
|
|
|
|
!(template32 = LockResource(hDlgTmpl32)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
|
|
|
|
hGlobal16 = GlobalAlloc16(0, size);
|
|
|
|
if (!hGlobal16)
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
|
|
|
|
ERR("alloc failure for %ld bytes\n", size);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
template = GlobalLock16(hGlobal16);
|
|
|
|
if (!template)
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
|
|
|
|
ERR("global lock failure for %x handle\n", hGlobal16);
|
|
|
|
GlobalFree16(hGlobal16);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template);
|
2002-06-01 01:06:46 +02:00
|
|
|
hDlgTmpl16 = hGlobal16;
|
2000-07-23 15:35:14 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* lpTemplateName is not used in the dialog */
|
|
|
|
lpTemplateName=lpChFont->lpTemplateName;
|
|
|
|
lpChFont->lpTemplateName=(SEGPTR)&cf32a;
|
2000-07-23 15:35:14 +02:00
|
|
|
|
2000-11-27 22:54:01 +01:00
|
|
|
ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 16);
|
2002-09-06 22:40:42 +02:00
|
|
|
hInst = GetWindowLongA(HWND_32(lpChFont->hwndOwner), GWL_HINSTANCE);
|
2000-07-23 15:35:14 +02:00
|
|
|
bRet = DialogBoxIndirectParam16(hInst, hDlgTmpl16, lpChFont->hwndOwner,
|
|
|
|
(DLGPROC16) ptr, (DWORD)lpChFont);
|
|
|
|
if (hResource16) FreeResource16(hDlgTmpl16);
|
|
|
|
if (hGlobal16)
|
|
|
|
{
|
|
|
|
GlobalUnlock16(hGlobal16);
|
|
|
|
GlobalFree16(hGlobal16);
|
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
lpChFont->lpTemplateName=lpTemplateName;
|
2000-11-29 19:38:24 +01:00
|
|
|
|
|
|
|
|
2000-12-13 21:20:09 +01:00
|
|
|
font16 = MapSL(lpChFont->lpLogFont);
|
2000-11-29 19:38:24 +01:00
|
|
|
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 );
|
1999-02-28 21:05:11 +01:00
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* ChooseFontA (COMDLG32.@)
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI ChooseFontA(LPCHOOSEFONTA lpChFont)
|
|
|
|
{
|
1999-04-25 20:31:35 +02:00
|
|
|
LPCVOID template;
|
2002-09-17 00:47:05 +02:00
|
|
|
HRSRC hResInfo;
|
2002-11-08 19:56:46 +01:00
|
|
|
HINSTANCE hDlginst;
|
2002-09-17 00:47:05 +02:00
|
|
|
HGLOBAL hDlgTmpl;
|
1999-04-25 20:31:35 +02:00
|
|
|
|
2002-11-13 05:08:57 +01:00
|
|
|
if ( (lpChFont->Flags&CF_ENABLETEMPLATEHANDLE)!=0 )
|
1999-04-25 20:31:35 +02:00
|
|
|
{
|
2002-11-13 05:08:57 +01:00
|
|
|
template=(LPCVOID)lpChFont->hInstance;
|
2002-11-08 19:56:46 +01:00
|
|
|
} else
|
|
|
|
{
|
2002-11-13 05:08:57 +01:00
|
|
|
if ( (lpChFont->Flags&CF_ENABLETEMPLATE)!=0 )
|
2002-11-08 19:56:46 +01:00
|
|
|
{
|
2002-11-13 05:08:57 +01:00
|
|
|
hDlginst=lpChFont->hInstance;
|
|
|
|
if( !(hResInfo = FindResourceA(hDlginst, lpChFont->lpTemplateName,
|
|
|
|
RT_DIALOGA)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
hDlginst=COMMDLG_hInstance32;
|
|
|
|
if (!(hResInfo = FindResourceA(hDlginst, "CHOOSE_FONT", RT_DIALOGA)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!(hDlgTmpl = LoadResource(hDlginst, hResInfo )) ||
|
|
|
|
!(template = LockResource( hDlgTmpl )))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
2002-11-08 19:56:46 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
1999-04-25 20:31:35 +02:00
|
|
|
}
|
2001-05-05 02:42:54 +02:00
|
|
|
if (TRACE_ON(commdlg))
|
|
|
|
_dump_cf_flags(lpChFont->Flags);
|
1999-04-25 20:31:35 +02:00
|
|
|
|
2002-11-13 05:08:57 +01:00
|
|
|
if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS ))
|
|
|
|
FIXME(": unimplemented flag (ignored)\n");
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return DialogBoxIndirectParamA(COMMDLG_hInstance32, template,
|
2002-10-31 02:04:39 +01:00
|
|
|
lpChFont->hwndOwner, FormatCharDlgProcA, (LPARAM)lpChFont );
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
2001-06-13 22:06:42 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* ChooseFontW (COMDLG32.@)
|
2001-06-13 22:06:42 +02:00
|
|
|
*
|
|
|
|
* NOTES:
|
|
|
|
*
|
|
|
|
* The LOGFONT conversion functions will break if the structure ever
|
|
|
|
* grows beyond the lfFaceName element.
|
|
|
|
*
|
|
|
|
* The CHOOSEFONT conversion functions assume that both versions of
|
|
|
|
* lpLogFont and lpszStyle (if used) point to pre-allocated objects.
|
|
|
|
*
|
|
|
|
* The ASCII version of lpTemplateName is created by ChooseFontAtoW
|
|
|
|
* and freed by ChooseFontWtoA.
|
|
|
|
*/
|
|
|
|
inline static VOID LogFontWtoA(const LOGFONTW *lfw, LOGFONTA *lfa)
|
|
|
|
{
|
|
|
|
memcpy(lfa, lfw, sizeof(LOGFONTA));
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, lfw->lfFaceName, -1, lfa->lfFaceName,
|
|
|
|
LF_FACESIZE, NULL, NULL);
|
|
|
|
lfa->lfFaceName[LF_FACESIZE - 1] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static VOID LogFontAtoW(const LOGFONTA *lfa, LOGFONTW *lfw)
|
|
|
|
{
|
|
|
|
memcpy(lfw, lfa, sizeof(LOGFONTA));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, lfa->lfFaceName, -1, lfw->lfFaceName,
|
|
|
|
LF_FACESIZE);
|
|
|
|
lfw->lfFaceName[LF_FACESIZE - 1] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL ChooseFontWtoA(const CHOOSEFONTW *cfw, CHOOSEFONTA *cfa)
|
|
|
|
{
|
|
|
|
LOGFONTA *lpLogFont = cfa->lpLogFont;
|
|
|
|
LPSTR lpszStyle = cfa->lpszStyle;
|
|
|
|
|
|
|
|
memcpy(cfa, cfw, sizeof(CHOOSEFONTA));
|
|
|
|
cfa->lpLogFont = lpLogFont;
|
|
|
|
cfa->lpszStyle = lpszStyle;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-13 22:06:42 +02:00
|
|
|
LogFontWtoA(cfw->lpLogFont, lpLogFont);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-07-10 22:31:17 +02:00
|
|
|
if ((cfw->Flags&CF_ENABLETEMPLATE)!=0 && HIWORD(cfw->lpTemplateName)!=0)
|
2001-06-13 22:06:42 +02:00
|
|
|
{
|
|
|
|
cfa->lpTemplateName = HEAP_strdupWtoA(GetProcessHeap(), 0,
|
|
|
|
cfw->lpTemplateName);
|
|
|
|
if (cfa->lpTemplateName == NULL)
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-13 22:06:42 +02:00
|
|
|
if ((cfw->Flags & CF_USESTYLE) != 0 && cfw->lpszStyle != NULL)
|
|
|
|
{
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, cfw->lpszStyle, -1, cfa->lpszStyle,
|
|
|
|
LF_FACESIZE, NULL, NULL);
|
|
|
|
cfa->lpszStyle[LF_FACESIZE - 1] = '\0';
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-13 22:06:42 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VOID ChooseFontAtoW(const CHOOSEFONTA *cfa, CHOOSEFONTW *cfw)
|
|
|
|
{
|
|
|
|
LOGFONTW *lpLogFont = cfw->lpLogFont;
|
|
|
|
LPWSTR lpszStyle = cfw->lpszStyle;
|
|
|
|
LPCWSTR lpTemplateName = cfw->lpTemplateName;
|
|
|
|
|
|
|
|
memcpy(cfw, cfa, sizeof(CHOOSEFONTA));
|
|
|
|
cfw->lpLogFont = lpLogFont;
|
|
|
|
cfw->lpszStyle = lpszStyle;
|
|
|
|
cfw->lpTemplateName = lpTemplateName;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-13 22:06:42 +02:00
|
|
|
LogFontAtoW(cfa->lpLogFont, lpLogFont);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-07-10 22:31:17 +02:00
|
|
|
if ((cfa->Flags&CF_ENABLETEMPLATE)!=0 && HIWORD(cfa->lpTemplateName) != 0)
|
2001-06-13 22:06:42 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, (LPSTR)(cfa->lpTemplateName));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-13 22:06:42 +02:00
|
|
|
if ((cfa->Flags & CF_USESTYLE) != 0 && cfa->lpszStyle != NULL)
|
|
|
|
{
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, cfa->lpszStyle, -1, cfw->lpszStyle,
|
|
|
|
LF_FACESIZE);
|
|
|
|
cfw->lpszStyle[LF_FACESIZE - 1] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI ChooseFontW(LPCHOOSEFONTW lpChFont)
|
|
|
|
{
|
|
|
|
CHOOSEFONTA cf_a;
|
|
|
|
LOGFONTA lf_a;
|
|
|
|
CHAR style_a[LF_FACESIZE];
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-13 22:06:42 +02:00
|
|
|
cf_a.lpLogFont = &lf_a;
|
|
|
|
cf_a.lpszStyle = style_a;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-13 22:06:42 +02:00
|
|
|
if (ChooseFontWtoA(lpChFont, &cf_a) == FALSE)
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-13 22:06:42 +02:00
|
|
|
if (ChooseFontA(&cf_a) == FALSE)
|
|
|
|
{
|
|
|
|
if (cf_a.lpTemplateName != NULL)
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPSTR)(cf_a.lpTemplateName));
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-13 22:06:42 +02:00
|
|
|
ChooseFontAtoW(&cf_a, lpChFont);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-06-13 22:06:42 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* ChooseFontW (COMDLG32.@)
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI ChooseFontW(LPCHOOSEFONTW lpChFont)
|
|
|
|
{
|
|
|
|
BOOL bRet=FALSE;
|
|
|
|
CHOOSEFONTA cf32a;
|
|
|
|
LOGFONTA lf32a;
|
1999-04-25 20:31:35 +02:00
|
|
|
LPCVOID template;
|
|
|
|
HANDLE hResInfo, hDlgTmpl;
|
|
|
|
|
2001-05-05 02:42:54 +02:00
|
|
|
if (TRACE_ON(commdlg))
|
|
|
|
_dump_cf_flags(lpChFont->Flags);
|
|
|
|
|
1999-04-25 20:31:35 +02:00
|
|
|
if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_FONT", RT_DIALOGA)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
|
|
|
|
!(template = LockResource( hDlgTmpl )))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS | CF_ENABLETEMPLATE |
|
1999-06-12 17:45:58 +02:00
|
|
|
CF_ENABLETEMPLATEHANDLE)) FIXME(": unimplemented flag (ignored)\n");
|
1999-02-28 21:05:11 +01:00
|
|
|
memcpy(&cf32a, lpChFont, sizeof(cf32a));
|
|
|
|
memcpy(&lf32a, lpChFont->lpLogFont, sizeof(LOGFONTA));
|
2000-11-28 23:40:56 +01:00
|
|
|
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, lpChFont->lpLogFont->lfFaceName, -1,
|
|
|
|
lf32a.lfFaceName, LF_FACESIZE, NULL, NULL );
|
|
|
|
lf32a.lfFaceName[LF_FACESIZE-1] = 0;
|
1999-02-28 21:05:11 +01:00
|
|
|
cf32a.lpLogFont=&lf32a;
|
|
|
|
cf32a.lpszStyle=HEAP_strdupWtoA(GetProcessHeap(), 0, lpChFont->lpszStyle);
|
|
|
|
lpChFont->lpTemplateName=(LPWSTR)&cf32a;
|
2002-06-01 01:06:46 +02:00
|
|
|
bRet = DialogBoxIndirectParamW(COMMDLG_hInstance32, template,
|
2002-10-31 02:04:39 +01:00
|
|
|
lpChFont->hwndOwner, FormatCharDlgProcW, (LPARAM)lpChFont );
|
1999-02-28 21:05:11 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, cf32a.lpszStyle);
|
|
|
|
lpChFont->lpTemplateName=(LPWSTR)cf32a.lpTemplateName;
|
|
|
|
memcpy(lpChFont->lpLogFont, &lf32a, sizeof(CHOOSEFONTA));
|
2000-11-28 23:40:56 +01:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, lf32a.lfFaceName, -1,
|
|
|
|
lpChFont->lpLogFont->lfFaceName, LF_FACESIZE );
|
|
|
|
lpChFont->lpLogFont->lfFaceName[LF_FACESIZE-1] = 0;
|
1999-02-28 21:05:11 +01:00
|
|
|
return bRet;
|
|
|
|
}
|
2001-06-13 22:06:42 +02:00
|
|
|
#endif
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
#define TEXT_EXTRAS 4
|
|
|
|
#define TEXT_COLORS 16
|
|
|
|
|
|
|
|
static const COLORREF textcolors[TEXT_COLORS]=
|
|
|
|
{
|
|
|
|
0x00000000L,0x00000080L,0x00008000L,0x00008080L,
|
|
|
|
0x00800000L,0x00800080L,0x00808000L,0x00808080L,
|
|
|
|
0x00c0c0c0L,0x000000ffL,0x0000ff00L,0x0000ffffL,
|
|
|
|
0x00ff0000L,0x00ff00ffL,0x00ffff00L,0x00FFFFFFL
|
|
|
|
};
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CFn_HookCallChk [internal]
|
|
|
|
*/
|
|
|
|
static BOOL CFn_HookCallChk(LPCHOOSEFONT16 lpcf)
|
|
|
|
{
|
|
|
|
if (lpcf)
|
|
|
|
if(lpcf->Flags & CF_ENABLEHOOK)
|
|
|
|
if (lpcf->lpfnHook)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CFn_HookCallChk32 [internal]
|
|
|
|
*/
|
|
|
|
static BOOL CFn_HookCallChk32(LPCHOOSEFONTA lpcf)
|
|
|
|
{
|
|
|
|
if (lpcf)
|
|
|
|
if(lpcf->Flags & CF_ENABLEHOOK)
|
|
|
|
if (lpcf->lpfnHook)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-05-07 20:16:17 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
HWND hWnd1;
|
|
|
|
HWND hWnd2;
|
|
|
|
LPCHOOSEFONTA lpcf32a;
|
|
|
|
int added;
|
|
|
|
} CFn_ENUMSTRUCT, *LPCFn_ENUMSTRUCT;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* AddFontFamily [internal]
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static INT AddFontFamily(const LOGFONTA *lplf, UINT nFontType,
|
2001-05-07 20:16:17 +02:00
|
|
|
LPCHOOSEFONTA lpcf, HWND hwnd, LPCFn_ENUMSTRUCT e)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
WORD w;
|
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("font=%s (nFontType=%d)\n", lplf->lfFaceName,nFontType);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
if (lpcf->Flags & CF_FIXEDPITCHONLY)
|
|
|
|
if (!(lplf->lfPitchAndFamily & FIXED_PITCH))
|
|
|
|
return 1;
|
|
|
|
if (lpcf->Flags & CF_ANSIONLY)
|
|
|
|
if (lplf->lfCharSet != ANSI_CHARSET)
|
|
|
|
return 1;
|
|
|
|
if (lpcf->Flags & CF_TTONLY)
|
|
|
|
if (!(nFontType & TRUETYPE_FONTTYPE))
|
2002-06-01 01:06:46 +02:00
|
|
|
return 1;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2001-05-07 20:16:17 +02:00
|
|
|
if (e) e->added++;
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
i=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)lplf->lfFaceName);
|
|
|
|
if (i!=CB_ERR)
|
|
|
|
{
|
|
|
|
w=(lplf->lfCharSet << 8) | lplf->lfPitchAndFamily;
|
|
|
|
SendMessageA(hwnd, CB_SETITEMDATA, i, MAKELONG(nFontType,w));
|
|
|
|
return 1 ; /* store some important font information */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FontFamilyEnumProc32 [internal]
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static INT WINAPI FontFamilyEnumProc(const LOGFONTA *lpLogFont,
|
2000-11-25 04:09:30 +01:00
|
|
|
const TEXTMETRICA *metrics, DWORD dwFontType, LPARAM lParam)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
LPCFn_ENUMSTRUCT e;
|
|
|
|
e=(LPCFn_ENUMSTRUCT)lParam;
|
2001-05-07 20:16:17 +02:00
|
|
|
return AddFontFamily(lpLogFont, dwFontType, e->lpcf32a, e->hWnd1, e);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* FontFamilyEnumProc (COMMDLG.19)
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
|
|
|
INT16 WINAPI FontFamilyEnumProc16( SEGPTR logfont, SEGPTR metrics,
|
|
|
|
UINT16 nFontType, LPARAM lParam )
|
|
|
|
{
|
2002-09-06 22:40:42 +02:00
|
|
|
HWND hwnd=HWND_32(LOWORD(lParam));
|
2000-08-08 22:49:16 +02:00
|
|
|
HWND hDlg=GetParent(hwnd);
|
2002-06-01 01:06:46 +02:00
|
|
|
LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
|
2000-12-13 21:20:09 +01:00
|
|
|
LOGFONT16 *lplf = MapSL( logfont );
|
1999-02-28 21:05:11 +01:00
|
|
|
LOGFONTA lf32a;
|
|
|
|
FONT_LogFont16To32A(lplf, &lf32a);
|
|
|
|
return AddFontFamily(&lf32a, nFontType, (LPCHOOSEFONTA)lpcf->lpTemplateName,
|
2001-05-07 20:16:17 +02:00
|
|
|
hwnd,NULL);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SetFontStylesToCombo2 [internal]
|
|
|
|
*
|
|
|
|
* Fill font style information into combobox (without using font.c directly)
|
|
|
|
*/
|
2000-11-25 04:09:30 +01:00
|
|
|
static int SetFontStylesToCombo2(HWND hwnd, HDC hdc, const LOGFONTA *lplf)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
#define FSTYLES 4
|
|
|
|
struct FONTSTYLE
|
2002-06-01 01:06:46 +02:00
|
|
|
{ int italic;
|
1999-02-28 21:05:11 +01:00
|
|
|
int weight;
|
|
|
|
char stname[20]; };
|
2002-06-01 01:06:46 +02:00
|
|
|
static struct FONTSTYLE fontstyles[FSTYLES]={
|
1999-02-28 21:05:11 +01:00
|
|
|
{ 0,FW_NORMAL,"Regular"},{0,FW_BOLD,"Bold"},
|
|
|
|
{ 1,FW_NORMAL,"Italic"}, {1,FW_BOLD,"Bold Italic"}};
|
2000-08-08 22:49:16 +02:00
|
|
|
HFONT hf;
|
|
|
|
TEXTMETRICA tm;
|
1999-02-28 21:05:11 +01:00
|
|
|
int i,j;
|
2000-11-25 04:09:30 +01:00
|
|
|
LOGFONTA lf;
|
|
|
|
|
|
|
|
memcpy(&lf, lplf, sizeof(LOGFONTA));
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
for (i=0;i<FSTYLES;i++)
|
|
|
|
{
|
2000-11-25 04:09:30 +01:00
|
|
|
lf.lfItalic=fontstyles[i].italic;
|
|
|
|
lf.lfWeight=fontstyles[i].weight;
|
|
|
|
hf=CreateFontIndirectA(&lf);
|
1999-02-28 21:05:11 +01:00
|
|
|
hf=SelectObject(hdc,hf);
|
2000-08-08 22:49:16 +02:00
|
|
|
GetTextMetricsA(hdc,&tm);
|
1999-02-28 21:05:11 +01:00
|
|
|
hf=SelectObject(hdc,hf);
|
|
|
|
DeleteObject(hf);
|
|
|
|
|
|
|
|
if (tm.tmWeight==fontstyles[i].weight &&
|
|
|
|
tm.tmItalic==fontstyles[i].italic) /* font successful created ? */
|
|
|
|
{
|
2000-11-27 22:54:01 +01:00
|
|
|
j=SendMessageA(hwnd,CB_ADDSTRING,0,(LPARAM)fontstyles[i].stname );
|
1999-02-28 21:05:11 +01:00
|
|
|
if (j==CB_ERR) return 1;
|
2000-11-30 20:07:09 +01:00
|
|
|
j=SendMessageA(hwnd, CB_SETITEMDATA, j,
|
1999-02-28 21:05:11 +01:00
|
|
|
MAKELONG(fontstyles[i].weight,fontstyles[i].italic));
|
2002-06-01 01:06:46 +02:00
|
|
|
if (j==CB_ERR) return 1;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* AddFontSizeToCombo3 [internal]
|
|
|
|
*/
|
|
|
|
static int AddFontSizeToCombo3(HWND hwnd, UINT h, LPCHOOSEFONTA lpcf)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
char buffer[20];
|
|
|
|
|
|
|
|
if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
|
|
|
|
((lpcf->Flags & CF_LIMITSIZE) && (h >= lpcf->nSizeMin) && (h <= lpcf->nSizeMax)))
|
|
|
|
{
|
|
|
|
sprintf(buffer, "%2d", h);
|
|
|
|
j=SendMessageA(hwnd, CB_FINDSTRINGEXACT, -1, (LPARAM)buffer);
|
|
|
|
if (j==CB_ERR)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
j=SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)buffer);
|
|
|
|
if (j!=CB_ERR) j = SendMessageA(hwnd, CB_SETITEMDATA, j, h);
|
1999-02-28 21:05:11 +01:00
|
|
|
if (j==CB_ERR) return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* SetFontSizesToCombo3 [internal]
|
|
|
|
*/
|
|
|
|
static int SetFontSizesToCombo3(HWND hwnd, LPCHOOSEFONTA lpcf)
|
|
|
|
{
|
|
|
|
static const int sizes[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0; sizes[i]; i++)
|
|
|
|
if (AddFontSizeToCombo3(hwnd, sizes[i], lpcf)) return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AddFontStyle [internal]
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static INT AddFontStyle(const LOGFONTA *lplf, UINT nFontType,
|
1999-02-28 21:05:11 +01:00
|
|
|
LPCHOOSEFONTA lpcf, HWND hcmb2, HWND hcmb3, HWND hDlg)
|
|
|
|
{
|
|
|
|
int i;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("(nFontType=%d)\n",nFontType);
|
|
|
|
TRACE(" %s h=%ld w=%ld e=%ld o=%ld wg=%ld i=%d u=%d s=%d"
|
1999-02-28 21:05:11 +01:00
|
|
|
" ch=%d op=%d cp=%d q=%d pf=%xh\n",
|
|
|
|
lplf->lfFaceName,lplf->lfHeight,lplf->lfWidth,
|
|
|
|
lplf->lfEscapement,lplf->lfOrientation,
|
|
|
|
lplf->lfWeight,lplf->lfItalic,lplf->lfUnderline,
|
|
|
|
lplf->lfStrikeOut,lplf->lfCharSet, lplf->lfOutPrecision,
|
|
|
|
lplf->lfClipPrecision,lplf->lfQuality, lplf->lfPitchAndFamily);
|
|
|
|
if (nFontType & RASTER_FONTTYPE)
|
|
|
|
{
|
|
|
|
if (AddFontSizeToCombo3(hcmb3, lplf->lfHeight, lpcf)) return 0;
|
|
|
|
} else if (SetFontSizesToCombo3(hcmb3, lpcf)) return 0;
|
|
|
|
|
|
|
|
if (!SendMessageA(hcmb2, CB_GETCOUNT, 0, 0))
|
|
|
|
{
|
2002-02-02 19:06:03 +01:00
|
|
|
HDC hdc= ((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
|
1999-02-28 21:05:11 +01:00
|
|
|
i=SetFontStylesToCombo2(hcmb2,hdc,lplf);
|
2002-02-02 19:06:03 +01:00
|
|
|
if (!((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC))
|
1999-02-28 21:05:11 +01:00
|
|
|
ReleaseDC(hDlg,hdc);
|
|
|
|
if (i)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1 ;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* FontStyleEnumProc (COMMDLG.18)
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
|
|
|
INT16 WINAPI FontStyleEnumProc16( SEGPTR logfont, SEGPTR metrics,
|
|
|
|
UINT16 nFontType, LPARAM lParam )
|
|
|
|
{
|
2002-09-06 22:40:42 +02:00
|
|
|
HWND hcmb2=HWND_32(LOWORD(lParam));
|
|
|
|
HWND hcmb3=HWND_32(HIWORD(lParam));
|
2000-08-08 22:49:16 +02:00
|
|
|
HWND hDlg=GetParent(hcmb3);
|
2002-06-01 01:06:46 +02:00
|
|
|
LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
|
2000-12-13 21:20:09 +01:00
|
|
|
LOGFONT16 *lplf = MapSL(logfont);
|
1999-02-28 21:05:11 +01:00
|
|
|
LOGFONTA lf32a;
|
|
|
|
FONT_LogFont16To32A(lplf, &lf32a);
|
|
|
|
return AddFontStyle(&lf32a, nFontType, (LPCHOOSEFONTA)lpcf->lpTemplateName,
|
|
|
|
hcmb2, hcmb3, hDlg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FontStyleEnumProc32 [internal]
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static INT WINAPI FontStyleEnumProc( const LOGFONTA *lpFont,
|
2000-11-25 04:09:30 +01:00
|
|
|
const TEXTMETRICA *metrics, DWORD dwFontType, LPARAM lParam )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
LPCFn_ENUMSTRUCT s=(LPCFn_ENUMSTRUCT)lParam;
|
|
|
|
HWND hcmb2=s->hWnd1;
|
|
|
|
HWND hcmb3=s->hWnd2;
|
|
|
|
HWND hDlg=GetParent(hcmb3);
|
2000-11-25 04:09:30 +01:00
|
|
|
return AddFontStyle(lpFont, dwFontType, s->lpcf32a, hcmb2,
|
1999-02-28 21:05:11 +01:00
|
|
|
hcmb3, hDlg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CFn_WMInitDialog [internal]
|
|
|
|
*/
|
1999-06-26 16:58:24 +02:00
|
|
|
static LRESULT CFn_WMInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam,
|
1999-02-28 21:05:11 +01:00
|
|
|
LPCHOOSEFONTA lpcf)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
int i,j,res,init=0;
|
|
|
|
long l;
|
|
|
|
LPLOGFONTA lpxx;
|
|
|
|
HCURSOR hcursor=SetCursor(LoadCursorA(0,IDC_WAITA));
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
SetWindowLongA(hDlg, DWL_USER, lParam);
|
1999-02-28 21:05:11 +01:00
|
|
|
lpxx=lpcf->lpLogFont;
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("WM_INITDIALOG lParam=%08lX\n", lParam);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
if (lpcf->lStructSize != sizeof(CHOOSEFONTA))
|
|
|
|
{
|
1999-06-12 17:45:58 +02:00
|
|
|
ERR("structure size failure !!!\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
EndDialog (hDlg, 0);
|
1999-02-28 21:05:11 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!hBitmapTT)
|
|
|
|
hBitmapTT = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_TRTYPE));
|
|
|
|
|
|
|
|
/* This font will be deleted by WM_COMMAND */
|
2002-11-08 19:56:46 +01:00
|
|
|
SendDlgItemMessageA(hDlg,stc5,WM_SETFONT,
|
2002-11-01 02:50:06 +01:00
|
|
|
(WPARAM)CreateFontA(0, 0, 1, 1, 400, 0, 0, 0, 0, 0, 0, 0, 0, NULL),FALSE);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
if (!(lpcf->Flags & CF_SHOWHELP) || !IsWindow(lpcf->hwndOwner))
|
|
|
|
ShowWindow(GetDlgItem(hDlg,pshHelp),SW_HIDE);
|
|
|
|
if (!(lpcf->Flags & CF_APPLY))
|
|
|
|
ShowWindow(GetDlgItem(hDlg,psh3),SW_HIDE);
|
|
|
|
if (lpcf->Flags & CF_EFFECTS)
|
|
|
|
{
|
|
|
|
for (res=1,i=0;res && i<TEXT_COLORS;i++)
|
|
|
|
{
|
|
|
|
/* FIXME: load color name from resource: res=LoadString(...,i+....,buffer,.....); */
|
|
|
|
char name[20];
|
|
|
|
strcpy( name, "[color name]" );
|
|
|
|
j=SendDlgItemMessageA(hDlg, cmb4, CB_ADDSTRING, 0, (LPARAM)name);
|
|
|
|
SendDlgItemMessageA(hDlg, cmb4, CB_SETITEMDATA16, j, textcolors[j]);
|
|
|
|
/* look for a fitting value in color combobox */
|
|
|
|
if (textcolors[j]==lpcf->rgbColors)
|
|
|
|
SendDlgItemMessageA(hDlg,cmb4, CB_SETCURSEL,j,0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ShowWindow(GetDlgItem(hDlg,cmb4),SW_HIDE);
|
|
|
|
ShowWindow(GetDlgItem(hDlg,chx1),SW_HIDE);
|
|
|
|
ShowWindow(GetDlgItem(hDlg,chx2),SW_HIDE);
|
|
|
|
ShowWindow(GetDlgItem(hDlg,grp1),SW_HIDE);
|
|
|
|
ShowWindow(GetDlgItem(hDlg,stc4),SW_HIDE);
|
|
|
|
}
|
2002-02-02 19:06:03 +01:00
|
|
|
hdc= ((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
|
1999-02-28 21:05:11 +01:00
|
|
|
if (hdc)
|
|
|
|
{
|
|
|
|
CFn_ENUMSTRUCT s;
|
|
|
|
s.hWnd1=GetDlgItem(hDlg,cmb1);
|
|
|
|
s.lpcf32a=lpcf;
|
2001-05-07 20:16:17 +02:00
|
|
|
do {
|
|
|
|
s.added = 0;
|
|
|
|
if (!EnumFontFamiliesA(hdc, NULL, FontFamilyEnumProc, (LPARAM)&s)) {
|
|
|
|
TRACE("EnumFontFamilies returns 0\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (s.added) break;
|
|
|
|
if (lpcf->Flags & CF_FIXEDPITCHONLY) {
|
|
|
|
FIXME("No founds found with fixed pitch only, dropping flag.\n");
|
|
|
|
lpcf->Flags &= ~CF_FIXEDPITCHONLY;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (lpcf->Flags & CF_TTONLY) {
|
|
|
|
FIXME("No founds found with truetype only, dropping flag.\n");
|
|
|
|
lpcf->Flags &= ~CF_TTONLY;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} while (1);
|
|
|
|
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
if (lpcf->Flags & CF_INITTOLOGFONTSTRUCT)
|
|
|
|
{
|
|
|
|
/* look for fitting font name in combobox1 */
|
|
|
|
j=SendDlgItemMessageA(hDlg,cmb1,CB_FINDSTRING,-1,(LONG)lpxx->lfFaceName);
|
|
|
|
if (j!=CB_ERR)
|
|
|
|
{
|
|
|
|
SendDlgItemMessageA(hDlg, cmb1, CB_SETCURSEL, j, 0);
|
|
|
|
SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
|
2002-09-06 22:40:42 +02:00
|
|
|
(LPARAM)GetDlgItem(hDlg,cmb1));
|
1999-02-28 21:05:11 +01:00
|
|
|
init=1;
|
|
|
|
/* look for fitting font style in combobox2 */
|
|
|
|
l=MAKELONG(lpxx->lfWeight > FW_MEDIUM ? FW_BOLD:FW_NORMAL,lpxx->lfItalic !=0);
|
|
|
|
for (i=0;i<TEXT_EXTRAS;i++)
|
|
|
|
{
|
|
|
|
if (l==SendDlgItemMessageA(hDlg, cmb2, CB_GETITEMDATA, i, 0))
|
|
|
|
SendDlgItemMessageA(hDlg, cmb2, CB_SETCURSEL, i, 0);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/* look for fitting font size in combobox3 */
|
|
|
|
j=SendDlgItemMessageA(hDlg, cmb3, CB_GETCOUNT, 0, 0);
|
|
|
|
for (i=0;i<j;i++)
|
|
|
|
{
|
|
|
|
if (lpxx->lfHeight==(int)SendDlgItemMessageA(hDlg,cmb3, CB_GETITEMDATA,i,0))
|
|
|
|
SendDlgItemMessageA(hDlg,cmb3,CB_SETCURSEL,i,0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!init)
|
|
|
|
{
|
|
|
|
SendDlgItemMessageA(hDlg,cmb1,CB_SETCURSEL,0,0);
|
|
|
|
SendMessageA(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
|
2002-09-06 22:40:42 +02:00
|
|
|
(LPARAM)GetDlgItem(hDlg,cmb1));
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
if (lpcf->Flags & CF_USESTYLE && lpcf->lpszStyle)
|
|
|
|
{
|
|
|
|
j=SendDlgItemMessageA(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,
|
2002-09-06 22:40:42 +02:00
|
|
|
MAKELONG(HWND_16(GetDlgItem(hDlg,cmb2)),CBN_SELCHANGE));
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-06-12 17:45:58 +02:00
|
|
|
WARN("HDC failure !!!\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
EndDialog (hDlg, 0);
|
1999-02-28 21:05:11 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-02-02 19:06:03 +01:00
|
|
|
if (!((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC))
|
1999-02-28 21:05:11 +01:00
|
|
|
ReleaseDC(hDlg,hdc);
|
2002-06-01 01:06:46 +02:00
|
|
|
SetCursor(hcursor);
|
1999-02-28 21:05:11 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CFn_WMMeasureItem [internal]
|
|
|
|
*/
|
1999-06-26 16:58:24 +02:00
|
|
|
static LRESULT CFn_WMMeasureItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
BITMAP bm;
|
|
|
|
LPMEASUREITEMSTRUCT lpmi=(LPMEASUREITEMSTRUCT)lParam;
|
|
|
|
if (!hBitmapTT)
|
|
|
|
hBitmapTT = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_TRTYPE));
|
|
|
|
GetObjectA( hBitmapTT, sizeof(bm), &bm );
|
|
|
|
lpmi->itemHeight=bm.bmHeight;
|
|
|
|
/* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CFn_WMDrawItem [internal]
|
|
|
|
*/
|
1999-06-26 16:58:24 +02:00
|
|
|
static LRESULT CFn_WMDrawItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
HBRUSH hBrush;
|
|
|
|
char buffer[40];
|
|
|
|
BITMAP bm;
|
|
|
|
COLORREF cr, oldText=0, oldBk=0;
|
|
|
|
RECT rect;
|
2002-06-01 01:06:46 +02:00
|
|
|
#if 0
|
1999-02-28 21:05:11 +01:00
|
|
|
HDC hMemDC;
|
|
|
|
int nFontType;
|
|
|
|
HBITMAP hBitmap; /* for later TT usage */
|
2002-06-01 01:06:46 +02:00
|
|
|
#endif
|
1999-02-28 21:05:11 +01:00
|
|
|
LPDRAWITEMSTRUCT lpdi = (LPDRAWITEMSTRUCT)lParam;
|
|
|
|
|
2001-11-12 16:48:20 +01:00
|
|
|
if (lpdi->itemID == (UINT)-1) /* got no items */
|
1999-02-28 21:05:11 +01:00
|
|
|
DrawFocusRect(lpdi->hDC, &lpdi->rcItem);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (lpdi->CtlType == ODT_COMBOBOX)
|
|
|
|
{
|
|
|
|
if (lpdi->itemState ==ODS_SELECTED)
|
|
|
|
{
|
|
|
|
hBrush=GetSysColorBrush(COLOR_HIGHLIGHT);
|
|
|
|
oldText=SetTextColor(lpdi->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
|
|
|
oldBk=SetBkColor(lpdi->hDC, GetSysColor(COLOR_HIGHLIGHT));
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
hBrush = SelectObject(lpdi->hDC, GetStockObject(LTGRAY_BRUSH));
|
|
|
|
SelectObject(lpdi->hDC, hBrush);
|
|
|
|
}
|
|
|
|
FillRect(lpdi->hDC, &lpdi->rcItem, hBrush);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return TRUE; /* this should never happen */
|
|
|
|
|
|
|
|
rect=lpdi->rcItem;
|
|
|
|
switch (lpdi->CtlID)
|
|
|
|
{
|
|
|
|
case cmb1: /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
|
|
|
|
SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
|
2002-06-01 01:06:46 +02:00
|
|
|
(LPARAM)buffer);
|
1999-02-28 21:05:11 +01:00
|
|
|
GetObjectA( hBitmapTT, sizeof(bm), &bm );
|
|
|
|
TextOutA(lpdi->hDC, lpdi->rcItem.left + bm.bmWidth + 10,
|
2000-08-14 16:41:19 +02:00
|
|
|
lpdi->rcItem.top, buffer, strlen(buffer));
|
1999-02-28 21:05:11 +01:00
|
|
|
#if 0
|
|
|
|
nFontType = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
|
|
|
|
/* FIXME: draw bitmap if truetype usage */
|
|
|
|
if (nFontType&TRUETYPE_FONTTYPE)
|
|
|
|
{
|
|
|
|
hMemDC = CreateCompatibleDC(lpdi->hDC);
|
|
|
|
hBitmap = SelectObject(hMemDC, hBitmapTT);
|
|
|
|
BitBlt(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top,
|
|
|
|
bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
|
|
|
|
SelectObject(hMemDC, hBitmap);
|
|
|
|
DeleteDC(hMemDC);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case cmb2:
|
|
|
|
case cmb3: /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
|
|
|
|
SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
|
|
|
|
(LPARAM)buffer);
|
|
|
|
TextOutA(lpdi->hDC, lpdi->rcItem.left,
|
2000-08-14 16:41:19 +02:00
|
|
|
lpdi->rcItem.top, buffer, strlen(buffer));
|
1999-02-28 21:05:11 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case cmb4: /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
|
|
|
|
SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
|
|
|
|
(LPARAM)buffer);
|
|
|
|
TextOutA(lpdi->hDC, lpdi->rcItem.left + 25+5,
|
2000-08-14 16:41:19 +02:00
|
|
|
lpdi->rcItem.top, buffer, strlen(buffer));
|
1999-02-28 21:05:11 +01:00
|
|
|
cr = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
|
|
|
|
hBrush = CreateSolidBrush(cr);
|
|
|
|
if (hBrush)
|
|
|
|
{
|
|
|
|
hBrush = SelectObject (lpdi->hDC, hBrush) ;
|
|
|
|
rect.right=rect.left+25;
|
|
|
|
rect.top++;
|
|
|
|
rect.left+=5;
|
|
|
|
rect.bottom--;
|
|
|
|
Rectangle( lpdi->hDC, rect.left, rect.top,
|
|
|
|
rect.right, rect.bottom );
|
|
|
|
DeleteObject( SelectObject (lpdi->hDC, hBrush)) ;
|
|
|
|
}
|
|
|
|
rect=lpdi->rcItem;
|
|
|
|
rect.left+=25+5;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: return TRUE; /* this should never happen */
|
|
|
|
}
|
|
|
|
if (lpdi->itemState == ODS_SELECTED)
|
|
|
|
{
|
|
|
|
SetTextColor(lpdi->hDC, oldText);
|
|
|
|
SetBkColor(lpdi->hDC, oldBk);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CFn_WMCtlColor [internal]
|
|
|
|
*/
|
1999-06-26 16:58:24 +02:00
|
|
|
static LRESULT CFn_WMCtlColorStatic(HWND hDlg, WPARAM wParam, LPARAM lParam,
|
1999-02-28 21:05:11 +01:00
|
|
|
LPCHOOSEFONTA lpcf)
|
|
|
|
{
|
|
|
|
if (lpcf->Flags & CF_EFFECTS)
|
2002-11-08 19:56:46 +01:00
|
|
|
if (GetDlgCtrlID(HWND_32(LOWORD(lParam)))==stc5)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
SetTextColor((HDC)wParam, lpcf->rgbColors);
|
2002-11-01 02:50:06 +01:00
|
|
|
return (LRESULT)GetStockObject(WHITE_BRUSH);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CFn_WMCommand [internal]
|
|
|
|
*/
|
1999-06-26 16:58:24 +02:00
|
|
|
static LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam,
|
1999-02-28 21:05:11 +01:00
|
|
|
LPCHOOSEFONTA lpcf)
|
|
|
|
{
|
|
|
|
HFONT hFont;
|
|
|
|
int i,j;
|
|
|
|
long l;
|
|
|
|
HDC hdc;
|
|
|
|
LPLOGFONTA lpxx=lpcf->lpLogFont;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("WM_COMMAND wParam=%08lX lParam=%08lX\n", (LONG)wParam, lParam);
|
1999-02-28 21:05:11 +01:00
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case cmb1:if (HIWORD(wParam)==CBN_SELCHANGE)
|
|
|
|
{
|
2002-02-02 19:06:03 +01:00
|
|
|
hdc=((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC) ? lpcf->hDC : GetDC(hDlg);
|
1999-02-28 21:05:11 +01:00
|
|
|
if (hdc)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
SendDlgItemMessageA(hDlg, cmb2, CB_RESETCONTENT16, 0, 0);
|
1999-02-28 21:05:11 +01:00
|
|
|
SendDlgItemMessageA(hDlg, cmb3, CB_RESETCONTENT16, 0, 0);
|
|
|
|
i=SendDlgItemMessageA(hDlg, cmb1, CB_GETCURSEL16, 0, 0);
|
|
|
|
if (i!=CB_ERR)
|
|
|
|
{
|
|
|
|
HCURSOR hcursor=SetCursor(LoadCursorA(0,IDC_WAITA));
|
|
|
|
CFn_ENUMSTRUCT s;
|
|
|
|
char str[256];
|
|
|
|
SendDlgItemMessageA(hDlg, cmb1, CB_GETLBTEXT, i,
|
|
|
|
(LPARAM)str);
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("WM_COMMAND/cmb1 =>%s\n",str);
|
1999-02-28 21:05:11 +01:00
|
|
|
s.hWnd1=GetDlgItem(hDlg, cmb2);
|
|
|
|
s.hWnd2=GetDlgItem(hDlg, cmb3);
|
|
|
|
s.lpcf32a=lpcf;
|
|
|
|
EnumFontFamiliesA(hdc, str, FontStyleEnumProc, (LPARAM)&s);
|
2001-05-05 02:42:54 +02:00
|
|
|
SendDlgItemMessageA(hDlg,cmb2, CB_SETCURSEL, 0, 0);
|
|
|
|
SendDlgItemMessageA(hDlg,cmb3, CB_SETCURSEL, 0, 0);
|
1999-02-28 21:05:11 +01:00
|
|
|
SetCursor(hcursor);
|
|
|
|
}
|
2002-02-02 19:06:03 +01:00
|
|
|
if (!((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC))
|
1999-02-28 21:05:11 +01:00
|
|
|
ReleaseDC(hDlg,hdc);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-06-12 17:45:58 +02:00
|
|
|
WARN("HDC failure !!!\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
EndDialog (hDlg, 0);
|
1999-02-28 21:05:11 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case chx1:
|
|
|
|
case chx2:
|
|
|
|
case cmb2:
|
|
|
|
case cmb3:if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED )
|
|
|
|
{
|
|
|
|
char str[256];
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("WM_COMMAND/cmb2,3 =%08lX\n", lParam);
|
1999-02-28 21:05:11 +01:00
|
|
|
i=SendDlgItemMessageA(hDlg,cmb1,CB_GETCURSEL,0,0);
|
|
|
|
if (i==CB_ERR)
|
|
|
|
i=GetDlgItemTextA( hDlg, cmb1, str, 256 );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SendDlgItemMessageA(hDlg,cmb1,CB_GETLBTEXT,i,
|
|
|
|
(LPARAM)str);
|
|
|
|
l=SendDlgItemMessageA(hDlg,cmb1,CB_GETITEMDATA,i,0);
|
|
|
|
j=HIWORD(l);
|
|
|
|
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=j&0xff;
|
|
|
|
lpxx->lfCharSet=j>>8;
|
|
|
|
}
|
|
|
|
strcpy(lpxx->lfFaceName,str);
|
|
|
|
i=SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
|
|
|
|
if (i!=CB_ERR)
|
|
|
|
{
|
|
|
|
l=SendDlgItemMessageA(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);
|
|
|
|
if (i!=CB_ERR)
|
|
|
|
lpxx->lfHeight=-LOWORD(SendDlgItemMessageA(hDlg, cmb3, CB_GETITEMDATA, i, 0));
|
|
|
|
else
|
|
|
|
lpxx->lfHeight=0;
|
|
|
|
lpxx->lfStrikeOut=IsDlgButtonChecked(hDlg,chx1);
|
|
|
|
lpxx->lfUnderline=IsDlgButtonChecked(hDlg,chx2);
|
|
|
|
lpxx->lfWidth=lpxx->lfOrientation=lpxx->lfEscapement=0;
|
|
|
|
lpxx->lfOutPrecision=OUT_DEFAULT_PRECIS;
|
|
|
|
lpxx->lfClipPrecision=CLIP_DEFAULT_PRECIS;
|
|
|
|
lpxx->lfQuality=DEFAULT_QUALITY;
|
|
|
|
lpcf->iPointSize= -10*lpxx->lfHeight;
|
|
|
|
|
|
|
|
hFont=CreateFontIndirectA(lpxx);
|
|
|
|
if (hFont)
|
|
|
|
{
|
2002-11-08 19:56:46 +01:00
|
|
|
HFONT oldFont=(HFONT)SendDlgItemMessageA(hDlg, stc5,
|
1999-02-28 21:05:11 +01:00
|
|
|
WM_GETFONT, 0, 0);
|
2002-11-08 19:56:46 +01:00
|
|
|
SendDlgItemMessageA(hDlg,stc5,WM_SETFONT,(WPARAM)hFont,TRUE);
|
1999-02-28 21:05:11 +01:00
|
|
|
DeleteObject(oldFont);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case cmb4:i=SendDlgItemMessageA(hDlg, cmb4, CB_GETCURSEL, 0, 0);
|
|
|
|
if (i!=CB_ERR)
|
|
|
|
{
|
|
|
|
lpcf->rgbColors=textcolors[i];
|
2002-11-08 19:56:46 +01:00
|
|
|
InvalidateRect( GetDlgItem(hDlg,stc5), NULL, 0 );
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-01-22 03:13:58 +01:00
|
|
|
case psh15:i=RegisterWindowMessageA( HELPMSGSTRINGA );
|
1999-02-28 21:05:11 +01:00
|
|
|
if (lpcf->hwndOwner)
|
|
|
|
SendMessageA(lpcf->hwndOwner, i, 0, (LPARAM)GetWindowLongA(hDlg, DWL_USER));
|
|
|
|
/* if (CFn_HookCallChk(lpcf))
|
|
|
|
CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDOK:if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
|
2002-06-01 01:06:46 +02:00
|
|
|
( (lpcf->Flags & CF_LIMITSIZE) &&
|
|
|
|
(-lpxx->lfHeight >= lpcf->nSizeMin) &&
|
1999-02-28 21:05:11 +01:00
|
|
|
(-lpxx->lfHeight <= lpcf->nSizeMax)))
|
|
|
|
EndDialog(hDlg, TRUE);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char buffer[80];
|
|
|
|
sprintf(buffer,"Select a font size between %d and %d points.",
|
|
|
|
lpcf->nSizeMin,lpcf->nSizeMax);
|
|
|
|
MessageBoxA(hDlg, buffer, NULL, MB_OK);
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
return(TRUE);
|
|
|
|
case IDCANCEL:EndDialog(hDlg, FALSE);
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT CFn_WMDestroy(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2002-11-08 19:56:46 +01:00
|
|
|
DeleteObject((HFONT)SendDlgItemMessageA(hwnd, stc5, WM_GETFONT, 0, 0));
|
1999-02-28 21:05:11 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* FormatCharDlgProc (COMMDLG.16)
|
1999-02-28 21:05:11 +01:00
|
|
|
FIXME: 1. some strings are "hardcoded", but it's better load from sysres
|
|
|
|
2. some CF_.. flags are not supported
|
|
|
|
3. some TType extensions
|
|
|
|
*/
|
2002-10-31 02:04:39 +01:00
|
|
|
BOOL16 CALLBACK FormatCharDlgProc16(HWND16 hDlg16, UINT16 message,
|
2002-09-06 22:40:42 +02:00
|
|
|
WPARAM16 wParam, LPARAM lParam)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2002-09-06 22:40:42 +02:00
|
|
|
HWND hDlg = HWND_32(hDlg16);
|
1999-02-28 21:05:11 +01:00
|
|
|
LPCHOOSEFONT16 lpcf;
|
|
|
|
LPCHOOSEFONTA lpcf32a;
|
2002-10-31 02:04:39 +01:00
|
|
|
BOOL16 res=0;
|
1999-02-28 21:05:11 +01:00
|
|
|
if (message!=WM_INITDIALOG)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
|
1999-02-28 21:05:11 +01:00
|
|
|
if (!lpcf)
|
|
|
|
return FALSE;
|
|
|
|
if (CFn_HookCallChk(lpcf))
|
2002-09-06 22:40:42 +02:00
|
|
|
res=CallWindowProc16((WNDPROC16)lpcf->lpfnHook,hDlg16,message,wParam,lParam);
|
1999-02-28 21:05:11 +01:00
|
|
|
if (res)
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lpcf=(LPCHOOSEFONT16)lParam;
|
|
|
|
lpcf32a=(LPCHOOSEFONTA)lpcf->lpTemplateName;
|
2002-06-01 01:06:46 +02:00
|
|
|
if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("CFn_WMInitDialog returned FALSE\n");
|
1999-02-28 21:05:11 +01:00
|
|
|
return FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
if (CFn_HookCallChk(lpcf))
|
2002-09-06 22:40:42 +02:00
|
|
|
return CallWindowProc16((WNDPROC16)lpcf->lpfnHook,hDlg16,WM_INITDIALOG,wParam,lParam);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
lpcf32a=(LPCHOOSEFONTA)lpcf->lpTemplateName;
|
2000-11-30 20:07:09 +01:00
|
|
|
switch (message)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-11-30 20:07:09 +01:00
|
|
|
case WM_MEASUREITEM:
|
|
|
|
{
|
2000-12-13 21:20:09 +01:00
|
|
|
MEASUREITEMSTRUCT16* mis16 = MapSL(lParam);
|
2000-11-30 20:07:09 +01:00
|
|
|
MEASUREITEMSTRUCT mis;
|
|
|
|
mis.CtlType = mis16->CtlType;
|
|
|
|
mis.CtlID = mis16->CtlID;
|
|
|
|
mis.itemID = mis16->itemID;
|
|
|
|
mis.itemWidth = mis16->itemWidth;
|
|
|
|
mis.itemHeight = mis16->itemHeight;
|
|
|
|
mis.itemData = mis16->itemData;
|
|
|
|
res = CFn_WMMeasureItem(hDlg, wParam, (LPARAM)&mis);
|
|
|
|
mis16->itemWidth = (UINT16)mis.itemWidth;
|
|
|
|
mis16->itemHeight = (UINT16)mis.itemHeight;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_DRAWITEM:
|
|
|
|
{
|
2000-12-13 21:20:09 +01:00
|
|
|
DRAWITEMSTRUCT16* dis16 = MapSL(lParam);
|
2000-11-30 20:07:09 +01:00
|
|
|
DRAWITEMSTRUCT dis;
|
|
|
|
dis.CtlType = dis16->CtlType;
|
|
|
|
dis.CtlID = dis16->CtlID;
|
|
|
|
dis.itemID = dis16->itemID;
|
|
|
|
dis.itemAction = dis16->itemAction;
|
|
|
|
dis.itemState = dis16->itemState;
|
2002-09-06 22:40:42 +02:00
|
|
|
dis.hwndItem = HWND_32(dis16->hwndItem);
|
2002-11-01 02:50:06 +01:00
|
|
|
dis.hDC = HDC_32(dis16->hDC);
|
2000-11-30 20:07:09 +01:00
|
|
|
dis.itemData = dis16->itemData;
|
|
|
|
CONV_RECT16TO32( &dis16->rcItem, &dis.rcItem );
|
|
|
|
res = CFn_WMDrawItem(hDlg, wParam, (LPARAM)&dis);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_CTLCOLOR:
|
|
|
|
if (HIWORD(lParam) == CTLCOLOR_STATIC)
|
2002-11-01 02:50:06 +01:00
|
|
|
res=CFn_WMCtlColorStatic(hDlg, wParam, LOWORD(lParam), lpcf32a);
|
2000-11-30 20:07:09 +01:00
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
res=CFn_WMCommand(hDlg, MAKEWPARAM( wParam, HIWORD(lParam) ), LOWORD(lParam), lpcf32a);
|
|
|
|
break;
|
|
|
|
case WM_DESTROY:
|
|
|
|
res=CFn_WMDestroy(hDlg, wParam, lParam);
|
|
|
|
break;
|
|
|
|
case WM_CHOOSEFONT_GETLOGFONT:
|
|
|
|
TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n", lParam);
|
|
|
|
FIXME("current logfont back to caller\n");
|
|
|
|
break;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* FormatCharDlgProcA [internal]
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2002-10-31 02:04:39 +01:00
|
|
|
INT_PTR CALLBACK FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
|
1999-02-28 21:05:11 +01:00
|
|
|
LPARAM lParam)
|
|
|
|
{
|
|
|
|
LPCHOOSEFONTA lpcf;
|
2002-10-31 02:04:39 +01:00
|
|
|
INT_PTR res = FALSE;
|
1999-02-28 21:05:11 +01:00
|
|
|
if (uMsg!=WM_INITDIALOG)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
lpcf=(LPCHOOSEFONTA)GetWindowLongA(hDlg, DWL_USER);
|
1999-02-28 21:05:11 +01:00
|
|
|
if (!lpcf)
|
|
|
|
return FALSE;
|
|
|
|
if (CFn_HookCallChk32(lpcf))
|
1999-06-05 17:23:20 +02:00
|
|
|
res=CallWindowProcA((WNDPROC)lpcf->lpfnHook, hDlg, uMsg, wParam, lParam);
|
1999-02-28 21:05:11 +01:00
|
|
|
if (res)
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lpcf=(LPCHOOSEFONTA)lParam;
|
2002-06-01 01:06:46 +02:00
|
|
|
if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("CFn_WMInitDialog returned FALSE\n");
|
1999-02-28 21:05:11 +01:00
|
|
|
return FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
if (CFn_HookCallChk32(lpcf))
|
1999-06-05 17:23:20 +02:00
|
|
|
return CallWindowProcA((WNDPROC)lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_MEASUREITEM:
|
|
|
|
return CFn_WMMeasureItem(hDlg, wParam, lParam);
|
|
|
|
case WM_DRAWITEM:
|
|
|
|
return CFn_WMDrawItem(hDlg, wParam, lParam);
|
|
|
|
case WM_CTLCOLORSTATIC:
|
|
|
|
return CFn_WMCtlColorStatic(hDlg, wParam, lParam, lpcf);
|
|
|
|
case WM_COMMAND:
|
|
|
|
return CFn_WMCommand(hDlg, wParam, lParam, lpcf);
|
|
|
|
case WM_DESTROY:
|
|
|
|
return CFn_WMDestroy(hDlg, wParam, lParam);
|
|
|
|
case WM_CHOOSEFONT_GETLOGFONT:
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
|
1999-02-28 21:05:11 +01:00
|
|
|
lParam);
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("current logfont back to caller\n");
|
1999-02-28 21:05:11 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* FormatCharDlgProcW [internal]
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2002-10-31 02:04:39 +01:00
|
|
|
INT_PTR CALLBACK FormatCharDlgProcW(HWND hDlg, UINT uMsg, WPARAM wParam,
|
1999-02-28 21:05:11 +01:00
|
|
|
LPARAM lParam)
|
|
|
|
{
|
|
|
|
LPCHOOSEFONTW lpcf32w;
|
|
|
|
LPCHOOSEFONTA lpcf32a;
|
2002-10-31 02:04:39 +01:00
|
|
|
INT_PTR res = FALSE;
|
1999-02-28 21:05:11 +01:00
|
|
|
if (uMsg!=WM_INITDIALOG)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
lpcf32w=(LPCHOOSEFONTW)GetWindowLongA(hDlg, DWL_USER);
|
1999-02-28 21:05:11 +01:00
|
|
|
if (!lpcf32w)
|
|
|
|
return FALSE;
|
|
|
|
if (CFn_HookCallChk32((LPCHOOSEFONTA)lpcf32w))
|
1999-06-05 17:23:20 +02:00
|
|
|
res=CallWindowProcW((WNDPROC)lpcf32w->lpfnHook, hDlg, uMsg, wParam, lParam);
|
1999-02-28 21:05:11 +01:00
|
|
|
if (res)
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lpcf32w=(LPCHOOSEFONTW)lParam;
|
|
|
|
lpcf32a=(LPCHOOSEFONTA)lpcf32w->lpTemplateName;
|
2002-06-01 01:06:46 +02:00
|
|
|
if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("CFn_WMInitDialog returned FALSE\n");
|
1999-02-28 21:05:11 +01:00
|
|
|
return FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
if (CFn_HookCallChk32((LPCHOOSEFONTA)lpcf32w))
|
1999-06-05 17:23:20 +02:00
|
|
|
return CallWindowProcW((WNDPROC)lpcf32w->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
lpcf32a=(LPCHOOSEFONTA)lpcf32w->lpTemplateName;
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_MEASUREITEM:
|
|
|
|
return CFn_WMMeasureItem(hDlg, wParam, lParam);
|
|
|
|
case WM_DRAWITEM:
|
|
|
|
return CFn_WMDrawItem(hDlg, wParam, lParam);
|
|
|
|
case WM_CTLCOLORSTATIC:
|
|
|
|
return CFn_WMCtlColorStatic(hDlg, wParam, lParam, lpcf32a);
|
|
|
|
case WM_COMMAND:
|
|
|
|
return CFn_WMCommand(hDlg, wParam, lParam, lpcf32a);
|
|
|
|
case WM_DESTROY:
|
|
|
|
return CFn_WMDestroy(hDlg, wParam, lParam);
|
2002-06-01 01:06:46 +02:00
|
|
|
case WM_CHOOSEFONT_GETLOGFONT:
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
|
1999-02-28 21:05:11 +01:00
|
|
|
lParam);
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("current logfont back to caller\n");
|
1999-02-28 21:05:11 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|