2015-05-19 20:05:18 -05:00
|
|
|
// 19 may 2015
|
|
|
|
#include "uipriv_windows.h"
|
|
|
|
|
|
|
|
struct progressbar {
|
|
|
|
uiProgressBar p;
|
|
|
|
HWND hwnd;
|
|
|
|
};
|
|
|
|
|
2015-05-29 17:03:24 -05:00
|
|
|
uiDefineControlType(uiProgressBar, uiTypeProgressBar, struct progressbar)
|
2015-05-19 20:05:18 -05:00
|
|
|
|
2015-05-29 18:48:27 -05:00
|
|
|
static uintptr_t progressbarHandle(uiControl *c)
|
|
|
|
{
|
|
|
|
struct progressbar *p = (struct progressbar *) c;
|
|
|
|
|
|
|
|
return (uintptr_t) (p->hwnd);
|
|
|
|
}
|
|
|
|
|
2015-05-19 20:05:18 -05:00
|
|
|
// via http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
|
|
|
#define pbarWidth 237
|
|
|
|
#define pbarHeight 8
|
|
|
|
|
|
|
|
static void progressbarPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
|
|
|
|
{
|
|
|
|
struct label *l = (struct label *) c;
|
|
|
|
|
|
|
|
*width = uiWindowsDlgUnitsToX(pbarWidth, d->Sys->BaseX);
|
|
|
|
*height = uiWindowsDlgUnitsToY(pbarHeight, d->Sys->BaseY);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO bypass Aero animations
|
|
|
|
static void progressbarSetValue(uiProgressBar *pp, int value)
|
|
|
|
{
|
|
|
|
struct progressbar *p = (struct progressbar *) pp;
|
|
|
|
|
|
|
|
SendMessageW(p->hwnd, PBM_SETPOS, (WPARAM) value, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
uiProgressBar *uiNewProgressBar(void)
|
|
|
|
{
|
2015-05-29 17:03:24 -05:00
|
|
|
struct progressbar *p;
|
2015-05-19 20:05:18 -05:00
|
|
|
|
2015-05-29 17:03:24 -05:00
|
|
|
p = (struct progressbar *) uiWindowsNewSingleHWNDControl(uiTypeProgressBar());
|
2015-05-19 20:05:18 -05:00
|
|
|
|
2015-05-29 17:03:24 -05:00
|
|
|
p->hwnd = uiWindowsNewSingleHWNDControl(0,
|
|
|
|
PROGRESS_CLASSW, L"",
|
|
|
|
PBS_SMOOTH,
|
|
|
|
hInstance, NULL,
|
|
|
|
FALSE);
|
2015-05-19 20:05:18 -05:00
|
|
|
|
2015-05-29 18:48:27 -05:00
|
|
|
uiControl(p)->Handle = progressbarHandle;
|
2015-05-29 17:03:24 -05:00
|
|
|
uiControl(p)->PreferredSize = progressbarPreferredSize;
|
2015-05-19 20:05:18 -05:00
|
|
|
|
2015-05-29 17:03:24 -05:00
|
|
|
uiProgressBar(p)->SetValue = progressbarSetValue;
|
2015-05-19 20:05:18 -05:00
|
|
|
|
2015-05-29 17:03:24 -05:00
|
|
|
return uiProgressBar(p);
|
2015-05-19 20:05:18 -05:00
|
|
|
}
|