mGNCS API Reference  v1.5.0
A new control set and a new framework for MiniGUI apps
mdatabinding.h
Go to the documentation of this file.
1 //
3 // IMPORTANT NOTICE
4 //
5 // The following open source license statement does not apply to any
6 // entity in the Exception List published by FMSoft.
7 //
8 // For more information, please visit:
9 //
10 // https://www.fmsoft.cn/exception-list
11 //
13 
54 #ifndef MINICTRL_DATA_BINDING_H
55 #define MINICTRL_DATA_BINDING_H
56 
57 #ifdef __cplusplus
58 extern "C"{
59 #endif
60 
61 typedef struct _mBindPropClass mBindPropClass;
62 #ifndef BIND_PROP
63 #define BIND_PROP
64 typedef struct _mBindProp mBindProp;
65 #endif
66 
67 #define mBindPropClassHeader(clss, superCls) \
68  mObjectClassHeader(clss, superCls) \
69  DWORD (* get)(clss *); \
70  BOOL (* set)(clss *, DWORD newdata);
71 
72 struct _mBindPropClass{
73  mBindPropClassHeader(mBindProp, mObject)
74 };
75 
76 MGNCS_EXPORT extern mBindPropClass g_stmBindPropCls;
77 
78 typedef struct _mBindPropListNode{
79  mBindProp * p;
80  struct _mBindPropListNode * next;
81 }mBindPropListNode;
82 
83 #define NCS_PROP_FLAG_READ 0x01
84 #define NCS_PROP_FLAG_WRITE 0x02
85 #define mBindPropHeader(clss) \
86  mObjectHeader(clss) \
87  int read:1; \
88  int write:1; \
89  int vtype:14; \
90  int ref:16; \
91  mBindPropListNode * listens; \
92  mBindProp * next;
93 
94 #define MAKE_BINDPROP_INFO(br, bw, type) \
95  (((br)?NCS_PROP_FLAG_READ:0)|((bw)?NCS_PROP_FLAG_WRITE:0)|((type)<<16))
96 
97 struct _mBindProp{
98  mBindPropHeader(mBindProp)
99 };
101 MGNCS_EXPORT void ncsBindPropRasieChanged(mBindProp *bprop);
102 
103 MGNCS_EXPORT int ncsBindPropAddRef(mBindProp *bprop);
104 MGNCS_EXPORT int ncsBindPropRelease(mBindProp *bprop);
105 MGNCS_EXPORT void ncsBindPropAutoRelfect(mBindProp *bprop);
106 
107 MGNCS_EXPORT BOOL ncsConnectBindProps(mBindProp * psource, mBindProp* plistener, int type);
108 
109 enum ncsBindPropType{
110  NCS_BPT_SINGLE = 0,
111  NCS_BPT_DBL
112 };
113 
115 MGNCS_EXPORT BOOL ncsAutoReflectObjectBindProps(mObject * obj);
116 MGNCS_EXPORT BOOL ncsRemoveObjectBindProps(mObject *obj);
117 
118 MGNCS_EXPORT BOOL ncsAddObjectBindProps(mObject *obj, mBindProp *bprop);
119 
120 typedef BOOL (*NCS_TEST_BINDPROP)(mBindProp*, void *param);
121 typedef mBindProp* (*NCS_NEW_BINDPROP)(void* param);
122 
123 MGNCS_EXPORT mBindProp* ncsRegisterBindProp(mObject* obj,
124  NCS_TEST_BINDPROP test_exist,
125  NCS_NEW_BINDPROP new_prop,
126  void *param);
127 
128 typedef BOOL (*NCS_RAISE_TEST)(mBindProp* prop, DWORD param);
129 MGNCS_EXPORT void ncsRaiseObjectBindProps(mObject *obj, NCS_RAISE_TEST raise_test, DWORD param);
130 
132 MGNCS_EXPORT void *ncsNewBindPropsObjGroup(void);
133 MGNCS_EXPORT void ncsDeleteBindPropsGroup(void*);
134 MGNCS_EXPORT void ncsAutoReflexBindPropsGroup(void* group);
135 MGNCS_EXPORT void ncsAddBindPropsObj(void *group, mObject *obj);
136 
138 // component
139 
140 typedef struct _mCompBindPropClass mCompBindPropClass;
141 typedef struct _mCompBindProp mCompBindProp;
142 
143 #define mCompBindPropClassHeader(clss, superCls) \
144  mBindPropClassHeader(clss, superCls)
145 
146 struct _mCompBindPropClass{
147  mCompBindPropClassHeader(mCompBindProp, mBindProp)
148 };
149 
150 MGNCS_EXPORT extern mCompBindPropClass g_stmCompBindPropCls;
151 
152 #define mCompBindPropHeader(clss) \
153  mBindPropHeader(clss) \
154  mComponent * host; \
155  int prop_id; \
156  int event_id;
157 
158 struct _mCompBindProp{
159  mCompBindPropHeader(mCompBindProp)
160 };
161 
162 
163 MGNCS_EXPORT void ncsRaiseComponentBindProps(mComponent *comp, int event_id);
164 
165 MGNCS_EXPORT mBindProp * ncsRegisterComponentBindProp(mComponent* comp, int event_id, int prop_id, int data_type, DWORD flags);
166 #define NCS_CMPT_PROP(comp, event_id, prop_id, data_type, flags) \
167  ncsRegisterComponentBindProp((mComponent*)(comp), (event_id), (prop_id), (data_type), flags)
168 
169 
171 // simple value data
172 
173 typedef struct _mVariableBindPropClass mVariableBindPropClass;
174 typedef struct _mVariableBindProp mVariableBindProp;
175 
176 #define mVariableBindPropClassHeader(clss, super) \
177  mBindPropClassHeader(clss, super)
178 
179 struct _mVariableBindPropClass{
180  mVariableBindPropClassHeader(mVariableBindProp, mBindProp)
181 };
182 
183 MGNCS_EXPORT extern mVariableBindPropClass g_stmVariableBindPropCls;
184 
185 #define mVariableBindPropHeader(clss) \
186  mBindPropHeader(clss) \
187  void *p;
188 
189 struct _mVariableBindProp{
190  mVariableBindPropHeader(mVariableBindProp)
191 };
192 
193 #define _SET_VAR(type, left, right) \
194  *((type*)(left)) = ((type)(right))
195 
196 
197 MGNCS_EXPORT mBindProp * ncsRegisterVariableBindProp(void *pvalue, int data_type, DWORD flags);
198 #define VAR_PROP(value, data_type, flags) \
199  ncsRegisterVariableBindProp((void*)(&(value)), (data_type), (flags))
200 
201 #define INT_PROP(value, flags) VAR_PROP(value, NCS_BT_INT, flags)
202 #define STRPTR_PROP(value, flags) VAR_PROP(value, NCS_BT_STR_PTR, flags)
203 
204 #define ncsRaiseVariableBindProp(pvalue) \
205  ncsRaiseObjectBindProps((mObject*)(pvalue),NULL, 0)
206 
207 
208 MGNCS_EXPORT BOOL ncsInitDataBinding(void);
209 
210 #ifdef __cplusplus
211 }
212 #endif
213 
214 #endif
215 
mComponent
the component member define
mObject
the Object struct