Controls4U: Included HyperlinkLabel

git-svn-id: svn://ultimatepp.org/upp/trunk@8353 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
koldo 2015-04-15 08:27:30 +00:00
parent d96ed951d2
commit 09e61bed5d
2 changed files with 54 additions and 0 deletions

View file

@ -137,6 +137,7 @@ public:
bool Set(Image image);
void Clear() {Set(Image());}
Image &Get() {return origImage;}
void SetData(const Value& data) {Set(data.ToString());}
void operator=(String fileName) {Set(fileName);}
void operator=(Image image) {Set(image);}
@ -634,6 +635,21 @@ struct AboutUpp : StaticRect {
AboutUpp();
};
class HyperlinkLabel : public Label {
public:
HyperlinkLabel() {
NoIgnoreMouse();
SetInk(LtBlue());
}
HyperlinkLabel& SetHyperlink(const char* str) {hyperlink = str; return *this;}
private:
String hyperlink;
virtual Image CursorImage(Point p, dword keyflags) {return Image::Hand();}
virtual void LeftDown(Point p, dword keyflags) {LaunchWebBrowser(hyperlink);}
};
END_UPP_NAMESPACE
#endif

View file

@ -1297,3 +1297,41 @@ ctrl PainterCanvas {
}
}
}
ctrl HyperlinkLabel {
group "Static";
GetMinSize() { return XMinSize(); }
GetStdSize() { sz = XMinSize(); sz.cy += 6; sz.cx *= 5; return sz; }
Doc SetHyperlink ? "Hyperlink" ;
Doc SetText ? "Label of control" ;
Align SetAlign = ALIGN_LEFT;
Font SetFont = StdFont();
Frame SetFrame @1;
ViewRect(w) {
r = GetRect();
DrawCtrlFrame(w, r, .SetFrame);
return r;
}
ViewSize(w) {
r = ViewRect(w);
return Size(r.right - r.left, r.bottom - r.top);
}
Paint(w) {
sz = ViewSize(w);
textsize = GetTextSize(.SetText, .SetFont);
px = 0;
if(.SetAlign == "ALIGN_CENTER")
px = (sz.cx - textsize.cx) / 2;
if(.SetAlign == "ALIGN_RIGHT")
px = sz.cx - textsize.cx;
w.DrawText(px, (sz.cy - textsize.cy) / 2, .SetText, .SetFont, :SLtBlue);
}
Sample() {
.SetText = "Text";
.SetFont = Arial(10).Bold().Italic();
}
};