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 » Community » Newbie corner » How to print staticlabel text at an angle?
How to print staticlabel text at an angle? [message #32385] Sun, 15 May 2011 05:47 Go to next message
jerson is currently offline  jerson
Messages: 202
Registered: June 2010
Location: Bombay, India
Experienced Member

Can someone please show me how to print a rotated "StaticLabel' or point me to a relevant post that does this?

What I am trying to do is print a 'StaticLabel' at 90degrees. I know I can modify stuff down inside LabelBase.DrawSmartText and DrawTextUtil.DrawTLText line 116 to call the appropriate version that uses angle. I know there must be a better and cleaner way to do it. Can someone please show me how?

On the other hand, it is relatively easy to modify the USC file to rotate the label, but, I need to pass it down to the actual object.

Cheers

[Updated on: Sun, 15 May 2011 05:49]

Report message to a moderator

Re: How to print staticlabel text at an angle? [message #32391 is a reply to message #32385] Sun, 15 May 2011 14:59 Go to previous messageGo to next message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
Hi, there!

Coincidentally, I needed it once too, and I wrote the following code, which worked fine for me:

in VerticalLabel.h file:
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct VertDisplay : Display {
    virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const;
};

class VerticalLabel : public Label
{
	public:
	
		typedef VerticalLabel CLASSNAME;
		
		VerticalLabel();
		VerticalLabel& SetText(const char *text);
		
	private:
		PaintRect pr;
};



VerticalLabel.cpp file:
#include "VerticalLabel.h"

void VertDisplay::Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
{
    w.DrawRect(r, paper);
	w.DrawText(r.left,r.top,900,q.ToString(),StdFont(),(style & CURSOR)&&(style & FOCUS)?SLtRed:ink);
}

VerticalLabel::VerticalLabel()
{
	SetAlign(ALIGN_LEFT);
	SetVAlign(ALIGN_BOTTOM);
	pr.SetDisplay(Single<VertDisplay>());
}

VerticalLabel& VerticalLabel::SetText(const char *text)
{
	pr.SetValue(text);
	SetPaintRect(pr);
	return *this;
}


I hope this helps.
Re: How to print staticlabel text at an angle? [message #32396 is a reply to message #32391] Mon, 16 May 2011 03:33 Go to previous message
jerson is currently offline  jerson
Messages: 202
Registered: June 2010
Location: Bombay, India
Experienced Member

Thank you very much for your help. I shall come back here if I am still left with any issues.
Previous Topic: Eigen and UPP? (STL question?)
Next Topic: [Printing] How to retrieve DPI, page size, etc
Goto Forum:
  


Current Time: Thu Mar 28 13:13:37 CET 2024

Total time taken to generate the page: 0.01371 seconds