container.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * File : container.h
  3. * This file is part of 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-16 Bernard first version
  13. */
  14. #ifndef __RTGUI_CONTAINER_H__
  15. #define __RTGUI_CONTAINER_H__
  16. #include <rtgui/widgets/widget.h>
  17. #include <rtgui/widgets/box.h>
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. DECLARE_CLASS_TYPE(container);
  22. /** Gets the type of a container */
  23. #define RTGUI_CONTAINER_TYPE (RTGUI_TYPE(container))
  24. /** Casts the object to an rtgui_container */
  25. #define RTGUI_CONTAINER(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_CONTAINER_TYPE, rtgui_container_t))
  26. /** Checks if the object is an rtgui_container */
  27. #define RTGUI_IS_CONTAINER(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_CONTAINER_TYPE))
  28. /*
  29. * the container widget
  30. */
  31. struct rtgui_container
  32. {
  33. struct rtgui_widget parent;
  34. /* layout box */
  35. struct rtgui_box* layout_box;
  36. rtgui_list_t children;
  37. };
  38. typedef struct rtgui_container rtgui_container_t;
  39. rtgui_container_t* rtgui_container_create(void);
  40. void rtgui_container_destroy(rtgui_container_t* container);
  41. rt_bool_t rtgui_container_event_handler(struct rtgui_object* widget, struct rtgui_event* event);
  42. /* set layout box */
  43. void rtgui_container_set_box(struct rtgui_container* container, struct rtgui_box* box);
  44. void rtgui_container_layout(struct rtgui_container* container);
  45. void rtgui_container_add_child(rtgui_container_t *container, rtgui_widget_t* child);
  46. void rtgui_container_remove_child(rtgui_container_t *container, rtgui_widget_t* child);
  47. void rtgui_container_destroy_children(rtgui_container_t *container);
  48. rtgui_widget_t* rtgui_container_get_first_child(rtgui_container_t* container);
  49. rt_bool_t rtgui_container_event_handler(struct rtgui_object* widget, rtgui_event_t* event);
  50. rt_bool_t rtgui_container_dispatch_event(rtgui_container_t *container, rtgui_event_t* event);
  51. rt_bool_t rtgui_container_dispatch_mouse_event(rtgui_container_t *container, struct rtgui_event_mouse* event);
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif