window.h 3.6 KB

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