[COMCTL32] add padding for status bar text
[reactos.git] / dll / win32 / comctl32 / status.c
index 43b65aa..cfee259 100644 (file)
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  *
- * NOTE
- * 
- * This code was audited for completeness against the documented features
- * of Comctl32.dll version 6.0 on Sep. 24, 2002, by Dimitrie O. Paun.
- * 
- * Unless otherwise noted, we believe this code to be complete, as per
- * the specification mentioned above.
- * If you discover missing features, or bugs, please note them below.
- * 
  * TODO:
  *     -- CCS_BOTTOM (default)
  *     -- CCS_LEFT
@@ -127,8 +118,8 @@ STATUSBAR_ComputeHeight(STATUS_INFO *infoPtr)
          * textHeight pixels large */
         HDC hdc = GetDC(infoPtr->Self);
         RECT r;
-        memset (&r, 0, sizeof (r));
-        r.bottom = max(infoPtr->minHeight, tm.tmHeight);
+
+        SetRect(&r, 0, 0, 0, max(infoPtr->minHeight, tm.tmHeight));
         if (SUCCEEDED(GetThemeBackgroundExtent(theme, hdc, SP_PANE, 0, &r, &r)))
         {
             height = r.bottom - r.top;
@@ -143,60 +134,26 @@ STATUSBAR_ComputeHeight(STATUS_INFO *infoPtr)
 static void
 STATUSBAR_DrawSizeGrip (HTHEME theme, HDC hdc, LPRECT lpRect)
 {
-    HPEN hPenFace, hPenShadow, hPenHighlight, hOldPen;
-    POINT pt;
-    INT i;
+    RECT rc = *lpRect;
 
     TRACE("draw size grip %s\n", wine_dbgstr_rect(lpRect));
 
     if (theme)
     {
-        RECT gripperRect;
         SIZE gripperSize;
-        gripperRect = *lpRect;
         if (SUCCEEDED (GetThemePartSize (theme, hdc, SP_GRIPPER, 0, lpRect, 
             TS_DRAW, &gripperSize)))
         {
-            gripperRect.left = gripperRect.right - gripperSize.cx;
-            gripperRect.top = gripperRect.bottom - gripperSize.cy;
-            if (SUCCEEDED (DrawThemeBackground(theme, hdc, SP_GRIPPER, 0, &gripperRect, NULL)))
+            rc.left = rc.right - gripperSize.cx;
+            rc.top = rc.bottom - gripperSize.cy;
+            if (SUCCEEDED (DrawThemeBackground(theme, hdc, SP_GRIPPER, 0, &rc, NULL)))
                 return;
         }
     }
 
-    pt.x = lpRect->right - 1;
-    pt.y = lpRect->bottom - 1;
-
-    hPenFace = CreatePen( PS_SOLID, 1, comctl32_color.clr3dFace);
-    hOldPen = SelectObject( hdc, hPenFace );
-    MoveToEx (hdc, pt.x - 12, pt.y, NULL);
-    LineTo (hdc, pt.x, pt.y);
-    LineTo (hdc, pt.x, pt.y - 13);
-
-    pt.x--;
-    pt.y--;
-
-    hPenShadow = CreatePen( PS_SOLID, 1, comctl32_color.clr3dShadow);
-    SelectObject( hdc, hPenShadow );
-    for (i = 1; i < 11; i += 4) {
-       MoveToEx (hdc, pt.x - i, pt.y, NULL);
-       LineTo (hdc, pt.x + 1, pt.y - i - 1);
-
-       MoveToEx (hdc, pt.x - i - 1, pt.y, NULL);
-       LineTo (hdc, pt.x + 1, pt.y - i - 2);
-    }
-
-    hPenHighlight = CreatePen( PS_SOLID, 1, comctl32_color.clr3dHilight);
-    SelectObject( hdc, hPenHighlight );
-    for (i = 3; i < 13; i += 4) {
-       MoveToEx (hdc, pt.x - i, pt.y, NULL);
-       LineTo (hdc, pt.x + 1, pt.y - i - 1);
-    }
-
-    SelectObject (hdc, hOldPen);
-    DeleteObject( hPenFace );
-    DeleteObject( hPenShadow );
-    DeleteObject( hPenHighlight );
+    rc.left = max( rc.left, rc.right - GetSystemMetrics(SM_CXVSCROLL) - 1 );
+    rc.top  = max( rc.top, rc.bottom - GetSystemMetrics(SM_CYHSCROLL) - 1 );
+    DrawFrameControl( hdc, &rc, DFC_SCROLL, DFCS_SCROLLSIZEGRIP );
 }
 
 
@@ -243,7 +200,16 @@ STATUSBAR_DrawPart (const STATUS_INFO *infoPtr, HDC hdc, const STATUSWINDOWPART
         SendMessageW (infoPtr->Notify, WM_DRAWITEM, dis.CtlID, (LPARAM)&dis);
     } else {
         r.left += x;
+#ifdef __REACTOS__
+        r.left += 3;
+        r.right -= 3;
+        if (!theme)
+            DrawStatusTextW (hdc, &r, part->text, SBT_NOBORDERS);
+        else
+            DrawThemeText(theme, hdc, SP_PANE, 0, part->text, -1, DT_VCENTER|DT_SINGLELINE|DT_NOPREFIX, 0, &r);
+#else
         DrawStatusTextW (hdc, &r, part->text, SBT_NOBORDERS);
+#endif
     }
 }
 
@@ -285,7 +251,6 @@ STATUSBAR_RefreshPart (const STATUS_INFO *infoPtr, HDC hdc, const STATUSWINDOWPA
 static LRESULT
 STATUSBAR_Refresh (STATUS_INFO *infoPtr, HDC hdc)
 {
-    int      i;
     RECT   rect;
     HBRUSH hbrBk;
     HFONT  hOldFont;
@@ -319,6 +284,8 @@ STATUSBAR_Refresh (STATUS_INFO *infoPtr, HDC hdc)
     if (infoPtr->simple) {
        STATUSBAR_RefreshPart (infoPtr, hdc, &infoPtr->part0, 0);
     } else {
+        unsigned int i;
+
        for (i = 0; i < infoPtr->numParts; i++) {
            STATUSBAR_RefreshPart (infoPtr, hdc, &infoPtr->parts[i], i);
        }
@@ -336,7 +303,8 @@ STATUSBAR_Refresh (STATUS_INFO *infoPtr, HDC hdc)
 static int
 STATUSBAR_InternalHitTest(const STATUS_INFO *infoPtr, const POINT *pt)
 {
-    int i;
+    unsigned int i;
+
     if (infoPtr->simple)
         return 255;
 
@@ -352,7 +320,7 @@ STATUSBAR_SetPartBounds (STATUS_INFO *infoPtr)
 {
     STATUSWINDOWPART *part;
     RECT rect, *r;
-    int        i;
+    UINT i;
 
     /* get our window size */
     GetClientRect (infoPtr->Self, &rect);
@@ -698,10 +666,12 @@ STATUSBAR_SetParts (STATUS_INFO *infoPtr, INT count, LPINT parts)
     if (infoPtr->hwndToolTip) {
        INT nTipCount;
        TTTOOLINFOW ti;
+       WCHAR wEmpty = 0;
 
        ZeroMemory (&ti, sizeof(TTTOOLINFOW));
        ti.cbSize = sizeof(TTTOOLINFOW);
        ti.hwnd = infoPtr->Self;
+       ti.lpszText = &wEmpty;
 
        nTipCount = SendMessageW (infoPtr->hwndToolTip, TTM_GETTOOLCOUNT, 0, 0);
        if (nTipCount < infoPtr->numParts) {
@@ -883,7 +853,7 @@ STATUSBAR_Simple (STATUS_INFO *infoPtr, BOOL simple)
 static LRESULT
 STATUSBAR_WMDestroy (STATUS_INFO *infoPtr)
 {
-    int        i;
+    unsigned int i;
 
     TRACE("\n");
     for (i = 0; i < infoPtr->numParts; i++) {
@@ -1284,7 +1254,7 @@ StatusWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
             return STATUSBAR_WMGetText (infoPtr, (INT)wParam, (LPWSTR)lParam);
 
        case WM_GETTEXTLENGTH:
-           return STATUSBAR_GetTextLength (infoPtr, 0);
+           return LOWORD(STATUSBAR_GetTextLength (infoPtr, 0));
 
        case WM_LBUTTONDBLCLK:
             return STATUSBAR_SendMouseNotify(infoPtr, NM_DBLCLK, msg, wParam, lParam);