rtgui_system.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * File : rtgui_system.h
  3. * This file is part of RTGUI in 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-04 Bernard first version
  13. */
  14. #ifndef __RTGUI_SYSTEM_H__
  15. #define __RTGUI_SYSTEM_H__
  16. #include <rtthread.h>
  17. #include <rtgui/rtgui.h>
  18. struct rtgui_dc;
  19. struct rtgui_event;
  20. struct rtgui_widget;
  21. #ifdef RTGUI_USING_SMALL_SIZE
  22. #define RTGUI_EVENT_BUFFER_SIZE 64
  23. #else
  24. #define RTGUI_EVENT_BUFFER_SIZE 256
  25. #endif
  26. struct rtgui_thread
  27. {
  28. /* the thread id */
  29. rt_thread_t tid;
  30. /* the message queue of thread */
  31. rt_mq_t mq;
  32. /* the owner of thread */
  33. struct rtgui_widget* widget;
  34. /* event buffer */
  35. rt_uint8_t event_buffer[RTGUI_EVENT_BUFFER_SIZE];
  36. /* on idle event handler */
  37. void (*on_idle)(struct rtgui_widget* widget, struct rtgui_event *event);
  38. };
  39. typedef struct rtgui_thread rtgui_thread_t;
  40. struct rtgui_timer;
  41. typedef void (*rtgui_timeout_func)(struct rtgui_timer* timer, void* parameter);
  42. typedef void (*rtgui_idle_func)(struct rtgui_widget* widget, struct rtgui_event *event);
  43. struct rtgui_timer
  44. {
  45. /* context thread id */
  46. rt_thread_t tid;
  47. /* rt timer */
  48. struct rt_timer timer;
  49. /* timeout function and user data */
  50. rtgui_timeout_func timeout;
  51. void* user_data;
  52. };
  53. typedef struct rtgui_timer rtgui_timer_t;
  54. rtgui_timer_t* rtgui_timer_create(rt_int32_t time, rt_base_t flag, rtgui_timeout_func timeout, void* parameter);
  55. void rtgui_timer_destory(rtgui_timer_t* timer);
  56. void rtgui_timer_start(rtgui_timer_t* timer);
  57. void rtgui_timer_stop (rtgui_timer_t* timer);
  58. rtgui_thread_t* rtgui_thread_register(rt_thread_t tid, rt_mq_t mq);
  59. void rtgui_thread_deregister(rt_thread_t tid);
  60. void rtgui_thread_set_onidle(rtgui_idle_func onidle);
  61. rtgui_idle_func rtgui_thread_get_onidle(void);
  62. rtgui_thread_t* rtgui_thread_self(void);
  63. rt_thread_t rtgui_thread_get_server(void);
  64. void rtgui_thread_set_widget(struct rtgui_widget* widget);
  65. struct rtgui_widget* rtgui_thread_get_widget(void);
  66. rt_err_t rtgui_thread_send(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
  67. rt_err_t rtgui_thread_send_urgent(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
  68. rt_err_t rtgui_thread_send_sync(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
  69. rt_err_t rtgui_thread_recv(struct rtgui_event* event, rt_size_t event_size);
  70. rt_err_t rtgui_thread_recv_nosuspend(struct rtgui_event* event, rt_size_t event_size);
  71. rt_err_t rtgui_thread_recv_filter(rt_uint32_t type, struct rtgui_event* event, rt_size_t event_size);
  72. rt_err_t rtgui_thread_ack(struct rtgui_event* event, rt_int32_t status);
  73. /* rtgui system initialization function */
  74. void rtgui_system_server_init(void);
  75. void* rtgui_malloc(rt_size_t size);
  76. void rtgui_free(void* ptr);
  77. void* rtgui_realloc(void* ptr, rt_size_t size);
  78. #endif