The layouter performs all the layout work. More...
#include <gfx_layout.h>
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 LineCacheItem & | GetCachedParagraphLayout (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. |
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.
Layouter::Layouter | ( | const char * | str, | |
int | maxw = INT32_MAX , |
|||
TextColour | colour = TC_FROMSTRING , |
|||
FontSize | fontsize = FS_NORMAL | |||
) |
Create a new layouter.
str | The string to create the layout for. | |
maxw | The maximum width. | |
colour | The colour of the font. | |
fontsize | The size of font to use. |
Definition at line 426 of file gfx_layout.cpp.
References SmallVector< ParagraphLayout::Line *, S >::Append(), Layouter::LineCacheItem::buffer, SmallMap< T, U, S >::Contains(), FontState::cur_colour, FontState::fontsize, FS_LARGE, FS_SMALL, GetCachedParagraphLayout(), GetFont(), SmallMap< T, U, S >::Insert(), lastof, Layouter::LineCacheItem::layout, Layouter::LineCacheItem::runs, SCC_BIGFONT, SCC_TINYFONT, FontState::SetColour(), FontState::SetFontSize(), FontState::SetPreviousColour(), Layouter::LineCacheItem::state_after, and Utf8Decode().
Dimension Layouter::GetBounds | ( | ) |
Get the boundaries of this paragraph.
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.
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. |
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.
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().
Layouter::FontColourMap Layouter::fonts [static, private] |
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().