tbx  0.7.6
Public Types | Public Member Functions | List of all members
tbx::WimpFont Class Reference

Class to display and measure text using the current desktop font. More...

#include <font.h>

Public Types

enum  PaintFlags { WFPF_NONE, WFPF_VCENTRE = (1<<30), WFPF_RJUSTIFY = (1<<31) }
 Flags used for painting the WimpFont.
 

Public Member Functions

void set_colours (Colour foreground, Colour background)
 Set the foreground and background colour for the WIMP font. More...
 
int height_os () const
 Return height of the font. More...
 
int string_width_os (const std::string &text, int num_chars=0)
 Get the width of the text in OS units. More...
 
void paint (int x, int y, const std::string &text, int flags=WimpFont::WFPF_NONE) const
 Paint the wimp font at the given screen coordinates. More...
 
void paint (int x, int y, const char *text, int length=-1, int flags=WimpFont::WFPF_NONE) const
 Paint the wimp font at the given screen coordinates. More...
 

Detailed Description

Class to display and measure text using the current desktop font.

Member Function Documentation

◆ height_os()

int tbx::WimpFont::height_os ( ) const
inline

Return height of the font.

Returns
height of font in OS units

◆ paint() [1/2]

void WimpFont::paint ( int  x,
int  y,
const char *  text,
int  length = -1,
int  flags = WimpFont::WFPF_NONE 
) const

Paint the wimp font at the given screen coordinates.

Before plotting the colour should be set using Graphics::set_foreground/background(WimpColour) or the set_font_colours member of this class.

The background needs to be set as the it will be needed if the current desktop font is an antialias font.

Parameters
xx coordinate
yy coordinate
texttext to plot
lengthlength of text or -1 to plot to end of null terminated text
flagsflags to control painting, defaults to WFPF_NONE

◆ paint() [2/2]

void WimpFont::paint ( int  x,
int  y,
const std::string &  text,
int  flags = WimpFont::WFPF_NONE 
) const

Paint the wimp font at the given screen coordinates.

Before plotting the colour should be set using Graphics::set_foreground/background(WimpColour) or the set_font_colours member of this class.

The background needs to be set as the it will be needed if the current desktop font is an antialias font.

Parameters
xx coordinate
yy coordinate
texttext to plot
flagsflags to control painting, defaults to WFPF_NONE

◆ set_colours()

void WimpFont::set_colours ( Colour  foreground,
Colour  background 
)

Set the foreground and background colour for the WIMP font.

Note: If the current WIMP font is the system font this will change the colours for following graphics methods.

Parameters
foregroundforeground colour for the font
backgroundbackground colour the font is going to be painted on.

◆ string_width_os()

int WimpFont::string_width_os ( const std::string &  text,
int  num_chars = 0 
)

Get the width of the text in OS units.

Parameters
textto measure
num_charsnumber of characters to measure or 0 for whole string.

The documentation for this class was generated from the following files: