pm_textbox.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * File : pm_textbox.h
  3. * COPYRIGHT (C) 2012-2017, Shanghai Real-Thread Technology Co., Ltd
  4. *
  5. * Change Logs:
  6. * Date Author Notes
  7. * 2017-11-05 realthread the first version
  8. */
  9. #pragma once
  10. #include <pm_widget.h>
  11. namespace Persimmon
  12. {
  13. class TextBox : public Widget
  14. {
  15. public:
  16. TextBox(const Rect& rect);
  17. TextBox(struct rtgui_font* font, const Rect& rect);
  18. virtual ~TextBox();
  19. void addText(char* text);
  20. void addText(char text);
  21. void addText(int num);
  22. void cutText(void);
  23. char* getText(void);
  24. void clearText(void)
  25. {
  26. rt_free(text);
  27. text = RT_NULL;
  28. textLen = 0;
  29. }
  30. void setTextMaxLen(int len)
  31. {
  32. textMaxLen = len;
  33. }
  34. void enableMask(bool mas = true)
  35. {
  36. mask = mas;
  37. }
  38. virtual void render(struct rtgui_dc* dc, const Point &dcPoint = Point(),
  39. const Rect &srcRect = Rect(),
  40. RenderFlag flags = DrawNormal);
  41. private:
  42. void updateText(const char* fmt, ...);
  43. char *text;
  44. int textMaxLen, textLen;
  45. bool mask;
  46. };
  47. }