container.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. /** Gets the type of a container */
  18. #define RTGUI_CONTAINER_TYPE (rtgui_container_type_get())
  19. /** Casts the object to a rtgui_container */
  20. #define RTGUI_CONTAINER(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_CONTAINER_TYPE, rtgui_container_t))
  21. /** Checks if the object is a rtgui_container */
  22. #define RTGUI_IS_CONTAINER(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_CONTAINER_TYPE))
  23. struct rtgui_container
  24. {
  25. /* inherit from widget */
  26. struct rtgui_widget parent;
  27. struct rtgui_widget* focused;
  28. rtgui_list_t children;
  29. };
  30. typedef struct rtgui_container rtgui_container_t;
  31. rtgui_type_t *rtgui_container_type_get(void);
  32. void rtgui_container_add_child(rtgui_container_t *container, rtgui_widget_t* child);
  33. void rtgui_container_remove_child(rtgui_container_t *container, rtgui_widget_t* child);
  34. void rtgui_container_destroy_children(rtgui_container_t *container);
  35. rtgui_widget_t* rtgui_container_get_first_child(rtgui_container_t* container);
  36. rt_bool_t rtgui_container_event_handler(rtgui_widget_t* widget, rtgui_event_t* event);
  37. rt_bool_t rtgui_container_dispatch_event(rtgui_container_t *container, rtgui_event_t* event);
  38. rt_bool_t rtgui_container_dispatch_mouse_event(rtgui_container_t *container, struct rtgui_event_mouse* event);
  39. #endif