edit.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * File : edit.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2009, 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. * 2012-06-04 amsl first version
  13. */
  14. #ifndef __RTGUI_EDIT_H__
  15. #define __RTGUI_EDIT_H__
  16. #include <rtgui/widgets/widget.h>
  17. #include <rtgui/widgets/container.h>
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. DECLARE_CLASS_TYPE(edit);
  22. /** Gets the type of a edit */
  23. #define RTGUI_EDIT_TYPE (RTGUI_TYPE(edit))
  24. /** Casts the object to a rtgui_edit */
  25. #define RTGUI_EDIT(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_EDIT_TYPE, struct rtgui_edit))
  26. /** Checks if the object is a rtgui_edit */
  27. #define RTGUI_IS_EDIT(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_EDIT_TYPE))
  28. #define RTGUI_EDIT_NONE 0x00
  29. #define RTGUI_EDIT_CARET 0x01
  30. #define RTGUI_EDIT_VSCROLL 0x02
  31. #define RTGUI_EDIT_HSCROLL 0x04
  32. #define RTGUI_EDIT_SHIFT 0x10
  33. #define RTGUI_EDIT_CTRL 0x20
  34. #define RTGUI_EDIT_ALT 0x40
  35. #define RTGUI_EDIT_CAPSLOCK 0x80
  36. #define RTGUI_EDIT_NUMLOCK 0x100
  37. struct edit_update
  38. {
  39. /* rt_uint32_t type; */ /* update type */
  40. rtgui_point_t start, end; /* update area */
  41. };
  42. struct edit_line
  43. {
  44. rt_int16_t zsize; /* zone size */
  45. rt_int16_t len;
  46. struct edit_line *prev;
  47. struct edit_line *next;
  48. char *text;
  49. };
  50. struct rtgui_edit
  51. {
  52. /* inherit from container */
  53. rtgui_container_t parent;
  54. /* edit flag */
  55. rt_uint32_t flag;
  56. rt_int16_t max_rows, max_cols;
  57. rt_int16_t row_per_page, col_per_page;
  58. rtgui_point_t upleft;
  59. rtgui_point_t visual;
  60. rt_uint8_t tabsize;
  61. rt_uint8_t item_height;
  62. rt_uint8_t font_width, font_height;
  63. rt_uint8_t margin;
  64. rt_int16_t bzsize; /* base zone size */
  65. struct rtgui_timer *caret_timer;
  66. rtgui_color_t *caret;
  67. rtgui_rect_t caret_rect;
  68. struct edit_update update;
  69. char *update_buf; /* speed up renewal process */
  70. struct rtgui_dc *dbl_buf;
  71. struct edit_line *head;
  72. struct edit_line *tail;
  73. struct edit_line *first_line;
  74. #ifdef RTGUI_EDIT_USING_SCROLL
  75. struct rtgui_scrollbar *hscroll;
  76. struct rtgui_scrollbar *vscroll;
  77. #endif
  78. };
  79. rt_bool_t rtgui_edit_append_line(struct rtgui_edit *edit, const char *text);
  80. rt_bool_t rtgui_edit_insert_line(struct rtgui_edit *edit, struct edit_line *p, char *text);
  81. rt_bool_t rtgui_edit_delete_line(struct rtgui_edit *edit, struct edit_line *line);
  82. rt_bool_t rtgui_edit_connect_line(struct rtgui_edit *edit, struct edit_line *line, struct edit_line *connect);
  83. void _rtgui_edit_constructor(struct rtgui_edit *box);
  84. void _rtgui_edit_deconstructor(struct rtgui_edit *textbox);
  85. struct rtgui_edit *rtgui_edit_create(struct rtgui_container *container, int left, int top, int w, int h);
  86. void rtgui_edit_destroy(struct rtgui_edit *edit);
  87. void rtgui_edit_update(struct rtgui_edit *edit);
  88. void rtgui_edit_ondraw(struct rtgui_edit *edit);
  89. rt_bool_t rtgui_edit_event_handler(struct rtgui_object *object, rtgui_event_t *event);
  90. void rtgui_edit_set_text(struct rtgui_edit *edit, const char *text);
  91. rtgui_point_t rtgui_edit_get_current_point(struct rtgui_edit *edit);
  92. rt_uint32_t rtgui_edit_get_mem_consume(struct rtgui_edit *edit);
  93. rt_bool_t rtgui_edit_readin_file(struct rtgui_edit *edit, const char *filename);
  94. rt_bool_t rtgui_edit_saveas_file(struct rtgui_edit *edit, const char *filename);
  95. #ifdef __cplusplus
  96. }
  97. #endif
  98. #endif