fontdialog patch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Changelog:
	dlls/commdlg	: Makefile.in,
			 cdlg_xx.rc,
			 cdlg.h,
			 fontdlg.c,
			 fontdlg16.c
	include		: wingdi.h

	- Add a bitmap resource with the font icons: TrueType, printer,
	OpenType and Type 1. Modify the code so that they will be used
	if or when the needed bits are passed to the FontEnumProc.
	- Use EnumFontFamiliesEx instead of EnumFontFamilies.
	- Fix the fixme in the WM_MEASUREITEM message handler.

Rein.
-- 
Rein Klazes
rklazes@xxxxxxxxx
--- wine/dlls/commdlg/Makefile.in	2003-12-12 09:57:34.000000000 +0100
+++ mywine/dlls/commdlg/Makefile.in	2003-12-12 16:50:05.000000000 +0100
@@ -31,6 +31,7 @@
 RC_BINSRC = cdlg_xx.rc
 RC_BINARIES = \
 	800.bmp \
+	fontpics.bmp \
 	cdrom.ico \
 	floppy.ico \
 	folder2.ico \
--- wine/dlls/commdlg/cdlg_xx.rc	2003-12-16 09:19:43.000000000 +0100
+++ mywine/dlls/commdlg/cdlg_xx.rc	2003-12-18 19:19:11.000000000 +0100
@@ -566,3 +566,56 @@
  '00 00 80 00 00 00 80 00 00 00 80 00 00 00 C0 00'
  '00 00 E0 01 00 00 FF FF 00 00 FF FF 00 00'
 } */
+
+/* BINRES fontpics.bmp */
+38 BITMAP DISCARDABLE LOADONCALL fontpics.bmp
+/*{
+ '42 4D E6 02 00 00 00 00 00 00 76 00 00 00 28 00'
+ '00 00 64 00 00 00 0C 00 00 00 01 00 04 00 00 00'
+ '00 00 70 02 00 00 00 00 00 00 00 00 00 00 00 00'
+ '00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 80'
+ '00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80'
+ '00 00 C0 C0 C0 00 80 80 80 00 00 00 FF 00 00 FF'
+ '00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF'
+ '00 00 FF FF FF 00 CC CC CC CC C5 55 55 5C CC CC'
+ 'CC C0 00 00 00 00 00 00 00 CC CC CC CC 78 06 87'
+ 'CC CC CC CC CC CC CC 78 06 87 CC CC CC CC CC CC'
+ 'CC CC CC CC CC CC CC CC 00 00 CC CC CC CC CC C5'
+ '5C CC CC CC CC 07 77 77 77 77 77 77 77 0C CC CC'
+ 'C8 87 CC C7 67 CC CC CC CC CC C8 87 CC C7 67 CC'
+ 'CC CC CC CC C7 97 7C C7 87 CC CC CC 00 00 CC CC'
+ '66 66 66 C5 5C CC CC CC CC 07 77 77 77 77 99 AA'
+ '77 0C CC CC 70 7C CC CC 76 7C CC CC CC CC 70 7C'
+ '66 6C 76 7C CC CC CC CC C9 99 97 C9 99 97 CC CC'
+ '00 00 CC CC CC 66 CC C5 5C CC CC CC CC C0 00 08'
+ '88 88 88 00 00 CC CC CC 80 CC CC CC C8 6C CC CC'
+ 'CC CC 80 CC CC C6 C8 6C CC CC CC CC C9 99 C7 C7'
+ '99 C7 CC CC 00 00 CC CC CC 66 CC C5 5C CC CC CC'
+ 'CC C8 0F FF FF FF FF FF 08 CC CC CC 00 CC CC CC'
+ 'C7 67 CC CC CC CC 00 6C C6 66 C7 67 CC CC CC CC'
+ 'C7 99 CC 77 99 CC CC CC 00 00 CC CC CC 66 CC C5'
+ '5C CC CC CC CC C8 FF F8 88 88 88 FF F8 CC CC CC'
+ '00 CC CC CC CC 67 CC CC CC CC 00 C6 CC 6C CC 67'
+ 'CC CC CC CC C7 99 CC C8 99 7C CC CC 00 00 CC CC'
+ 'CC 65 CC C5 5C CC 5C CC CC C8 0F FF FF FF FF FF'
+ '08 CC CC CC 80 CC CC CC CC 66 CC CC CC CC 80 C6'
+ '6C 66 6C 66 CC CC CC CC CC 99 7C C7 99 7C CC CC'
+ '00 00 CC CC CC 65 5C C5 5C C5 5C CC CC C8 FF F8'
+ '88 88 88 FF F8 CC CC CC 70 7C CC CC CC 66 CC CC'
+ 'CC CC 70 7C 6C 6C CC 66 CC CC CC CC CC 89 7C CC'
+ '99 7C CC CC 00 00 CC CC CC 65 55 55 55 55 5C CC'
+ 'CC C8 0F FF FF FF FF FF 08 CC CC CC C0 8C CC CC'
+ 'CC 68 CC CC CC CC C0 8C 66 CC CC 68 CC CC CC CC'
+ 'CC C9 9C CC 99 9C CC CC 00 00 CC 6C CC 66 CC C6'
+ 'CC CC CC CC CC C8 FF F8 88 88 88 FF F8 CC CC CC'
+ 'C7 07 CC CC C7 67 CC CC CC CC C7 07 CC CC C7 67'
+ 'CC CC CC CC CC CC 77 CC 89 9C CC CC 00 00 CC 66'
+ 'CC 66 CC 66 CC CC CC CC CC C8 0F FF FF FF FF FF'
+ '08 CC CC CC CC 78 7C CC 78 7C CC CC CC CC CC 78'
+ '7C CC 78 7C CC CC CC CC CC CC CC 89 97 7C CC CC'
+ '00 00 CC 66 66 66 66 66 CC CC CC CC CC C8 88 88'
+ '88 88 88 88 88 CC CC CC CC CC 78 06 77 CC CC CC'
+ 'CC CC CC CC 78 06 77 CC CC CC CC CC CC CC CC CC'
+ 'CC CC CC CC 00 00'
+}*/ 
+
--- wine/dlls/commdlg/cdlg.h	2003-12-12 09:57:34.000000000 +0100
+++ mywine/dlls/commdlg/cdlg.h	2003-12-19 20:41:51.000000000 +0100
@@ -203,9 +203,10 @@
   int  added;
 } CFn_ENUMSTRUCT, *LPCFn_ENUMSTRUCT;
 
-INT AddFontFamily(const LOGFONTA *lplf, UINT nFontType, LPCHOOSEFONTA lpcf, 
-					HWND hwnd, LPCFn_ENUMSTRUCT e);
-INT AddFontStyle(const ENUMLOGFONTEXA *lpElfex, const TEXTMETRICA *metrics,
+INT AddFontFamily(const ENUMLOGFONTEXA *lpElfex, const NEWTEXTMETRICEXA *lpNTM,
+                  UINT nFontType, LPCHOOSEFONTA lpcf, HWND hwnd,
+                  LPCFn_ENUMSTRUCT e);
+INT AddFontStyle(const ENUMLOGFONTEXA *lpElfex, const NEWTEXTMETRICEXA *metrics,
                  UINT nFontType, LPCHOOSEFONTA lpcf, HWND hcmb2, HWND hcmb3,
                  HWND hDlg, BOOL iswin16);
 void _dump_cf_flags(DWORD cflags);
--- wine/dlls/commdlg/fontdlg.c	2003-12-12 09:57:36.000000000 +0100
+++ mywine/dlls/commdlg/fontdlg.c	2003-12-19 20:40:27.000000000 +0100
@@ -41,7 +41,9 @@
 
 #include "cdlg.h"
 
-static HBITMAP hBitmapTT = 0;
+/* image list with TrueType bitmaps and more */
+static HIMAGELIST himlTT = 0;
+#define TTBITMAP_XSIZE 20 /* x-size of the bitmaps */
 
 
 INT_PTR CALLBACK FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
@@ -394,11 +396,12 @@
 /*************************************************************************
  *              AddFontFamily                               [internal]
  */
-INT AddFontFamily(const LOGFONTA *lplf, UINT nFontType,
-        LPCHOOSEFONTA lpcf, HWND hwnd, LPCFn_ENUMSTRUCT e)
+INT AddFontFamily(const ENUMLOGFONTEXA *lpElfex, const NEWTEXTMETRICEXA *lpNTM,
+        UINT nFontType, LPCHOOSEFONTA lpcf, HWND hwnd, LPCFn_ENUMSTRUCT e)
 {
     int i;
     WORD w;
+    const LOGFONTA *lplf = &(lpElfex->elfLogFont);
 
     TRACE("font=%s (nFontType=%d)\n", lplf->lfFaceName,nFontType);
 
@@ -418,8 +421,9 @@
     if (i == CB_ERR) {
         i = SendMessageA(hwnd, CB_ADDSTRING, 0, (LPARAM)lplf->lfFaceName);
         if( i != CB_ERR) {
-            w=(lplf->lfCharSet << 8) | lplf->lfPitchAndFamily;
             /* store some important font information */
+            w = (lplf->lfPitchAndFamily) << 8 |
+                (HIWORD(lpNTM->ntmTm.ntmFlags) & 0xff);
             SendMessageA(hwnd, CB_SETITEMDATA, i, MAKELONG(nFontType,w));
         }
     }
@@ -429,12 +433,13 @@
 /*************************************************************************
  *              FontFamilyEnumProc32                           [internal]
  */
-static INT WINAPI FontFamilyEnumProc(const LOGFONTA *lpLogFont,
+static INT WINAPI FontFamilyEnumProc(const ENUMLOGFONTEXA *lpElfex,
         const TEXTMETRICA *metrics, DWORD dwFontType, LPARAM lParam)
 {
     LPCFn_ENUMSTRUCT e;
     e=(LPCFn_ENUMSTRUCT)lParam;
-    return AddFontFamily(lpLogFont, dwFontType, e->lpcf32a, e->hWnd1, e);
+    return AddFontFamily( lpElfex, (NEWTEXTMETRICEXA *) metrics,
+            dwFontType, e->lpcf32a, e->hWnd1, e);
 }
 
 /*************************************************************************
@@ -545,7 +550,7 @@
 /***********************************************************************
  *                 AddFontStyle                          [internal]
  */
-INT AddFontStyle( const ENUMLOGFONTEXA *lpElfex, const TEXTMETRICA *lpTM,
+INT AddFontStyle( const ENUMLOGFONTEXA *lpElfex, const NEWTEXTMETRICEXA *lpNTM,
                 UINT nFontType, LPCHOOSEFONTA lpcf, HWND hcmb2, HWND hcmb3,
                 HWND hDlg, BOOL iswin16)
 {
@@ -566,8 +571,8 @@
     {
         INT points;
         if(!(hdc = CFn_GetDC(lpcf))) return 0;
-        points = MulDiv( lpTM->tmHeight - lpTM->tmInternalLeading, 72,
-                GetDeviceCaps(hdc, LOGPIXELSY));
+        points = MulDiv( lpNTM->ntmTm.tmHeight - lpNTM->ntmTm.tmInternalLeading,
+                72, GetDeviceCaps(hdc, LOGPIXELSY));
         CFn_ReleaseDC(lpcf, hdc);
         i = AddFontSizeToCombo3(hcmb3, points, lpcf);
         if( i) return 0;
@@ -669,8 +674,8 @@
     HWND hcmb2=s->hWnd1;
     HWND hcmb3=s->hWnd2;
     HWND hDlg=GetParent(hcmb3);
-    return AddFontStyle( lpElfex, metrics, dwFontType, s->lpcf32a,
-            hcmb2, hcmb3, hDlg, FALSE);
+    return AddFontStyle( lpElfex, (const NEWTEXTMETRICEXA *) metrics,
+            dwFontType, s->lpcf32a, hcmb2, hcmb3, hDlg, FALSE);
 }
 
 /***********************************************************************
@@ -696,8 +701,9 @@
         EndDialog (hDlg, 0);
         return FALSE;
     }
-    if (!hBitmapTT)
-        hBitmapTT = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_TRTYPE));
+    if (!himlTT)
+        himlTT = ImageList_LoadImageA( COMDLG32_hInstance, MAKEINTRESOURCEA(38),
+                TTBITMAP_XSIZE, 0, CLR_DEFAULT, IMAGE_BITMAP, 0);
 
     if (!(lpcf->Flags & CF_SHOWHELP) || !IsWindow(lpcf->hwndOwner))
         ShowWindow(GetDlgItem(hDlg,pshHelp),SW_HIDE);
@@ -737,9 +743,14 @@
     s.hWnd1=GetDlgItem(hDlg,cmb1);
     s.lpcf32a=lpcf;
     do {
+        LOGFONTA elf;
         s.added = 0;
-        if (!EnumFontFamiliesA(hdc, NULL, FontFamilyEnumProc, (LPARAM)&s)) {
-            TRACE("EnumFontFamilies returns 0\n");
+        elf.lfCharSet = DEFAULT_CHARSET; /* enum all charsets */
+        elf.lfPitchAndFamily = 0;
+        elf.lfFaceName[0] = '\0'; /* enum all fonts */
+        if (!EnumFontFamiliesExA(hdc, &elf, FontFamilyEnumProc, (LPARAM)&s, 0))
+        {
+            TRACE("EnumFontFamiliesEx returns 0\n");
             break;
         }
         if (s.added) break;
@@ -808,13 +819,23 @@
  */
 LRESULT CFn_WMMeasureItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
 {
-    BITMAP bm;
+    HDC hdc;
+    HFONT hfontprev;
+    TEXTMETRICW tm;
     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 .*/
+    if (!himlTT)
+        himlTT = ImageList_LoadImageA( COMDLG32_hInstance, MAKEINTRESOURCEA(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);
+    if(!hdc) return 0;
+    hfontprev = SelectObject( hdc, GetStockObject( SYSTEM_FONT));
+    GetTextMetricsW( hdc, &tm);
+    if( tm.tmHeight > lpmi->itemHeight) lpmi->itemHeight = tm.tmHeight;
+    SelectObject( hdc, hfontprev);
+    ReleaseDC( hDlg, hdc);
     return 0;
 }
 
@@ -826,12 +847,10 @@
 {
     HBRUSH hBrush;
     char buffer[40];
-    BITMAP bm;
     COLORREF cr, oldText=0, oldBk=0;
     RECT rect;
-    HDC hMemDC;
     int nFontType;
-    HBITMAP objPrev; /* for TT usage */
+    int idx;
     LPDRAWITEMSTRUCT lpdi = (LPDRAWITEMSTRUCT)lParam;
 
     if (lpdi->itemID == (UINT)-1)  /* got no items */
@@ -862,19 +881,23 @@
             /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
             SendMessageA(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
                          (LPARAM)buffer);
-            GetObjectA( hBitmapTT, sizeof(bm), &bm );
-            TextOutA(lpdi->hDC, lpdi->rcItem.left + bm.bmWidth + 10,
+            TextOutA(lpdi->hDC, lpdi->rcItem.left + TTBITMAP_XSIZE + 10,
                      lpdi->rcItem.top, buffer, strlen(buffer));
             nFontType = SendMessageA(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
-            if (nFontType & TRUETYPE_FONTTYPE)
-            {
-                hMemDC = CreateCompatibleDC(lpdi->hDC);
-                objPrev = SelectObject(hMemDC, hBitmapTT);
-                BitBlt(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top,
-                       bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
-                SelectObject(hMemDC, objPrev);
-                DeleteDC(hMemDC);
-            }
+            idx = -1;
+            if (nFontType & TRUETYPE_FONTTYPE) {
+                idx = 0;  /* picture: TT */
+                if( nFontType & NTM_TT_OPENTYPE)
+                    idx = 2; /* picture: O */
+            } else if( nFontType & NTM_PS_OPENTYPE)
+                idx = 3; /* picture: O+ps */
+            else if( nFontType & NTM_TYPE1)
+                idx = 4; /* picture: a */
+            else if( nFontType & DEVICE_FONTTYPE)
+                idx = 1; /* picture: printer */
+            if( idx >= 0)
+                ImageList_Draw( himlTT, idx, lpdi->hDC, lpdi->rcItem.left,
+                        lpdi->rcItem.top, ILD_TRANSPARENT);
             break;
         case cmb2:
         case cmb3:
@@ -927,7 +950,7 @@
 LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam,
         LPCHOOSEFONTA lpcf)
 {
-    int i,j;
+    int i;
     long l;
     HDC hdc;
     LPLOGFONTA lpxx=lpcf->lpLogFont;
@@ -1000,13 +1023,11 @@
                 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;
+                lpxx->lfPitchAndFamily = HIWORD(l) >> 8;
             }
             strcpy(lpxx->lfFaceName,str);
             i=SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0);
@@ -1035,6 +1056,8 @@
             i=SendDlgItemMessageA(hDlg, cmb5, CB_GETCURSEL, 0, 0);
             if (i!=CB_ERR)
                 lpxx->lfCharSet=SendDlgItemMessageA(hDlg, cmb5, CB_GETITEMDATA, i, 0);
+            else
+                lpxx->lfCharSet = DEFAULT_CHARSET;
             lpxx->lfStrikeOut=IsDlgButtonChecked(hDlg,chx1);
             lpxx->lfUnderline=IsDlgButtonChecked(hDlg,chx2);
             lpxx->lfWidth=lpxx->lfOrientation=lpxx->lfEscapement=0;
--- wine/dlls/commdlg/fontdlg16.c	2003-12-12 09:57:36.000000000 +0100
+++ mywine/dlls/commdlg/fontdlg16.c	2003-12-20 15:25:33.000000000 +0100
@@ -59,12 +59,13 @@
     lstrcpynA( font32->lfFaceName, font16->lfFaceName, LF_FACESIZE );
 };
 
-static void FONT_Metrics16To32A( const TEXTMETRIC16 *pm16, TEXTMETRICA *pm32a)
+static void FONT_Metrics16To32A( const TEXTMETRIC16 *pm16,
+                                 NEWTEXTMETRICEXA *pnm32a)
 {
-    ZeroMemory( pm32a, sizeof(TEXTMETRICA));
+    ZeroMemory( pnm32a, sizeof(NEWTEXTMETRICEXA));
     /* NOTE: only the fields used by AddFontStyle() are filled in */
-    pm32a->tmHeight = pm16->tmHeight;
-    pm32a->tmExternalLeading = pm16->tmExternalLeading;
+    pnm32a->ntmTm.tmHeight = pm16->tmHeight;
+    pnm32a->ntmTm.tmExternalLeading = pm16->tmExternalLeading;
 };
 
 static void CFn_CHOOSEFONT16to32A(LPCHOOSEFONT16 chf16, LPCHOOSEFONTA chf32a)
@@ -108,10 +109,13 @@
   HWND hDlg=GetParent(hwnd);
   LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLongA(hDlg, DWL_USER);
   LOGFONT16 *lplf = MapSL( logfont );
-  LOGFONTA lf32a;
-  FONT_LogFont16To32A(lplf, &lf32a);
-  return AddFontFamily(&lf32a, nFontType, (LPCHOOSEFONTA)lpcf->lpTemplateName,
-                       hwnd,NULL);
+  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);
 }
 
 /***********************************************************************
@@ -127,10 +131,10 @@
   LOGFONT16 *lplf = MapSL(logfont);
   TEXTMETRIC16 *lpmtrx16 = MapSL(metrics);
   ENUMLOGFONTEXA elf32a;
-  TEXTMETRICA mtrx32a;
+  NEWTEXTMETRICEXA nmtrx32a;
   FONT_LogFont16To32A(lplf, &(elf32a.elfLogFont));
-  FONT_Metrics16To32A(lpmtrx16, &mtrx32a);
-  return AddFontStyle(&elf32a, &mtrx32a, nFontType,
+  FONT_Metrics16To32A(lpmtrx16, &nmtrx32a);
+  return AddFontStyle(&elf32a, &nmtrx32a, nFontType,
           (LPCHOOSEFONTA)lpcf->lpTemplateName, hcmb2, hcmb3, hDlg, TRUE);
 }
 
--- wine/include/wingdi.h	2003-12-02 08:04:42.000000000 +0100
+++ mywine/include/wingdi.h	2003-12-14 19:31:26.000000000 +0100
@@ -1098,6 +1098,15 @@
 #define NTM_BOLD        0x00000020L
 #define NTM_ITALIC      0x00000001L
 
+/* Win2K additions */    
+#define NTM_NONNEGATIVE_AC  0x00010000L
+#define NTM_PS_OPENTYPE     0x00020000L
+#define NTM_TT_OPENTYPE     0x00040000L
+#define NTM_MULTIPLEMASTER  0x00080000L
+#define NTM_TYPE1           0x00100000L
+#define NTM_DSIG            0x00200000L
+
+
 typedef struct
 {
     LONG      tmHeight;

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux