Data Structures | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Static Private Attributes

Layouter Class Reference

The layouter performs all the layout work. More...

#include <gfx_layout.h>

Inheritance diagram for Layouter:
AutoDeleteSmallVector< ParagraphLayout::Line *, 4 > SmallVector< ParagraphLayout::Line *, S >

Data Structures

struct  LineCacheItem
 Item in the linecache. More...
struct  LineCacheKey
 Key into the linecache. More...

Public Member Functions

 Layouter (const char *str, int maxw=INT32_MAX, TextColour colour=TC_FROMSTRING, FontSize fontsize=FS_NORMAL)
 Create a new layouter.
Dimension GetBounds ()
 Get the boundaries of this paragraph.

Static Public Member Functions

static void ResetFontCache (FontSize size)
 Reset cached font information.
static void ResetLineCache ()
 Clear line cache.
static void ReduceLineCache ()
 Reduce the size of linecache if necessary to prevent infinite growth.

Private Types

typedef UChar CharType
 The type of character used within the layouter.
typedef std::map< LineCacheKey,
LineCacheItem
LineCache
typedef SmallMap< TextColour,
Font * > 
FontColourMap

Private Member Functions

size_t AppendToBuffer (CharType *buff, const CharType *buffer_last, WChar c)
ParagraphLayout * GetParagraphLayout (CharType *buff, CharType *buff_end, FontMap &fontMapping)

Static Private Member Functions

static LineCacheItemGetCachedParagraphLayout (const char *str, size_t len, const FontState &state)
 Get reference to cache item.
static Font * GetFont (FontSize size, TextColour colour)
 Get a static font instance.

Static Private Attributes

static LineCache * linecache
 Cache of ParagraphLayout lines.
static FontColourMap fonts [FS_END]
 Cache of Font instances.

Detailed Description

The layouter performs all the layout work.

It also accounts for the memory allocations and frees.

Definition at line 164 of file gfx_layout.h.


Constructor & Destructor Documentation

Layouter::Layouter ( const char *  str,
int  maxw = INT32_MAX,
TextColour  colour = TC_FROMSTRING,
FontSize  fontsize = FS_NORMAL 
)

Member Function Documentation

Dimension Layouter::GetBounds (  ) 

Get the boundaries of this paragraph.

Returns:
The boundaries.

Definition at line 505 of file gfx_layout.cpp.

References SmallVector< ParagraphLayout::Line *, S >::Begin(), and SmallVector< ParagraphLayout::Line *, S >::End().

Referenced by DrawStringMultiLine(), GetStringBoundingBox(), and GetStringHeight().

Layouter::LineCacheItem & Layouter::GetCachedParagraphLayout ( const char *  str,
size_t  len,
const FontState state 
) [static, private]

Get reference to cache item.

If the item does not exist yet, it is default constructed.

Parameters:
str Source string of the line (including colour and font size codes).
len Length of str in bytes (no termination).
state State of the font at the beginning of the line.
Returns:
Reference to cache item.

Definition at line 551 of file gfx_layout.cpp.

References linecache, Layouter::LineCacheKey::state_before, and Layouter::LineCacheKey::str.

Referenced by Layouter().

void Layouter::ResetFontCache ( FontSize  size  )  [static]

Reset cached font information.

Parameters:
size Font size to reset.

Definition at line 532 of file gfx_layout.cpp.

References SmallVector< ParagraphLayout::Line *, S >::Begin(), SmallVector< T, S >::Clear(), SmallVector< T, S >::End(), fonts, and ResetLineCache().

Referenced by FontCache::FontCache(), and FontCache::~FontCache().


Field Documentation

Cache of Font instances.

Definition at line 206 of file gfx_layout.h.

Referenced by GetFont(), and ResetFontCache().

Layouter::LineCache * Layouter::linecache [static, private]

Cache of ParagraphLayout lines.

Definition at line 201 of file gfx_layout.h.

Referenced by GetCachedParagraphLayout(), ReduceLineCache(), and ResetLineCache().


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