rtgui_app.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * File : rtgui_app.h
  3. * This file is part of RTGUI in RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2012, 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-01-13 Grissiom first version
  13. */
  14. #ifndef __RTGUI_APP_H__
  15. #define __RTGUI_APP_H__
  16. #include <rtthread.h>
  17. #include <rtgui/rtgui.h>
  18. #include <rtgui/event.h>
  19. #include <rtgui/rtgui_system.h>
  20. DECLARE_CLASS_TYPE(application);
  21. /** Gets the type of a application */
  22. #define RTGUI_APP_TYPE (RTGUI_TYPE(application))
  23. /** Casts the object to an rtgui_workbench */
  24. #define RTGUI_APP(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_APP_TYPE, struct rtgui_app))
  25. /** Checks if the object is an rtgui_workbench */
  26. #define RTGUI_IS_APP(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_APP_TYPE))
  27. enum rtgui_app_flag
  28. {
  29. RTGUI_APP_FLAG_EXITED = 0x04,
  30. RTGUI_APP_FLAG_SHOWN = 0x08
  31. };
  32. typedef void (*rtgui_idle_func_t)(struct rtgui_object *obj, struct rtgui_event *event);
  33. struct rtgui_app
  34. {
  35. struct rtgui_object parent;
  36. /* application name */
  37. unsigned char *name;
  38. struct rtgui_image* icon;
  39. enum rtgui_app_flag state_flag;
  40. rt_uint16_t ref_count;
  41. rt_uint16_t exit_code;
  42. /* the thread id */
  43. rt_thread_t tid;
  44. /* the RTGUI server id */
  45. rt_thread_t server;
  46. /* the message queue of thread */
  47. rt_mq_t mq;
  48. /* event buffer */
  49. rt_uint8_t event_buffer[sizeof(union rtgui_event_generic)];
  50. /* if not RT_NULL, the application is in modal state by modal_object. If is
  51. * RT_NULL, nothing modal windows. */
  52. struct rtgui_object *modal_object;
  53. struct rtgui_object *main_object;
  54. /* on idle event handler */
  55. rtgui_idle_func_t on_idle;
  56. };
  57. /**
  58. * create an application named @myname on thread @param tid
  59. */
  60. struct rtgui_app *rtgui_app_create(rt_thread_t tid, const char *title);
  61. void rtgui_app_destroy(struct rtgui_app *app);
  62. rt_bool_t rtgui_app_event_handler(struct rtgui_object *obj, rtgui_event_t *event);
  63. rt_base_t rtgui_app_run(struct rtgui_app *app);
  64. void rtgui_app_exit(struct rtgui_app *app, rt_uint16_t code);
  65. void rtgui_app_activate(struct rtgui_app *app);
  66. void rtgui_app_close(struct rtgui_app *app);
  67. void rtgui_app_set_onidle(rtgui_idle_func_t onidle);
  68. rtgui_idle_func_t rtgui_app_get_onidle(void);
  69. struct rtgui_app *rtgui_app_self(void);
  70. rt_err_t rtgui_app_set_as_wm(void);
  71. void rtgui_app_set_main_win(struct rtgui_win *win);
  72. #endif /* end of include guard: __RTGUI_APP_H__ */