Home » Developing U++ » UppHub » Display inspirations...
Display inspirations... [message #14147] |
Fri, 15 February 2008 13:26  |
 |
mirek
Messages: 14257 Registered: November 2005
|
Ultimate Member |
|
|
I was asked about Display by a friend, so I am answering here, I guess it will not hurt posting this code.
These are some of my "ad-hoc" displays (not part of uppsrc):
class FontDisplay : public Display {
public:
void Paint(Draw& w, const Rect& r, const Value& q,
Color ink, Color paper, dword style) const;
protected:
Font font;
public:
static FontDisplay Bold;
static FontDisplay Italic;
static FontDisplay Underline;
static FontDisplay BoldItalic;
FontDisplay(Font font) : font(font) {}
};
class ColoredDisplay : public Display {
public:
void Paint(Draw& w, const Rect& r, const Value& q,
Color ink, Color paper, dword style) const;
protected:
Color color;
public:
ColoredDisplay(Color color) : color(color) {}
};
class FontColorDisplay : public Display {
public:
void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const;
protected:
Color color;
Font font;
public:
FontColorDisplay(Color color, Font font) : color(color), font(font) {}
};
FontDisplay FontDisplay::Bold(GuiFont().Bold());
FontDisplay FontDisplay::Italic(GuiFont().Italic());
FontDisplay FontDisplay::Underline(GuiFont().Underline());
FontDisplay FontDisplay::BoldItalic(GuiFont().Italic().Underline());
void FontDisplay::Paint(Draw& w, const Rect& r, const Value& q,
Color ink, Color paper, dword style) const
{
w.DrawRect(r, paper);
DrawSmartText(w, r.left, r.top, r.Width(),
String(IsString(q) ? q : StdFormat(q)), font, ink);
}
void ColoredDisplay::Paint(Draw& w, const Rect& r, const Value& q,
Color ink, Color paper, dword style) const
{
w.DrawRect(r, paper);
if((style & (CURSOR|FOCUS)) != (CURSOR|FOCUS))
ink = color;
DrawSmartText(w, r.left, r.top, r.Width(),
String(IsString(q) ? q : StdFormat(q)), StdFont(), ink);
}
void FontColorDisplay::Paint(Draw& w, const Rect& r, const Value& q,
Color ink, Color paper, dword style) const
{
w.DrawRect(r, paper);
if((style & (CURSOR|FOCUS)) != (CURSOR|FOCUS))
ink = color;
DrawSmartText(w, r.left, r.top, r.Width(), String(IsString(q) ? q : StdFormat(q)), font, ink);
}
Mirek
|
|
|
|
|
Goto Forum:
Current Time: Mon May 12 20:24:03 CEST 2025
Total time taken to generate the page: 0.03085 seconds
|