window.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * File : window.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_WINDOW_H__
  15. #define __RTGUI_WINDOW_H__
  16. #include <rtgui/rtgui.h>
  17. #include <rtgui/list.h>
  18. #include <rtgui/widgets/widget.h>
  19. #include <rtgui/widgets/toplevel.h>
  20. #include <rtgui/widgets/box.h>
  21. /** Gets the type of a win */
  22. #define RTGUI_WIN_TYPE (rtgui_win_type_get())
  23. /** Casts the object to an rtgui_win */
  24. #define RTGUI_WIN(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_WIN_TYPE, rtgui_win_t))
  25. /** Checks if the object is an rtgui_win */
  26. #define RTGUI_IS_WIN(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_WIN_TYPE))
  27. #define RTGUI_WIN_STYLE_MODAL 0x01 /* modal mode window */
  28. #define RTGUI_WIN_STYLE_CLOSED 0x02 /* window is closed */
  29. #define RTGUI_WIN_STYLE_ACTIVATE 0x04 /* window is activated */
  30. #define RTGUI_WIN_STYLE_NO_FOCUS 0x08 /* non-focused window */
  31. #define RTGUI_WIN_STYLE_NO_TITLE 0x10 /* no title window */
  32. #define RTGUI_WIN_STYLE_NO_BORDER 0x20 /* no border window */
  33. #define RTGUI_WIN_STYLE_CLOSEBOX 0x40 /* window has the close button */
  34. #define RTGUI_WIN_STYLE_MINIBOX 0x80 /* window has the mini button */
  35. #define RTGUI_WIN_STYLE_DEFAULT (RTGUI_WIN_STYLE_CLOSEBOX | RTGUI_WIN_STYLE_MINIBOX)
  36. struct rtgui_win_title;
  37. struct rtgui_win_area;
  38. struct rtgui_win
  39. {
  40. /* inherit from toplevel */
  41. struct rtgui_toplevel parent;
  42. /* parent toplevel */
  43. rtgui_toplevel_t* parent_toplevel;
  44. /* top window style */
  45. rt_uint8_t style;
  46. rt_uint8_t flag;
  47. rtgui_modal_code_t modal_code;
  48. rtgui_widget_t* modal_widget;
  49. /* window title */
  50. char* title;
  51. /* call back */
  52. rt_bool_t (*on_activate) (struct rtgui_widget* widget, struct rtgui_event* event);
  53. rt_bool_t (*on_deactivate) (struct rtgui_widget* widget, struct rtgui_event* event);
  54. rt_bool_t (*on_close) (struct rtgui_widget* widget, struct rtgui_event* event);
  55. /* reserved user data */
  56. rt_uint32_t user_data;
  57. };
  58. rtgui_type_t *rtgui_win_type_get(void);
  59. rtgui_win_t* rtgui_win_create(rtgui_toplevel_t* parent_toplevel, const char* title,
  60. rtgui_rect_t *rect, rt_uint8_t flag);
  61. void rtgui_win_destroy(rtgui_win_t* win);
  62. rtgui_modal_code_t rtgui_win_show(rtgui_win_t* win, rt_bool_t is_modal);
  63. void rtgui_win_hiden(rtgui_win_t* win);
  64. void rtgui_win_end_modal(rtgui_win_t* win, rtgui_modal_code_t modal_code);
  65. rt_bool_t rtgui_win_is_activated(struct rtgui_win* win);
  66. void rtgui_win_move(struct rtgui_win* win, int x, int y);
  67. /* reset extent of window */
  68. void rtgui_win_set_rect(rtgui_win_t* win, rtgui_rect_t* rect);
  69. #ifndef RTGUI_USING_SMALL_SIZE
  70. void rtgui_win_set_box(rtgui_win_t* win, rtgui_box_t* box);
  71. #endif
  72. void rtgui_win_set_onactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler);
  73. void rtgui_win_set_ondeactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler);
  74. void rtgui_win_set_onclose(rtgui_win_t* win, rtgui_event_handler_ptr handler);
  75. rt_bool_t rtgui_win_event_handler(rtgui_widget_t* win, struct rtgui_event* event);
  76. void rtgui_win_event_loop(rtgui_win_t* wnd);
  77. void rtgui_win_set_title(rtgui_win_t* win, const char *title);
  78. char* rtgui_win_get_title(rtgui_win_t* win);
  79. #endif