comctl32/progress: Update position by one step on PBM_SETPOS in PBS_MARQUEE style.

This commit is contained in:
Nikolay Sivov 2014-06-08 00:04:28 +04:00 committed by Alexandre Julliard
parent c69a7ecfb6
commit 2a348791ee
1 changed files with 47 additions and 38 deletions

View File

@ -448,38 +448,32 @@ static LRESULT PROGRESS_Paint (PROGRESS_INFO *infoPtr, HDC hdc)
/*********************************************************************** /***********************************************************************
* PROGRESS_Timer * Advance marquee progress by one step.
* Handle the marquee timer messages
*/ */
static LRESULT PROGRESS_Timer (PROGRESS_INFO *infoPtr, INT idTimer) static void PROGRESS_UpdateMarquee (PROGRESS_INFO *infoPtr)
{ {
if(idTimer == ID_MARQUEE_TIMER) LONG style = GetWindowLongW (infoPtr->Self, GWL_STYLE);
{ RECT rect;
LONG style = GetWindowLongW (infoPtr->Self, GWL_STYLE); int ledWidth, leds;
RECT rect; HTHEME theme = GetWindowTheme (infoPtr->Self);
int ledWidth, leds; BOOL smooth = (style & PBS_SMOOTH) && !theme;
HTHEME theme = GetWindowTheme (infoPtr->Self);
BOOL barSmooth = (style & PBS_SMOOTH) && !theme;
get_client_rect (infoPtr->Self, &rect); get_client_rect (infoPtr->Self, &rect);
if(!barSmooth) if (smooth)
ledWidth = get_led_size( infoPtr, style, &rect ) + ledWidth = 1;
get_led_gap( infoPtr ); else
else ledWidth = get_led_size( infoPtr, style, &rect ) + get_led_gap( infoPtr );
ledWidth = 1;
leds = (get_bar_size( style, &rect ) + ledWidth - 1) / leds = (get_bar_size( style, &rect ) + ledWidth - 1) /
ledWidth; ledWidth;
/* increment the marquee progress */ /* increment the marquee progress */
if(++infoPtr->MarqueePos >= leds) if (++infoPtr->MarqueePos >= leds)
infoPtr->MarqueePos = 0; infoPtr->MarqueePos = 0;
InvalidateRect(infoPtr->Self, &rect, TRUE); InvalidateRect(infoPtr->Self, &rect, TRUE);
UpdateWindow(infoPtr->Self); UpdateWindow(infoPtr->Self);
}
return 0;
} }
@ -522,6 +516,30 @@ static DWORD PROGRESS_SetRange (PROGRESS_INFO *infoPtr, int low, int high)
return res; return res;
} }
static UINT PROGRESS_SetPos (PROGRESS_INFO *infoPtr, INT pos)
{
DWORD style = GetWindowLongW(infoPtr->Self, GWL_STYLE);
if (style & PBS_MARQUEE)
{
PROGRESS_UpdateMarquee(infoPtr);
return 1;
}
else
{
UINT oldVal;
oldVal = infoPtr->CurVal;
if (oldVal != pos) {
infoPtr->CurVal = pos;
PROGRESS_CoercePos(infoPtr);
TRACE("PBM_SETPOS: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal);
PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal );
UpdateWindow( infoPtr->Self );
}
return oldVal;
}
}
/*********************************************************************** /***********************************************************************
* ProgressWindowProc * ProgressWindowProc
*/ */
@ -596,7 +614,9 @@ static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message,
return PROGRESS_Paint (infoPtr, (HDC)wParam); return PROGRESS_Paint (infoPtr, (HDC)wParam);
case WM_TIMER: case WM_TIMER:
return PROGRESS_Timer (infoPtr, (INT)wParam); if (wParam == ID_MARQUEE_TIMER)
PROGRESS_UpdateMarquee (infoPtr);
return 0;
case WM_THEMECHANGED: case WM_THEMECHANGED:
{ {
@ -632,18 +652,7 @@ static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message,
} }
case PBM_SETPOS: case PBM_SETPOS:
{ return PROGRESS_SetPos(infoPtr, wParam);
UINT oldVal;
oldVal = infoPtr->CurVal;
if(oldVal != wParam) {
infoPtr->CurVal = (INT)wParam;
PROGRESS_CoercePos(infoPtr);
TRACE("PBM_SETPOS: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal);
PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal );
UpdateWindow( infoPtr->Self );
}
return oldVal;
}
case PBM_SETRANGE: case PBM_SETRANGE:
return PROGRESS_SetRange (infoPtr, (int)LOWORD(lParam), (int)HIWORD(lParam)); return PROGRESS_SetRange (infoPtr, (int)LOWORD(lParam), (int)HIWORD(lParam));