mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-17 14:16:10 -06:00
178 lines
3.8 KiB
Text
178 lines
3.8 KiB
Text
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);
|
|
}
|
|
}
|
|
}
|