mGNCS API Reference  v1.2.0
A new control set and a new framework for MiniGUI apps
mdatabinding.h
Go to the documentation of this file.
1 
42 #ifndef MINICTRL_DATA_BINDING_H
43 #define MINICTRL_DATA_BINDING_H
44 
45 #ifdef __cplusplus
46 extern "C"{
47 #endif
48 
49 typedef struct _mBindPropClass mBindPropClass;
50 #ifndef BIND_PROP
51 #define BIND_PROP
52 typedef struct _mBindProp mBindProp;
53 #endif
54 
55 #define mBindPropClassHeader(clss, superCls) \
56  mObjectClassHeader(clss, superCls) \
57  DWORD (* get)(clss *); \
58  BOOL (* set)(clss *, DWORD newdata);
59 
60 struct _mBindPropClass{
61  mBindPropClassHeader(mBindProp, mObject)
62 };
63 
64 MGNCS_EXPORT extern mBindPropClass g_stmBindPropCls;
65 
66 typedef struct _mBindPropListNode{
67  mBindProp * p;
68  struct _mBindPropListNode * next;
69 }mBindPropListNode;
70 
71 #define NCS_PROP_FLAG_READ 0x01
72 #define NCS_PROP_FLAG_WRITE 0x02
73 #define mBindPropHeader(clss) \
74  mObjectHeader(clss) \
75  int read:1; \
76  int write:1; \
77  int vtype:14; \
78  int ref:16; \
79  mBindPropListNode * listens; \
80  mBindProp * next;
81 
82 #define MAKE_BINDPROP_INFO(br, bw, type) \
83  (((br)?NCS_PROP_FLAG_READ:0)|((bw)?NCS_PROP_FLAG_WRITE:0)|((type)<<16))
84 
85 struct _mBindProp{
86  mBindPropHeader(mBindProp)
87 };
89 MGNCS_EXPORT void ncsBindPropRasieChanged(mBindProp *bprop);
90 
91 MGNCS_EXPORT int ncsBindPropAddRef(mBindProp *bprop);
92 MGNCS_EXPORT int ncsBindPropRelease(mBindProp *bprop);
93 MGNCS_EXPORT void ncsBindPropAutoRelfect(mBindProp *bprop);
94 
95 MGNCS_EXPORT BOOL ncsConnectBindProps(mBindProp * psource, mBindProp* plistener, int type);
96 
97 enum ncsBindPropType{
98  NCS_BPT_SINGLE = 0,
99  NCS_BPT_DBL
100 };
101 
103 MGNCS_EXPORT BOOL ncsAutoReflectObjectBindProps(mObject * obj);
104 MGNCS_EXPORT BOOL ncsRemoveObjectBindProps(mObject *obj);
105 
106 MGNCS_EXPORT BOOL ncsAddObjectBindProps(mObject *obj, mBindProp *bprop);
107 
108 typedef BOOL (*NCS_TEST_BINDPROP)(mBindProp*, void *param);
109 typedef mBindProp* (*NCS_NEW_BINDPROP)(void* param);
110 
111 MGNCS_EXPORT mBindProp* ncsRegisterBindProp(mObject* obj,
112  NCS_TEST_BINDPROP test_exist,
113  NCS_NEW_BINDPROP new_prop,
114  void *param);
115 
116 typedef BOOL (*NCS_RAISE_TEST)(mBindProp* prop, DWORD param);
117 MGNCS_EXPORT void ncsRaiseObjectBindProps(mObject *obj, NCS_RAISE_TEST raise_test, DWORD param);
118 
120 MGNCS_EXPORT void *ncsNewBindPropsObjGroup(void);
121 MGNCS_EXPORT void ncsDeleteBindPropsGroup(void*);
122 MGNCS_EXPORT void ncsAutoReflexBindPropsGroup(void* group);
123 MGNCS_EXPORT void ncsAddBindPropsObj(void *group, mObject *obj);
124 
126 // component
127 
128 typedef struct _mCompBindPropClass mCompBindPropClass;
129 typedef struct _mCompBindProp mCompBindProp;
130 
131 #define mCompBindPropClassHeader(clss, superCls) \
132  mBindPropClassHeader(clss, superCls)
133 
134 struct _mCompBindPropClass{
135  mCompBindPropClassHeader(mCompBindProp, mBindProp)
136 };
137 
138 MGNCS_EXPORT extern mCompBindPropClass g_stmCompBindPropCls;
139 
140 #define mCompBindPropHeader(clss) \
141  mBindPropHeader(clss) \
142  mComponent * host; \
143  int prop_id; \
144  int event_id;
145 
146 struct _mCompBindProp{
147  mCompBindPropHeader(mCompBindProp)
148 };
149 
150 
151 MGNCS_EXPORT void ncsRaiseComponentBindProps(mComponent *comp, int event_id);
152 
153 MGNCS_EXPORT mBindProp * ncsRegisterComponentBindProp(mComponent* comp, int event_id, int prop_id, int data_type, DWORD flags);
154 #define NCS_CMPT_PROP(comp, event_id, prop_id, data_type, flags) \
155  ncsRegisterComponentBindProp((mComponent*)(comp), (event_id), (prop_id), (data_type), flags)
156 
157 
159 // simple value data
160 
161 typedef struct _mVariableBindPropClass mVariableBindPropClass;
162 typedef struct _mVariableBindProp mVariableBindProp;
163 
164 #define mVariableBindPropClassHeader(clss, super) \
165  mBindPropClassHeader(clss, super)
166 
167 struct _mVariableBindPropClass{
168  mVariableBindPropClassHeader(mVariableBindProp, mBindProp)
169 };
170 
171 MGNCS_EXPORT extern mVariableBindPropClass g_stmVariableBindPropCls;
172 
173 #define mVariableBindPropHeader(clss) \
174  mBindPropHeader(clss) \
175  void *p;
176 
177 struct _mVariableBindProp{
178  mVariableBindPropHeader(mVariableBindProp)
179 };
180 
181 #define _SET_VAR(type, left, right) \
182  *((type*)(left)) = ((type)(right))
183 
184 
185 MGNCS_EXPORT mBindProp * ncsRegisterVariableBindProp(void *pvalue, int data_type, DWORD flags);
186 #define VAR_PROP(value, data_type, flags) \
187  ncsRegisterVariableBindProp((void*)(&(value)), (data_type), (flags))
188 
189 #define INT_PROP(value, flags) VAR_PROP(value, NCS_BT_INT, flags)
190 #define STRPTR_PROP(value, flags) VAR_PROP(value, NCS_BT_STR_PTR, flags)
191 
192 #define ncsRaiseVariableBindProp(pvalue) \
193  ncsRaiseObjectBindProps((mObject*)(pvalue),NULL, 0)
194 
195 
196 MGNCS_EXPORT BOOL ncsInitDataBinding(void);
197 
198 #ifdef __cplusplus
199 }
200 #endif
201 
202 #endif
203 
the Object struct
the component member define