class Display
Display and Display-derived classes render Value into the specified rectangular area. References to Displays are used in many widgets as attributes affecting the rendering of widget Values. Default implementation uses StdDisplay to perform all actions (see below for StdDisplay description).
Visual style constants are used as "style" parameter bit flags of rendering methods and provide additional information about required visual appearance:
CURSOR Gui element is current ("has cursor").
FOCUS Gui element has focus.
SELECT Gui element is selected.
READONLY Gui element is read-only.
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
This virtual method is used to paint rectangle content according to specified Value. Note that it is OK for derived class to understand just Value types it was designed for (and crash otherwise) - it is client code responsibility to use the correct Display.
|
ink |
Suggested foreground color. |
|
paper |
Suggested background color. |
virtual void PaintBackground(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
This virtual method is used to paint areas of GUI element that are outside of rectangle specified in Paint method, but should have color related somewhat to current Display class - usually this color is the same as background painted in Paint. (Note that Paint method must clear the background separately, although base Display class is defined to use PaintBackground for this task).
|
ink |
Suggested foreground color. |
|
paper |
Suggested background color. |
virtual Size GetStdSize(const Value& q) const
Should return standard size for given value and Display. E.g. if Display is rendering Images, it should return the Size of the Image in pixels. Base Display returns the size of textual representation of the Value.
|
Return value |
Size of Value for Display. |
virtual Size RatioSize(const Value& q, int cx, int cy) const
Returns size for defined value keeping the aspect ratio.
|
cx |
Required width. If zero, it should be computed to keep aspect ratio with cy. |
|
cy |
Required height. If zero, it should be computed to keep aspect ratio with cx. |
|
Return value |
Size of Value for Display. |
struct AttrText
Helper class convertible to the Value. StdDisplay, StdRightDisplay and StdCenterDisplay detect whether Value passed in is of AttrText type and handle it differently by adopting non-null attributes for the text painted. AttrText is 'rich' Value type, supporting comparison and serialization. It can be compred to other Value types. It is also possible to assign text that is different from AttrText value.
WString text
Text to be displayed.
Value value
Represents Value of AttrText, usually for comparison/sorting.
Font font
Font of text. It is default initialized by constructor to StdFont.
Color ink
Text color.
Color normalink
Text color to be used if the item is not in selected nor focused nor read-only state.
Color paper
Background color
Color normalpaper
Background color to be used if the item is not in selected nor focused nor read-only state.
int align
Current alignment. Can be one of ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER.
Image img
Icon aligned to the left side.
int imgspc
Space between icon and text.
AttrText& Set(const Value& v)
AttrText& operator=(const Value& v)
Sets the value of AttrText and also text of it (using AsString).
AttrText& Text(const String& txt)
AttrText& Text(const WString& txt)
AttrText& Text(const char *txt)
Sets the text independent of Value.
AttrText& Ink(Color c)
Sets the text color.
AttrText& NormalInk(Color c)
Sets the text color to be used if the item is not in selected nor focused nor read-only state.
AttrText& Paper(Color c)
Sets the paper color.
AttrText& NormalPaper(Color c)
Sets the background color to be used if the item is not in selected nor focused nor read-only state.
AttrText& SetFont(Font f)
Sets the font.
AttrText& Bold(bool b = true)
Calls font.Bold(b). Returns *this.
AttrText& Italic(bool b = true)
Calls font.Italic(b). Returns *this.
AttrText& Underline(bool b = true)
Calls font.Underline(b). Returns *this.
AttrText& Strikeout(bool b = true)
Calls font.Strikeout(b). Returns *this.
AttrText& Align(int a)
Sets the text horizontal alignment. Approved values are ALIGN_LEFT, ALIGN_CENTER and ALIGN_RIGHT.
AttrText& Left()
Aligns the text left.
AttrText& Center()
Aligns the text to the center.
AttrText& Right()
Aligns the text right.
AttrText& SetImage(const Image& m, int spc = 4)
Sets the icon and space between the icon and text.
operator Value() const
Converts AttrText to Value.
AttrText(const Value& v)
Converts Value to AttrText. If v is not AttrText, it gets Set as Value of default constructed AttrText.
AttrText()
Default constructor. Assigns Null to all members except font, which is initialized to StdFont.
Standard Displays are implemented as "functional globals" - functions returning constant reference to single global Display instance.
Display name
|
Description
|
StdDisplay
|
Standard Display. Displays Value as text, unless it is AttrText (see above).
|
StdRightDisplay
|
Standard Display. Displays Value as right-aligned text, unless it is AttrText (see above).
|
StdCenterDisplay
|
Standard Display. Displays Value as centered text, unless it is AttrText (see above).
|
ColorDisplay
|
Displays Color (required) - simply paints background using the Value passed in.
|
SizeTextDisplay
|
Similar to StdDisplay, but stretches the text size to fill whole display area.
|
ImageDisplay
|
Displays Image passed in as Value, aligns it to the top-left corner.
|
FittedImageDisplay
|
Displays Image scaled to fit the rectangle.
|
CenteredImageDisplay
|
Displays Image centered in the rectangle.
|
CenteredHighlightImageDisplay
|
Displays Image centered in the rectangle with 1 pixel wide white border.
|
DrawingDisplay
|
Displays Drawing scaled to fit the rectangle.
|
|
|