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. | |
Point | GetCharPosition (const char *ch) const |
Get the position of a character in the layout. | |
const char * | GetCharAtPosition (int x) const |
Get the character that is at a position. | |
Static Public Member Functions | |
static Font * | GetFont (FontSize size, TextColour colour) |
Get a static font instance. | |
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 std::map< LineCacheKey, LineCacheItem > | LineCache |
typedef SmallMap< TextColour, Font * > | FontColourMap |
Static Private Member Functions | |
static LineCacheItem & | GetCachedParagraphLayout (const char *str, size_t len, const FontState &state) |
Get reference to cache item. | |
Private Attributes | |
const char * | string |
Pointer to the original string. | |
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 139 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 633 of file gfx_layout.cpp.
References SmallVector< const ParagraphLayouter::Line *, S >::Append(), DEBUG, GetCachedParagraphLayout(), Layouter::LineCacheItem::layout, Layouter::LineCacheItem::state_after, and Utf8Decode().
Dimension Layouter::GetBounds | ( | ) |
Get the boundaries of this paragraph.
Definition at line 689 of file gfx_layout.cpp.
References SmallVector< const ParagraphLayouter::Line *, S >::Begin(), and SmallVector< const ParagraphLayouter::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 820 of file gfx_layout.cpp.
References linecache, Layouter::LineCacheKey::state_before, and Layouter::LineCacheKey::str.
Referenced by Layouter().
const char * Layouter::GetCharAtPosition | ( | int | x | ) | const |
Get the character that is at a position.
x | Position in the string. |
Definition at line 752 of file gfx_layout.cpp.
References SmallVector< const ParagraphLayouter::Line *, S >::Begin(), and IsInsideMM().
Referenced by GetCharAtPosition().
Point Layouter::GetCharPosition | ( | const char * | ch | ) | const |
Get the position of a character in the layout.
ch | Character to get the position of. |
Definition at line 705 of file gfx_layout.cpp.
References SmallVector< const ParagraphLayouter::Line *, S >::Begin(), string, and Utf8Decode().
Referenced by GetCharPosInString().
void Layouter::ResetFontCache | ( | FontSize | size | ) | [static] |
Reset cached font information.
size | Font size to reset. |
Definition at line 801 of file gfx_layout.cpp.
References SmallVector< const ParagraphLayouter::Line *, S >::Begin(), SmallVector< T, S >::Clear(), SmallVector< T, S >::End(), fonts, and ResetLineCache().
Referenced by FreeTypeFontCache::ClearFontCache(), SpriteFontCache::ClearFontCache(), FontCache::FontCache(), and FontCache::~FontCache().
Layouter::FontColourMap Layouter::fonts [static, private] |
Cache of Font instances.
Definition at line 176 of file gfx_layout.h.
Referenced by GetFont(), and ResetFontCache().
Layouter::LineCache * Layouter::linecache [static, private] |
Cache of ParagraphLayout lines.
Definition at line 171 of file gfx_layout.h.
Referenced by GetCachedParagraphLayout(), ReduceLineCache(), and ResetLineCache().