[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    Re: Toolbar patch
From:       Francois Gouget <fgouget () free ! fr>
Date:       2000-09-23 6:22:09
[Download RAW message or body]

Hi Chris,

Chris Morgan wrote:
> 
> ChangeLog entry:
> 
> *dlls/comctl32/toolbar.c:
> Chris Morgan <cmorgan@codeweavers.com>
> Fixed button image to be offset to the center of the button horizontally,
> visible with WinZip and CuteFTP 4.0.  Fixed compile warnings from format type
> specifiers in two TRACE's.  Removed TRACE in TOOLBAR_GetItemRect().  Added
> button width to TRACE in TOOLBAR_CalcToolbar().

   I tried your patch but I found two problems:

 * nButtonWidth is the size of the button including the border. But
rc.left refers to the inside of the button. So we must substract the
width of the border (2) twice when computing xOffset. I hardcoded the
border size, maybe I should get it from somewhere (the sysmetrics
array)?

 * since we are adding xOffset we must no longer add the +1 (and the +2s
become +1s).

   I updated the patch with this in mind. What do you think?


-- 
Francois Gouget
fgouget@codeweavers.com
["diff20000922-toolbar3.txt" (text/plain)]

Index: dlls/comctl32/toolbar.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/toolbar.c,v
retrieving revision 1.62
diff -u -r1.62 toolbar.c
--- dlls/comctl32/toolbar.c	2000/09/18 01:41:50	1.62
+++ dlls/comctl32/toolbar.c	2000/09/22 07:55:00
@@ -286,6 +287,7 @@
     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     RECT rc;
+    INT xOffset = (infoPtr->nButtonWidth - infoPtr->nBitmapWidth - 2*2) / 2;
 
     if (btnPtr->fsState & TBSTATE_HIDDEN)
 	return;
@@ -315,9 +317,9 @@
 	if (infoPtr->himlDis && 
             TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
 	    ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
-				rc.left+1, rc.top+1, ILD_NORMAL);
+			rc.left + xOffset, rc.top + 1, ILD_NORMAL);
 	else
-	    TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
+	    TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left + xOffset, rc.top + 1);
 
 	TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
 	return;
@@ -329,9 +331,11 @@
 	    DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST);
 	else
 	    DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
-        if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
+        if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
 	    ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
-			rc.left+2, rc.top+2, ILD_NORMAL);
+			rc.left + xOffset + 1, rc.top + 2, ILD_NORMAL);
+	}
+
 	TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
 	return;
     }
@@ -350,8 +354,7 @@
         
         if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
 	    ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
-			rc.left+2, rc.top+2, ILD_NORMAL);
-
+			rc.left + xOffset+1, rc.top + 2, ILD_NORMAL);
 	TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
 	return;
     }
@@ -362,7 +365,7 @@
 		    BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
 
 	TOOLBAR_DrawPattern (hdc, &rc);
-	TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
+	TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left + xOffset, rc.top + 1);
 	TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
 	return;
     }
@@ -378,10 +381,10 @@
 	if (btnPtr->bHot && infoPtr->himlHot && 
             TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
 	    ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc,
-			    rc.left +2, rc.top +2, ILD_NORMAL);
+			rc.left + xOffset + 1, rc.top + 2, ILD_NORMAL);
 	else if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
 	    ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
-			    rc.left +2, rc.top +2, ILD_NORMAL);
+			rc.left + xOffset + 1, rc.top + 2, ILD_NORMAL);
     }
     else
     {
@@ -390,7 +393,7 @@
 
         if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
 	    ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
-			rc.left+1, rc.top+1, ILD_NORMAL);
+			rc.left + xOffset, rc.top + 1, ILD_NORMAL);
     }
 
     TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
@@ -440,7 +442,7 @@
     SelectObject (hdc, hOldFont);
     ReleaseDC (0, hdc);
 
-    TRACE("string size %d x %d!\n", lpSize->cx, lpSize->cy);
+    TRACE("string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
 }
 
 static void
@@ -467,7 +469,7 @@
         }
     }
 
-    TRACE("string size %d x %d!\n", lpSize->cx, lpSize->cy);
+    TRACE("string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
 }
 
 /***********************************************************************
@@ -809,7 +811,7 @@
 		       	nSepRows * (SEPARATOR_WIDTH * 2 / 3) +
 			nSepRows * (infoPtr->nBitmapHeight + 1) + 
 			BOTTOM_BORDER; 
-    TRACE("toolbar height %d\n", infoPtr->nHeight);
+    TRACE("toolbar height %d, button width %d\n", infoPtr->nHeight, infoPtr->nButtonWidth);
 }
 
 
@@ -2134,8 +2140,6 @@
     LPRECT     lpRect;
     INT        nIndex;
 
-    TRACE("\n");
-
     if (infoPtr == NULL)
 	return FALSE;
     nIndex = (INT)wParam;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic