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
* Handle the marquee timer messages
* Advance marquee progress by one step.
*/
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;
int ledWidth, leds;
HTHEME theme = GetWindowTheme (infoPtr->Self);
BOOL barSmooth = (style & PBS_SMOOTH) && !theme;
LONG style = GetWindowLongW (infoPtr->Self, GWL_STYLE);
RECT rect;
int ledWidth, leds;
HTHEME theme = GetWindowTheme (infoPtr->Self);
BOOL smooth = (style & PBS_SMOOTH) && !theme;
get_client_rect (infoPtr->Self, &rect);
get_client_rect (infoPtr->Self, &rect);
if(!barSmooth)
ledWidth = get_led_size( infoPtr, style, &rect ) +
get_led_gap( infoPtr );
else
ledWidth = 1;
if (smooth)
ledWidth = 1;
else
ledWidth = get_led_size( infoPtr, style, &rect ) + get_led_gap( infoPtr );
leds = (get_bar_size( style, &rect ) + ledWidth - 1) /
ledWidth;
leds = (get_bar_size( style, &rect ) + ledWidth - 1) /
ledWidth;
/* increment the marquee progress */
if(++infoPtr->MarqueePos >= leds)
infoPtr->MarqueePos = 0;
/* increment the marquee progress */
if (++infoPtr->MarqueePos >= leds)
infoPtr->MarqueePos = 0;
InvalidateRect(infoPtr->Self, &rect, TRUE);
UpdateWindow(infoPtr->Self);
}
return 0;
InvalidateRect(infoPtr->Self, &rect, TRUE);
UpdateWindow(infoPtr->Self);
}
@ -522,6 +516,30 @@ static DWORD PROGRESS_SetRange (PROGRESS_INFO *infoPtr, int low, int high)
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
*/
@ -596,7 +614,9 @@ static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message,
return PROGRESS_Paint (infoPtr, (HDC)wParam);
case WM_TIMER:
return PROGRESS_Timer (infoPtr, (INT)wParam);
if (wParam == ID_MARQUEE_TIMER)
PROGRESS_UpdateMarquee (infoPtr);
return 0;
case WM_THEMECHANGED:
{
@ -632,18 +652,7 @@ static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message,
}
case PBM_SETPOS:
{
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;
}
return PROGRESS_SetPos(infoPtr, wParam);
case PBM_SETRANGE:
return PROGRESS_SetRange (infoPtr, (int)LOWORD(lParam), (int)HIWORD(lParam));