|
|
Hasty Badger
Small UI library (a branch of Turbo Badger)
|
Edit and formats TBTextFragment's. More...
#include <tb_style_edit.h>
Public Member Functions | |
| void | SetListener (TBStyleEditListener *listener) |
| void | SetContentFactory (TBTextFragmentContentFactory *content_factory) |
| void | SetFont (const TBFontDescription &font_desc) |
| void | Paint (const TBRect &rect, const TBFontDescription &font_desc, const TBColor &text_color) |
| bool | KeyDown (int key, SPECIAL_KEY special_key, MODIFIER_KEYS modifierkeys) |
| bool | MouseDown (const TBPoint &point, int button, int clicks, MODIFIER_KEYS modifierkeys, bool touch) |
| bool | MouseUp (const TBPoint &point, int button, MODIFIER_KEYS modifierkeys, bool touch) |
| bool | MouseMove (const TBPoint &point) |
| void | Focus (bool focus) |
| void | Clear (bool init_new=true) |
| bool | SetText (const TBStr &text, TB_CARET_POS pos=TB_CARET_POS_BEGINNING) |
| bool | GetText (TBStr &text) const |
| bool | IsEmpty () const |
| void | SetAlign (TB_TEXT_ALIGN align) |
| Set the default text alignment and all currently selected blocks, or the block of the current caret position if nothing is selected. More... | |
| void | SetMultiline (bool multiline=true) |
| void | SetStyling (bool styling=true) |
| void | SetReadOnly (bool readonly=true) |
| void | SetSelection (bool selection=true) |
| void | SetPassword (bool password=true) |
| void | SetWrapping (bool wrapping=true) |
| void | SetWindowsStyleBreak (bool win_style_br) |
| Set if line breaks should be inserted in windows style ( ) or unix style ( ). More... | |
| void | Cut () |
| void | Copy () |
| void | Paste () |
| void | Delete () |
| void | Undo () |
| void | Redo () |
| bool | CanUndo () const |
| bool | CanRedo () const |
| void | InsertText (const char *text, int32_t len=TB_ALL_TO_TERMINATION, bool after_last=false, bool clear_undo_redo=false) |
| void | AppendText (const char *text, int32_t len=TB_ALL_TO_TERMINATION, bool clear_undo_redo=false) |
| void | InsertBreak () |
| TBBlock * | FindBlock (int32_t y) const |
| void | ScrollIfNeeded (bool x=true, bool y=true) |
| void | SetScrollPos (int32_t x, int32_t y) |
| void | SetLayoutSize (int32_t width, int32_t height, bool is_virtual_reformat) |
| void | Reformat (bool update_fragments) |
| int32_t | GetContentWidth () |
| int32_t | GetContentHeight () const |
| int32_t | GetOverflowX () const |
| int32_t | GetOverflowY () const |
| void | BeginLockScrollbars () |
| Call BeginLockScrollbars & EndLockScrollbars around a scope which does lots of changes, to prevent UpdateScrollbar from happening for each block (May cause recalculation of content_width by iterating through all blocks) | |
| void | EndLockScrollbars () |
| bool | GetSizeAffectsLayout () const |
| Return true if changing layout_width and layout_height requires relayouting. More... | |
Public Attributes | |
| TBStyleEditListener * | listener |
| TBTextFragmentContentFactory | default_content_factory |
| TBTextFragmentContentFactory * | content_factory |
| int32_t | layout_width |
| int32_t | layout_height |
| int32_t | content_width |
| int32_t | content_height |
| TBLinkListOf< TBBlock > | blocks |
| TBCaret | caret |
| TBSelection | selection |
| TBUndoRedoStack | undoredo |
| int32_t | scroll_x |
| int32_t | scroll_y |
| int8_t | select_state |
| TBPoint | mousedown_point |
| TBTextFragment * | mousedown_fragment |
| TBFontFace * | font |
| DEPRECATED! This will be removed when using different fonts is properly supported! | |
| TBFontDescription | font_desc |
| TB_TEXT_ALIGN | align |
| union { | |
| struct { | |
| uint32_t multiline_on: 1 | |
| uint32_t styling_on: 1 | |
| uint32_t read_only: 1 | |
| uint32_t selection_on: 1 | |
| uint32_t show_whitespace: 1 | |
| uint32_t password_on: 1 | |
| uint32_t wrapping: 1 | |
| uint32_t win_style_br: 1 | |
| uint32_t calculate_content_width_needed: 1 | |
| If content_width needs to be updated next GetContentWidth-. | |
| uint32_t lock_scrollbars_counter: 5 | |
| Incremental counter for if UpdateScrollbar should be probhited. | |
| } packed | |
| uint32_t packed_init | |
| }; | |
Edit and formats TBTextFragment's.
It handles the text in a TBStyleEditView.
| bool tb::TBStyleEdit::GetSizeAffectsLayout | ( | ) | const |
Return true if changing layout_width and layout_height requires relayouting.
| void tb::TBStyleEdit::SetAlign | ( | TB_TEXT_ALIGN | align | ) |
Set the default text alignment and all currently selected blocks, or the block of the current caret position if nothing is selected.
| void tb::TBStyleEdit::SetLayoutSize | ( | int32_t | width, |
| int32_t | height, | ||
| bool | is_virtual_reformat | ||
| ) |
< Trig a bounds check (scroll if outside)
|
inline |
Set if line breaks should be inserted in windows style (
) or unix style (
).
The default is windows style on the windows platform and disabled elsewhere.
Note: This only affects InsertBreak (pressing enter). Content set from SetText (and clipboard etc.) maintains the used line break.