Label.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef LABEL_H_
  2. #define LABEL_H_
  3. #include "Control.h"
  4. #include "Theme.h"
  5. namespace gameplay
  6. {
  7. /**
  8. * A label is the most basic type of control, capable only of rendering text within its border.
  9. *
  10. * The following properties are available for labels:
  11. *
  12. * label <Label ID>
  13. * {
  14. * style = <Style ID>
  15. * position = <x, y>
  16. * size = <width, height>
  17. * text = <string>
  18. * }
  19. */
  20. class Label : public Control
  21. {
  22. friend class Container;
  23. public:
  24. /**
  25. * Set the text for this label to display.
  26. *
  27. * @param text The text to display.
  28. */
  29. void setText(const char* text);
  30. /**
  31. * Get the text displayed by this label.
  32. *
  33. * @return The text displayed by this label.
  34. */
  35. const char* getText();
  36. protected:
  37. Label();
  38. virtual ~Label();
  39. /**
  40. * Create a label with a given style and properties.
  41. *
  42. * @param style The style to apply to this label.
  43. * @param properties The properties to set on this label.
  44. *
  45. * @return The new label.
  46. */
  47. static Label* create(Theme::Style* style, Properties* properties);
  48. /**
  49. * Initialize this label.
  50. */
  51. virtual void init(Theme::Style* style, Properties* properties);
  52. /**
  53. * Draw this label's text.
  54. *
  55. * @param clip The clipping rectangle of this label's parent container.
  56. */
  57. void drawText(const Rectangle& clip);
  58. std::string _text; // The text displayed by this label.
  59. private:
  60. Label(const Label& copy);
  61. };
  62. }
  63. #endif