Hasty Badger
Small UI library (a branch of Turbo Badger)
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends Groups Pages
tb::TBBlock Class Reference

A block of text (a line, that might be wrapped) More...

#include <tb_style_edit.h>

Inheritance diagram for tb::TBBlock:
tb::TBLinkOf< TBBlock > tb::TBLink

Public Member Functions

 TBBlock (TBStyleEdit *styledit)
 
void Clear ()
 
void Set (TBStr newstr)
 
void SetAlign (TB_TEXT_ALIGN align)
 
int32_t InsertText (int32_t ofs, const char *text, int32_t len, bool allow_line_recurse)
 
void RemoveContent (int32_t ofs, int32_t len)
 
void Split ()
 Check if this block contains extra line breaks and split into new blocks if it does. More...
 
void Merge ()
 Check if we've lost the ending break on this block and if so merge it with the next block. More...
 
void Layout (bool update_fragments, bool propagate_height)
 Layout the block. More...
 
void SetSize (int32_t old_w, int32_t new_w, int32_t new_h, bool propagate_height)
 Update the size of this block. More...
 
TBTextFragmentFindFragment (int32_t ofs, bool prefer_first=false) const
 
TBTextFragmentFindFragment (int32_t x, int32_t y) const
 
int32_t CalculateStringWidth (TBFontFace *font, const char *str, int len=TB_ALL_TO_TERMINATION) const
 
int32_t CalculateTabWidth (TBFontFace *font, int32_t xpos) const
 
int32_t CalculateLineHeight (TBFontFace *font) const
 
int32_t CalculateBaseline (TBFontFace *font) const
 
void Invalidate () const
 
void BuildSelectionRegion (int32_t translate_x, int32_t translate_y, TBTextProps *props, TBRegion &bg_region, TBRegion &fg_region)
 
void Paint (int32_t translate_x, int32_t translate_y, TBTextProps *props)
 

Public Attributes

TBStyleEditstyledit
 
TBLinkListOf< TBTextFragmentfragments
 
int32_t ypos
 
int16_t height
 
int8_t align
 
int line_width_max
 
TBStr str
 
int32_t str_len
 

Detailed Description

A block of text (a line, that might be wrapped)

Member Function Documentation

void tb::TBBlock::Layout ( bool  update_fragments,
bool  propagate_height 
)

Layout the block.

To be called when the text has changed or the layout width has changed.

Parameters
update_fragmentsShould be true if the text has been changed (will recreate elements).
propagate_heightIf true, all following blocks will be moved if the height changed.
void tb::TBBlock::Merge ( )

Check if we've lost the ending break on this block and if so merge it with the next block.

void tb::TBBlock::SetSize ( int32_t  old_w,
int32_t  new_w,
int32_t  new_h,
bool  propagate_height 
)

Update the size of this block.

If propagate_height is true, all following blocks will be moved if the height changed.

void tb::TBBlock::Split ( )

Check if this block contains extra line breaks and split into new blocks if it does.


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