comdlg32: Use SetRect() instead of open coding it (try 2)

Frédéric Delanoy frederic.delanoy at gmail.com
Wed May 4 07:05:42 CDT 2016


Signed-off-by: Frédéric Delanoy <frederic.delanoy at gmail.com>
---
 dlls/comdlg32/colordlg.c | 20 ++++----------------
 dlls/comdlg32/itemdlg.c  | 44 +++++++++++++++-----------------------------
 2 files changed, 19 insertions(+), 45 deletions(-)

diff --git a/dlls/comdlg32/colordlg.c b/dlls/comdlg32/colordlg.c
index 8b307ae..20152ee 100644
--- a/dlls/comdlg32/colordlg.c
+++ b/dlls/comdlg32/colordlg.c
@@ -494,10 +494,7 @@ static void CC_PaintTriangle(CCPRIV *infoPtr)
    hbr = (HBRUSH)GetClassLongPtrW( hwnd, GCLP_HBRBACKGROUND);
    if (!hbr) hbr = GetSysColorBrush(COLOR_BTNFACE);
    FillRect(hDC, &infoPtr->old3angle, hbr);
-   infoPtr->old3angle.left  = points[0].x;
-   infoPtr->old3angle.right = points[1].x + 1;
-   infoPtr->old3angle.top   = points[2].y - 1;
-   infoPtr->old3angle.bottom= points[1].y + 1;
+   SetRect(&infoPtr->old3angle, points[0].x, points[2].y - 1, points[1].x + 1, points[1].y + 1);
 
    hbr = SelectObject(hDC, GetStockObject(BLACK_BRUSH));
    Polygon(hDC, points, 3);
@@ -539,10 +536,7 @@ static void CC_PaintCross(CCPRIV *infoPtr)
               infoPtr->oldcross.right - infoPtr->oldcross.left,
               infoPtr->oldcross.bottom - infoPtr->oldcross.top,
               infoPtr->hdcMem, infoPtr->oldcross.left, infoPtr->oldcross.top, SRCCOPY);
-   infoPtr->oldcross.left   = point.x - w - 1;
-   infoPtr->oldcross.right  = point.x + w + 1;
-   infoPtr->oldcross.top    = point.y - w - 1;
-   infoPtr->oldcross.bottom = point.y + w + 1;
+   SetRect(&infoPtr->oldcross, point.x - w - 1, point.y - w - 1, point.x + w + 1, point.y + w + 1);
 
    hPen = CreatePen(PS_SOLID, 3, RGB(0, 0, 0)); /* -black- color */
    hPen = SelectObject(hDC, hPen);
@@ -766,10 +760,7 @@ static void CC_PaintPredefColorArray(const CCPRIV *infoPtr, int rows, int cols)
    hBrush = CreateSolidBrush(predefcolors[j][i]);
    if (hBrush)
    {
-    blockrect.left = rect.left;
-    blockrect.top = rect.top;
-    blockrect.right = rect.left + dx - DISTANCE;
-    blockrect.bottom = rect.top + dy - DISTANCE;
+    SetRect(&blockrect, rect.left, rect.top, rect.left + dx - DISTANCE, rect.top + dy - DISTANCE);
     FillRect(hdc, &blockrect, hBrush);
     DrawEdge(hdc, &blockrect, BDR_SUNKEN, BF_RECT);
     DeleteObject(hBrush);
@@ -814,10 +805,7 @@ static void CC_PaintUserColorArray(const CCPRIV *infoPtr, int rows, int cols)
     hBrush = CreateSolidBrush(infoPtr->lpcc->lpCustColors[i+j*cols]);
     if (hBrush)
     {
-     blockrect.left = rect.left;
-     blockrect.top = rect.top;
-     blockrect.right = rect.left + dx - DISTANCE;
-     blockrect.bottom = rect.top + dy - DISTANCE;
+     SetRect(&blockrect, rect.left, rect.top, rect.left + dx - DISTANCE, rect.top + dy - DISTANCE);
      FillRect(hdc, &blockrect, hBrush);
      DrawEdge(hdc, &blockrect, BDR_SUNKEN, BF_RECT);
      DeleteObject(hBrush);
diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c
index 43261f4..8eb1c59 100644
--- a/dlls/comdlg32/itemdlg.c
+++ b/dlls/comdlg32/itemdlg.c
@@ -1659,10 +1659,8 @@ static void update_layout(FileDialogImpl *This)
         cancel_width = cancel_rc.right - cancel_rc.left;
         cancel_height = cancel_rc.bottom - cancel_rc.top;
 
-        cancel_rc.left = dialog_rc.right - cancel_width - hspacing;
-        cancel_rc.top = dialog_rc.bottom - cancel_height - vspacing;
-        cancel_rc.right = cancel_rc.left + cancel_width;
-        cancel_rc.bottom = cancel_rc.top + cancel_height;
+        SetRect(&cancel_rc, dialog_rc.right - cancel_width - hspacing, dialog_rc.bottom - cancel_height - vspacing,
+                dialog_rc.right - hspacing, dialog_rc.bottom - vspacing);
     }
 
     /* Open/Save dropdown */
@@ -1677,10 +1675,8 @@ static void update_layout(FileDialogImpl *This)
         dropdown_width = dropdown_rc.right - dropdown_rc.left;
         dropdown_height = dropdown_rc.bottom - dropdown_rc.top;
 
-        dropdown_rc.left = cancel_rc.left - dropdown_width - hspacing;
-        dropdown_rc.top = cancel_rc.top;
-        dropdown_rc.right = dropdown_rc.left + dropdown_width;
-        dropdown_rc.bottom = dropdown_rc.top + dropdown_height;
+        SetRect(&dropdown_rc, cancel_rc.left - dropdown_width - hspacing, cancel_rc.top,
+                cancel_rc.left - hspacing, cancel_rc.top + dropdown_height);
     }
     else
     {
@@ -1698,10 +1694,8 @@ static void update_layout(FileDialogImpl *This)
         open_width = open_rc.right - open_rc.left;
         open_height = open_rc.bottom - open_rc.top;
 
-        open_rc.left = dropdown_rc.left - open_width;
-        open_rc.top = dropdown_rc.top;
-        open_rc.right = open_rc.left + open_width;
-        open_rc.bottom = open_rc.top + open_height;
+        SetRect(&open_rc, dropdown_rc.left - open_width, dropdown_rc.top,
+                dropdown_rc.left, dropdown_rc.top + open_height);
     }
 
     /* The filetype combobox. */
@@ -1714,11 +1708,8 @@ static void update_layout(FileDialogImpl *This)
         filetype_width = filetype_rc.right - filetype_rc.left;
         filetype_height = filetype_rc.bottom - filetype_rc.top;
 
-        filetype_rc.right = cancel_rc.right;
-
-        filetype_rc.left = filetype_rc.right - filetype_width;
-        filetype_rc.top = cancel_rc.top - filetype_height - vspacing;
-        filetype_rc.bottom = filetype_rc.top + filetype_height;
+        SetRect(&filetype_rc, cancel_rc.right - filetype_width, cancel_rc.top - filetype_height - vspacing,
+                cancel_rc.right, cancel_rc.top - vspacing);
 
         if(!This->filterspec_count)
             filetype_rc.left = filetype_rc.right;
@@ -1729,15 +1720,14 @@ static void update_layout(FileDialogImpl *This)
     if(hwnd)
     {
         int filetypelabel_width, filetypelabel_height;
+        int left_pos = 160; /* FIXME */
         GetWindowRect(hwnd, &filenamelabel_rc);
 
         filetypelabel_width = filenamelabel_rc.right - filenamelabel_rc.left;
         filetypelabel_height = filenamelabel_rc.bottom - filenamelabel_rc.top;
 
-        filenamelabel_rc.left = 160; /* FIXME */
-        filenamelabel_rc.top = filetype_rc.top;
-        filenamelabel_rc.right = filenamelabel_rc.left + filetypelabel_width;
-        filenamelabel_rc.bottom = filenamelabel_rc.top + filetypelabel_height;
+        SetRect(&filenamelabel_rc, left_pos, filetype_rc.top,
+                left_pos + filetypelabel_width, filetype_rc.top + filetypelabel_height);
     }
 
     /* Filename edit box. */
@@ -1750,10 +1740,8 @@ static void update_layout(FileDialogImpl *This)
         filename_width = filetype_rc.left - filenamelabel_rc.right - hspacing*2;
         filename_height = filename_rc.bottom - filename_rc.top;
 
-        filename_rc.left = filenamelabel_rc.right + hspacing;
-        filename_rc.top = filetype_rc.top;
-        filename_rc.right = filename_rc.left + filename_width;
-        filename_rc.bottom = filename_rc.top + filename_height;
+        SetRect(&filename_rc, filenamelabel_rc.right + hspacing, filetype_rc.top,
+                filenamelabel_rc.right + hspacing + filename_width, filetype_rc.top + filename_height);
     }
 
     hwnd = GetDlgItem(This->dlg_hwnd, IDC_NAV_TOOLBAR);
@@ -1771,10 +1759,8 @@ static void update_layout(FileDialogImpl *This)
         ctrl_container_resize(This, customctrls_rc.right - customctrls_rc.left);
 
     /* The ExplorerBrowser control. */
-    ebrowser_rc.left = dialog_rc.left + hspacing;
-    ebrowser_rc.top = toolbar_rc.bottom + vspacing;
-    ebrowser_rc.right = dialog_rc.right - hspacing;
-    ebrowser_rc.bottom = customctrls_rc.top - vspacing;
+    SetRect(&ebrowser_rc, dialog_rc.left + hspacing, toolbar_rc.bottom + vspacing,
+            dialog_rc.right - hspacing, customctrls_rc.top - vspacing);
 
     /****
      * Move everything to the right place.
-- 
2.8.2




More information about the wine-patches mailing list