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  |
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   |
 |
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.
|
|
|
|
Goto Forum:
Current Time: Sun Apr 27 01:32:50 CEST 2025
Total time taken to generate the page: 0.00865 seconds
|