Home » Community » Newbie corner » How to print staticlabel text at an angle?
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: Thu May 09 09:33:17 CEST 2024
Total time taken to generate the page: 0.02511 seconds
|