VSF Documented
vsf_tgui_dynamic.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __VSF_TINY_GUI_EXT_DYNAMIC_H__
19#define __VSF_TINY_GUI_EXT_DYNAMIC_H__
20
21/*============================ INCLUDES ======================================*/
22
23#if VSF_TGUI_CFG_DYNAMIC == ENABLED
24
25/*============================ MACROS ========================================*/
26/*============================ MACROFIED FUNCTIONS ===========================*/
27
28// heap
29
30#if !defined(VSF_TGUI_HEAP_HEADER) && VSF_USE_HEAP == ENABLED
31# define VSF_TGUI_HEAP_HEADER "service/heap/vsf_heap.h"
32# define vsf_tgui_malloc(__size) vsf_heap_malloc(__size)
33# define vsf_tgui_free(__ptr) vsf_heap_free(__ptr)
34#endif
35
36// control
37
38#define vsf_tgui_control_set_width(__control, __w) \
39 do { \
40 (__control)->tSize.iWidth = (__w); \
41 } while(0)
42
43#define vsf_tgui_control_set_height(__control, __h) \
44 do { \
45 (__control)->tSize.iHeight = (__h); \
46 } while(0)
47
48#define vsf_tui_control_set_size(__control, __w, __h) \
49 do { \
50 (__control)->tSize.iWidth = (__w); \
51 (__control)->tSize.iHeight = (__h); \
52 } while(0)
53
54#define vsf_tgui_control_set_margin(__control, __left, __top, __right, __bottom)\
55 do { \
56 (__control)->tMargin.chLeft = (__left); \
57 (__control)->tMargin.chTop = (__top); \
58 (__control)->tMargin.chRight = (__right); \
59 (__control)->tMargin.chBottom = (__bottom); \
60 } while(0)
61
62#define vsf_control_set_msghandler(__control, __handler, __num) \
63 do { \
64 (__control)->tMSGMap.ptItems = (__handler); \
65 (__control)->tMSGMap.chCount = (__num); \
66 } while (0)
67
68// container
69
70#define vsf_tgui_container_set_type2(__container, __type, __autosize) \
71 do { \
72 (__container)->ContainerAttribute.u5Type = (__type), \
73 (__container)->ContainerAttribute.bIsAutoSize = (__autosize); \
74 } while(0)
75#define vsf_tgui_container_set_type1(__container, __type) \
76 vsf_tgui_container_set_type2((__container), (__type), true)
77// protocol: void vsf_tgui_container_set_type(vsf_tgui_container_t *container, int type, bool autosize = true);
78#define vsf_tgui_container_set_type(__container, ...) \
79 __PLOOC_EVAL(vsf_tgui_container_set_type, __VA_ARGS__)((__container), ##__VA_ARGS__)
80
81/*============================ TYPES =========================================*/
82/*============================ GLOBAL VARIABLES ==============================*/
83/*============================ PROTOTYPES ====================================*/
84
87
88extern void vsf_tgui_control_add(vsf_tgui_container_t *parent, vsf_tgui_control_t *control_prev, vsf_tgui_control_t *control);
89extern void vsf_tgui_control_remove(vsf_tgui_container_t *parent, vsf_tgui_control_t *control);
90extern void vsf_tgui_control_sync(vsf_tgui_container_t *parent, vsf_tgui_control_t *control);
91
92// container
93
94extern vsf_tgui_container_t * vsf_tgui_container_new(char *name);
95
96// label
97
98extern vsf_tgui_label_t * vsf_tgui_label_new(char *name);
99extern void vsf_tgui_label_set_text_static(vsf_tgui_label_t *label, const char *text);
100extern const char * vsf_tgui_label_get_text(vsf_tgui_label_t *label);
101
102// button
103
104extern vsf_tgui_button_t * vsf_tgui_button_new(char *name);
105#define vsf_tgui_button_set_text_static(__button, __text) \
106 vsf_tgui_label_set_text_static((vsf_tgui_label_t *)(__button), (__text))
107
108// list
109
110#define vsf_tgui_list_get_child(__list) \
111 ((vsf_tgui_control_t *) (((vsf_tgui_container_t *)((__list)->node_ptr))->node_ptr) )
112
113#endif
114#endif
115/* EOF */
enum vsf_msgt_node_id_t vsf_tree_msg_node_id_t
struct vsf_tgui_control_t vsf_tgui_control_t
Definition vsf_tgui_common.h:549
void vsf_tgui_control_remove(vsf_tgui_container_t *parent, vsf_tgui_control_t *control)
Definition vsf_tgui_dynamic.c:126
vsf_tgui_button_t * vsf_tgui_button_new(char *name)
Definition vsf_tgui_dynamic.c:218
vsf_tgui_control_t * vsf_tgui_control_new(vsf_tree_msg_node_id_t id, char *name)
Definition vsf_tgui_dynamic.c:62
vsf_tgui_label_t * vsf_tgui_label_new(char *name)
Definition vsf_tgui_dynamic.c:182
const char * vsf_tgui_label_get_text(vsf_tgui_label_t *label)
Definition vsf_tgui_dynamic.c:211
void vsf_tgui_control_add(vsf_tgui_container_t *parent, vsf_tgui_control_t *control_prev, vsf_tgui_control_t *control)
Definition vsf_tgui_dynamic.c:106
vsf_tgui_container_t * vsf_tgui_container_new(char *name)
Definition vsf_tgui_dynamic.c:167
void vsf_tgui_label_set_text_static(vsf_tgui_label_t *label, const char *text)
Definition vsf_tgui_dynamic.c:200
void vsf_tgui_control_sync(vsf_tgui_container_t *parent, vsf_tgui_control_t *control)
Definition vsf_tgui_dynamic.c:152
void vsf_tgui_control_destroy(vsf_tgui_control_t *control)
Definition vsf_tgui_dynamic.c:101