mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
CtrlLib: OptionBox
git-svn-id: svn://ultimatepp.org/upp/trunk@11748 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
c906733c12
commit
164177f0c5
9 changed files with 214 additions and 3064 deletions
|
|
@ -543,13 +543,35 @@ void Option::RefreshFocus() {
|
|||
Refresh();
|
||||
}
|
||||
|
||||
void Option::State(int s)
|
||||
{
|
||||
AutoSync();
|
||||
Pusher::State(s);
|
||||
}
|
||||
|
||||
void Option::RefreshPush() {
|
||||
if(box)
|
||||
Refresh(0, 0, GetSize().cx, GetSmartTextSize(label, font).cy);
|
||||
else
|
||||
if(showlabel)
|
||||
Refresh(0, 0, CtrlsImg::O0().GetSize().cx, GetSize().cy);
|
||||
else
|
||||
Pusher::RefreshPush();
|
||||
}
|
||||
|
||||
void Option::AutoSync()
|
||||
{
|
||||
if(!autobox)
|
||||
return;
|
||||
Ctrl *p = GetParent();
|
||||
if(!p)
|
||||
return;
|
||||
Rect r = GetScreenRect();
|
||||
for(Ctrl *q = p->GetFirstChild(); q; q = q->GetNext())
|
||||
if(q != this && r.Intersects(q->GetScreenRect()))
|
||||
q->Enable(option);
|
||||
}
|
||||
|
||||
Size Option::GetMinSize() const {
|
||||
Size isz = CtrlsImg::O0().GetSize();
|
||||
return AddFrameSize(isz.cx + (GetSmartTextSize(label).cx + 4) * showlabel,
|
||||
|
|
@ -563,14 +585,25 @@ void Option::Paint(Draw& w) {
|
|||
w.DrawRect(0, 0, sz.cx, sz.cy, SColorFace);
|
||||
|
||||
Size isz = CtrlsImg::O0().GetSize();
|
||||
Size tsz(0, 0);
|
||||
int ix = 0, iy = 0, ty = 0;
|
||||
|
||||
if(showlabel) {
|
||||
tsz = GetSmartTextSize(label, font);
|
||||
ty = (sz.cy - tsz.cy) / 2;
|
||||
iy = (tsz.cy - isz.cy) / 2 + ty;
|
||||
} else {
|
||||
Size tsz = GetSmartTextSize(label, font);
|
||||
int ix = 0;
|
||||
int d = tsz.cy >> 1;
|
||||
int ty = (sz.cy - tsz.cy) / 2;
|
||||
int iy = (tsz.cy - isz.cy) / 2 + ty;
|
||||
|
||||
if(box) {
|
||||
ix = d + DPI(4);
|
||||
if(tsz.cy > isz.cy) {
|
||||
ty = 0;
|
||||
iy = (tsz.cy - isz.cy) / 2;
|
||||
}
|
||||
else {
|
||||
iy = 0;
|
||||
ty = (isz.cy - tsz.cy) / 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
if(!showlabel) {
|
||||
ix = (sz.cx - isz.cx) / 2;
|
||||
iy = (sz.cy - isz.cy) / 2;
|
||||
}
|
||||
|
|
@ -586,11 +619,18 @@ void Option::Paint(Draw& w) {
|
|||
|
||||
if(showlabel) {
|
||||
bool ds = !IsShowEnabled();
|
||||
DrawSmartText(w, isz.cx + 4, ty, tsz.cx, label, font,
|
||||
DrawSmartText(w, ix + isz.cx + DPI(2), ty, tsz.cx, label, font,
|
||||
ds || IsReadOnly() ? SColorDisabled : Nvl(color, GetLabelTextColor(this)),
|
||||
VisibleAccessKeys() ? accesskey : 0);
|
||||
if(HasFocus())
|
||||
DrawFocus(w, RectC(isz.cx + 2, ty - 1, tsz.cx + 3, tsz.cy + 2) & sz);
|
||||
DrawFocus(w, RectC(isz.cx + DPI(2), ty - DPI(1), tsz.cx + DPI(3), tsz.cy + DPI(2)) & sz);
|
||||
}
|
||||
|
||||
if(box) {
|
||||
w.Begin();
|
||||
w.ExcludeClip(ix - DPI(3), 0, isz.cx + DPI(8) + tsz.cx, tsz.cy);
|
||||
PaintLabelBox(w, sz, Null, d);
|
||||
w.End();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -614,6 +654,7 @@ void Option::PerformAction() {
|
|||
option = 1;
|
||||
UpdateAction();
|
||||
RefreshPush();
|
||||
AutoSync();
|
||||
}
|
||||
|
||||
Option& Option::Set(int b)
|
||||
|
|
@ -622,6 +663,7 @@ Option& Option::Set(int b)
|
|||
option = b;
|
||||
Update();
|
||||
RefreshPush();
|
||||
AutoSync();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -632,6 +674,7 @@ Option::Option() {
|
|||
switchimage = threestate = false;
|
||||
blackedge = false;
|
||||
showlabel = true;
|
||||
autobox = box = false;
|
||||
Transparent();
|
||||
font = StdFont();
|
||||
color = Null;
|
||||
|
|
|
|||
|
|
@ -349,6 +349,8 @@ ctrl Option {
|
|||
Text SetLabel @1 ? "Option text";
|
||||
Font SetFont = StdFont() @1;
|
||||
Frame SetFrame @2;
|
||||
bool Box;
|
||||
bool AutoBox;
|
||||
bool BlackEdge;
|
||||
bool SwitchImage;
|
||||
bool SetEditable = true @1 ? "Editable";
|
||||
|
|
@ -370,18 +372,45 @@ ctrl Option {
|
|||
}
|
||||
|
||||
Paint(w) {
|
||||
x = self;
|
||||
sz = ViewSize(w);
|
||||
img = .SwitchImage ? "ClassicCtrlsImg::S0"
|
||||
: .ThreeState ? "ClassicCtrlsImg::O2"
|
||||
: "ClassicCtrlsImg::O0";
|
||||
imagesize = GetImageSize(img);
|
||||
textsize = GetSmartTextSize(.SetLabel, .SetFont);
|
||||
w.DrawImage(0, (sz.cy - imagesize.cy) / 2, img);
|
||||
w.DrawSmartText(imagesize.cx + 4, (sz.cy - textsize.cy) / 2, .SetLabel, .SetFont);
|
||||
|
||||
if(.Box || .AutoBox) {
|
||||
w.DrawImage(10, (textsize.cy - imagesize.cy) / 2, img);
|
||||
w.DrawSmartText(imagesize.cx + 14, 0, .SetLabel, .SetFont);
|
||||
|
||||
d = textsize.cy / 2;
|
||||
w.DrawRect(0, d + 2, 1, sz.cy - d - 4, :SGray);
|
||||
w.DrawRect(1, d + 2, 1, sz.cy - d - 4, :SWhite);
|
||||
w.DrawRect(sz.cx - 2, d, 1, sz.cy - d - 2, :SGray);
|
||||
w.DrawRect(sz.cx - 1, d, 1, sz.cy - d - 2, :SWhite);
|
||||
w.DrawRect(0, sz.cy - 2, sz.cx - 1, 1, :SGray);
|
||||
w.DrawRect(0, sz.cy - 1, sz.cx - 1, 1, :SWhite);
|
||||
w.DrawRect(sz.cx - 1, sz.cy - 2, 1, 2, :SWhite);
|
||||
w.DrawRect(1, d, d - 1, 1, :SGray);
|
||||
w.DrawRect(1, d + 1, d - 1, 1, :SWhite);
|
||||
w.DrawRect(0, d, 1, 2, :SGray);
|
||||
x = textsize.cx + imagesize.cx + 8;
|
||||
w.DrawRect(d + x, d, sz.cx - d - x, 1, :SGray);
|
||||
w.DrawRect(d + x, d + 1, sz.cx - d - x, 1, :SWhite);
|
||||
}
|
||||
else {
|
||||
w.DrawImage(0, (sz.cy - imagesize.cy) / 2, img);
|
||||
w.DrawSmartText(imagesize.cx + 4, (sz.cy - textsize.cy) / 2, .SetLabel, .SetFont);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ctrl OptionBox {
|
||||
> Option;
|
||||
|
||||
bool Box = true;
|
||||
}
|
||||
|
||||
ctrl Switch {
|
||||
group "Push";
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ void DrawFileName(Draw& ww, int x0, int y, int wcx0, int cy, const WString& mnam
|
|||
ww.DrawText(x, y, name, font, ink, (int)(ext - name));
|
||||
ww.DrawText(x + GetTextSize(fi, name, ext), y, ext, font, extink, (int)(mname.End() - ext));
|
||||
if(!IsEmpty(desc) && pass)
|
||||
DrawTextEllipsis(ww, x + fi.GetHeight(), y, wcx - txtcx,
|
||||
DrawTextEllipsis(ww, x + GetTextSize(fi, name), y, wcx - txtcx,
|
||||
desc, "...", descfont, extink);
|
||||
x += txtcx;
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -170,6 +170,7 @@ public:
|
|||
virtual Value GetData() const;
|
||||
virtual void MouseEnter(Point, dword);
|
||||
virtual void MouseLeave();
|
||||
virtual void State(int);
|
||||
|
||||
protected:
|
||||
virtual void RefreshPush();
|
||||
|
|
@ -184,7 +185,11 @@ protected:
|
|||
bool notnull;
|
||||
bool blackedge;
|
||||
bool showlabel;
|
||||
bool box;
|
||||
bool autobox;
|
||||
Color color;
|
||||
|
||||
void AutoSync();
|
||||
|
||||
public:
|
||||
Option& Set(int b);
|
||||
|
|
@ -205,11 +210,18 @@ public:
|
|||
Option& NoNotNull() { return NotNull(false); }
|
||||
bool IsNotNull() const { return notnull; }
|
||||
Option& SetColor(Color c) { color = c; Refresh(); return *this; }
|
||||
Option& Box(bool b = true) { box = b; return *this; }
|
||||
Option& AutoBox(bool b = true) { Box(autobox = b); return *this; }
|
||||
|
||||
Option();
|
||||
virtual ~Option();
|
||||
};
|
||||
|
||||
class OptionBox : public Option {
|
||||
public:
|
||||
OptionBox() { Box(); }
|
||||
};
|
||||
|
||||
class ButtonOption : public Ctrl {
|
||||
public:
|
||||
virtual void Paint(Draw& w);
|
||||
|
|
|
|||
|
|
@ -112,19 +112,10 @@ Rect LabelBox::GetVoidRect() const
|
|||
return r;
|
||||
}
|
||||
|
||||
void LabelBox::Paint(Draw& w)
|
||||
void PaintLabelBox(Draw& w, Size sz, Color color, int d)
|
||||
{
|
||||
Size sz = GetSize();
|
||||
if(!IsTransparent())
|
||||
w.DrawRect(sz, SColorFace);
|
||||
Size lsz = GetLabelSize();
|
||||
int d = lsz.cy >> 1;
|
||||
bool hline = sz.cy < 2 * Draw::GetStdFontCy();
|
||||
bool vline = sz.cx < 2 * Draw::GetStdFontCy();
|
||||
int ty = hline ? (sz.cy - lsz.cy) / 2 : 0;
|
||||
Size ts = PaintLabel(w, d + 2, ty, sz.cx, lsz.cy, !IsShowEnabled(), false, false, VisibleAccessKeys());
|
||||
w.Begin();
|
||||
w.ExcludeClip(d, ty, ts.cx + 4, ts.cy);
|
||||
if(GUI_GlobalStyle() >= GUISTYLE_XP || !IsNull(color)) {
|
||||
if(hline) {
|
||||
d = sz.cy / 2;
|
||||
|
|
@ -185,6 +176,20 @@ void LabelBox::Paint(Draw& w)
|
|||
w.DrawRect(1, sz.cy - 1, sz.cx - 2, 1, SColorLight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LabelBox::Paint(Draw& w)
|
||||
{
|
||||
Size sz = GetSize();
|
||||
if(!IsTransparent())
|
||||
w.DrawRect(sz, SColorFace);
|
||||
Size lsz = GetLabelSize();
|
||||
int d = lsz.cy >> 1;
|
||||
int ty = sz.cy < 2 * Draw::GetStdFontCy() ? (sz.cy - lsz.cy) / 2 : 0;
|
||||
Size ts = PaintLabel(w, d + DPI(2), ty, sz.cx, lsz.cy, !IsShowEnabled(), false, false, VisibleAccessKeys());
|
||||
w.Begin();
|
||||
w.ExcludeClip(d, ty, ts.cx + DPI(4), ts.cy);
|
||||
PaintLabelBox(w, sz, color, d);
|
||||
w.End();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ public:
|
|||
LabelBox& operator=(const char *s) { SetText(s); return *this; }
|
||||
};
|
||||
|
||||
void PaintLabelBox(Draw& w, Size sz, Color color, int d);
|
||||
|
||||
Color LabelBoxTextColor();
|
||||
Color LabelBoxColor();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
topic "Option";
|
||||
[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,6 +8,7 @@ topic "Option";
|
|||
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
|
||||
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
|
||||
[b42;2 $$9,9#13035079074754324216151401829390:normal]
|
||||
[2 $$0,0#00000000000000000000000000000000:Default]
|
||||
[{_}
|
||||
[ {{10000@3 [s0;%% [*@(229)4 Option]]}}&]
|
||||
[s3; &]
|
||||
|
|
@ -18,6 +18,9 @@ er]&]
|
|||
[s2;%%
|
||||
@@image:712&131
|
||||
(A3IAFQAAAOv/AAAAAHic7Zhtio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J57IiSdy4omceCInnsiJJ3LiiZx4IieeyIkncuKJnHgiJ57IiSdy4omceCInnsiJJ3LiiZx4IieeyIkncuKJnHgiJ57IiSdy4pVFrnNeRXGuOuclfDLUf8Nttp1vX/iVAQAAAACASH8BOEK7+g==)
|
||||
&]
|
||||
[s0;%% &]
|
||||
[s9;%% Widget providing the selection of 2 or alternatively 3 states
|
||||
|
|
@ -48,7 +51,7 @@ and standard appearance.&]
|
|||
[s5;:Option`:`:Set`(int`): [_^Option^ Option][@(0.0.255) `&]_[* Set]([@(0.0.255) int]_[*@3 b])&]
|
||||
[s2;%% Sets Option to the specified state (0, 1 or Null).&]
|
||||
[s7;%% [%-*C@3 b]-|State.&]
|
||||
[s3;%% &]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Option`:`:Get`(`)const: [@(0.0.255) int]_[* Get]()_[@(0.0.255) const]&]
|
||||
[s7;%% [*/ Return value]-|Current state of Option.&]
|
||||
|
|
@ -123,6 +126,18 @@ st]&]
|
|||
the default color.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:Option`:`:Box`(bool`): [_^Upp`:`:Option^ Option][@(0.0.255) `&]_[* Box]([@(0.0.255) b
|
||||
ool]_[*@3 b]_`=_[@(0.0.255) true])&]
|
||||
[s2;%% Changes the visual representation to `"checked box`".&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:Option`:`:AutoBox`(bool`): [_^Upp`:`:Option^ Option][@(0.0.255) `&]_[* AutoBox](
|
||||
[@(0.0.255) bool]_[*@3 b]_`=_[@(0.0.255) true])&]
|
||||
[s2;%% Calls Box([%-*@3 b]) and activates mode where all widgets that
|
||||
are children of Option`'s parent and are intersecting Option
|
||||
rectangle are enabled / disabled based on the status of the Option.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Option`:`:ShowLabel`(bool`): [_^Option^ Option][@(0.0.255) `&]_[* ShowLabel]([@(0.0.255) b
|
||||
ool]_[*@3 b]_`=_[@(0.0.255) true])&]
|
||||
[s2;%% Toggles the display of the option`'s label.&]
|
||||
|
|
@ -131,4 +146,11 @@ ool]_[*@3 b]_`=_[@(0.0.255) true])&]
|
|||
[s5;:Upp`:`:Option`:`:IsShowLabel`(`)const: [@(0.0.255) bool]_[* IsShowLabel]()_[@(0.0.255) c
|
||||
onst]&]
|
||||
[s2;%% Returns true if ShowLabel is active.&]
|
||||
[s0; &]
|
||||
[s0; &]
|
||||
[ {{10000@3 [s0;%% [*@(229)4 OptionBox]]}}&]
|
||||
[s0; &]
|
||||
[s1;:Upp`:`:OptionBox`:`:class: [@(0.0.255)3 class][3 _][*3 OptionBox][3 _:_][@(0.0.255)3 public
|
||||
][3 _][*@3;3 Option]&]
|
||||
[s2;%% Option with Box modifier active.&]
|
||||
[s0; ]]
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -288,6 +288,9 @@ void Ide::UscProcessDirDeep(const String& dir)
|
|||
void Ide::SyncUsc()
|
||||
{
|
||||
CleanUsc();
|
||||
UscProcessDir(GetLocalDir());
|
||||
UscProcessDir(GetFileFolder(ConfigFile("x")));
|
||||
|
||||
if(IsNull(main))
|
||||
return;
|
||||
::Workspace wspc;
|
||||
|
|
@ -301,8 +304,6 @@ void Ide::SyncUsc()
|
|||
UscFile(file);
|
||||
}
|
||||
}
|
||||
UscProcessDir(GetLocalDir());
|
||||
UscProcessDir(GetFileFolder(ConfigFile("x")));
|
||||
}
|
||||
|
||||
void Ide::CodeBaseSync()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue