textview.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * File : textview.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2011, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2011-03-05 Bernard first version
  13. */
  14. #ifndef __RTGUI_TEXTVIEW_H__
  15. #define __RTGUI_TEXTVIEW_H__
  16. #include <rtgui/widgets/widget.h>
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /**
  21. * @defgroup rtgui_textview
  22. * @{
  23. */
  24. DECLARE_CLASS_TYPE(textview);
  25. /** Gets the type of a textview */
  26. #define RTGUI_TEXTVIEW_TYPE (RTGUI_TYPE(textview))
  27. /** Casts the object to an rtgui_textview */
  28. #define RTGUI_TEXTVIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_TEXTVIEW_TYPE, rtgui_textview_t))
  29. /** Checks if the object is an rtgui_textview */
  30. #define RTGUI_IS_TEXTVIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_TEXTVIEW_TYPE))
  31. /*
  32. * the textview widget
  33. */
  34. struct rtgui_textview
  35. {
  36. /* inherit from widget */
  37. struct rtgui_widget parent;
  38. rt_uint16_t line_width;
  39. rt_uint16_t line_count;
  40. char* lines;
  41. rt_int16_t line_current;
  42. rt_uint16_t line_page_count;
  43. };
  44. typedef struct rtgui_textview rtgui_textview_t;
  45. rtgui_textview_t* rtgui_textview_create(const char* text, const rtgui_rect_t *rect);
  46. void rtgui_textview_destroy(rtgui_textview_t* textview);
  47. rt_bool_t rtgui_textview_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
  48. void rtgui_textview_set_text(rtgui_textview_t* textview, const char* text);
  49. /** @} */
  50. #ifdef __cplusplus
  51. }
  52. #endif
  53. #endif