Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Creating a hyperlink label
Re: Creating a hyperlink label [message #43755 is a reply to message #41235] Fri, 03 October 2014 09:31 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3361
Registered: August 2008
Senior Veteran
Hello all

If you do not mind I would like to include it in Controls4U.

.cpp/.h
class HyperlinkText : public ParentCtrl {
public:
	HyperlinkText() {
		label.SetInk(LtBlue());
		*this << label.SizePos();
	}
	HyperlinkText& SetText(const char* txt) {
		label.SetText(txt); 
		return *this;
	}
	HyperlinkText& SetHyperlink(const char* str) {
		hyperlink = str; 
		return *this; 
	}

private:
	StaticText label;
	String hyperlink;
	virtual Image CursorImage(Point p, dword keyflags) {
		return Image::Hand();
	}
	virtual void LeftDown(Point p, dword keyflags) {
		LaunchWebBrowser(hyperlink);
	}
};

.usc
ctrl HyperlinkText {
	group "Static";

	GetMinSize() { return XMinSize(); }
	GetStdSize() { sz = XMinSize(); sz.cy += 6; sz.cx *= 5; return sz; }

	Doc    SetText ? "Label of control" ;
	Doc    SetHyperlink ? "Hyperlink" ;
	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();
	}
};


Best regards
IƱaki
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Using a Button to load a window/form using Run. THISBACK syntax
Next Topic: Win32: custom WM_XXXXX message processing
Goto Forum:
  


Current Time: Tue May 14 15:25:14 CEST 2024

Total time taken to generate the page: 0.01492 seconds