From: Michael Stefaniuc Subject: comctl32: Use SetRect() instead of open coding it. Message-Id: <20160429132101.GA3805@redhat.com> Date: Fri, 29 Apr 2016 15:21:01 +0200 Signed-off-by: Michael Stefaniuc --- dlls/comctl32/animate.c | 5 +---- dlls/comctl32/comboex.c | 7 ++----- dlls/comctl32/datetime.c | 5 +---- dlls/comctl32/draglist.c | 6 ++---- dlls/comctl32/listview.c | 22 +++++++--------------- dlls/comctl32/progress.c | 32 ++++++-------------------------- dlls/comctl32/propsheet.c | 23 ++++------------------- dlls/comctl32/syslink.c | 5 +---- dlls/comctl32/tab.c | 8 ++------ dlls/comctl32/toolbar.c | 4 +--- dlls/comctl32/trackbar.c | 12 ++++-------- 11 files changed, 31 insertions(+), 98 deletions(-) diff --git a/dlls/comctl32/animate.c b/dlls/comctl32/animate.c index a86ff85..68b2bb6 100644 --- a/dlls/comctl32/animate.c +++ b/dlls/comctl32/animate.c @@ -312,10 +312,7 @@ static BOOL ANIMATE_PaintFrame(ANIMATE_INFO* infoPtr, HDC hDC) HBITMAP hbmOld2 = SelectObject(hdcFinal, hbmFinal); RECT rect; - rect.left = 0; - rect.top = 0; - rect.right = nWidth; - rect.bottom = nHeight; + SetRect(&rect, 0, 0, nWidth, nHeight); if(!infoPtr->hbrushBG) infoPtr->hbrushBG = GetCurrentObject(hDC, OBJ_BRUSH); diff --git a/dlls/comctl32/comboex.c b/dlls/comctl32/comboex.c index 86b9150..f86a519 100644 --- a/dlls/comctl32/comboex.c +++ b/dlls/comctl32/comboex.c @@ -1311,7 +1311,7 @@ static LRESULT COMBOEX_DrawItem (COMBOEX_INFO *infoPtr, DRAWITEMSTRUCT const *di RECT exrc, cbrc, edrc; GetWindowRect (infoPtr->hwndSelf, &exrc); GetWindowRect (infoPtr->hwndCombo, &cbrc); - edrc.left = edrc.top = edrc.right = edrc.bottom = -1; + SetRect(&edrc, -1, -1, -1, -1); if (infoPtr->hwndEdit) GetWindowRect (infoPtr->hwndEdit, &edrc); TRACE("window rects ex=(%s), cb=(%s), ed=(%s)\n", wine_dbgstr_rect(&exrc), wine_dbgstr_rect(&cbrc), @@ -1466,10 +1466,7 @@ static LRESULT COMBOEX_DrawItem (COMBOEX_INFO *infoPtr, DRAWITEMSTRUCT const *di x = xbase + xioff; y = dis->rcItem.top + (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2; - rect.left = x; - rect.right = x + txtsize.cx; - rect.top = dis->rcItem.top + 1; - rect.bottom = dis->rcItem.bottom - 1; + SetRect(&rect, x, dis->rcItem.top + 1, x + txtsize.cx, dis->rcItem.bottom - 1); TRACE("drawing item %d text, rect=(%s)\n", dis->itemID, wine_dbgstr_rect(&rect)); ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED, diff --git a/dlls/comctl32/datetime.c b/dlls/comctl32/datetime.c index 83db50e..86435ca 100644 --- a/dlls/comctl32/datetime.c +++ b/dlls/comctl32/datetime.c @@ -783,10 +783,7 @@ DATETIME_Refresh (DATETIME_INFO *infoPtr, HDC hdc) GetTextExtentPoint32W (hdc, txt, strlenW(txt), &size); } - selection.left = 0; - selection.top = 0; - selection.right = size.cx; - selection.bottom = size.cy; + SetRect(&selection, 0, 0, size.cx, size.cy); /* center rectangle */ OffsetRect(&selection, (field->right + field->left - size.cx)/2, (field->bottom - size.cy)/2); diff --git a/dlls/comctl32/draglist.c b/dlls/comctl32/draglist.c index 2097edb..9a54132 100644 --- a/dlls/comctl32/draglist.c +++ b/dlls/comctl32/draglist.c @@ -246,10 +246,8 @@ VOID WINAPI DrawInsert (HWND hwndParent, HWND hwndLB, INT nItem) if (!MapWindowPoints(HWND_DESKTOP, hwndParent, (LPPOINT)&rcListBox, 2)) return; - rcDragIcon.left = rcListBox.left - DRAGICON_HOTSPOT_X; - rcDragIcon.top = rcItem.top - DRAGICON_HOTSPOT_Y; - rcDragIcon.right = rcListBox.left; - rcDragIcon.bottom = rcDragIcon.top + DRAGICON_HEIGHT; + SetRect(&rcDragIcon, rcListBox.left - DRAGICON_HOTSPOT_X, rcItem.top - DRAGICON_HOTSPOT_Y, + rcListBox.left, rcDragIcon.top + DRAGICON_HEIGHT); if (!GetWindowSubclass(hwndLB, DragList_SubclassWindowProc, DRAGLIST_SUBCLASSID, (DWORD_PTR*)&data)) return; diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 758b640..a4336e8 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -5445,9 +5445,7 @@ static HIMAGELIST LISTVIEW_CreateDragImage(LISTVIEW_INFO *infoPtr, INT iItem, LP hOldbmp = SelectObject(hdc, hbmp); hOldFont = SelectObject(hdc, infoPtr->hFont); - rcItem.left = rcItem.top = 0; - rcItem.right = size.cx; - rcItem.bottom = size.cy; + SetRect(&rcItem, 0, 0, size.cx, size.cy); FillRect(hdc, &rcItem, infoPtr->hBkBrush); pos.x = pos.y = 0; @@ -5756,10 +5754,9 @@ static void LISTVIEW_ScrollOnInsert(LISTVIEW_INFO *infoPtr, INT nItem, INT dir) if (infoPtr->uView == LV_VIEW_DETAILS) return; /* now for LISTs, we have to deal with the columns to the right */ - rcScroll.left = (nItemCol + 1) * infoPtr->nItemWidth; - rcScroll.top = 0; - rcScroll.right = (infoPtr->nItemCount / nPerCol + 1) * infoPtr->nItemWidth; - rcScroll.bottom = nPerCol * infoPtr->nItemHeight; + SetRect(&rcScroll, (nItemCol + 1) * infoPtr->nItemWidth, 0, + (infoPtr->nItemCount / nPerCol + 1) * infoPtr->nItemWidth, + nPerCol * infoPtr->nItemHeight); OffsetRect(&rcScroll, Origin.x, Origin.y); if (IntersectRect(&rcScroll, &rcScroll, &infoPtr->rcList)) InvalidateRect(infoPtr->hwndSelf, &rcScroll, TRUE); @@ -8484,10 +8481,7 @@ static HIMAGELIST LISTVIEW_CreateCheckBoxIL(const LISTVIEW_INFO *infoPtr) hbm_mask = CreateBitmap(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 1, 1, NULL); ReleaseDC(infoPtr->hwndSelf, hdc_wnd); - rc.left = rc.top = 0; - rc.right = GetSystemMetrics(SM_CXSMICON); - rc.bottom = GetSystemMetrics(SM_CYSMICON); - + SetRect(&rc, 0, 0, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)); hbm_orig = SelectObject(hdc, hbm_mask); FillRect(hdc, &rc, hbr_white); InflateRect(&rc, -2, -2); @@ -8847,10 +8841,8 @@ static BOOL LISTVIEW_SetItemCount(LISTVIEW_INFO *infoPtr, INT nItems, DWORD dwFl if (infoPtr->uView == LV_VIEW_DETAILS) { - rcErase.left = 0; - rcErase.top = nFrom * infoPtr->nItemHeight; - rcErase.right = infoPtr->nItemWidth; - rcErase.bottom = nTo * infoPtr->nItemHeight; + SetRect(&rcErase, 0, nFrom * infoPtr->nItemHeight, infoPtr->nItemWidth, + nTo * infoPtr->nItemHeight); OffsetRect(&rcErase, Origin.x, Origin.y); if (IntersectRect(&rcErase, &rcErase, &infoPtr->rcList)) LISTVIEW_InvalidateRect(infoPtr, &rcErase); diff --git a/dlls/comctl32/progress.c b/dlls/comctl32/progress.c index 1b8fcf7..98c803c 100644 --- a/dlls/comctl32/progress.c +++ b/dlls/comctl32/progress.c @@ -163,10 +163,7 @@ typedef void (*ProgressDrawProc)(const ProgressDrawInfo* di, int start, int end) static void draw_solid_bar_H (const ProgressDrawInfo* di, int start, int end) { RECT r; - r.left = di->rect.left + start; - r.top = di->rect.top; - r.right = di->rect.left + end; - r.bottom = di->rect.bottom; + SetRect(&r, di->rect.left + start, di->rect.top, di->rect.left + end, di->rect.bottom); FillRect (di->hdc, &r, di->hbrBar); } @@ -174,10 +171,7 @@ static void draw_solid_bar_H (const ProgressDrawInfo* di, int start, int end) static void draw_solid_bkg_H (const ProgressDrawInfo* di, int start, int end) { RECT r; - r.left = di->rect.left + start; - r.top = di->rect.top; - r.right = di->rect.left + end; - r.bottom = di->rect.bottom; + SetRect(&r, di->rect.left + start, di->rect.top, di->rect.left + end, di->rect.bottom); FillRect (di->hdc, &r, di->hbrBk); } @@ -185,10 +179,7 @@ static void draw_solid_bkg_H (const ProgressDrawInfo* di, int start, int end) static void draw_solid_bar_V (const ProgressDrawInfo* di, int start, int end) { RECT r; - r.left = di->rect.left; - r.top = di->rect.bottom - end; - r.right = di->rect.right; - r.bottom = di->rect.bottom - start; + SetRect(&r, di->rect.left, di->rect.bottom - end, di->rect.right, di->rect.bottom - start); FillRect (di->hdc, &r, di->hbrBar); } @@ -196,10 +187,7 @@ static void draw_solid_bar_V (const ProgressDrawInfo* di, int start, int end) static void draw_solid_bkg_V (const ProgressDrawInfo* di, int start, int end) { RECT r; - r.left = di->rect.left; - r.top = di->rect.bottom - end; - r.right = di->rect.right; - r.bottom = di->rect.bottom - start; + SetRect(&r, di->rect.left, di->rect.bottom - end, di->rect.right, di->rect.bottom - start); FillRect (di->hdc, &r, di->hbrBk); } @@ -282,11 +270,7 @@ static void draw_theme_bkg_H (const ProgressDrawInfo* di, int start, int end) { RECT bgrect, r; - r.left = di->rect.left + start; - r.top = di->rect.top; - r.right = di->rect.left + end; - r.bottom = di->rect.bottom; - + SetRect(&r, di->rect.left + start, di->rect.top, di->rect.left + end, di->rect.bottom); bgrect = di->bgRect; OffsetRect(&bgrect, -bgrect.left, -bgrect.top); @@ -298,11 +282,7 @@ static void draw_theme_bkg_V (const ProgressDrawInfo* di, int start, int end) { RECT bgrect, r; - r.left = di->rect.left; - r.top = di->rect.bottom - end; - r.right = di->rect.right; - r.bottom = di->rect.bottom - start; - + SetRect(&r, di->rect.left, di->rect.bottom - end, di->rect.right, di->rect.bottom - start); bgrect = di->bgRect; OffsetRect(&bgrect, -bgrect.left, -bgrect.top); diff --git a/dlls/comctl32/propsheet.c b/dlls/comctl32/propsheet.c index ed5f7d4..3b56853 100644 --- a/dlls/comctl32/propsheet.c +++ b/dlls/comctl32/propsheet.c @@ -709,11 +709,7 @@ static BOOL PROPSHEET_SizeMismatch(HWND hwndDlg, const PropSheetInfo* psInfo) /* * Biggest page size. */ - rcPage.left = 0; - rcPage.top = 0; - rcPage.right = psInfo->width; - rcPage.bottom = psInfo->height; - + SetRect(&rcPage, 0, 0, psInfo->width, psInfo->height); MapDialogRect(hwndDlg, &rcPage); TRACE("biggest page %s\n", wine_dbgstr_rect(&rcPage)); @@ -747,11 +743,7 @@ static BOOL PROPSHEET_AdjustSize(HWND hwndDlg, PropSheetInfo* psInfo) /* * Biggest page size. */ - rc.left = 0; - rc.top = 0; - rc.right = psInfo->width; - rc.bottom = psInfo->height; - + SetRect(&rc, 0, 0, psInfo->width, psInfo->height); MapDialogRect(hwndDlg, &rc); /* retrieve the dialog units */ @@ -822,10 +814,7 @@ static BOOL PROPSHEET_AdjustSizeWizard(HWND hwndDlg, const PropSheetInfo* psInfo RECT rc, lineRect, dialogRect; /* Biggest page size */ - rc.left = 0; - rc.top = 0; - rc.right = psInfo->width; - rc.bottom = psInfo->height; + SetRect(&rc, 0, 0, psInfo->width, psInfo->height); MapDialogRect(hwndDlg, &rc); TRACE("Biggest page %s\n", wine_dbgstr_rect(&rc)); @@ -3319,11 +3308,7 @@ static LRESULT PROPSHEET_Paint(HWND hwnd, HDC hdcParam) GetClientRect(hwndLine, &r); MapWindowPoints(hwndLine, hwnd, (LPPOINT) &r, 2); - - rzone.left = 0; - rzone.top = 0; - rzone.right = r.right; - rzone.bottom = r.top - 1; + SetRect(&rzone, 0, 0, r.right, r.top - 1); hbr = GetSysColorBrush(COLOR_WINDOW); FillRect(hdc, &rzone, hbr); diff --git a/dlls/comctl32/syslink.c b/dlls/comctl32/syslink.c index 233169c..7e0b49b 100644 --- a/dlls/comctl32/syslink.c +++ b/dlls/comctl32/syslink.c @@ -776,10 +776,7 @@ static VOID SYSLINK_Render (const SYSLINK_INFO *infoPtr, HDC hdc, PRECT pRect) cbl->nChars = LineLen; cbl->nSkip = SkipChars; - cbl->rc.left = x; - cbl->rc.top = y; - cbl->rc.right = x + szDim.cx; - cbl->rc.bottom = y + szDim.cy; + SetRect(&cbl->rc, x, y, x + szDim.cx, y + szDim.cy); if (cbl->rc.right > szDoc.cx) szDoc.cx = cbl->rc.right; diff --git a/dlls/comctl32/tab.c b/dlls/comctl32/tab.c index ead3f56..e67a682 100644 --- a/dlls/comctl32/tab.c +++ b/dlls/comctl32/tab.c @@ -1769,8 +1769,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect rcImage = *drawRect; rcTemp = *drawRect; - - rcText.left = rcText.top = rcText.right = rcText.bottom = 0; + SetRectEmpty(&rcText); /* get the rectangle that the text fits in */ if (item->pszText) @@ -2136,10 +2135,7 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem) /* Now erase the top corner and draw diagonal edge */ SetBkColor(hdc, corner); - r1.left = r.right - ROUND_CORNER_SIZE - 1; - r1.top = r.top; - r1.right = r.right; - r1.bottom = r1.top + ROUND_CORNER_SIZE; + SetRect(&r1, r.right - ROUND_CORNER_SIZE - 1, r.top, r.right, r1.top + ROUND_CORNER_SIZE); ExtTextOutW(hdc, 0, 0, 2, &r1, NULL, 0, 0); r1.right--; DrawEdge(hdc, &r1, EDGE_RAISED, BF_SOFT|BF_DIAGONAL_ENDTOPLEFT); diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index ae6f21e..9307fd4 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -1231,9 +1231,7 @@ TOOLBAR_MeasureString(const TOOLBAR_INFO *infoPtr, const TBUTTON_INFO *btnPtr, GetTextExtentPoint32W (hdc, lpText, strlenW (lpText), lpSize); /* feed above size into the rectangle for DrawText */ - myrect.left = myrect.top = 0; - myrect.right = lpSize->cx; - myrect.bottom = lpSize->cy; + SetRect(&myrect, 0, 0, lpSize->cx, lpSize->cy); /* Use DrawText to get true size as drawn (less pesky "&") */ DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE | diff --git a/dlls/comctl32/trackbar.c b/dlls/comctl32/trackbar.c index 12c3e9d..8c99ad0 100644 --- a/dlls/comctl32/trackbar.c +++ b/dlls/comctl32/trackbar.c @@ -497,16 +497,12 @@ TRACKBAR_DrawOneTic (const TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos, int fla if (flags & TBS_VERT) { offsetthumb = (infoPtr->rcThumb.bottom - infoPtr->rcThumb.top)/2; - rcTics.left = infoPtr->rcThumb.left - 2; - rcTics.right = infoPtr->rcThumb.right + 2; - rcTics.top = infoPtr->rcChannel.top + offsetthumb; - rcTics.bottom = infoPtr->rcChannel.bottom - offsetthumb - 1; + SetRect(&rcTics, infoPtr->rcThumb.left - 2, infoPtr->rcChannel.top + offsetthumb, + infoPtr->rcThumb.right + 2, infoPtr->rcChannel.bottom - offsetthumb - 1); } else { offsetthumb = (infoPtr->rcThumb.right - infoPtr->rcThumb.left)/2; - rcTics.left = infoPtr->rcChannel.left + offsetthumb; - rcTics.right = infoPtr->rcChannel.right - offsetthumb - 1; - rcTics.top = infoPtr->rcThumb.top - 2; - rcTics.bottom = infoPtr->rcThumb.bottom + 2; + SetRect(&rcTics, infoPtr->rcChannel.left + offsetthumb, infoPtr->rcThumb.top - 2, + infoPtr->rcChannel.right - offsetthumb - 1, infoPtr->rcThumb.bottom + 2); } if (flags & (TBS_TOP | TBS_LEFT)) { -- 2.4.11