Text.pkg 2.3 KB

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