Overview
Examples
Screenshots
Comparisons
Applications
Download
Manual
Status & Roadmap
FAQ
Authors & License
Forums
Wiki
Funding Ultimate++
Search on this site











SourceForge.net Logo



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(Draww, const Rectr, const Valueq, Color ink, Color paper, dword styleconst

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.

w

Draw.

r

Target rectangle.

q

Value to be painted.

ink

Suggested foreground color.

paper

Suggested background color.

style

Visual style.

 

virtual void PaintBackground(Draww, const Rectr, const Valueq, Color ink, Color paper, dword styleconst

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).

w

Draw.

r

Target rectangle.

q

Value to be painted.

ink

Suggested foreground color.

paper

Suggested background color.

style

Visual style.

 

virtual Size GetStdSize(const Valueqconst

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.

q

Value.

Return value

Size of Value for Display.

 

virtual Size RatioSize(const Valueq, int cx, int cyconst

Returns size for defined value keeping the aspect ratio.

q

Value.

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

Simple 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.

 

WString text

Text to be displayed.

 

Font font

Font of text.

 

Color ink

Text color.

 

Color paper

Background color

 

AttrText& Ink(Color c)

Sets the text color.

c

The color.

Return value

*this.

 

AttrText& Paper(Color c)

Sets the paper color.

c

The color.

Return value

*this.

 

AttrText& SetFont(Font f)

Sets the font.

f

The font.

Return value

*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.

 

operator Value() const

Return value

AttrText as raw Value.

 

AttrText(const char *text)

Constructs AttrText, assigning the text attribute and all other attributes to zero.

 

AttrText(const wchar *text)

Constructs AttrText, assigning the text attribute and all other attributes to zero.

 

AttrText(const WString& text)

Constructs AttrText, assigning the text attribute and all other attributes to zero.

 

 

 

Standard Displays

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.

 

 

 

class PaintRect : private Moveable<PaintRect

PaintRect is a simple helper class that combines Value and a reference to the Display to provide "visual content" of rectangle. It is Moveable.

 

void Paint(Draww, const Rectr, Color ink = SColorText, Color paper = SColorPaper, dword style = 0const

Invokes Paint of contained Display for contained Value.

w

Draw.

r

Target rectangle.

ink

Suggested foreground color.

paper

Suggested background color.

style

Visual style.

 

void Paint(Draww, int x, int y, int cx, int cy, Color ink = SColorText, Color paper = SColorPaper, dword style = 0const

Invokes contained Display with contained Value.

w

Draw.

x, y, cx, cy

Target rectangle (left, top, width, height).

ink

Suggested foreground color.

paper

Suggested background color.

style

Visual style.

 

Size GetStdSize() const

Invokes GetStdSize of contained Display for contained Value.

Return value

Preferred Size of Value.

 

Size RatioSize(int cx, int cyconst

Invokes RatioSize of contained Display for contained Value.

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.

 

Size RatioSize(Size szconst

Equivalent to RatioSize(sz.cx, sz.cy).

 

void SetDisplay(const Display& d)

Sets the Display.

d

Display.

 

void SetValue(const Value& v)

Sets the Value.

v

Value.

 

void Set(const Display& d, const Value& v)

Sets the Display and the Value.

d

Display.

v

Value.

 

void Clear()

Removes the Display - subsequent calls to Paint act as "no operation", calls to GetStdSize and RatioSize return Size(0, 0).

 

const ValueGetValue() const

Returns the Value.

Return value

Value.

 

const DisplayGetDisplay() const

Returns the Display.

Return value

Display.

 

operator bool() const

Return value

true if Display is set.

 

PaintRect()

Constructs empty PaintRect, with no Display assigned.

 

PaintRect(const Display& display)

Constructs PaintRect with specified Display.

display

Display.

 

PaintRect(const Display& display, const Value& val)

Constructs PaintRext with specified Display and Value.

display

Display.

val

Value.