diff --git a/bazaar/Controls4U/Controls4U.h b/bazaar/Controls4U/Controls4U.h index 7dfcf68a0..0b8b47d24 100644 --- a/bazaar/Controls4U/Controls4U.h +++ b/bazaar/Controls4U/Controls4U.h @@ -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 diff --git a/bazaar/Controls4U/Controls4U.usc b/bazaar/Controls4U/Controls4U.usc index 64f5f4e41..f4d37fe86 100644 --- a/bazaar/Controls4U/Controls4U.usc +++ b/bazaar/Controls4U/Controls4U.usc @@ -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(); + } +}; \ No newline at end of file