GDisplayString Class Reference

Cache for text measuring, glyph substitution and painting. More...

#include <GDisplayString.h>

List of all members.

Public Member Functions

 GDisplayString (GFont *f, char *s, int l=-1, GSurface *pdc=0, int tabOrigin=0)
 Constructor.
 GDisplayString (GFont *f, char16 *s, int l=-1, GSurface *pdc=0, int tabOrigin=0)
 Constructor.
bool ShowVisibleTab ()
void ShowVisibleTab (bool i)
GFontGetFont ()
void TruncateWithDots (int Width)
 Fits string into 'width' pixels, truncating with '...' if it's not going to fit.
bool IsTruncated ()
 Returns true if the string is trucated.
int Length ()
 Returns the chars in the OsChar string.
void Length (int NewLen)
 Sets the number of chars in the OsChar string.
 operator OsChar * ()
 Returns the pointer to the native string.
int X ()
 Returns the width of the whole string.
int Y ()
 Returns the height of the whole string.
void Size (int *x, int *y)
 Returns the width and height of the whole string.
int CharAt (int x)
 Returns the number of characters that fit in 'x' pixels.
void Draw (GSurface *pDC, int x, int y, GRect *r=0)
 Draws the string onto a device surface.


Detailed Description

Cache for text measuring, glyph substitution and painting.

To paint text onto the screen several stages need to be implemented to properly support unicode on multiple platforms. This class addresses all of those needs and then allows you to cache the results to reduce text related workload.

The first stage is converting text into the native format for the OS's API. This usually involved converting the text to wide characters for Linux or Windows, or Utf-8 for BeOS. Then the text is converted into runs of characters that can be rendered in the same font. If glyph substitution is required to render the characters a separate run is used with a different font ID. Finally you can measure or paint these runs of text. Also tab characters are expanded to the current tab size setting.


Constructor & Destructor Documentation

GDisplayString::GDisplayString ( GFont f,
char *  s,
int  l = -1,
GSurface pdc = 0,
int  tabOrigin = 0 
)

Constructor.

Parameters:
f  The base font. Must not be destroyed during the lifetime of this object.
s  Utf-8 input string
l  Number of bytes in the input string or -1 for NULL terminated.

References GFontSystem::Inst().

GDisplayString::GDisplayString ( GFont f,
char16 s,
int  l = -1,
GSurface pdc = 0,
int  tabOrigin = 0 
)

Constructor.

Parameters:
f  The base font. Must not be destroyed during the lifetime of this object.
s  A wide character input string
l  The number of characters in the input string (NOT the number of bytes) or -1 for NULL terminated

References GFontSystem::Inst().


Member Function Documentation

void GDisplayString::Draw ( GSurface pDC,
int  x,
int  y,
GRect r = 0 
)

Draws the string onto a device surface.

Parameters:
pDC  The output device
x  The x coordinate of the top left corner of the output box
y  The y coordinate of the top left corner of the output box
r  An optional clipping rectangle. If the font is not transparent this rectangle will be filled with the background colour.

References B24, GTypeFace::Back(), GTypeFace::Colour(), GSurface::Colour(), GFont::Create(), GFontSystem::Font, GTypeFace::Fore(), G24, GSurface::GetOrigin(), GFont::Handle(), GSurface::Handle(), GFontSystem::Inst(), GSurface::IsScreen(), GTypeFace::PointSize(), R24, GSurface::Rectangle(), Rgb24, GTypeFace::Transparent(), GTypeFace::Underline(), GRect::Valid(), X(), GRect::X(), GRect::x1, GRect::x2, Y(), GSurface::Y(), GRect::Y(), GRect::y1, and GRect::y2.

Referenced by GToolButton::OnPaint(), GTextView3::OnPaint(), GDropDown::OnPaint(), and GFilterView::OnPaint().

GFont* GDisplayString::GetFont (  )  [inline]

Returns:
the font used to create the layout

void GDisplayString::ShowVisibleTab ( bool  i  ) 

Sets the ShowVisibleTab setting. Treats Unicode-2192 (left arrow) as a tab char

bool GDisplayString::ShowVisibleTab (  ) 

Returns the ShowVisibleTab setting. Treats Unicode-2192 (left arrow) as a tab char

void GDisplayString::TruncateWithDots ( int  Width  ) 

Fits string into 'width' pixels, truncating with '...' if it's not going to fit.

Parameters:
Width  The number of pixels the string has to fit

References CharAt(), GFont::Create(), GFontSystem::Font, GFont::Handle(), GFontSystem::Inst(), GTypeFace::PointSize(), and X().


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

Generated on Wed Dec 1 15:41:02 2010 for Lgi by  doxygen 1.5.7.1