rtgui_system.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. };
  37. typedef struct rtgui_thread rtgui_thread_t;
  38. struct rtgui_timer;
  39. typedef void (*rtgui_timeout_func)(struct rtgui_timer* timer, void* parameter);
  40. struct rtgui_timer
  41. {
  42. /* context thread id */
  43. rt_thread_t 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. typedef struct rtgui_timer rtgui_timer_t;
  51. rtgui_timer_t* rtgui_timer_create(rt_int32_t time, rt_base_t flag, rtgui_timeout_func timeout, void* parameter);
  52. void rtgui_timer_destory(rtgui_timer_t* timer);
  53. void rtgui_timer_start(rtgui_timer_t* timer);
  54. void rtgui_timer_stop (rtgui_timer_t* timer);
  55. rtgui_thread_t* rtgui_thread_register(rt_thread_t tid, rt_mq_t mq);
  56. void rtgui_thread_deregister(rt_thread_t tid);
  57. rtgui_thread_t* rtgui_thread_self(void);
  58. rt_thread_t rtgui_thread_get_server(void);
  59. void rtgui_thread_set_widget(struct rtgui_widget* widget);
  60. struct rtgui_widget* rtgui_thread_get_widget(void);
  61. rt_err_t rtgui_thread_send(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
  62. rt_err_t rtgui_thread_send_urgent(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
  63. rt_err_t rtgui_thread_send_sync(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
  64. rt_err_t rtgui_thread_recv(struct rtgui_event* event, rt_size_t event_size);
  65. rt_err_t rtgui_thread_recv_filter(rt_uint32_t type, struct rtgui_event* event, rt_size_t event_size);
  66. rt_err_t rtgui_thread_ack(struct rtgui_event* event, rt_int32_t status);
  67. /* rtgui system initialization function */
  68. void rtgui_system_server_init(void);
  69. void* rtgui_malloc(rt_size_t size);
  70. void rtgui_free(void* ptr);
  71. #endif