ReactOS 0.4.15-dev-8434-g155a7c7
progress.c File Reference
#include <stdarg.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "commctrl.h"
#include "comctl32.h"
#include "uxtheme.h"
#include "vssym32.h"
#include "wine/debug.h"
#include "wine/heap.h"
Include dependency graph for progress.c:

Go to the source code of this file.

Classes

struct  PROGRESS_INFO
 
struct  tagProgressDrawInfo
 

Macros

#define LED_GAP   2
 
#define MARQUEE_LEDS   5
 
#define ID_MARQUEE_TIMER   1
 
#define DEFAULT_MARQUEE_PERIOD   30
 

Typedefs

typedef struct tagProgressDrawInfo ProgressDrawInfo
 
typedef void(* ProgressDrawProc) (const ProgressDrawInfo *di, int start, int end)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (progress)
 
static int get_led_size (const PROGRESS_INFO *infoPtr, LONG style, const RECT *rect)
 
static int get_led_gap (const PROGRESS_INFO *infoPtr)
 
static void get_client_rect (HWND hwnd, RECT *rect)
 
static int get_bar_size (LONG style, const RECT *rect)
 
static int get_bar_position (const PROGRESS_INFO *infoPtr, LONG style, const RECT *rect, INT value)
 
static void PROGRESS_Invalidate (const PROGRESS_INFO *infoPtr, INT old, INT new)
 
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)
 
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)
 
static void draw_chunk_bar_H (const ProgressDrawInfo *di, int start, int end)
 
static void draw_chunk_bar_V (const ProgressDrawInfo *di, int start, int end)
 
static void draw_theme_bar_H (const ProgressDrawInfo *di, int start, int end)
 
static void draw_theme_bar_V (const ProgressDrawInfo *di, int start, int end)
 
static void draw_theme_bkg_H (const ProgressDrawInfo *di, int start, int end)
 
static void draw_theme_bkg_V (const ProgressDrawInfo *di, int start, int end)
 
static LRESULT PROGRESS_Draw (PROGRESS_INFO *infoPtr, HDC hdc)
 
static LRESULT PROGRESS_Paint (PROGRESS_INFO *infoPtr, HDC hdc)
 
static void PROGRESS_UpdateMarquee (PROGRESS_INFO *infoPtr)
 
static void PROGRESS_CoercePos (PROGRESS_INFO *infoPtr)
 
static HFONT PROGRESS_SetFont (PROGRESS_INFO *infoPtr, HFONT hFont, BOOL bRedraw)
 
static DWORD PROGRESS_SetRange (PROGRESS_INFO *infoPtr, int low, int high)
 
static UINT PROGRESS_SetPos (PROGRESS_INFO *infoPtr, INT pos)
 
static LRESULT WINAPI ProgressWindowProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 
void PROGRESS_Register (void)
 
void PROGRESS_Unregister (void)
 

Variables

static const ProgressDrawProc drawProcClassic [8]
 
static const ProgressDrawProc drawProcThemed [8]
 

Macro Definition Documentation

◆ DEFAULT_MARQUEE_PERIOD

#define DEFAULT_MARQUEE_PERIOD   30

Definition at line 63 of file progress.c.

◆ ID_MARQUEE_TIMER

#define ID_MARQUEE_TIMER   1

Definition at line 62 of file progress.c.

◆ LED_GAP

#define LED_GAP   2

Definition at line 60 of file progress.c.

◆ MARQUEE_LEDS

#define MARQUEE_LEDS   5

Definition at line 61 of file progress.c.

Typedef Documentation

◆ ProgressDrawInfo

◆ ProgressDrawProc

typedef void(* ProgressDrawProc) (const ProgressDrawInfo *di, int start, int end)

Definition at line 152 of file progress.c.

Function Documentation

◆ draw_chunk_bar_H()

static void draw_chunk_bar_H ( const ProgressDrawInfo di,
int  start,
int  end 
)
static

Definition at line 187 of file progress.c.

188{
189 RECT r;
190 int right = di->rect.left + end;
191 r.left = di->rect.left + start;
192 r.top = di->rect.top;
193 r.bottom = di->rect.bottom;
194 while (r.left < right)
195 {
196 r.right = min (r.left + di->ledW, right);
197 FillRect (di->hdc, &r, di->hbrBar);
198 r.left = r.right;
199 r.right = min (r.left + di->ledGap, right);
200 FillRect (di->hdc, &r, di->hbrBk);
201 r.left = r.right;
202 }
203}
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble right
Definition: glext.h:10859
#define min(a, b)
Definition: monoChain.cc:55
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)

◆ draw_chunk_bar_V()

static void draw_chunk_bar_V ( const ProgressDrawInfo di,
int  start,
int  end 
)
static

Definition at line 206 of file progress.c.

207{
208 RECT r;
209 int top = di->rect.bottom - end;
210 r.left = di->rect.left;
211 r.right = di->rect.right;
212 r.bottom = di->rect.bottom - start;
213 while (r.bottom > top)
214 {
215 r.top = max (r.bottom - di->ledW, top);
216 FillRect (di->hdc, &r, di->hbrBar);
217 r.bottom = r.top;
218 r.top = max (r.bottom - di->ledGap, top);
219 FillRect (di->hdc, &r, di->hbrBk);
220 r.bottom = r.top;
221 }
222}
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
LONG right
Definition: windef.h:308
#define max(a, b)
Definition: svc.c:63

◆ draw_solid_bar_H()

static void draw_solid_bar_H ( const ProgressDrawInfo di,
int  start,
int  end 
)
static

Definition at line 155 of file progress.c.

156{
157 RECT r;
158 SetRect(&r, di->rect.left + start, di->rect.top, di->rect.left + end, di->rect.bottom);
159 FillRect (di->hdc, &r, di->hbrBar);
160}
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

◆ draw_solid_bar_V()

static void draw_solid_bar_V ( const ProgressDrawInfo di,
int  start,
int  end 
)
static

Definition at line 171 of file progress.c.

172{
173 RECT r;
174 SetRect(&r, di->rect.left, di->rect.bottom - end, di->rect.right, di->rect.bottom - start);
175 FillRect (di->hdc, &r, di->hbrBar);
176}

◆ draw_solid_bkg_H()

static void draw_solid_bkg_H ( const ProgressDrawInfo di,
int  start,
int  end 
)
static

Definition at line 163 of file progress.c.

164{
165 RECT r;
166 SetRect(&r, di->rect.left + start, di->rect.top, di->rect.left + end, di->rect.bottom);
167 FillRect (di->hdc, &r, di->hbrBk);
168}

◆ draw_solid_bkg_V()

static void draw_solid_bkg_V ( const ProgressDrawInfo di,
int  start,
int  end 
)
static

Definition at line 179 of file progress.c.

180{
181 RECT r;
182 SetRect(&r, di->rect.left, di->rect.bottom - end, di->rect.right, di->rect.bottom - start);
183 FillRect (di->hdc, &r, di->hbrBk);
184}

◆ draw_theme_bar_H()

static void draw_theme_bar_H ( const ProgressDrawInfo di,
int  start,
int  end 
)
static

Definition at line 239 of file progress.c.

240{
241 RECT r;
242 r.left = di->rect.left + start;
243 r.top = di->rect.top;
244 r.bottom = di->rect.bottom;
245 r.right = di->rect.left + end;
246 DrawThemeBackground (di->theme, di->hdc, PP_CHUNK, 0, &r, NULL);
247}
#define NULL
Definition: types.h:112
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
Definition: draw.c:128
@ PP_CHUNK
Definition: vsstyle.h:976

◆ draw_theme_bar_V()

static void draw_theme_bar_V ( const ProgressDrawInfo di,
int  start,
int  end 
)
static

Definition at line 250 of file progress.c.

251{
252 RECT r;
253 r.left = di->rect.left;
254 r.right = di->rect.right;
255 r.bottom = di->rect.bottom - start;
256 r.top = di->rect.bottom - end;
258}
@ PP_CHUNKVERT
Definition: vsstyle.h:977

◆ draw_theme_bkg_H()

static void draw_theme_bkg_H ( const ProgressDrawInfo di,
int  start,
int  end 
)
static

Definition at line 261 of file progress.c.

262{
263 RECT bgrect, r;
264
265 SetRect(&r, di->rect.left + start, di->rect.top, di->rect.left + end, di->rect.bottom);
266 bgrect = di->bgRect;
267 OffsetRect(&bgrect, -bgrect.left, -bgrect.top);
268
269 DrawThemeBackground (di->theme, di->hdc, PP_BAR, 0, &bgrect, &r);
270}
@ PP_BAR
Definition: vsstyle.h:974
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)

◆ draw_theme_bkg_V()

static void draw_theme_bkg_V ( const ProgressDrawInfo di,
int  start,
int  end 
)
static

Definition at line 273 of file progress.c.

274{
275 RECT bgrect, r;
276
277 SetRect(&r, di->rect.left, di->rect.bottom - end, di->rect.right, di->rect.bottom - start);
278 bgrect = di->bgRect;
279 OffsetRect(&bgrect, -bgrect.left, -bgrect.top);
280
281 DrawThemeBackground (di->theme, di->hdc, PP_BARVERT, 0, &bgrect, &r);
282}
@ PP_BARVERT
Definition: vsstyle.h:975

◆ get_bar_position()

static int get_bar_position ( const PROGRESS_INFO infoPtr,
LONG  style,
const RECT rect,
INT  value 
)
inlinestatic

Definition at line 122 of file progress.c.

124{
125 return MulDiv (value - infoPtr->MinVal, get_bar_size (style, rect),
126 infoPtr->MaxVal - infoPtr->MinVal);
127}
Arabic default style
Definition: afstyles.h:94
static int get_bar_size(LONG style, const RECT *rect)
Definition: progress.c:113
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
& rect
Definition: startmenu.cpp:1413
Definition: pdh_main.c:94

Referenced by PROGRESS_Draw().

◆ get_bar_size()

static int get_bar_size ( LONG  style,
const RECT rect 
)
inlinestatic

Definition at line 113 of file progress.c.

114{
115 if (style & PBS_VERTICAL)
116 return rect->bottom - rect->top;
117 else
118 return rect->right - rect->left;
119}
#define PBS_VERTICAL
Definition: commctrl.h:2181

Referenced by get_bar_position(), PROGRESS_Draw(), and PROGRESS_UpdateMarquee().

◆ get_client_rect()

static void get_client_rect ( HWND  hwnd,
RECT rect 
)
inlinestatic

Definition at line 98 of file progress.c.

99{
100 HTHEME theme = GetWindowTheme (hwnd);
102 if (!theme)
103 InflateRect(rect, -1, -1);
104 else
105 {
106 DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE);
107 int part = (dwStyle & PBS_VERTICAL) ? PP_BARVERT : PP_BAR;
108 GetThemeBackgroundContentRect (theme, 0, part, 0, rect, rect);
109 }
110}
HRESULT WINAPI GetThemeBackgroundContentRect(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pBoundingRect, RECT *pContentRect)
Definition: draw.c:1479
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:851
unsigned long DWORD
Definition: ntddk_ex.h:95
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define GWL_STYLE
Definition: winuser.h:852

Referenced by PROGRESS_UpdateMarquee().

◆ get_led_gap()

static int get_led_gap ( const PROGRESS_INFO infoPtr)
inlinestatic

Definition at line 84 of file progress.c.

85{
86 HTHEME theme = GetWindowTheme (infoPtr->Self);
87 if (theme)
88 {
89 int spaceSize;
90 if (SUCCEEDED( GetThemeInt( theme, 0, 0, TMT_PROGRESSSPACESIZE, &spaceSize )))
91 return spaceSize;
92 }
93
94 return LED_GAP;
95}
#define LED_GAP
Definition: progress.c:60
HRESULT WINAPI GetThemeInt(HTHEME hTheme, int iPartId, int iStateId, int iPropId, int *piVal)
Definition: property.c:126
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define TMT_PROGRESSSPACESIZE
Definition: vssym32.h:283

Referenced by PROGRESS_Draw(), and PROGRESS_UpdateMarquee().

◆ get_led_size()

static int get_led_size ( const PROGRESS_INFO infoPtr,
LONG  style,
const RECT rect 
)
inlinestatic

Definition at line 66 of file progress.c.

68{
69 HTHEME theme = GetWindowTheme (infoPtr->Self);
70 if (theme)
71 {
72 int chunkSize;
73 if (SUCCEEDED( GetThemeInt( theme, 0, 0, TMT_PROGRESSCHUNKSIZE, &chunkSize )))
74 return chunkSize;
75 }
76
77 if (style & PBS_VERTICAL)
78 return MulDiv (rect->right - rect->left, 2, 3);
79 else
80 return MulDiv (rect->bottom - rect->top, 2, 3);
81}
#define TMT_PROGRESSCHUNKSIZE
Definition: vssym32.h:282

Referenced by PROGRESS_Draw(), and PROGRESS_UpdateMarquee().

◆ PROGRESS_CoercePos()

static void PROGRESS_CoercePos ( PROGRESS_INFO infoPtr)
static

Definition at line 466 of file progress.c.

467{
468 if(infoPtr->CurVal < infoPtr->MinVal)
469 infoPtr->CurVal = infoPtr->MinVal;
470 if(infoPtr->CurVal > infoPtr->MaxVal)
471 infoPtr->CurVal = infoPtr->MaxVal;
472}

Referenced by PROGRESS_SetPos(), PROGRESS_SetRange(), and ProgressWindowProc().

◆ PROGRESS_Draw()

static LRESULT PROGRESS_Draw ( PROGRESS_INFO infoPtr,
HDC  hdc 
)
static

Definition at line 302 of file progress.c.

303{
304 int barSize;
305 DWORD dwStyle;
306 BOOL barSmooth;
307 const ProgressDrawProc* drawProcs;
309
310 TRACE("(infoPtr=%p, hdc=%p)\n", infoPtr, hdc);
311
312 pdi.hdc = hdc;
313 pdi.theme = GetWindowTheme (infoPtr->Self);
314
315 /* get the required bar brush */
316 if (infoPtr->ColorBar == CLR_DEFAULT)
318 else
319 pdi.hbrBar = CreateSolidBrush (infoPtr->ColorBar);
320
321 if (infoPtr->ColorBk == CLR_DEFAULT)
323 else
324 pdi.hbrBk = CreateSolidBrush(infoPtr->ColorBk);
325
326 /* get the window style */
327 dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE);
328
329 /* get client rectangle */
330 GetClientRect (infoPtr->Self, &pdi.rect);
331 if (!pdi.theme) {
332 FrameRect( hdc, &pdi.rect, pdi.hbrBk );
333 InflateRect(&pdi.rect, -1, -1);
334 }
335 else
336 {
337 RECT cntRect;
338 int part = (dwStyle & PBS_VERTICAL) ? PP_BARVERT : PP_BAR;
339
340 GetThemeBackgroundContentRect (pdi.theme, hdc, part, 0, &pdi.rect,
341 &cntRect);
342
343 /* Exclude content rect - content background will be drawn later */
344 ExcludeClipRect (hdc, cntRect.left, cntRect.top,
345 cntRect.right, cntRect.bottom);
346 if (IsThemeBackgroundPartiallyTransparent (pdi.theme, part, 0))
348 DrawThemeBackground (pdi.theme, hdc, part, 0, &pdi.rect, NULL);
350 pdi.rect = cntRect;
351 }
352
353 /* compute some drawing parameters */
354 barSmooth = (dwStyle & PBS_SMOOTH) && !pdi.theme;
355 drawProcs = &((pdi.theme ? drawProcThemed : drawProcClassic)[(barSmooth ? 0 : 4)
356 + ((dwStyle & PBS_VERTICAL) ? 2 : 0)]);
357 barSize = get_bar_size( dwStyle, &pdi.rect );
358 if (pdi.theme)
359 {
360 GetWindowRect( infoPtr->Self, &pdi.bgRect );
361 MapWindowPoints( infoPtr->Self, 0, (POINT*)&pdi.bgRect, 2 );
362 }
363
364 if (!barSmooth)
365 pdi.ledW = get_led_size( infoPtr, dwStyle, &pdi.rect);
366 pdi.ledGap = get_led_gap( infoPtr );
367
368 if (dwStyle & PBS_MARQUEE)
369 {
370 const int ledW = !barSmooth ? (pdi.ledW + pdi.ledGap) : 1;
371 const int leds = (barSize + ledW - 1) / ledW;
372 const int ledMEnd = infoPtr->MarqueePos + MARQUEE_LEDS;
373
374 if (ledMEnd > leds)
375 {
376 /* case 1: the marquee bar extends over the end and wraps around to
377 * the start */
378 const int gapStart = max((ledMEnd - leds) * ledW, 0);
379 const int gapEnd = min(infoPtr->MarqueePos * ledW, barSize);
380
381 drawProcs[0]( &pdi, 0, gapStart);
382 drawProcs[1]( &pdi, gapStart, gapEnd);
383 drawProcs[0]( &pdi, gapEnd, barSize);
384 }
385 else
386 {
387 /* case 2: the marquee bar is between start and end */
388 const int barStart = infoPtr->MarqueePos * ledW;
389 const int barEnd = min (ledMEnd * ledW, barSize);
390
391 drawProcs[1]( &pdi, 0, barStart);
392 drawProcs[0]( &pdi, barStart, barEnd);
393 drawProcs[1]( &pdi, barEnd, barSize);
394 }
395 }
396 else
397 {
398 int barEnd = get_bar_position( infoPtr, dwStyle, &pdi.rect,
399 infoPtr->CurVal);
400 if (!barSmooth)
401 {
402 const int ledW = pdi.ledW + pdi.ledGap;
403 barEnd = min (((barEnd + ledW - 1) / ledW) * ledW, barSize);
404 }
405 drawProcs[0]( &pdi, 0, barEnd);
406 drawProcs[1]( &pdi, barEnd, barSize);
407 }
408
409 /* delete bar brush */
410 if (infoPtr->ColorBar != CLR_DEFAULT) DeleteObject (pdi.hbrBar);
411 if (infoPtr->ColorBk != CLR_DEFAULT) DeleteObject (pdi.hbrBk);
412
413 return 0;
414}
static int get_led_size(const PROGRESS_INFO *infoPtr, LONG style, const RECT *rect)
Definition: progress.c:66
static int get_led_gap(const PROGRESS_INFO *infoPtr)
Definition: progress.c:84
void(* ProgressDrawProc)(const ProgressDrawInfo *di, int start, int end)
Definition: progress.c:152
static int get_bar_position(const PROGRESS_INFO *infoPtr, LONG style, const RECT *rect, INT value)
Definition: progress.c:122
static const ProgressDrawProc drawProcThemed[8]
Definition: progress.c:285
static const ProgressDrawProc drawProcClassic[8]
Definition: progress.c:225
#define MARQUEE_LEDS
Definition: progress.c:61
BOOL WINAPI IsThemeBackgroundPartiallyTransparent(HTHEME hTheme, int iPartId, int iStateId)
Definition: draw.c:1883
HRESULT WINAPI DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT *prc)
Definition: draw.c:72
unsigned int BOOL
Definition: ntddk_ex.h:94
pKey DeleteObject()
HDC hdc
Definition: main.c:9
#define PBS_MARQUEE
Definition: commctrl.h:2198
#define PBS_SMOOTH
Definition: commctrl.h:2180
#define CLR_DEFAULT
Definition: commctrl.h:320
#define TRACE(s)
Definition: solgame.cpp:4
INT MarqueePos
Definition: progress.c:51
COLORREF ColorBar
Definition: progress.c:53
COLORREF ColorBk
Definition: progress.c:54
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO * pdi
Definition: winddi.h:3554
int WINAPI ExcludeClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
int WINAPI FrameRect(_In_ HDC, _In_ LPCRECT, _In_ HBRUSH)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define COLOR_HIGHLIGHT
Definition: winuser.h:926
HBRUSH WINAPI GetSysColorBrush(_In_ int)
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define COLOR_3DFACE
Definition: winuser.h:929

Referenced by PROGRESS_Paint().

◆ PROGRESS_Invalidate()

static void PROGRESS_Invalidate ( const PROGRESS_INFO infoPtr,
INT  old,
INT  new 
)
static

Definition at line 135 of file progress.c.

136{
137 InvalidateRect( infoPtr->Self, NULL, old > new );
138}
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

Referenced by PROGRESS_SetPos(), and ProgressWindowProc().

◆ PROGRESS_Paint()

static LRESULT PROGRESS_Paint ( PROGRESS_INFO infoPtr,
HDC  hdc 
)
static

Definition at line 421 of file progress.c.

422{
423 PAINTSTRUCT ps;
424 if (hdc) return PROGRESS_Draw (infoPtr, hdc);
425 hdc = BeginPaint (infoPtr->Self, &ps);
426 PROGRESS_Draw (infoPtr, hdc);
427 EndPaint (infoPtr->Self, &ps);
428 return 0;
429}
static LRESULT PROGRESS_Draw(PROGRESS_INFO *infoPtr, HDC hdc)
Definition: progress.c:302
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)

Referenced by ProgressWindowProc().

◆ PROGRESS_Register()

void PROGRESS_Register ( void  )

Definition at line 748 of file progress.c.

749{
750 WNDCLASSW wndClass;
751
752 ZeroMemory (&wndClass, sizeof(wndClass));
755 wndClass.cbClsExtra = 0;
756 wndClass.cbWndExtra = sizeof (PROGRESS_INFO *);
757 wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW);
759
760 RegisterClassW (&wndClass);
761}
static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: progress.c:528
#define PROGRESS_CLASSW
Definition: commctrl.h:2176
LPCWSTR lpszClassName
Definition: winuser.h:3185
int cbClsExtra
Definition: winuser.h:3178
UINT style
Definition: winuser.h:3176
WNDPROC lpfnWndProc
Definition: winuser.h:3177
int cbWndExtra
Definition: winuser.h:3179
HCURSOR hCursor
Definition: winuser.h:3182
#define ZeroMemory
Definition: winbase.h:1712
#define CS_VREDRAW
Definition: winuser.h:658
#define CS_HREDRAW
Definition: winuser.h:653
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:687
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2149
#define CS_GLOBALCLASS
Definition: winuser.h:652
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DllMain().

◆ PROGRESS_SetFont()

static HFONT PROGRESS_SetFont ( PROGRESS_INFO infoPtr,
HFONT  hFont,
BOOL  bRedraw 
)
static

Definition at line 479 of file progress.c.

480{
481 HFONT hOldFont = infoPtr->Font;
482 infoPtr->Font = hFont;
483 /* Since infoPtr->Font is not used, there is no need for repaint */
484 return hOldFont;
485}
HFONT hFont
Definition: main.c:53
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
HFONT Font
Definition: progress.c:55

Referenced by ProgressWindowProc().

◆ PROGRESS_SetPos()

static UINT PROGRESS_SetPos ( PROGRESS_INFO infoPtr,
INT  pos 
)
static

Definition at line 501 of file progress.c.

502{
504
505 if (style & PBS_MARQUEE)
506 {
507 PROGRESS_UpdateMarquee(infoPtr);
508 return 1;
509 }
510 else
511 {
512 UINT oldVal;
513 oldVal = infoPtr->CurVal;
514 if (oldVal != pos) {
515 infoPtr->CurVal = pos;
516 PROGRESS_CoercePos(infoPtr);
517 TRACE("PBM_SETPOS: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal);
518 PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal );
519 UpdateWindow( infoPtr->Self );
520 }
521 return oldVal;
522 }
523}
static void PROGRESS_Invalidate(const PROGRESS_INFO *infoPtr, INT old, INT new)
Definition: progress.c:135
static void PROGRESS_CoercePos(PROGRESS_INFO *infoPtr)
Definition: progress.c:466
static void PROGRESS_UpdateMarquee(PROGRESS_INFO *infoPtr)
Definition: progress.c:435
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI UpdateWindow(_In_ HWND)

Referenced by ProgressWindowProc().

◆ PROGRESS_SetRange()

static DWORD PROGRESS_SetRange ( PROGRESS_INFO infoPtr,
int  low,
int  high 
)
static

Definition at line 487 of file progress.c.

488{
489 DWORD res = MAKELONG(LOWORD(infoPtr->MinVal), LOWORD(infoPtr->MaxVal));
490
491 /* if nothing changes, simply return */
492 if(infoPtr->MinVal == low && infoPtr->MaxVal == high) return res;
493
494 infoPtr->MinVal = low;
495 infoPtr->MaxVal = high;
496 PROGRESS_CoercePos(infoPtr);
497 InvalidateRect(infoPtr->Self, NULL, TRUE);
498 return res;
499}
#define TRUE
Definition: types.h:120
GLuint res
Definition: glext.h:9613
#define LOWORD(l)
Definition: pedump.c:82
#define MAKELONG(a, b)
Definition: typedefs.h:249

Referenced by ProgressWindowProc().

◆ PROGRESS_Unregister()

void PROGRESS_Unregister ( void  )

Definition at line 769 of file progress.c.

770{
772}
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)

Referenced by DllMain().

◆ PROGRESS_UpdateMarquee()

static void PROGRESS_UpdateMarquee ( PROGRESS_INFO infoPtr)
static

Definition at line 435 of file progress.c.

436{
437 LONG style = GetWindowLongW (infoPtr->Self, GWL_STYLE);
438 RECT rect;
439 int ledWidth, leds;
440 HTHEME theme = GetWindowTheme (infoPtr->Self);
441 BOOL smooth = (style & PBS_SMOOTH) && !theme;
442
443 get_client_rect (infoPtr->Self, &rect);
444
445 if (smooth)
446 ledWidth = 1;
447 else
448 ledWidth = get_led_size( infoPtr, style, &rect ) + get_led_gap( infoPtr );
449
450 leds = (get_bar_size( style, &rect ) + ledWidth - 1) /
451 ledWidth;
452
453 /* increment the marquee progress */
454 if (++infoPtr->MarqueePos >= leds)
455 infoPtr->MarqueePos = 0;
456
457 InvalidateRect(infoPtr->Self, &rect, TRUE);
458 UpdateWindow(infoPtr->Self);
459}
static void get_client_rect(HWND hwnd, RECT *rect)
Definition: progress.c:98
long LONG
Definition: pedump.c:60

Referenced by PROGRESS_SetPos(), and ProgressWindowProc().

◆ ProgressWindowProc()

static LRESULT WINAPI ProgressWindowProc ( HWND  hwnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 528 of file progress.c.

530{
531 PROGRESS_INFO *infoPtr;
532 static const WCHAR themeClass[] = {'P','r','o','g','r','e','s','s',0};
533 HTHEME theme;
534
535 TRACE("hwnd=%p msg=%04x wparam=%lx lParam=%lx\n", hwnd, message, wParam, lParam);
536
537 infoPtr = (PROGRESS_INFO *)GetWindowLongPtrW(hwnd, 0);
538
539 if (!infoPtr && message != WM_CREATE)
541
542 switch(message) {
543 case WM_CREATE:
544 {
545 DWORD dwExStyle = GetWindowLongW (hwnd, GWL_EXSTYLE);
546
547 theme = OpenThemeData (hwnd, themeClass);
548
549 dwExStyle &= ~(WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE);
550 if (!theme) dwExStyle |= WS_EX_STATICEDGE;
551 SetWindowLongW (hwnd, GWL_EXSTYLE, dwExStyle);
552 /* Force recalculation of a non-client area */
553 SetWindowPos(hwnd, 0, 0, 0, 0, 0,
555
556 /* allocate memory for info struct */
557 infoPtr = heap_alloc_zero (sizeof(*infoPtr));
558 if (!infoPtr) return -1;
559 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
560
561 /* initialize the info struct */
562 infoPtr->Self = hwnd;
563 infoPtr->MinVal = 0;
564 infoPtr->MaxVal = 100;
565 infoPtr->CurVal = 0;
566 infoPtr->Step = 10;
567 infoPtr->MarqueePos = 0;
568 infoPtr->Marquee = FALSE;
569 infoPtr->ColorBar = CLR_DEFAULT;
570 infoPtr->ColorBk = CLR_DEFAULT;
571 infoPtr->Font = 0;
572
573 TRACE("Progress Ctrl creation, hwnd=%p\n", hwnd);
574 return 0;
575 }
576
577 case WM_DESTROY:
578 TRACE("Progress Ctrl destruction, hwnd=%p\n", hwnd);
579 heap_free (infoPtr);
580 SetWindowLongPtrW(hwnd, 0, 0);
581 theme = GetWindowTheme (hwnd);
582 CloseThemeData (theme);
583 return 0;
584
585 case WM_ERASEBKGND:
586 return 1;
587
588 case WM_GETFONT:
589 return (LRESULT)infoPtr->Font;
590
591 case WM_SETFONT:
592 return (LRESULT)PROGRESS_SetFont(infoPtr, (HFONT)wParam, (BOOL)lParam);
593
594 case WM_PRINTCLIENT:
595 case WM_PAINT:
596 return PROGRESS_Paint (infoPtr, (HDC)wParam);
597
598 case WM_TIMER:
600 PROGRESS_UpdateMarquee (infoPtr);
601 return 0;
602
603 case WM_THEMECHANGED:
604 {
605 DWORD dwExStyle = GetWindowLongW (hwnd, GWL_EXSTYLE);
606
607 theme = GetWindowTheme (hwnd);
608 CloseThemeData (theme);
609 theme = OpenThemeData (hwnd, themeClass);
610
611 /* WS_EX_STATICEDGE disappears when the control is themed */
612 if (theme)
613 dwExStyle &= ~WS_EX_STATICEDGE;
614 else
615 dwExStyle |= WS_EX_STATICEDGE;
616 SetWindowLongW (hwnd, GWL_EXSTYLE, dwExStyle);
617
619 return 0;
620 }
621
622 case PBM_DELTAPOS:
623 {
624 INT oldVal;
625 oldVal = infoPtr->CurVal;
626 if(wParam != 0) {
627 infoPtr->CurVal += (INT)wParam;
628 PROGRESS_CoercePos (infoPtr);
629 TRACE("PBM_DELTAPOS: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal);
630 PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal );
631 UpdateWindow( infoPtr->Self );
632 }
633 return oldVal;
634 }
635
636 case PBM_SETPOS:
637 return PROGRESS_SetPos(infoPtr, wParam);
638
639 case PBM_SETRANGE:
640 return PROGRESS_SetRange (infoPtr, (int)LOWORD(lParam), (int)HIWORD(lParam));
641
642 case PBM_SETSTEP:
643 {
644 INT oldStep;
645 oldStep = infoPtr->Step;
646 infoPtr->Step = (INT)wParam;
647 return oldStep;
648 }
649
650 case PBM_GETSTEP:
651 return infoPtr->Step;
652
653 case PBM_STEPIT:
654 {
655 int oldVal = infoPtr->CurVal;
656
657 if (infoPtr->MinVal != infoPtr->MaxVal)
658 {
659 infoPtr->CurVal += infoPtr->Step;
660 if (infoPtr->CurVal > infoPtr->MaxVal)
661 infoPtr->CurVal = (infoPtr->CurVal - infoPtr->MinVal) % (infoPtr->MaxVal - infoPtr->MinVal) + infoPtr->MinVal;
662 if (infoPtr->CurVal < infoPtr->MinVal)
663 infoPtr->CurVal = (infoPtr->CurVal - infoPtr->MinVal) % (infoPtr->MaxVal - infoPtr->MinVal) + infoPtr->MaxVal;
664
665 if (oldVal != infoPtr->CurVal)
666 {
667 TRACE("PBM_STEPIT: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal);
668 PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal );
669 UpdateWindow( infoPtr->Self );
670 }
671 }
672
673 return oldVal;
674 }
675
676 case PBM_SETRANGE32:
677 return PROGRESS_SetRange (infoPtr, (int)wParam, (int)lParam);
678
679 case PBM_GETRANGE:
680 if (lParam) {
681 ((PPBRANGE)lParam)->iLow = infoPtr->MinVal;
682 ((PPBRANGE)lParam)->iHigh = infoPtr->MaxVal;
683 }
684 return wParam ? infoPtr->MinVal : infoPtr->MaxVal;
685
686 case PBM_GETPOS:
687 return infoPtr->CurVal;
688
689 case PBM_SETBARCOLOR:
690 {
691 COLORREF clr = infoPtr->ColorBar;
692
693 infoPtr->ColorBar = (COLORREF)lParam;
695 return clr;
696 }
697
698 case PBM_GETBARCOLOR:
699 return infoPtr->ColorBar;
700
701 case PBM_SETBKCOLOR:
702 {
703 COLORREF clr = infoPtr->ColorBk;
704
705 infoPtr->ColorBk = (COLORREF)lParam;
707 return clr;
708 }
709
710 case PBM_GETBKCOLOR:
711 return infoPtr->ColorBk;
712
713 case PBM_SETSTATE:
714 if(wParam != PBST_NORMAL)
715 FIXME("state %04lx not yet handled\n", wParam);
716 return PBST_NORMAL;
717
718 case PBM_GETSTATE:
719 return PBST_NORMAL;
720
721 case PBM_SETMARQUEE:
722 if(wParam != 0)
723 {
725 infoPtr->Marquee = TRUE;
726 SetTimer(infoPtr->Self, ID_MARQUEE_TIMER, period, NULL);
727 }
728 else
729 {
730 infoPtr->Marquee = FALSE;
732 }
733 return infoPtr->Marquee;
734
735 default:
737 ERR("unknown msg %04x wp=%04lx lp=%08lx\n", message, wParam, lParam );
739 }
740}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
BOOL COMCTL32_IsReflectedMessage(UINT uMsg) DECLSPEC_HIDDEN
Definition: commctrl.c:1748
#define FALSE
Definition: types.h:117
static const WCHAR themeClass[]
Definition: header.c:115
#define DEFAULT_MARQUEE_PERIOD
Definition: progress.c:63
#define ID_MARQUEE_TIMER
Definition: progress.c:62
static UINT PROGRESS_SetPos(PROGRESS_INFO *infoPtr, INT pos)
Definition: progress.c:501
static HFONT PROGRESS_SetFont(PROGRESS_INFO *infoPtr, HFONT hFont, BOOL bRedraw)
Definition: progress.c:479
static DWORD PROGRESS_SetRange(PROGRESS_INFO *infoPtr, int low, int high)
Definition: progress.c:487
static LRESULT PROGRESS_Paint(PROGRESS_INFO *infoPtr, HDC hdc)
Definition: progress.c:421
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
Definition: system.c:835
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
Definition: system.c:950
#define WM_APP
Definition: eventvwr.h:73
static HDC
Definition: imagelist.c:92
#define INT
Definition: polytest.cpp:20
#define PBM_SETRANGE32
Definition: commctrl.h:2188
#define PBM_SETSTEP
Definition: commctrl.h:2186
#define PBM_GETPOS
Definition: commctrl.h:2194
#define PBM_DELTAPOS
Definition: commctrl.h:2185
#define PBM_SETPOS
Definition: commctrl.h:2184
#define PBM_GETRANGE
Definition: commctrl.h:2193
#define PBM_SETRANGE
Definition: commctrl.h:2183
#define PBM_STEPIT
Definition: commctrl.h:2187
#define PBM_SETBARCOLOR
Definition: commctrl.h:2195
struct PBRANGE * PPBRANGE
#define PBM_SETBKCOLOR
Definition: commctrl.h:2196
#define PBM_SETMARQUEE
Definition: commctrl.h:2199
#define WM_PRINTCLIENT
Definition: richedit.h:70
BOOL Marquee
Definition: progress.c:52
Definition: tftpd.h:60
uint32_t DWORD_PTR
Definition: typedefs.h:65
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
LONG_PTR LRESULT
Definition: windef.h:209
DWORD COLORREF
Definition: windef.h:300
#define WM_PAINT
Definition: winuser.h:1620
#define WM_ERASEBKGND
Definition: winuser.h:1625
#define WS_EX_STATICEDGE
Definition: winuser.h:403
#define SWP_NOACTIVATE
Definition: winuser.h:1242
#define GetWindowLongPtrW
Definition: winuser.h:4829
#define SWP_FRAMECHANGED
Definition: winuser.h:1240
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1608
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
#define SWP_NOMOVE
Definition: winuser.h:1244
#define SWP_NOSIZE
Definition: winuser.h:1245
#define WM_GETFONT
Definition: winuser.h:1651
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_SETFONT
Definition: winuser.h:1650
#define WM_TIMER
Definition: winuser.h:1742
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
#define WM_USER
Definition: winuser.h:1895
#define WM_DESTROY
Definition: winuser.h:1609
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define SWP_NOZORDER
Definition: winuser.h:1247
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define SetWindowLongPtrW
Definition: winuser.h:5355
#define GWL_EXSTYLE
Definition: winuser.h:851
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by PROGRESS_Register().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( progress  )

Variable Documentation

◆ drawProcClassic

const ProgressDrawProc drawProcClassic[8]
static
Initial value:
= {
}
static void draw_solid_bar_V(const ProgressDrawInfo *di, int start, int end)
Definition: progress.c:171
static void draw_solid_bar_H(const ProgressDrawInfo *di, int start, int end)
Definition: progress.c:155
static void draw_chunk_bar_H(const ProgressDrawInfo *di, int start, int end)
Definition: progress.c:187
static void draw_solid_bkg_H(const ProgressDrawInfo *di, int start, int end)
Definition: progress.c:163
static void draw_chunk_bar_V(const ProgressDrawInfo *di, int start, int end)
Definition: progress.c:206
static void draw_solid_bkg_V(const ProgressDrawInfo *di, int start, int end)
Definition: progress.c:179

Definition at line 225 of file progress.c.

Referenced by PROGRESS_Draw().

◆ drawProcThemed

const ProgressDrawProc drawProcThemed[8]
static
Initial value:
= {
}
static void draw_theme_bkg_V(const ProgressDrawInfo *di, int start, int end)
Definition: progress.c:273
static void draw_theme_bkg_H(const ProgressDrawInfo *di, int start, int end)
Definition: progress.c:261
static void draw_theme_bar_V(const ProgressDrawInfo *di, int start, int end)
Definition: progress.c:250
static void draw_theme_bar_H(const ProgressDrawInfo *di, int start, int end)
Definition: progress.c:239

Definition at line 285 of file progress.c.

Referenced by PROGRESS_Draw().