Fix checkbox buttons

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

 



In the notification section of the preference dialog box of emule you
can see a checkbox button whose the text is not aligned with the
checkbox. It comes from the fact that the checkbox must be aligned with
the text and not the size of the component provided in the resources. So
I moved the drawing of the checkbox after the computation of the size of
the text.

Moreover, the code now handles correctly the BS_TOP/BS_BOTTOM flags.
Actually, the checkbox must be aligned according to these flags what was
not correctly implemented.

This code is based on tests preformed on win xp. Now there should be no
alignment problems.

( As you may have seen emule is my actual favorite test app because the
people from emule are kind enough to provide the sources, it's easy to
debug :) )

a+

Max

ChangeLog:
  * Fix some indentation problems
  * Hanlde correctly the alignement of the checkboxes if the
BS_TOP/BS_BOTTOM flags are set

-- 
Maxime Bellengà <maxime.bellenge@laposte.net>
Index: wine/controls/button.c
===================================================================
RCS file: /home/wine/wine/controls/button.c,v
retrieving revision 1.63
diff -u -r1.63 button.c
--- wine/controls/button.c	2 Dec 2002 18:11:00 -0000	1.63
+++ wine/controls/button.c	27 Apr 2003 12:47:52 -0000
@@ -862,6 +862,12 @@
         rbox.right = checkBoxWidth;
     }
 
+    /* Draw label */
+    client = rtext;
+    dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &rtext);
+    
+    rbox.top = rtext.top;
+    rbox.bottom = rtext.bottom;
     /* Draw the check-box bitmap */
     if (action == ODA_DRAWENTIRE || action == ODA_SELECT)
     {
@@ -871,29 +877,29 @@
 
         if( TWEAK_WineLook == WIN31_LOOK )
         {
-        HDC hMemDC = CreateCompatibleDC( hDC );
-        int x = 0, y = 0;
-        delta = (rbox.bottom - rbox.top - checkBoxHeight) / 2;
-
-	/* Check in case the client area is smaller than the checkbox bitmap */
-	if (delta < 0) delta = 0;
-
-        if (state & BUTTON_HIGHLIGHTED) x += 2 * checkBoxWidth;
-        if (state & (BUTTON_CHECKED | BUTTON_3STATE)) x += checkBoxWidth;
-        if ((get_button_type(style) == BS_RADIOBUTTON) ||
-            (get_button_type(style) == BS_AUTORADIOBUTTON)) y += checkBoxHeight;
-        else if (state & BUTTON_3STATE) y += 2 * checkBoxHeight;
-
-	/* The bitmap for the radio button is not aligned with the
-	 * left of the window, it is 1 pixel off. */
-        if ((get_button_type(style) == BS_RADIOBUTTON) ||
-            (get_button_type(style) == BS_AUTORADIOBUTTON))
-	  rbox.left += 1;
-
-	SelectObject( hMemDC, hbitmapCheckBoxes );
-	BitBlt( hDC, rbox.left, rbox.top + delta, checkBoxWidth,
-		  checkBoxHeight, hMemDC, x, y, SRCCOPY );
-	DeleteDC( hMemDC );
+	    HDC hMemDC = CreateCompatibleDC( hDC );
+	    int x = 0, y = 0;
+	    delta = (rbox.bottom - rbox.top - checkBoxHeight) / 2;
+	    
+	    /* Check in case the client area is smaller than the checkbox bitmap */
+	    if (delta < 0) delta = 0;
+	    
+	    if (state & BUTTON_HIGHLIGHTED) x += 2 * checkBoxWidth;
+	    if (state & (BUTTON_CHECKED | BUTTON_3STATE)) x += checkBoxWidth;
+	    if ((get_button_type(style) == BS_RADIOBUTTON) ||
+		(get_button_type(style) == BS_AUTORADIOBUTTON)) y += checkBoxHeight;
+	    else if (state & BUTTON_3STATE) y += 2 * checkBoxHeight;
+	    
+	    /* The bitmap for the radio button is not aligned with the
+	     * left of the window, it is 1 pixel off. */
+	    if ((get_button_type(style) == BS_RADIOBUTTON) ||
+		(get_button_type(style) == BS_AUTORADIOBUTTON))
+	      rbox.left += 1;
+	    
+	    SelectObject( hMemDC, hbitmapCheckBoxes );
+	    BitBlt( hDC, rbox.left, rbox.top + delta, checkBoxWidth,
+		    checkBoxHeight, hMemDC, x, y, SRCCOPY );
+	    DeleteDC( hMemDC );
         }
         else
         {
@@ -910,27 +916,40 @@
 	    if (style & WS_DISABLED) flags |= DFCS_INACTIVE;
 
 	    /* rbox must have the correct height */
- 	    delta = rbox.bottom - rbox.top - checkBoxHeight;
-	    if (delta > 0)
-	    {
-		int ofs = (abs(delta) / 2);
-		rbox.bottom -= ofs + 1;
-		rbox.top = rbox.bottom - checkBoxHeight;
-	    }
-	    else if (delta < 0)
-	    {
-		int ofs = (abs(delta) / 2);
-		rbox.top -= ofs + 1;
+	    delta = rbox.bottom - rbox.top - checkBoxHeight;
+	    
+	    if (style & BS_TOP) {
+	      if (delta > 0) {
 		rbox.bottom = rbox.top + checkBoxHeight;
+	      } else {
+		rbox.top -= -delta/2 + 1;
+		rbox.bottom += rbox.top + checkBoxHeight;
+	      }
+	    } else if (style & BS_BOTTOM) {
+	      if (delta > 0) {
+		rbox.top = rbox.bottom - checkBoxHeight;
+	      } else {
+		rbox.bottom += -delta/2 + 1;
+		rbox.top = rbox.bottom -= checkBoxHeight;
+	      }
+	    } else { // Default
+	      if (delta > 0)
+		{
+		  int ofs = (delta / 2);
+		  rbox.bottom -= ofs + 1;
+		  rbox.top = rbox.bottom - checkBoxHeight;
+		}
+	      else if (delta < 0)
+		{
+		  int ofs = (-delta / 2);
+		  rbox.top -= ofs + 1;
+		  rbox.bottom = rbox.top + checkBoxHeight;
+		}
 	    }
 
 	    DrawFrameControl( hDC, &rbox, DFC_BUTTON, flags );
         }
     }
-
-    /* Draw label */
-    client = rtext;
-    dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &rtext);
 
     if (dtFlags == (UINT)-1L) /* Noting to draw */
 	return;

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

  Powered by Linux