container.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * File : container.h
  3. * This file is part of RT-Thread GUI Engine
  4. * COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2009-10-16 Bernard first version
  23. */
  24. #ifndef __RTGUI_CONTAINER_H__
  25. #define __RTGUI_CONTAINER_H__
  26. #include <rtgui/widgets/widget.h>
  27. #include <rtgui/widgets/box.h>
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. DECLARE_CLASS_TYPE(container);
  32. /** Gets the type of a container */
  33. #define RTGUI_CONTAINER_TYPE (RTGUI_TYPE(container))
  34. /** Casts the object to an rtgui_container */
  35. #define RTGUI_CONTAINER(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_CONTAINER_TYPE, rtgui_container_t))
  36. /** Checks if the object is an rtgui_container */
  37. #define RTGUI_IS_CONTAINER(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_CONTAINER_TYPE))
  38. /*
  39. * the container widget
  40. */
  41. struct rtgui_container
  42. {
  43. struct rtgui_widget parent;
  44. /* layout box */
  45. struct rtgui_box *layout_box;
  46. rtgui_list_t children;
  47. };
  48. typedef struct rtgui_container rtgui_container_t;
  49. rtgui_container_t *rtgui_container_create(void);
  50. void rtgui_container_destroy(rtgui_container_t *container);
  51. rt_bool_t rtgui_container_event_handler(struct rtgui_object *widget, struct rtgui_event *event);
  52. /* set layout box */
  53. void rtgui_container_set_box(struct rtgui_container *container, struct rtgui_box *box);
  54. void rtgui_container_layout(struct rtgui_container *container);
  55. void rtgui_container_add_child(rtgui_container_t *container, rtgui_widget_t *child);
  56. void rtgui_container_remove_child(rtgui_container_t *container, rtgui_widget_t *child);
  57. void rtgui_container_destroy_children(rtgui_container_t *container);
  58. rtgui_widget_t *rtgui_container_get_first_child(rtgui_container_t *container);
  59. rt_bool_t rtgui_container_event_handler(struct rtgui_object *widget, rtgui_event_t *event);
  60. rt_bool_t rtgui_container_dispatch_event(rtgui_container_t *container, rtgui_event_t *event);
  61. rt_bool_t rtgui_container_dispatch_mouse_event(rtgui_container_t *container, struct rtgui_event_mouse *event);
  62. struct rtgui_object* rtgui_container_get_object(struct rtgui_container *container, rt_uint32_t id);
  63. #ifdef __cplusplus
  64. }
  65. #endif
  66. #endif