My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
enum_property Frame {
"NullFrame()",
"FieldFrame()",
"InsetFrame()",
"OutsetFrame()",
"ButtonFrame()",
"ThinInsetFrame()",
"ThinOutsetFrame()",
"BlackFrame()",
"TopSeparatorFrame()",
"BottomSeparatorFrame()",
"LeftSeparatorFrame()",
"RightSeparatorFrame()"
};

enum_property Align {
"ALIGN_LEFT",
"ALIGN_CENTER",
"ALIGN_RIGHT"
};

fn DeflateRect(&r)
{
r.top++;
r.left++;
r.right--;
r.bottom--;
}

fn DrawFrame(w, &r, c1, c2) {
w.DrawRect(r.left, r.top, r.right - r.left, 1, c1);
w.DrawRect(r.left, r.top, 1, r.bottom - r.top, c1);
w.DrawRect(r.right - 1, r.top, 1, r.bottom - r.top, c2);
w.DrawRect(r.left, r.bottom - 1, r.right - r.left, 1, c2);
DeflateRect(r);
}

fn DrawBorder(w, &r, ...)
{
for(i = 0; i < count(argv); i += 2)
DrawFrame(w, r, argv[i], argv[i + 1]);
}

fn DrawButtonFrame(w, &r)
{
DrawBorder(w, r, :SWhite, :SBlack, :SWhiteGray, :SGray);
}

fn DrawEdgeButtonFrame(w, &r)
{
DrawBorder(w, r, :SWhiteGray, :SBlack, :SWhite, :SGray);
}

fn DrawEdgeButton(w, &r)
{
DrawEdgeButtonFrame(w, r);
w.DrawRect(r, :SLtGray);
}

fn DrawInsetFrame(w, &r)
{
DrawBorder(w, r, :SGray, :SWhite, :SBlack, :SLtGray);
}

fn DrawCtrlFrame(w, &r, frame)
{
width = r.right - r.left;
height = r.bottom - r.top;
switch(frame) {
case "FieldFrame()":
case "InsetFrame()": DrawInsetFrame(w, r); break;
case "OutsetFrame()": DrawBorder(w, r, :SLtGray, :SBlack, :SWhite, :SGray); break;
case "ButtonFrame()": DrawButtonFrame(w, r); break;
case "ThinInsetFrame()": DrawBorder(w, r, :SGray, :SWhite); break;
case "ThinOutsetFrame()": DrawBorder(w, r, :SWhite, :SGray); break;
case "BlackFrame()": DrawBorder(w, r, :SBlack, :SBlack); break;
case "TopSeparatorFrame()":
w.DrawRect(r.left, r.top, width, 1, :SGray);
w.DrawRect(r.left, r.top + 1, width, 1, :SWhite);
r.top += 2;
break;
case "BottomSeparatorFrame()":
w.DrawRect(r.left, r.bottom - 2, width, 1, :SGray);
w.DrawRect(r.left, r.bottom - 1, width, 1, :SWhite);
r.bottom -= 2;
break;
case "LeftSeparatorFrame()":
w.DrawRect(r.left, r.top, 1, height, :SGray);
w.DrawRect(r.left + 1, r.top, 1, height, :SWhite);
r.left += 2;
break;
case "RightSeparatorFrame()":
w.DrawRect(r.right - 2, r.top, 1, height, :SGray);
w.DrawRect(r.right - 1, r.top, 1, height, :SWhite);
r.right -= 2;
break;
}
}

fn GradientColor(fc, tc, i, n)
{
return Color(
fc.r + i * (tc.r - fc.r) / n,
fc.g + i * (tc.g - fc.g) / n,
fc.b + i * (tc.b - fc.b) / n
);
}

fn max(a, b)
{
return a > b ? a : b;
}

fn min(a, b)
{
return a < b ? a : b;
}

fn DrawSpinButtons(w, r)
{
h = r.bottom - r.top;
h2 = int(h / 2);
h7 = int(7 * h / 10);
x = r.right - h7;
DrawEdgeButton(w, RectC(x, r.top, h7, h2));
w.DrawImage((h7 - 5) / 2 + x, (h2 - 3) / 2 + r.top, "CtrlsImg::SpU");
DrawEdgeButton(w, RectC(x, r.top + h2, h7, h - h2));
w.DrawImage((h7 - 5) / 2 + x, (h - h2 - 3) / 2 + r.top + h2, "CtrlsImg::SpD");
}

fn XMinSize()
{
return Size(8, 13);
}

ctrl StarIndicator {
group "Progress";

GetMinSize() { return Size(0, 0); }
GetStdSize() { return Size(64, 8); }

bool AlwaysShowValue=false;
Color SetFontColor=Black;
int SetVotesHigh=50;
int SetVotesLow=5;
bool ShowPercent=false;
bool ShowTotal=true;
bool ShowVotes=true;

Frame SetFrame @1;

Paint(w) {
r = GetRect();
sz = Size(r.right - r.left, r.bottom - r.top);
x=sz.cx;
y=(x/5+0.5);
x=5*y;
r.right = r.left+x;
r.bottom = r.top + y;

DrawCtrlFrame(w, r, .SetFrame);
DrawInsetFrame(w, r);

sz = Size(r.right - r.left, r.bottom - r.top);

w.DrawRect(r.left, r.top, sz.cx, sz.cy, :SBlack);
DeflateRect(r);
sz = Size(r.right - r.left, r.bottom - r.top);
w.DrawRect(r.left, r.top, sz.cx, sz.cy, :SWhite);

if(sz.cx > sz.cy) {
w.DrawRect(r.left, r.top, sz.cx >> 2, sz.cy, :SYellow);
}
else {
w.DrawRect(r.left, r.bottom - (sz.cy >> 2), sz.cx, sz.cy >> 2, :SYellow);
}
}
}

Change log

r4233 by koldo on Dec 2, 2011   Diff
Controls4U: Added StarIndicator and doc by
Jibe
Go to: 
Project members, sign in to write a code review

Older revisions

r3774 by koldo on Aug 20, 2011   Diff
Controls4U: Added SliderCtrlX and
StarIndicator. Removed internal
MyBufferPainter
All revisions of this file

File info

Size: 3878 bytes, 178 lines
Powered by Google Project Hosting