textbox.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * File : textbox.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. * 2009-10-16 Bernard first version
  13. */
  14. #ifndef __RTGUI_TEXTBOX_H__
  15. #define __RTGUI_TEXTBOX_H__
  16. #include <rtgui/rtgui.h>
  17. #include <rtgui/rtgui_system.h>
  18. /** Gets the type of a textbox */
  19. #define RTGUI_TEXTBOX_TYPE (rtgui_textbox_type_get())
  20. /** Casts the object to a rtgui_textbox_t */
  21. #define RTGUI_TEXTBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_TEXTBOX_TYPE, rtgui_textbox_t))
  22. /** Checks if the object is a rtgui_textbox_t */
  23. #define RTGUI_IS_TEXTBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_TEXTBOX_TYPE))
  24. #define RTGUI_TEXTBOX_DEFAULT_WIDTH 80
  25. #define RTGUI_TEXTBOX_DEFAULT_HEIGHT 20
  26. #define RTGUI_TEXTBOX_NONE 0x00
  27. #define RTGUI_TEXTBOX_MULTI 0x01 //多行
  28. #define RTGUI_TEXTBOX_MASK 0x02 //密码
  29. #define RTGUI_TEXTBOX_DIGIT 0x04 //输入限制为数字
  30. #define RTGUI_TEXTBOX_CARET_SHOW 0x10
  31. #define RTGUI_TEXTBOX_CARET_STAT 0x20
  32. #define RTGUI_TEXTBOX_LINE_MAX 128 //行缓存的长度
  33. struct rtgui_textbox
  34. {
  35. /* inherit from widget */
  36. rtgui_widget_t parent;
  37. /* text box flag */
  38. rt_uint32_t flag;
  39. rt_uint32_t isedit;//是否可编辑
  40. /* current line and position */
  41. rt_uint16_t line, line_begin, position, line_length;
  42. rt_uint16_t dis_length; /*may be display length.*/
  43. char* text;
  44. rt_size_t font_width;
  45. rtgui_timer_t* caret_timer;
  46. /* widget private data */
  47. rt_bool_t (*on_change)(PVOID wdt, rtgui_event_t* event);
  48. rt_bool_t (*on_enter) (PVOID wdt, rtgui_event_t* event);
  49. };
  50. typedef struct rtgui_textbox rtgui_textbox_t;
  51. void _rtgui_textbox_constructor(rtgui_textbox_t *box);
  52. void _rtgui_textbox_deconstructor(rtgui_textbox_t *textbox);
  53. rtgui_type_t *rtgui_textbox_type_get(void);
  54. rtgui_textbox_t* rtgui_textbox_create(PVOID wdt,const char* text,int left,int top,int w,int h, rt_uint32_t flag);
  55. void rtgui_textbox_destroy(rtgui_textbox_t* box);
  56. rt_bool_t rtgui_textbox_event_handler(PVOID wdt, rtgui_event_t* event);
  57. void rtgui_textbox_set_value(rtgui_textbox_t* box, const char* text);
  58. const char* rtgui_textbox_get_value(rtgui_textbox_t* box);
  59. void rtgui_textbox_set_line_length(rtgui_textbox_t* box, rt_size_t length);
  60. void rtgui_textbox_get_edit_rect(rtgui_textbox_t *box,rtgui_rect_t *rect);
  61. #endif