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 » Developing U++ » UppHub » Display inspirations...
Display inspirations... [message #14147] Fri, 15 February 2008 13:26 Go to next message
mirek is currently offline  mirek
Messages: 13975
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
Re: Display inspirations... [message #14148 is a reply to message #14147] Fri, 15 February 2008 14:06 Go to previous messageGo to next message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
Shouldn't it read

FontDisplay  FontDisplay::BoldItalic(GuiFont().Bold().Italic());

instead of

FontDisplay  FontDisplay::BoldItalic(GuiFont().Italic().Underline());

?

Furthermore - just for "cosmetic" reasons - I'd suggest to name the classes "ColoredDisplay" and "FontColorDisplay" uniformly either "ColorDisplay" & "FontColorDisplay" or "ColoredDisplay" & "FontColoredDisplay".

Werner

Re: Display inspirations... [message #14151 is a reply to message #14148] Fri, 15 February 2008 16:05 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
As I said, these are "ad-hoc" displays, not a quality we would accept into the main uppsrc tree Smile Only the inspiration.

Mirek
Previous Topic: ChessBoard
Next Topic: Another CImgCtrl (Zoom, drag, m. wheel, print, print embedded, etc )
Goto Forum:
  


Current Time: Sat Apr 20 07:00:58 CEST 2024

Total time taken to generate the page: 0.06639 seconds