rtgui_system.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #ifdef RTGUI_USING_SMALL_SIZE
  19. #define RTGUI_EVENT_BUFFER_SIZE 64
  20. #else
  21. #define RTGUI_EVENT_BUFFER_SIZE 256
  22. #endif
  23. struct rtgui_thread
  24. {
  25. /* the thread id */
  26. struct rt_thread* tid;
  27. /* the message queue of thread */
  28. struct rt_messagequeue* mq;
  29. /* the owner of thread */
  30. PVOID widget;
  31. /* event buffer */
  32. rt_uint8_t event_buffer[RTGUI_EVENT_BUFFER_SIZE];
  33. /* on idle event handler */
  34. void (*on_idle)(PVOID wdt, rtgui_event_t *event);
  35. };
  36. typedef struct rtgui_thread rtgui_thread_t;
  37. typedef struct rtgui_timer rtgui_timer_t;
  38. typedef void (*rtgui_timeout_func)(rtgui_timer_t* timer, void* parameter);
  39. typedef void (*rtgui_idle_func)(PVOID wdt, rtgui_event_t *event);
  40. struct rtgui_timer
  41. {
  42. /* context thread id */
  43. struct rt_thread* tid;
  44. /* rt timer */
  45. struct rt_timer timer;
  46. /* timeout function and user data */
  47. rtgui_timeout_func timeout;
  48. void* user_data;
  49. };
  50. rtgui_timer_t* rtgui_timer_create(rt_int32_t time, rt_int32_t flag, rtgui_timeout_func timeout, void* parameter);
  51. void rtgui_timer_destory(rtgui_timer_t* timer);
  52. void rtgui_timer_start(rtgui_timer_t* timer);
  53. void rtgui_timer_stop(rtgui_timer_t* timer);
  54. void rtgui_thread_register(struct rt_thread* tid, struct rt_messagequeue* mq);
  55. void rtgui_thread_deregister(struct rt_thread* tid);
  56. rtgui_thread_t* rtgui_thread_self(void);
  57. void rtgui_thread_set_onidle(rtgui_idle_func onidle);
  58. rtgui_idle_func rtgui_thread_get_onidle(void);
  59. struct rt_thread* rtgui_thread_get_server(void);
  60. void rtgui_thread_set_widget(PVOID widget);
  61. PVOID rtgui_thread_get_widget(void);
  62. rt_err_t rtgui_thread_send(struct rt_thread* tid, rtgui_event_t* event, rt_size_t event_size);
  63. rt_err_t rtgui_thread_send_urgent(struct rt_thread* tid, rtgui_event_t* event, rt_size_t event_size);
  64. rt_err_t rtgui_thread_send_sync(struct rt_thread* tid, rtgui_event_t* event, rt_size_t event_size);
  65. rt_err_t rtgui_thread_recv(rtgui_event_t* event, rt_size_t event_size);
  66. rt_err_t rtgui_thread_recv_nosuspend(rtgui_event_t* event, rt_size_t event_size);
  67. rt_err_t rtgui_thread_recv_filter(rt_uint32_t type, rtgui_event_t* event, rt_size_t event_size);
  68. rt_err_t rtgui_thread_ack(rtgui_event_t* event, rt_err_t errcode);
  69. /* rtgui system initialization function */
  70. void rtgui_system_server_init(void);
  71. void* rtgui_malloc(rt_size_t size);
  72. void rtgui_free(void* ptr);
  73. void* rtgui_realloc(void* ptr, rt_size_t size);
  74. #endif