Text.pkg 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. $#include "Text.h"
  2. /// %Text %UI element.
  3. class Text : public UIElement
  4. {
  5. public:
  6. /// Set font and font size.
  7. bool SetFont(const String& fontName, int size = DEFAULT_FONT_SIZE);
  8. /// Set font and font size.
  9. bool SetFont(Font* font, int size = DEFAULT_FONT_SIZE);
  10. /// Set text. Text is assumed to be either ASCII or UTF8-encoded.
  11. void SetText(const String& text);
  12. /// Set row alignment.
  13. void SetTextAlignment(HorizontalAlignment align);
  14. /// Set row spacing, 1.0 for original font spacing.
  15. void SetRowSpacing(float spacing);
  16. /// Set wordwrap. In wordwrap mode the text element will respect its current width. Otherwise it resizes itself freely.
  17. void SetWordwrap(bool enable);
  18. /// Set selection. When length is not provided, select until the text ends.
  19. void SetSelection(unsigned start, unsigned length = M_MAX_UNSIGNED);
  20. /// Clear selection.
  21. void ClearSelection();
  22. /// Set selection background color. Color with 0 alpha (default) disables.
  23. void SetSelectionColor(const Color& color);
  24. /// Set hover background color. Color with 0 alpha (default) disables.
  25. void SetHoverColor(const Color& color);
  26. /// Return font.
  27. Font* GetFont() const { return font_; }
  28. /// Return font size.
  29. int GetFontSize() const { return fontSize_; }
  30. /// Return text.
  31. const String& GetText() const { return text_; }
  32. /// Return row alignment.
  33. HorizontalAlignment GetTextAlignment() const { return textAlignment_; }
  34. /// Return row spacing.
  35. float GetRowSpacing() const { return rowSpacing_; }
  36. /// Return wordwrap mode.
  37. bool GetWordwrap() const { return wordWrap_; }
  38. /// Return selection start.
  39. unsigned GetSelectionStart() const { return selectionStart_; }
  40. /// Return selection length.
  41. unsigned GetSelectionLength() const { return selectionLength_; }
  42. /// Return selection background color.
  43. const Color& GetSelectionColor() const { return selectionColor_; }
  44. /// Return hover background color.
  45. const Color& GetHoverColor() const { return hoverColor_; }
  46. /// Return row height.
  47. int GetRowHeight() const { return rowHeight_; }
  48. /// Return number of rows.
  49. unsigned GetNumRows() const { return rowWidths_.Size(); }
  50. };