00001
00002 #ifndef MINICTRL_DATA_BINDING_H
00003 #define MINICTRL_DATA_BINDING_H
00004
00005 #ifdef __cplusplus
00006 extern "C"{
00007 #endif
00008
00009 typedef struct _mBindPropClass mBindPropClass;
00010 #ifndef BIND_PROP
00011 #define BIND_PROP
00012 typedef struct _mBindProp mBindProp;
00013 #endif
00014
00015 #define mBindPropClassHeader(clss, superCls) \
00016 mObjectClassHeader(clss, superCls) \
00017 DWORD (* get)(clss *); \
00018 BOOL (* set)(clss *, DWORD newdata);
00019
00020 struct _mBindPropClass{
00021 mBindPropClassHeader(mBindProp, mObject)
00022 };
00023
00024 MGNCS_EXPORT extern mBindPropClass g_stmBindPropCls;
00025
00026 typedef struct _mBindPropListNode{
00027 mBindProp * p;
00028 struct _mBindPropListNode * next;
00029 }mBindPropListNode;
00030
00031 #define NCS_PROP_FLAG_READ 0x01
00032 #define NCS_PROP_FLAG_WRITE 0x02
00033 #define mBindPropHeader(clss) \
00034 mObjectHeader(clss) \
00035 int read:1; \
00036 int write:1; \
00037 int vtype:14; \
00038 int ref:16; \
00039 mBindPropListNode * listens; \
00040 mBindProp * next;
00041
00042 #define MAKE_BINDPROP_INFO(br, bw, type) \
00043 (((br)?NCS_PROP_FLAG_READ:0)|((bw)?NCS_PROP_FLAG_WRITE:0)|((type)<<16))
00044
00045 struct _mBindProp{
00046 mBindPropHeader(mBindProp)
00047 };
00049 MGNCS_EXPORT void ncsBindPropRasieChanged(mBindProp *bprop);
00050
00051 MGNCS_EXPORT int ncsBindPropAddRef(mBindProp *bprop);
00052 MGNCS_EXPORT int ncsBindPropRelease(mBindProp *bprop);
00053 MGNCS_EXPORT void ncsBindPropAutoRelfect(mBindProp *bprop);
00054
00055 MGNCS_EXPORT BOOL ncsConnectBindProps(mBindProp * psource, mBindProp* plistener, int type);
00056
00057 enum ncsBindPropType{
00058 NCS_BPT_SINGLE = 0,
00059 NCS_BPT_DBL
00060 };
00061
00063 MGNCS_EXPORT BOOL ncsAutoReflectObjectBindProps(mObject * obj);
00064 MGNCS_EXPORT BOOL ncsRemoveObjectBindProps(mObject *obj);
00065
00066 MGNCS_EXPORT BOOL ncsAddObjectBindProps(mObject *obj, mBindProp *bprop);
00067
00068 typedef BOOL (*NCS_TEST_BINDPROP)(mBindProp*, void *param);
00069 typedef mBindProp* (*NCS_NEW_BINDPROP)(void* param);
00070
00071 MGNCS_EXPORT mBindProp* ncsRegisterBindProp(mObject* obj,
00072 NCS_TEST_BINDPROP test_exist,
00073 NCS_NEW_BINDPROP new_prop,
00074 void *param);
00075
00076 typedef BOOL (*NCS_RAISE_TEST)(mBindProp* prop, DWORD param);
00077 MGNCS_EXPORT void ncsRaiseObjectBindProps(mObject *obj, NCS_RAISE_TEST raise_test, DWORD param);
00078
00080 MGNCS_EXPORT void *ncsNewBindPropsObjGroup(void);
00081 MGNCS_EXPORT void ncsDeleteBindPropsGroup(void*);
00082 MGNCS_EXPORT void ncsAutoReflexBindPropsGroup(void* group);
00083 MGNCS_EXPORT void ncsAddBindPropsObj(void *group, mObject *obj);
00084
00086
00087
00088 typedef struct _mCompBindPropClass mCompBindPropClass;
00089 typedef struct _mCompBindProp mCompBindProp;
00090
00091 #define mCompBindPropClassHeader(clss, superCls) \
00092 mBindPropClassHeader(clss, superCls)
00093
00094 struct _mCompBindPropClass{
00095 mCompBindPropClassHeader(mCompBindProp, mBindProp)
00096 };
00097
00098 MGNCS_EXPORT extern mCompBindPropClass g_stmCompBindPropCls;
00099
00100 #define mCompBindPropHeader(clss) \
00101 mBindPropHeader(clss) \
00102 mComponent * host; \
00103 int prop_id; \
00104 int event_id;
00105
00106 struct _mCompBindProp{
00107 mCompBindPropHeader(mCompBindProp)
00108 };
00109
00110
00111 MGNCS_EXPORT void ncsRaiseComponentBindProps(mComponent *comp, int event_id);
00112
00113 MGNCS_EXPORT mBindProp * ncsRegisterComponentBindProp(mComponent* comp, int event_id, int prop_id, int data_type, DWORD flags);
00114 #define NCS_CMPT_PROP(comp, event_id, prop_id, data_type, flags) \
00115 ncsRegisterComponentBindProp((mComponent*)(comp), (event_id), (prop_id), (data_type), flags)
00116
00117
00119
00120
00121 typedef struct _mVariableBindPropClass mVariableBindPropClass;
00122 typedef struct _mVariableBindProp mVariableBindProp;
00123
00124 #define mVariableBindPropClassHeader(clss, super) \
00125 mBindPropClassHeader(clss, super)
00126
00127 struct _mVariableBindPropClass{
00128 mVariableBindPropClassHeader(mVariableBindProp, mBindProp)
00129 };
00130
00131 MGNCS_EXPORT extern mVariableBindPropClass g_stmVariableBindPropCls;
00132
00133 #define mVariableBindPropHeader(clss) \
00134 mBindPropHeader(clss) \
00135 void *p;
00136
00137 struct _mVariableBindProp{
00138 mVariableBindPropHeader(mVariableBindProp)
00139 };
00140
00141 #define _SET_VAR(type, left, right) \
00142 *((type*)(left)) = ((type)(right))
00143
00144
00145 MGNCS_EXPORT mBindProp * ncsRegisterVariableBindProp(void *pvalue, int data_type, DWORD flags);
00146 #define VAR_PROP(value, data_type, flags) \
00147 ncsRegisterVariableBindProp((void*)(&(value)), (data_type), (flags))
00148
00149 #define INT_PROP(value, flags) VAR_PROP(value, NCS_BT_INT, flags)
00150 #define STRPTR_PROP(value, flags) VAR_PROP(value, NCS_BT_STR_PTR, flags)
00151
00152 #define ncsRaiseVariableBindProp(pvalue) \
00153 ncsRaiseObjectBindProps((mObject*)(pvalue),NULL, 0)
00154
00155
00156 MGNCS_EXPORT BOOL ncsInitDataBinding(void);
00157
00158 #ifdef __cplusplus
00159 }
00160 #endif
00161
00162 #endif
00163