Zhiyi Zhang : comctl32/datetime: Change DATETIME_ReturnFieldWidth() to return width.
Alexandre Julliard
julliard at winehq.org
Mon Mar 26 16:01:22 CDT 2018
Module: wine
Branch: master
Commit: cc893cdcabb578b0eb434c6aca04acf61bcf8444
URL: https://source.winehq.org/git/wine.git/?a=commit;h=cc893cdcabb578b0eb434c6aca04acf61bcf8444
Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date: Mon Mar 26 18:09:19 2018 +0800
comctl32/datetime: Change DATETIME_ReturnFieldWidth() to return width.
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/comctl32/datetime.c | 24 ++++++------------------
1 file changed, 6 insertions(+), 18 deletions(-)
diff --git a/dlls/comctl32/datetime.c b/dlls/comctl32/datetime.c
index 6231070..fb8a5c0 100644
--- a/dlls/comctl32/datetime.c
+++ b/dlls/comctl32/datetime.c
@@ -598,8 +598,7 @@ DATETIME_IncreaseField (DATETIME_INFO *infoPtr, int number, int delta)
}
}
-static void
-DATETIME_ReturnFieldWidth (const DATETIME_INFO *infoPtr, HDC hdc, int count, SHORT *width)
+static int DATETIME_GetFieldWidth (const DATETIME_INFO *infoPtr, HDC hdc, int count)
{
/* fields are a fixed width, determined by the largest possible string */
/* presumably, these widths should be language dependent */
@@ -613,13 +612,7 @@ DATETIME_ReturnFieldWidth (const DATETIME_INFO *infoPtr, HDC hdc, int count, SHO
LPCWSTR bufptr;
SIZE size;
- TRACE ("%d,%d\n", infoPtr->nrFields, count);
- if (count>infoPtr->nrFields || count < 0) {
- WARN ("buffer overrun, have %d want %d\n", infoPtr->nrFields, count);
- return;
- }
-
- if (!infoPtr->fieldspec) return;
+ if (!infoPtr->fieldspec) return 0;
spec = infoPtr->fieldspec[count];
if (spec & DT_STRING) {
@@ -709,8 +702,7 @@ DATETIME_ReturnFieldWidth (const DATETIME_INFO *infoPtr, HDC hdc, int count, SHO
break;
}
}
- *width = cx;
- return;
+ return cx;
}
case ONELETTERAMPM:
bufptr = fld_am1;
@@ -724,7 +716,7 @@ DATETIME_ReturnFieldWidth (const DATETIME_INFO *infoPtr, HDC hdc, int count, SHO
}
}
GetTextExtentPoint32W (hdc, bufptr, strlenW(bufptr), &size);
- *width = size.cx;
+ return size.cx;
}
static void
@@ -738,7 +730,6 @@ DATETIME_Refresh (DATETIME_INFO *infoPtr, HDC hdc)
RECT *rcDraw = &infoPtr->rcDraw;
SIZE size;
COLORREF oldTextColor;
- SHORT fieldWidth = 0;
HFONT oldFont = SelectObject (hdc, infoPtr->hFont);
INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
WCHAR txt[80];
@@ -752,10 +743,9 @@ DATETIME_Refresh (DATETIME_INFO *infoPtr, HDC hdc)
for (i = 0; i < infoPtr->nrFields; i++) {
DATETIME_ReturnTxt (infoPtr, i, txt, ARRAY_SIZE(txt));
GetTextExtentPoint32W (hdc, txt, strlenW(txt), &size);
- DATETIME_ReturnFieldWidth (infoPtr, hdc, i, &fieldWidth);
field = &infoPtr->fieldRect[i];
field->left = prevright;
- field->right = prevright + fieldWidth;
+ field->right = prevright + DATETIME_GetFieldWidth (infoPtr, hdc, i);
field->top = rcDraw->top;
field->bottom = rcDraw->bottom;
prevright = field->right;
@@ -1458,7 +1448,6 @@ static BOOL DATETIME_GetIdealSize(DATETIME_INFO *infoPtr, SIZE *size)
{
SIZE field_size;
RECT rect;
- SHORT width;
WCHAR txt[80];
HDC hdc;
HFONT oldFont;
@@ -1477,8 +1466,7 @@ static BOOL DATETIME_GetIdealSize(DATETIME_INFO *infoPtr, SIZE *size)
/* Get text font width */
for (i = 0; i < infoPtr->nrFields; i++)
{
- DATETIME_ReturnFieldWidth(infoPtr, hdc, i, &width);
- size->cx += width;
+ size->cx += DATETIME_GetFieldWidth(infoPtr, hdc, i);
}
SelectObject(hdc, oldFont);
More information about the wine-cvs
mailing list