CtrlLib: Switch now allows setting gap and separators between cases

git-svn-id: svn://ultimatepp.org/upp/trunk@15185 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2020-10-01 15:35:46 +00:00
parent 99d568249e
commit 65f8631937
5 changed files with 382 additions and 289 deletions

View file

@ -118,7 +118,7 @@ file
CallbackN.i highlight cpp,
CallbackR.i highlight cpp,
Callback.h,
Concretes readonly separator,
Values readonly separator,
TimeDate.h,
TimeDate.cpp,
Value.h,

View file

@ -137,6 +137,14 @@ fn abs(a)
return a < 0 ? -a : a;
}
fn atoi(a)
{
n = 0;
for(i = 0; i < count(a); i++)
n = 10 * n + a[i] - '0';
return n;
}
fn DrawVertArrowFromTip(w, tipx, tipy, dir, l, color)
{
for(i = 0; i < l; i++) {
@ -608,33 +616,93 @@ ctrl Switch {
sz = GetSize();
ln = [];
cs = [];
for(i = 0; i < count(.SetLabel); i++) {
if(.SetLabel[i] >= 32 && .SetLabel[i] < 65536)
ln[] = .SetLabel[i];
if(.SetLabel[i] == '\n') {
gap = [];
sep = [];
g = 0;
sp = 0;
n = count(.SetLabel);
for(i = 0; i < n; i++) {
ch = .SetLabel[i];
if(ch == '^') {
if(i + 1 < n && .SetLabel[i + 1] == '^') {
ln[] = '^';
ln[] = '^';
i++;
}
else {
g = atoi(ln);
ln = "";
}
}
else
if(ch == '|') {
if(i + 1 < n && .SetLabel[i + 1] == '|') {
ln[] = '|';
ln[] = '|';
i++;
}
else {
g = atoi(ln);
ln = "";
sp = 1;
}
}
else
if(ch >= 32 && ch < 65536) {
ln[] = ch;
}
else
if(ch == '\n') {
cs[] = ln;
gap[] = g;
sep[] = sp;
ln = "";
g = 0;
}
}
cs[] = ln;
gap[] = g;
sep[] = sp;
tcy = GetTextSize("W", .SetFont).cy;
linecy = max(16, tcy + 2);
osz = OptionSize();
y = 0;
x = 0;
setlabel = .SetLabel;
for(i = 0; i < count(cs); i++) {
textsize = GetSmartTextSize(cs[i], .SetFont);
if(linecy * count(cs) > sz.cy) {
DrawOption(w, x, (sz.cy - osz) / 2, 2);
w.DrawSmartText(x + osz + 4, (sz.cy - tcy) / 2, cs[i], .SetFont);
x += osz + 4 + textsize.cx + max(osz, tcy) / 2;
}
else {
DrawOption(w, x, y, 2);
w.DrawSmartText(x + osz + 4, y + (osz - tcy) / 2, cs[i], .SetFont);
y += linecy;
horz = 0;
for(pass = 0; pass < 2; pass++) {
y = 0;
x = 0;
for(i = 0; i < count(cs); i++) {
textsize = GetSmartTextSize(cs[i], .SetFont);
if(gap[i]) {
gsz = gap[i] * tcy / 4;
if(sep[i] && pass) {
if(horz)
w.DrawRect(x + y + gsz / 2, y, 1 + IsUHD(), linecy, :SGray);
else
w.DrawRect(x, y + gsz / 2, sz.cx, 1 + IsUHD(), :SGray);
}
if(horz)
x += gsz;
else
y += gsz;
}
if(horz) {
if(pass) {
DrawOption(w, x, (sz.cy - osz) / 2, 2);
w.DrawSmartText(x + osz + 4, (sz.cy - tcy) / 2, cs[i], .SetFont);
}
x += osz + 4 + textsize.cx + max(osz, tcy) / 2;
}
else {
if(pass) {
DrawOption(w, x, y, 2);
w.DrawSmartText(x + osz + 4, y + (osz - tcy) / 2, cs[i], .SetFont);
}
y += linecy;
}
}
if(y > sz.cy)
horz = 1;
}
}
};

View file

@ -299,13 +299,13 @@ public:
virtual void LostFocus();
public:
struct Case : Moveable<Case> {
struct Case {
String label;
Value value;
int accesskey;
bool enabled;
Case() { accesskey = 0; enabled = true; }
int accesskey = 0;
bool enabled = true;
int gap = 0;
Rect16 rect = Rect16(0, 0, 0, 0);
};
private:
@ -313,7 +313,6 @@ private:
Value value;
int pushindex;
Array<Case> cs;
Vector<int> posx;
int linecy;
int light;
int mincy;
@ -329,14 +328,16 @@ private:
Rect GetCheckRect(int i) const;
public:
Switch& SetLabel(int i, const char *text);
enum { GAP_SEPARATOR = 1 << 20 };
Switch& SetLabel(int i, const char *text, int gap = 0);
Switch& SetLabel(const char *text);
String GetLabel() const { return GetLabel(GetIndex()); }
String GetLabel(int i) const { return cs[i].label; }
Switch& Set(int i, const Value& val, const char *text);
Switch& Set(int i, const Value& val, const char *text, int gap = 0);
Switch& Set(int i, const Value& val);
Switch& Add(const Value& val, const char *text);
Switch& Add(const char *text);
Switch& Add(const Value& val, const char *text, int gap = 0);
Switch& Add(const char *text, int gap = 0);
void EnableCase(int i, bool enable = true);
void DisableCase(int i) { EnableCase(i, false); }

View file

@ -10,23 +10,23 @@ Switch& Switch::Set(int i, const Value& val) {
return *this;
}
Switch& Switch::Set(int i, const Value& val, const char *text) {
Switch& Switch::Set(int i, const Value& val, const char *text, int gap) {
Case& v = cs.At(i);
if(value.IsVoid())
value = val;
SetLabel(i, text);
SetLabel(i, text, gap);
v.value = val;
Refresh();
return *this;
}
Switch& Switch::Add(const Value& val, const char *text) {
Switch& Switch::Add(const Value& val, const char *text, int gap) {
Set(cs.GetCount(), val, text);
return *this;
}
Switch& Switch::Add(const char *text) {
Set(cs.GetCount(), cs.GetCount(), text);
Switch& Switch::Add(const char *text, int gap) {
Set(cs.GetCount(), cs.GetCount(), text, gap);
return *this;
}
@ -37,11 +37,12 @@ int Switch::GetIndex() const {
return -1;
}
Switch& Switch::SetLabel(int i, const char *text) {
Switch& Switch::SetLabel(int i, const char *text, int gap) {
if(i >= cs.GetCount())
cs.At(i).value = i;
Case& v = cs[i];
v.accesskey = ExtractAccessKey(text, v.label);
v.gap = gap;
Refresh();
return *this;
}
@ -71,24 +72,43 @@ Switch& Switch::SetLabel(const char *text) {
const char *q = text;
int i = 0;
const char *s = text;
int gap = 0;
while(*s) {
if(*s == '\r') {
SetLabel(i++, String(q, s));
q = ++s;
if(*q == '\n') {
q++;
s++;
if(*s == '^') {
if(s[1] == '^')
s += 2;
else {
gap = atoi(String(q, s));
q = ++s;
}
}
else
if(*s == '|') {
if(s[1] == '|')
s += 2;
else {
gap = atoi(String(q, s)) | GAP_SEPARATOR;
q = ++s;
}
}
else
if(*s == '\r') {
SetLabel(i++, String(q, s), gap);
gap = 0;
q = ++s;
if(*q == '\n')
q = ++s;
}
else
if(*s == '\n') {
SetLabel(i++, String(q, s));
SetLabel(i++, String(q, s), gap);
gap = 0;
q = ++s;
}
else
s++;
}
SetLabel(i++, String(q, s));
SetLabel(i++, String(q, s), gap);
cs.SetCount(i);
return *this;
}
@ -108,19 +128,13 @@ Value Switch::GetData() const {
Rect Switch::GetCaseRect(int i) const {
Size sz = GetSize();
if(posx.GetCount())
return RectC(i ? posx[i - 1] : 0, 0, posx[i], sz.cy);
else
return RectC(0, linecy * i, sz.cx, linecy);
return i >= 0 && i < cs.GetCount() ? (Rect)cs[i].rect : Rect(Null);
}
Rect Switch::GetCheckRect(int i) const {
Size sz = GetSize();
int cx = CtrlsImg::S0().GetSize().cx;
if(posx.GetCount())
return RectC(i ? posx[i - 1] : 0, 0, cx, sz.cy);
else
return RectC(0, linecy * i, cx, linecy);
Rect r = GetCaseRect(i);
r.right = r.left + CtrlsImg::S0().GetSize().cx;
return r;
}
void Switch::EnableCase(int i, bool enable) {
@ -157,68 +171,74 @@ void Switch::Paint(Draw& w) {
int tcy = GetTextSize("W", font).cy;
Size isz = CtrlsImg::S0().GetSize();
linecy = max(mincy, max(isz.cy + DPI(2), tcy));
int y = 0;
int x = 0;
bool horz = linecy * cs.GetCount() > sz.cy;
bool horz = false;
if(direction == 1) horz = true;
for(int pass = !!direction; pass < 2; pass++) { // first pass to decide horz, second to actually draw
int y = 0;
int x = 0;
if(horz)
linecy = sz.cy;
if (direction == 1) horz = true;
else if (direction == -1) horz = false;
int ty = (linecy - tcy) / 2;
bool ds = !IsShowEnabled();
int i;
light = -1;
for(i = 0; i < cs.GetCount(); i++) {
Case& v = cs[i];
if(v.gap) {
int gsz = (v.gap & 255) * tcy / 4;
if(pass && (v.gap & GAP_SEPARATOR))
if(horz)
w.DrawRect(x + y + gsz / 2, y, DPI(1), linecy, SColorDisabled());
else
w.DrawRect(x, y + gsz / 2, sz.cx, DPI(1), SColorDisabled());
(horz ? x : y) += gsz;
}
bool dv = ds || !v.enabled;
if(horz) {
posx.SetCount(cs.GetCount());
linecy = sz.cy;
}
else
posx.Clear();
int ty = (linecy - tcy) / 2;
bool ds = !IsShowEnabled();
int i;
light = -1;
for(i = 0; i < cs.GetCount(); i++) {
Case& v = cs[i];
bool dv = ds || !v.enabled;
Size tsz = GetSmartTextSize(v.label, font);
int iy = (linecy - isz.cy) / 2;
Rect hr = RectC(x, y, horz ? tsz.cx + isz.cx + 4 : sz.cx, linecy);
bool mousein = HasMouseIn(hr);
if(mousein)
light = i;
Image img;
int q = dv ? CTRL_DISABLED :
pushindex == i ? CTRL_PRESSED :
mousein ? CTRL_HOT :
CTRL_NORMAL;
img = CtrlsImg::Get((v.value == value ? CtrlsImg::I_S1 : CtrlsImg::I_S0) + q);
w.DrawImage(x, y + iy, img);
DrawSmartText(w, x + isz.cx + 4, y + ty, sz.cx, v.label, font,
dv || IsReadOnly() ? SColorDisabled : GetLabelTextColor(this), ///////
VisibleAccessKeys() ? v.accesskey : 0);
if(HasFocus() && (pushindex == i || v.value == value && pushindex < 0))
DrawFocus(w, RectC(x + isz.cx + 2, y + ty - 1, tsz.cx + 3, tsz.cy + 2) & sz);
if(horz) {
x += hr.Width() + sz.cy / 2;
posx[i] = x;
Size tsz = GetSmartTextSize(v.label, font);
int iy = (linecy - isz.cy) / 2;
int width = horz ? tsz.cx + isz.cx + DPI(4) : sz.cx;
Rect hr = RectC(x, y, width, linecy);
bool mousein = HasMouseIn(hr);
if(mousein)
light = i;
if(pass) {
Image img;
int q = dv ? CTRL_DISABLED :
pushindex == i ? CTRL_PRESSED :
mousein ? CTRL_HOT :
CTRL_NORMAL;
img = CtrlsImg::Get((v.value == value ? CtrlsImg::I_S1 : CtrlsImg::I_S0) + q);
w.DrawImage(x, y + iy, img);
DrawSmartText(w, x + isz.cx + DPI(4), y + ty, sz.cx, v.label, font,
dv || IsReadOnly() ? SColorDisabled : GetLabelTextColor(this), ///////
VisibleAccessKeys() ? v.accesskey : 0);
if(HasFocus() && (pushindex == i || v.value == value && pushindex < 0))
DrawFocus(w, RectC(x + isz.cx + DPI(2), y + ty - DPI(1), tsz.cx + DPI(3), tsz.cy + DPI(2)) & sz);
}
v.rect = hr;
if(horz)
x += hr.Width() + tcy;
else
y += linecy;
}
else
y += linecy;
if(y > sz.cy)
horz = true;
}
if(horz)
posx[i - 1] = sz.cx;
}
int Switch::GetIndex(Point p) {
if(posx.GetCount()) {
for(int i = 0; i < posx.GetCount(); i++)
if(p.x < posx[i]) return cs[i].enabled ? i : -1;
return -1;
}
else {
int i = p.y / linecy;
i = i >= 0 && i < cs.GetCount() ? i : -1;
return i < 0 ? -1 : cs[i].enabled ? i : -1;
for(int i = 0; i < cs.GetCount(); i++) {
if(cs[i].rect.Contains(p))
return i;
}
return -1;
}
void Switch::MouseMove(Point p, dword keyflags) {
@ -239,6 +259,7 @@ void Switch::MouseMove(Point p, dword keyflags) {
}
void Switch::LeftDown(Point p, dword keyflags) {
DLOG("============= LeftDown");
if(IsReadOnly()) return;
if(Ctrl::ClickFocus()) SetWantFocus();
pushindex = GetIndex();

View file

@ -1,5 +1,4 @@
topic "Switch";
[2 $$0,0#00000000000000000000000000000000:Default]
[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class]
[l288;2 $$2,0#27521748481378242620020725143825:desc]
[0 $$3,0#96390100711032703541132217272105:end]
@ -9,217 +8,221 @@ topic "Switch";
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
[b42;2 $$9,9#13035079074754324216151401829390:normal]
[{_}%EN-US
[ {{10000@3 [s0; [*@(229)4 Switch]]}}&]
[s3;%- &]
[s1;:Switch`:`:class:%- [@(0.0.255)3 class][3 _][*3 Switch][3 _:_][@(0.0.255)3 public][3 _][*@3;3 Ct
rl]&]
[s0; Switch provides selection of mutually exclusive options (cases).&]
[s0; &]
[s2;
[2 $$0,0#00000000000000000000000000000000:Default]
[{_}
[ {{10000@3 [s0;%% [*@(229)4 Switch]]}}&]
[s3; &]
[s1;:Switch`:`:class: [@(0.0.255)3 class][3 _][*3 Switch][3 _:_][@(0.0.255)3 public][3 _][*@3;3 Ctrl
]&]
[s0;%% Switch provides selection of mutually exclusive options (cases).&]
[s0;%% &]
[s2;%%
@@image:1287&131
(A84AFQAAAOv/AAAAAHic7ZfNaxpBGMb9f3II5BSiJIdcvATPuaaHYFQ8BjEeJCTQQOhJaLCFtlBCckkRDGKw+cJDmhYlNMGP1FjBiGURQbz3wYVl2dmdHWdHo2SGh2Bmv377vs/Mu6/SLilSUlJSUlJSUlJTpVTq+/r628XFwNzcm6Wl4MbGXjp9+aoApppzMqlIbW4mPJ5gPJ5MpXJXVzfp9MX29ke3O7C1dfBKAKaaczKpTDl9vkg+/6NcLler1VqtVq/XG41GofAb87GYCa3L5WK5M+NpHADqzbUxyYEy5bRi5ngXvujxPUu7hONa7LpYDhrnQ+UhW8w+Pj02m81Wq3V3V8LRTOaaA5KRygBQH4xhAdhfnNuW4+EkTxhF9BwGjS+GKO7YdVXO5GVy9dtq6CLkPfYe3R61221FUXZ2PoVC+xyQjE7TA6iBag5GezCcADgM7yg4hTuNj2rYUAhxGr4hUdzV3Qw2O2meJP4kovfR+a/zrX+tTqeTy90sL4dZIA01QvtNL3B6AEOghgUwZTAAkL9ND42Ik1x9htpKBxZFZQVDgpGpJP9l9B5aFXxDorhnC1nsZqrN1n6tzR7PFuvFbrdbLJYWFvy2iSZpGTE0AC1QaqwQqO5gMAJYMZCuswUWy2nwktUTbYEFUtk6jR400/Vi6zR0xGhVwFl9qqJoqjbz5r0zn2eUjtLr9c7Pf7JsKWRIGTE0AH2UtECxA9AZTKNEOXlEnBQXscyIorJ1Gn2Sz2l+/x46YrQq4Dy8PUTRxG4Gm53en4Kz3+/v7n4Jh9+xOI3lRegAhvU4FIAtla3/x8Ap3GkcVHSf0F3nxGlYEW53AB0xWhVwPrefC/WCupuBs1L5i6NnZ3mxOaUAYOgDxQjAkbhhcyqQU6DTOKgoPrGqR3RsFpupikbf+3wRdMRoVfANqedcWYnE4x/IS8jSo5+0SqVAAAMDOUlhYAEWGCjbLOsx6MBi02c6Q7qO9Bh7ZknFYgceTxAdMVoVfEOiuGPXxXKwyrJwvTjAi3MOm7IJiR4HdiZzHQrt4+sRrQr+oriTtUC7ueme5lBOAEQxjIHTdAd2zs9Nxf3EMYddSkpKSkpKSkpKiP4DpnWuPQ==)
&]
[s2;
[s2;%%
@@image:406&312
(A0EAMgAAAM7/AAAAAHic7VnPSxtBGM3/40HwJCp68JKLePZqDxI15CgSPQRRqFA8BVrSQlsoohdLICKR1F/kYG3ZRVRM1sZtYF0sSygNge6tjyxdlv0xTman2YXO8AibzW7y3jff9+28jPn7lykQYxSLn+bmno+PLwwNPZuYWJyf3yyVTiJnRY+lpfzY2GIuVygWK6en56XS8dram9HRhZWVV5Fzo+Q/Pb1crX6u1WqKojQaDVVVm82mJF3h/Oqqj4pEIkF422cgfxB/m7/aHXf3d5qm6bp+eXmLTw8OzrwSnLSjlYD8R/44+Wvd8dgdhmGsr79Np1/EWQLqF/kP/jf1Gxd//YfearUqlfPJyYxXgpO5S45ToH0l4ZqQQP9B/Vr5r/0dFv+f3SHLtyMjKUoJ3qnxlcN3+tA/0X+c8Qd5m3+73T46+hI0C09OB0EUx4lIpTbRP9F/vPEH/06ns7HxPpPZCpLgG+cnJXDJHxuYAvR/9E/0H6sEnPzr9e/49PCw+o8k8JKTzb5E/0f/RP9B/Tr5T00t53KvvbcQngu+5ew65lvOFvD8Qv9H/0T/Qf0i/5E/iL8v/9gCzy/0f1Qu+g9ekf/e/HHFkHthCgjEAcIvRM6/V79ghuvtfNuXyy9gvVqWyzR+IQwfvhKcfqFwUpj5OJM+Tid3kzsXOwS/EJIPXwlOvwD+e9pe/ls+e50d/jBM8AtkPt4cC1p1eM/7HpNh+4WyVEb8Lf6zX2cHdwdlVQ7yC2T+ruOgM4QrfZdYQbD9gnKvIH8s/slqcuDdgNEygvwC4fvpRfFaxDr9wvbFNvIH8Qf//et9gl8g/AQvCfQqXH7h4fFBUiUr/pR+IfJEMln9AmGNGqacXbdQ5pL5//mFnpDwjMiVCgiQIfxC5PwZ9hfCNBm+fYl5fyHMj/KVwLy/EB8JzPsLhCwKs8DwPSYjzP6Cb0j7v8xj218gZIXvqq9XCZTkLbDtL/RBAr0KLvsL0SaSyeQXTOL/SGHK2XULZS6Zwi9wAvOzXkCAAX8A/IJmnw==)
&]
[s9; Options can be visually aligned horizontally or vertically `-
U`+`+ choses alignment based on size of options and Ctrl rectangle.
[s9;%% Options can be visually aligned horizontally or vertically
`- U`+`+ choses alignment based on size of options and Ctrl rectangle.
Each option represents a case with associated text and value.
Switch can be assigned any Value (not only Values associated
with current cases); if there is no case with Value equal to
the Value of Switch, no case is highlighted.&]
[s0;* &]
[s0;%- [%%/ Derived from][%% ][^topic`:`/`/CtrlCore`/src`/Ctrl`$en`-us^ Ctrl]&]
[s0;*%% &]
[s0; [%%/ Derived from][%% ][^topic`:`/`/CtrlCore`/src`/Ctrl`$en`-us^ Ctrl]&]
[s3;%% &]
[s0;%% &]
[ {{10000F(128)G(128)@1 [s0;%% [* Constructor Detail]]}}&]
[s3; &]
[s5;:Switch`:`:Switch`(`): [* Switch]()&]
[s2;%% Initializes the switch.&]
[s3;%% &]
[s4; &]
[s5;:Switch`:`:`~Switch`(`): [@(0.0.255) `~][* Switch]()&]
[s2;%% Default destructor.&]
[s3;%% &]
[s0; &]
[ {{10000F(128)G(128)@1 [s0; [* Constructor Detail]]}}&]
[s3;%- &]
[s5;:Switch`:`:Switch`(`):%- [* Switch]()&]
[s2; Initializes the switch.&]
[ {{10000F(128)G(128)@1 [s0;%% [* Public Method List]]}}&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:`~Switch`(`):%- [@(0.0.255) `~][* Switch]()&]
[s2; Default destructor.&]
[s3; &]
[s0;%- &]
[ {{10000F(128)G(128)@1 [s0; [* Public Method List]]}}&]
[s3;%- &]
[s5;:Switch`:`:SetLabel`(int`,const char`*`):%- [_^Switch^ Switch][@(0.0.255) `&]_[* SetLab
el]([@(0.0.255) int]_[*@3 i], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 text])&]
[s2; Sets text of case with specified index [*@3 i]. Text can contain
`'`\b`' for access`-key assignment. Value of case is set to [*@3 i].
If [*@3 i] is greater than current number of cases, empty cases
are added to Switch with values equivalent to their indexes.&]
[s7; [%-*C@3 i]-|Index of the case.&]
[s7; [%-*C@3 text]-|Text of the case.&]
[s7; [*/ Return value]-|`*this for chaining.&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:SetLabel`(const char`*`):%- [_^Switch^ Switch][@(0.0.255) `&]_[* SetLabel]([@(0.0.255) c
[s5;:Upp`:`:Switch`:`:SetLabel`(int`,const char`*`,int`): [_^Upp`:`:Switch^ Switch][@(0.0.255) `&
]_[* SetLabel]([@(0.0.255) int]_[*@3 i], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 text],
[@(0.0.255) int]_[*@3 gap]_`=_[@3 0])&]
[s2; [%% Sets text of case with specified index ][%%*@3 i][%% . Text can
contain `'`\b`' for access`-key assignment. Value of case is
set to ][%%*@3 i][%% . If ][%%*@3 i][%% is greater than current number
of cases, empty cases are added to Switch with values equivalent
to their indexes. ][*@3 gap]_is optional additional space added
before this case, its unit is the height of text / 4. [*@3 gap]
can be combined with GAP`_SEPARATOR, which adds a gray line in
the middle of the space.&]
[s3;%% &]
[s4; &]
[s5;:Switch`:`:SetLabel`(const char`*`): [_^Switch^ Switch][@(0.0.255) `&]_[* SetLabel]([@(0.0.255) c
onst]_[@(0.0.255) char]_`*[*@3 text])&]
[s2; Sets content of Switch. Each line of [*@3 text ]represents one
case with value equivalent to the index of line.&]
[s7; [%-*C@3 text]-|Content of the Switch.&]
[s7; [*/ Return value]-|`*this for chaining.&]
[s2; [%% Sets content of Switch. Each line of ][%%*@3 text ][%% represents
one case with value equivalent to the index of line. When there
is a number at the start line followed by `^ character, it represents
the ][*@3 gap] used in SetLabel. Same with `| character represents
[*@3 gap] with GAP`_SEPARATOR. Example&]
[s2; &]
[s0; -|SetLabel(`"First`\n1`^Second`\n4`|Third`")&]
[s0; &]
[s2; -|will create switch First, Second a Third labels; there will
be 1/4 line gap between First and Second and 1 line gap with
separator line in the middle between Second and Third.&]
[s3;%% &]
[s4; &]
[s5;:Switch`:`:GetLabel`(int`)const: [_^String^ String]_[* GetLabel]([@(0.0.255) int]_[*@3 i])
_[@(0.0.255) const]&]
[s2;%% Returns the text of case with specified index [*@3 i].&]
[s3;%% &]
[s3;%% &]
[s4; &]
[s5;:Switch`:`:GetLabel`(`)const: [_^String^ String]_[* GetLabel]()_[@(0.0.255) const]&]
[s2;%% Returns the context of the Switch.&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:GetLabel`(int`)const:%- [_^String^ String]_[* GetLabel]([@(0.0.255) int]_[*@3 i
])_[@(0.0.255) const]&]
[s2; Returns the text of case with specified index [*@3 i].&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:GetLabel`(`)const:%- [_^String^ String]_[* GetLabel]()_[@(0.0.255) const]&]
[s2; Returns the context of the Switch.&]
[s3;%- &]
[s4;%- &]
[s5;:Switch`:`:Set`(int`,const Value`&`,const char`*`):%- [_^Switch^ Switch][@(0.0.255) `&
]_[* Set]([@(0.0.255) int]_[*@3 i], [@(0.0.255) const]_[_^Value^ Value][@(0.0.255) `&]_[*@3 val
], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 text])&]
[s2; Sets text of case with specified index [*@3 i]. Text can contain
[s4; &]
[s5;:Upp`:`:Switch`:`:Set`(int`,const Upp`:`:Value`&`,const char`*`,int`): [_^Upp`:`:Switch^ S
witch][@(0.0.255) `&]_[* Set]([@(0.0.255) int]_[*@3 i], [@(0.0.255) const]_[_^Upp`:`:Value^ V
alue][@(0.0.255) `&]_[*@3 val], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 text],
[@(0.0.255) int]_[*@3 gap]_`=_[@3 0])&]
[s2;%% Sets text of case with specified index [*@3 i]. Text can contain
`'`\b`' for access`-key assignment. Value of case is set to [*@3 val].
If [*@3 i] is greater than current number of cases, empty cases
are added to Switch with values equivalent to their indexes.&]
[s7; [%-*C@3 i]-|Index of the case.&]
[s7; [%-*C@3 val]-|Value of the case.&]
[s7; [%-*C@3 text]-|Text of the case.&]
[s7; [*/ Return value]-|`*this for chaining.&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:Set`(int`,const Value`&`):%- [_^Switch^ Switch][@(0.0.255) `&]_[* Set]([@(0.0.255) i
are added to Switch with values equivalent to their indexes.
See SetLabel for [%-*@3 gap] parameter explanation.&]
[s3;%% &]
[s4; &]
[s5;:Switch`:`:Set`(int`,const Value`&`): [_^Switch^ Switch][@(0.0.255) `&]_[* Set]([@(0.0.255) i
nt]_[*@3 i], [@(0.0.255) const]_[_^Value^ Value][@(0.0.255) `&]_[*@3 val])&]
[s2; Sets the Value of of case with specified index [*@3 i]. The text
of case is unaltered.&]
[s7; [%-*C@3 i]-|Index of the case.&]
[s7; [%-*C@3 val]-|Value of the case.&]
[s7; [*/ Return value]-|`*this for chaining.&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:Add`(const Value`&`,const char`*`):%- [_^Switch^ Switch][@(0.0.255) `&]_[* A
dd]([@(0.0.255) const]_[_^Value^ Value][@(0.0.255) `&]_[*@3 val], [@(0.0.255) const]_[@(0.0.255) c
har]_`*[*@3 text])&]
[s2; Adds a new case to the Switch.&]
[s7; [%-*C@3 val]-|Value of the case.&]
[s7; [%-*C@3 text]-|Text of the case.&]
[s7; [*/ Return value]-|`*this for chaining.&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:Add`(const char`*`):%- [_^Switch^ Switch][@(0.0.255) `&]_[* Add]([@(0.0.255) c
onst]_[@(0.0.255) char]_`*[*@3 text])&]
[s2; Adds a new case to the Switch. Value of the case is equal to
its index.&]
[s7; [%-*C@3 text]-|Text of the case.&]
[s7; [*/ Return value]-|`*this for chaining&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:EnableCase`(int`,bool`):%- [@(0.0.255) void]_[* EnableCase]([@(0.0.255) int]_
[*@3 i], [@(0.0.255) bool]_[*@3 enable]_`=_[@(0.0.255) true])&]
[s2; Enables or disables case with the specified index [*@3 i].&]
[s7; [%-*C@3 i]-|Index of the case to be enabled or disabled.&]
[s7; [%-*C@3 enable]-|Enable flag (true if case is to be enabled).&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:DisableCase`(int`):%- [@(0.0.255) void]_[* DisableCase]([@(0.0.255) int]_[*@3 i
])&]
[s2; Same as [^topic`:`/`/CtrlLib`/src`/Switch`$en`-us`#Switch`:`:EnableCase`(int`,bool`)^ E
[s2;%% Sets the Value of of case with specified index [*@3 i]. The
text of case is unaltered.&]
[s3;%% &]
[s4; &]
[s5;:Upp`:`:Switch`:`:Add`(const Upp`:`:Value`&`,const char`*`,int`): [_^Upp`:`:Switch^ S
witch][@(0.0.255) `&]_[* Add]([@(0.0.255) const]_[_^Upp`:`:Value^ Value][@(0.0.255) `&]_[*@3 v
al], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 text], [@(0.0.255) int]_[*@3 gap]_`=_[@3 0])
&]
[s2;%% Adds a new case to the Switch. See SetLabel for [%-*@3 gap]
parameter explanation.&]
[s3;%% &]
[s4; &]
[s5;:Upp`:`:Switch`:`:Add`(const char`*`,int`): [_^Upp`:`:Switch^ Switch][@(0.0.255) `&]_
[* Add]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 text], [@(0.0.255) int]_[*@3 gap]_`=_[@3 0])
&]
[s2;%% Adds a new case to the Switch. Value of the case is set to
its index. See SetLabel for [%-*@3 gap] parameter explanation.&]
[s3;%% &]
[s4; &]
[s5;:Switch`:`:EnableCase`(int`,bool`): [@(0.0.255) void]_[* EnableCase]([@(0.0.255) int]_[*@3 i
], [@(0.0.255) bool]_[*@3 enable]_`=_[@(0.0.255) true])&]
[s2;%% Enables or disables case with the specified index [*@3 i].&]
[s7;%% [%-*C@3 i]-|Index of the case to be enabled or disabled.&]
[s7;%% [%-*C@3 enable]-|Enable flag (true if case is to be enabled).&]
[s3;%% &]
[s4; &]
[s5;:Switch`:`:DisableCase`(int`): [@(0.0.255) void]_[* DisableCase]([@(0.0.255) int]_[*@3 i])
&]
[s2;%% Same as [^topic`:`/`/CtrlLib`/src`/Switch`$en`-us`#Switch`:`:EnableCase`(int`,bool`)^ E
nableCase](i, false).&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:EnableValue`(const Value`&`,bool`):%- [@(0.0.255) void]_[* EnableValue]([@(0.0.255) c
[s3;%% &]
[s4; &]
[s5;:Switch`:`:EnableValue`(const Value`&`,bool`): [@(0.0.255) void]_[* EnableValue]([@(0.0.255) c
onst]_[_^Value^ Value][@(0.0.255) `&]_[*@3 val], [@(0.0.255) bool]_[*@3 enable]_`=_[@(0.0.255) t
rue])&]
[s2; Enables or disables case based on its value.&]
[s7; [%-*C@3 val]-|Value of the case to be enabled / disabled.&]
[s7; [%-*C@3 enable]-|Enable flag (true if case is to be enabled).&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:DisableValue`(const Value`&`):%- [@(0.0.255) void]_[* DisableValue]([@(0.0.255) c
[s2;%% Enables or disables case based on its value.&]
[s7;%% [%-*C@3 val]-|Value of the case to be enabled / disabled.&]
[s7;%% [%-*C@3 enable]-|Enable flag (true if case is to be enabled).&]
[s3;%% &]
[s4; &]
[s5;:Switch`:`:DisableValue`(const Value`&`): [@(0.0.255) void]_[* DisableValue]([@(0.0.255) c
onst]_[_^Value^ Value][@(0.0.255) `&]_[*@3 val])&]
[s2; Same as [^topic`:`/`/CtrlLib`/src`/Switch`$en`-us`#Switch`:`:EnableValue`(const Value`&`,bool`)^ E
[s2;%% Same as [^topic`:`/`/CtrlLib`/src`/Switch`$en`-us`#Switch`:`:EnableValue`(const Value`&`,bool`)^ E
nableValue](val, false).&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:Reset`(`):%- [@(0.0.255) void]_[* Reset]()&]
[s2; Removes content of the Switch.&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:GetCases`(`)const:%- [@(0.0.255) const]_[_^Array^ Array][@(0.0.255) <][_^Switch`:`:Case^ C
[s3;%% &]
[s4; &]
[s5;:Switch`:`:Reset`(`): [@(0.0.255) void]_[* Reset]()&]
[s2;%% Removes content of the Switch.&]
[s3;%% &]
[s4; &]
[s5;:Switch`:`:GetCases`(`)const: [@(0.0.255) const]_[_^Array^ Array][@(0.0.255) <][_^Switch`:`:Case^ C
ase][@(0.0.255) >`&]_[* GetCases]()_[@(0.0.255) const]&]
[s2;%- Retrieves information of all cases in the Switch.&]
[s7; [*/ Return value]-|Array of [^topic`:`/`/CtrlLib`/src`/Switch`$en`-us`#Switch`:`:Case`:`:struct^ S
[s2; Retrieves information of all cases in the Switch.&]
[s7;%% [*/ Return value]-|Array of [^topic`:`/`/CtrlLib`/src`/Switch`$en`-us`#Switch`:`:Case`:`:struct^ S
witch`::Case] structures.&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:operator int`(`)const:%- [* operator_int]()_[@(0.0.255) const]&]
[s2; Simplified access to Switch Value. Equivalent to (int)GetData().&]
[s6; Switch must be assigned an integer value.&]
[s7; [*/ Return value]-|Integer Value of Switch.&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:operator`=`(const Value`&`):%- [@(0.0.255) void]_[* operator`=]([@(0.0.255) c
onst]_[_^Value^ Value][@(0.0.255) `&]_[*@3 v])&]
[s2; Equivalent to SetData([%-*@3 v]).&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:SetFont`(Font`):%- [_^Switch^ Switch][@(0.0.255) `&]_[* SetFont]([_^Font^ Font
]_[*@3 f])&]
[s2; Alters the font to be used in the Switch.&]
[s7; [%-*C@3 f]-|Font to be used.&]
[s7; [*/ Return value]-|`*this for chaining.&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:GetFont`(`)const:%- [_^Font^ Font]_[* GetFont]()_[@(0.0.255) const]&]
[s2; Retrieves the font used in the Switch.&]
[s7; [*/ Return value]-|`*this for chaining.&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:MinCaseHeight`(int`):%- [_^Switch^ Switch][@(0.0.255) `&]_[* MinCaseHeight](
[@(0.0.255) int]_[*@3 cy])&]
[s2; Sets the minimal height of a case in the switch.&]
[s7; [%-*C@3 f]-|Font to be used.&]
[s7; [*/ Return value]-|`*this for chaining.&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:SetAutoDirection`(`):%- [_^Switch^ Switch][@(0.0.255) `&]_[* SetAutoDirectio
n]()&]
[s2; Sets Switch layout to automatic mode, where items are layed
[s3;%% &]
[s4; &]
[s5;:Switch`:`:operator int`(`)const: [* operator_int]()_[@(0.0.255) const]&]
[s2;%% Simplified access to Switch Value. Equivalent to (int)GetData().&]
[s6;%% Switch must be assigned an integer value.&]
[s7;%% [*/ Return value]-|Integer Value of Switch.&]
[s3;%% &]
[s4; &]
[s5;:Switch`:`:operator`=`(const Value`&`): [@(0.0.255) void]_[* operator`=]([@(0.0.255) co
nst]_[_^Value^ Value][@(0.0.255) `&]_[*@3 v])&]
[s2;%% Equivalent to SetData([%-*@3 v]).&]
[s3;%% &]
[s4; &]
[s5;:Switch`:`:SetFont`(Font`): [_^Switch^ Switch][@(0.0.255) `&]_[* SetFont]([_^Font^ Font]_
[*@3 f])&]
[s2;%% Alters the font to be used in the Switch.&]
[s7;%% [%-*C@3 f]-|Font to be used.&]
[s7;%% [*/ Return value]-|`*this for chaining.&]
[s3;%% &]
[s4; &]
[s5;:Switch`:`:GetFont`(`)const: [_^Font^ Font]_[* GetFont]()_[@(0.0.255) const]&]
[s2;%% Retrieves the font used in the Switch.&]
[s7;%% [*/ Return value]-|`*this for chaining.&]
[s3;%% &]
[s4; &]
[s5;:Switch`:`:MinCaseHeight`(int`): [_^Switch^ Switch][@(0.0.255) `&]_[* MinCaseHeight]([@(0.0.255) i
nt]_[*@3 cy])&]
[s2;%% Sets the minimal height of a case in the switch.&]
[s7;%% [%-*C@3 f]-|Font to be used.&]
[s7;%% [*/ Return value]-|`*this for chaining.&]
[s3;%% &]
[s4; &]
[s5;:Switch`:`:SetAutoDirection`(`): [_^Switch^ Switch][@(0.0.255) `&]_[* SetAutoDirection](
)&]
[s2;%% Sets Switch layout to automatic mode, where items are layed
out depending on the available area for switch (vertically is
the are is high enough, horizontally otherwise).&]
[s3;%- &]
[s4;%- &]
[s5;:Switch`:`:SetHorizontal`(`):%- [_^Switch^ Switch][@(0.0.255) `&]_[* SetHorizontal]()&]
[s2; Forces horizontal layout.&]
[s3;%- &]
[s4;%- &]
[s5;:Switch`:`:SetVertical`(`):%- [_^Switch^ Switch][@(0.0.255) `&]_[* SetVertical]()&]
[s2; Forces vertical layout.&]
[s3; &]
[s4; &]
[s5;:Switch`:`:SetHorizontal`(`): [_^Switch^ Switch][@(0.0.255) `&]_[* SetHorizontal]()&]
[s2;%% Forces horizontal layout.&]
[s3; &]
[s4; &]
[s5;:Switch`:`:SetVertical`(`): [_^Switch^ Switch][@(0.0.255) `&]_[* SetVertical]()&]
[s2;%% Forces vertical layout.&]
[s3;%% &]
[s0;%% &]
[s0; &]
[s0;%- &]
[ {{10000@3 [s0; [*@(229)4 Switch`::Case]]}}&]
[s3; &]
[s1;:Switch`:`:Case`:`:struct:%- [@(0.0.255)3 struct][3 _][*3 Case][3 _:_][@(0.0.255)3 public][3 _
][*@3;3 Moveable][@(0.0.255)3 <][*3 Case][@(0.0.255)3 >][3 _]&]
[s9; This structure is returned by the [^topic`:`/`/CtrlLib`/src`/Switch`$en`-us`#Switch`:`:GetCases`(`)const^ S
[ {{10000@3 [s0;%% [*@(229)4 Switch`::Case]]}}&]
[s3;%% &]
[s1;:Switch`:`:Case`:`:struct: [@(0.0.255)3 struct][3 _][*3 Case][3 _:_][@(0.0.255)3 public][3 _][*@3;3 M
oveable][@(0.0.255)3 <][*3 Case][@(0.0.255)3 >][3 _]&]
[s9;%% This structure is returned by the [^topic`:`/`/CtrlLib`/src`/Switch`$en`-us`#Switch`:`:GetCases`(`)const^ S
witch`::GetCases] method.&]
[s3;%% &]
[s0; &]
[ {{10000F(128)G(128)@1 [s0;%% [* Public Field List]]}}&]
[s3; &]
[s0;%- &]
[ {{10000F(128)G(128)@1 [s0; [* Public Field List]]}}&]
[s3;%- &]
[s5;:Switch`:`:Case`:`:label:%- [_^String^ String]_[* label]&]
[s2; Text of the case.&]
[s3;%- &]
[s4;%- &]
[s5;:Switch`:`:Case`:`:value:%- [_^Value^ Value]_[* value]&]
[s2; Value of the case.&]
[s5;:Switch`:`:Case`:`:label: [_^String^ String]_[* label]&]
[s2;%% Text of the case.&]
[s3; &]
[s4;%- &]
[s5;:Switch`:`:Case`:`:accesskey:%- [@(0.0.255) int]_[* accesskey]&]
[s2; Access key.&]
[s5; &]
[s4;%- &]
[s5;:Switch`:`:Case`:`:enabled:%- [@(0.0.255) bool]_[* enabled]&]
[s2; Enable flag.&]
[s3; &]
[s0; ]]
[s4; &]
[s5;:Switch`:`:Case`:`:value: [_^Value^ Value]_[* value]&]
[s2;%% Value of the case.&]
[s3;%% &]
[s4; &]
[s5;:Switch`:`:Case`:`:accesskey: [@(0.0.255) int]_[* accesskey]&]
[s2;%% Access key.&]
[s5;%% &]
[s4; &]
[s5;:Switch`:`:Case`:`:enabled: [@(0.0.255) bool]_[* enabled]&]
[s2;%% Enable flag.&]
[s3;%% &]
[s0;%% ]]