1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
#include "api__gen_ml.h"
#include "main.h"
#include "./skinnedprogressbar.h"
#include "./skinning.h"
#include "../winamp/wa_dlg.h"
#include "./colors.h"
#include <strsafe.h>
SkinnedProgressBar::SkinnedProgressBar(void)
: SkinnedWnd(FALSE), skinCursor(NULL)
{
}
SkinnedProgressBar::~SkinnedProgressBar(void)
{
}
BOOL SkinnedProgressBar::Attach(HWND hProgressBar)
{
if(!__super::Attach(hProgressBar)) return FALSE;
SetType(SKINNEDWND_TYPE_PROGRESSBAR);
return TRUE;
}
void SkinnedProgressBar::OnSkinChanged(BOOL bNotifyChildren, BOOL bRedraw)
{
skinCursor = (0 != (SWS_USESKINCURSORS & style)) ?
(HCURSOR)SENDWAIPC(plugin.hwndParent, IPC_GETSKINCURSORS, WACURSOR_NORMAL) : NULL;
HFONT hfOld = (HFONT)CallPrevWndProc(WM_GETFONT, 0, 0L);
__super::OnSkinChanged(bNotifyChildren, bRedraw);
if (hfOld != (HFONT)CallPrevWndProc(WM_GETFONT, 0, 0L))
CallPrevWndProc(TTM_UPDATE, 0, 0L);
}
void SkinnedProgressBar::OnPaint()
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
if (NULL == hdc) return;
int radius = (ps.rcPaint.bottom - ps.rcPaint.top - WASABI_API_APP->getScaleY(1)) / WASABI_API_APP->getScaleY(2);
int radius2 = WASABI_API_APP->getScaleY(5);
RECT r;
CopyRect(&r, &ps.rcPaint);
// fill the background accordingly
FillRect(hdc, &r, (HBRUSH)MlStockObjects_Get(WNDBCK_BRUSH));
r.right -= WASABI_API_APP->getScaleX(1);
r.bottom -= WASABI_API_APP->getScaleY(1);
OffsetRect(&r, 1, 1);
HPEN oldPen = SelectPen(hdc, MlStockObjects_Get(HILITE_PEN));
HBRUSH oldBrush = SelectBrush(hdc, MlStockObjects_Get(WNDBCK_BRUSH));
// draw the border edge offset to add a 'shadow'
RoundRect(hdc, r.left, r.top, r.right, r.bottom, radius2, radius);
ps.rcPaint.bottom -= WASABI_API_APP->getScaleY(1);
SelectObject(hdc, MlStockObjects_Get(ITEMBCK_PEN));
SelectObject(hdc, MlStockObjects_Get(ITEMBCK_BRUSH));
// draw the 'empty' part of the bar with a slight overlap of the 'shadow'
RoundRect(hdc, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom, radius2, radius);
int pos = (DWORD)CallPrevWndProc(PBM_GETPOS, 0, 0L);
if (pos > 0)
{
int range = (DWORD)CallPrevWndProc(PBM_GETRANGE, 0, 0L);
int val = (((ps.rcPaint.right) * pos) / range);
if (val > 0)
{
if ((ps.rcPaint.left + val + radius) > ps.rcPaint.right)
{
SelectObject(hdc, MlStockObjects_Get(ITEMTEXT_PEN));
SelectObject(hdc, MlStockObjects_Get(ITEMTEXT_BRUSH));
// draws the 'filled' part of the bar with a slight overlap of the 'shadow'
RoundRect(hdc, ps.rcPaint.left - WASABI_API_APP->getScaleX(10), ps.rcPaint.top,
val + (radius * WASABI_API_APP->getScaleY(2)) - WASABI_API_APP->getScaleY(10), ps.rcPaint.bottom, radius2, radius);
}
else
{
ps.rcPaint.right = ps.rcPaint.left + val;
FillRect(hdc, &ps.rcPaint, (HBRUSH)MlStockObjects_Get(ITEMTEXT_BRUSH));
}
}
// not keen on this at all but it sorts out the progress overlap
SelectObject(hdc, MlStockObjects_Get(WNDBCK_PEN));
MoveToEx(hdc, ps.rcPaint.left, ps.rcPaint.bottom, NULL);
LineTo(hdc, ps.rcPaint.left + ((radius)/ 2), ps.rcPaint.bottom);
LineTo(hdc, ps.rcPaint.left, ps.rcPaint.bottom - ((radius)/ WASABI_API_APP->getScaleY(2)));
LineTo(hdc, ps.rcPaint.left, ps.rcPaint.bottom);
MoveToEx(hdc, ps.rcPaint.left, ps.rcPaint.top, NULL);
LineTo(hdc, ps.rcPaint.left, ps.rcPaint.top + ((radius)/ WASABI_API_APP->getScaleY(2)));
MoveToEx(hdc, ps.rcPaint.left, ps.rcPaint.top, NULL);
LineTo(hdc, ps.rcPaint.left + ((radius)/ WASABI_API_APP->getScaleY(2)), ps.rcPaint.top);
}
SelectPen(hdc, oldPen);
SelectBrush(hdc, oldBrush);
}
UINT SkinnedProgressBar::GetBorderType(void)
{
return BORDER_NONE;
}
LRESULT SkinnedProgressBar::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_PAINT:
OnPaint();
return 0;
case WM_SETCURSOR:
if (NULL != skinCursor)
{
if (skinCursor != GetCursor())
SetCursor(skinCursor);
return TRUE;
}
break;
}
return __super::WindowProc(uMsg, wParam, lParam);
}
|