window.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. rtgui_modal_code_t modal_code;
  47. /* window title */
  48. char* title;
  49. /* call back */
  50. rt_bool_t (*on_activate) (struct rtgui_widget* widget, struct rtgui_event* event);
  51. rt_bool_t (*on_deactivate) (struct rtgui_widget* widget, struct rtgui_event* event);
  52. rt_bool_t (*on_close) (struct rtgui_widget* widget, struct rtgui_event* event);
  53. /* reserved user data */
  54. rt_uint32_t user_data;
  55. };
  56. rtgui_type_t *rtgui_win_type_get(void);
  57. rtgui_win_t* rtgui_win_create(rtgui_toplevel_t* parent_toplevel, const char* title,
  58. rtgui_rect_t *rect, rt_uint32_t flag);
  59. void rtgui_win_destroy(rtgui_win_t* win);
  60. rtgui_modal_code_t rtgui_win_show(rtgui_win_t* win, rt_bool_t is_modal);
  61. void rtgui_win_hiden(rtgui_win_t* win);
  62. void rtgui_win_end_modal(rtgui_win_t* win, rtgui_modal_code_t modal_code);
  63. rt_bool_t rtgui_win_is_activated(struct rtgui_win* win);
  64. void rtgui_win_move(struct rtgui_win* win, int x, int y);
  65. /* reset extent of window */
  66. void rtgui_win_set_rect(rtgui_win_t* win, rtgui_rect_t* rect);
  67. void rtgui_win_set_box(rtgui_win_t* win, rtgui_box_t* box);
  68. void rtgui_win_set_onactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler);
  69. void rtgui_win_set_ondeactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler);
  70. void rtgui_win_set_onclose(rtgui_win_t* win, rtgui_event_handler_ptr handler);
  71. rt_bool_t rtgui_win_event_handler(rtgui_widget_t* win, struct rtgui_event* event);
  72. void rtgui_win_event_loop(rtgui_win_t* wnd);
  73. void rtgui_win_set_title(rtgui_win_t* win, const char *title);
  74. char* rtgui_win_get_title(rtgui_win_t* win);
  75. #endif