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#ifdef __cplusplus
26extern "C" {
27#endif
28
29/*============================ MACROS ========================================*/
30/*============================ MACROFIED FUNCTIONS ===========================*/
31
32// heap
33
34#if !defined(VSF_TGUI_HEAP_HEADER) && VSF_USE_HEAP == ENABLED
35# define VSF_TGUI_HEAP_HEADER "service/heap/vsf_heap.h"
36# define vsf_tgui_malloc(__size) vsf_heap_malloc(__size)
37# define vsf_tgui_free(__ptr) vsf_heap_free(__ptr)
38#endif
39
40// control
41
42#define vsf_tgui_control_set_width(__control, __w) \
43 do { \
44 (__control)->tSize.iWidth = (__w); \
45 } while(0)
46
47#define vsf_tgui_control_set_height(__control, __h) \
48 do { \
49 (__control)->tSize.iHeight = (__h); \
50 } while(0)
51
52#define vsf_tui_control_set_size(__control, __w, __h) \
53 do { \
54 (__control)->tSize.iWidth = (__w); \
55 (__control)->tSize.iHeight = (__h); \
56 } while(0)
57
58#define vsf_tgui_control_set_margin(__control, __left, __top, __right, __bottom)\
59 do { \
60 (__control)->tMargin.chLeft = (__left); \
61 (__control)->tMargin.chTop = (__top); \
62 (__control)->tMargin.chRight = (__right); \
63 (__control)->tMargin.chBottom = (__bottom); \
64 } while(0)
65
66#define vsf_control_set_msghandler(__control, __handler, __num) \
67 do { \
68 (__control)->tMSGMap.ptItems = (__handler); \
69 (__control)->tMSGMap.chCount = (__num); \
70 } while (0)
71
72// container
73
74#define vsf_tgui_container_set_type2(__container, __type, __autosize) \
75 do { \
76 (__container)->ContainerAttribute.u5Type = (__type), \
77 (__container)->ContainerAttribute.bIsAutoSize = (__autosize); \
78 } while(0)
79#define vsf_tgui_container_set_type1(__container, __type) \
80 vsf_tgui_container_set_type2((__container), (__type), true)
81// protocol: void vsf_tgui_container_set_type(vsf_tgui_container_t *container, int type, bool autosize = true);
82#define vsf_tgui_container_set_type(__container, ...) \
83 __PLOOC_EVAL(vsf_tgui_container_set_type, __VA_ARGS__)((__container), ##__VA_ARGS__)
84
85/*============================ TYPES =========================================*/
86/*============================ GLOBAL VARIABLES ==============================*/
87/*============================ PROTOTYPES ====================================*/
88
91
92extern void vsf_tgui_control_add(vsf_tgui_container_t *parent, vsf_tgui_control_t *control_prev, vsf_tgui_control_t *control);
93extern void vsf_tgui_control_remove(vsf_tgui_container_t *parent, vsf_tgui_control_t *control);
94extern void vsf_tgui_control_sync(vsf_tgui_container_t *parent, vsf_tgui_control_t *control);
95
96// container
97
98extern vsf_tgui_container_t * vsf_tgui_container_new(char *name);
99
100// label
101
102extern vsf_tgui_label_t * vsf_tgui_label_new(char *name);
103extern void vsf_tgui_label_set_text_static(vsf_tgui_label_t *label, const char *text);
104extern const char * vsf_tgui_label_get_text(vsf_tgui_label_t *label);
105
106// button
107
108extern vsf_tgui_button_t * vsf_tgui_button_new(char *name);
109#define vsf_tgui_button_set_text_static(__button, __text) \
110 vsf_tgui_label_set_text_static((vsf_tgui_label_t *)(__button), (__text))
111
112// list
113
114#define vsf_tgui_list_get_child(__list) \
115 ((vsf_tgui_control_t *) (((vsf_tgui_container_t *)((__list)->node_ptr))->node_ptr) )
116
117#ifdef __cplusplus
118}
119#endif
120
121#endif
122#endif
123/* 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:555
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