summaryrefslogtreecommitdiff
path: root/components/gui/include/rtgui/widgets/container.h
blob: fc89a14556a6f9f6f28b8e00ae543cf0282e3752 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * File      : container.h
 * This file is part of RT-Thread RTOS
 * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rt-thread.org/license/LICENSE
 *
 * Change Logs:
 * Date           Author       Notes
 * 2009-10-16     Bernard      first version
 */
#ifndef __RTGUI_CONTAINER_H__
#define __RTGUI_CONTAINER_H__

#include <rtgui/widgets/widget.h>
#include <rtgui/widgets/box.h>

#ifdef __cplusplus
extern "C" {
#endif

DECLARE_CLASS_TYPE(container);
/** Gets the type of a container */
#define RTGUI_CONTAINER_TYPE       (RTGUI_TYPE(container))
/** Casts the object to an rtgui_container */
#define RTGUI_CONTAINER(obj)       (RTGUI_OBJECT_CAST((obj), RTGUI_CONTAINER_TYPE, rtgui_container_t))
/** Checks if the object is an rtgui_container */
#define RTGUI_IS_CONTAINER(obj)    (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_CONTAINER_TYPE))

/*
 * the container widget
 */
struct rtgui_container
{
    struct rtgui_widget parent;

    /* layout box */
    struct rtgui_box *layout_box;

    rtgui_list_t children;
};
typedef struct rtgui_container rtgui_container_t;

rtgui_container_t *rtgui_container_create(void);
void rtgui_container_destroy(rtgui_container_t *container);

rt_bool_t rtgui_container_event_handler(struct rtgui_object *widget, struct rtgui_event *event);

/* set layout box */
void rtgui_container_set_box(struct rtgui_container *container, struct rtgui_box *box);
void rtgui_container_layout(struct rtgui_container *container);

void rtgui_container_add_child(rtgui_container_t *container, rtgui_widget_t *child);
void rtgui_container_remove_child(rtgui_container_t *container, rtgui_widget_t *child);
void rtgui_container_destroy_children(rtgui_container_t *container);
rtgui_widget_t *rtgui_container_get_first_child(rtgui_container_t *container);

rt_bool_t rtgui_container_event_handler(struct rtgui_object *widget, rtgui_event_t *event);

rt_bool_t rtgui_container_dispatch_event(rtgui_container_t *container, rtgui_event_t *event);
rt_bool_t rtgui_container_dispatch_mouse_event(rtgui_container_t *container, struct rtgui_event_mouse *event);

struct rtgui_object* rtgui_container_get_object(struct rtgui_container *container, rt_uint32_t id);
#ifdef __cplusplus
}
#endif

#endif