ui/common/context.h

changeset 108
77254bd6dccb
parent 103
6606616eca9f
child 110
c00e968d018b
equal deleted inserted replaced
107:b34bd1557c6c 108:77254bd6dccb
38 38
39 #ifdef __cplusplus 39 #ifdef __cplusplus
40 extern "C" { 40 extern "C" {
41 #endif 41 #endif
42 42
43 typedef struct UiVar UiVar; 43 typedef struct UiVar UiVar;
44 typedef struct UiListPtr UiListPtr; 44 typedef struct UiListPtr UiListPtr;
45 typedef struct UiListVar UiListVar; 45 typedef struct UiListVar UiListVar;
46 typedef struct UiGroupWidget UiGroupWidget; 46 typedef struct UiGroupWidget UiGroupWidget;
47 typedef struct UiDestroyHandler UiDestroyHandler;
47 48
48 typedef enum UiVarType { 49 typedef enum UiVarType {
49 UI_VAR_SPECIAL = 0, 50 UI_VAR_SPECIAL = 0,
50 UI_VAR_INTEGER, 51 UI_VAR_INTEGER,
51 UI_VAR_DOUBLE, 52 UI_VAR_DOUBLE,
59 struct UiContext { 60 struct UiContext {
60 UiContext *parent; 61 UiContext *parent;
61 UiObject *obj; 62 UiObject *obj;
62 CxMempool *mp; 63 CxMempool *mp;
63 const CxAllocator *allocator; 64 const CxAllocator *allocator;
65 CxList *destroy_handler;
64 66
65 void *document; 67 void *document;
66 CxList *documents; 68 CxList *documents;
67 69
68 CxMap *vars; // manually created context vars 70 CxMap *vars; // manually created context vars
91 }; 93 };
92 94
93 // UiVar replacement, rename it to UiVar when finished 95 // UiVar replacement, rename it to UiVar when finished
94 struct UiVar { 96 struct UiVar {
95 void *value; 97 void *value;
98 void *original_value;
96 UiVarType type; 99 UiVarType type;
97 UiVar *from; 100 UiVar *from;
98 UiContext *from_ctx; 101 UiContext *from_ctx;
99 }; 102 };
100 103
101 struct UiGroupWidget { 104 struct UiGroupWidget {
102 void *widget; 105 void *widget;
103 ui_enablefunc enable; 106 ui_enablefunc enable;
104 int *groups; 107 int *groups;
105 int numgroups; 108 int numgroups;
106 }; 109 };
107 110
111 struct UiDestroyHandler {
112 cx_destructor_func destructor;
113 void *data;
114 };
115
108 116
109 void uic_init_global_context(void); 117 void uic_init_global_context(void);
110 118
111 UiContext* uic_context(UiObject *toplevel, CxMempool *mp); 119 UiContext* uic_context(UiObject *toplevel, CxMempool *mp);
112 UiContext* uic_root_context(UiContext *ctx); 120 UiContext* uic_root_context(UiContext *ctx);
113 void uic_context_set_document(UiContext *ctx, void *document); // deprecated 121 void uic_context_add_destructor(UiContext *ctx, cx_destructor_func func, void *data);
114 void uic_context_detach_document(UiContext *ctx); // deprecated
115 122
116 void uic_context_prepare_close(UiContext *ctx); 123 void uic_context_prepare_close(UiContext *ctx);
117 124
118 void uic_context_attach_document(UiContext *ctx, void *document); 125 void uic_context_attach_document(UiContext *ctx, void *document);
119 void uic_context_detach_document2(UiContext *ctx, void *document); 126 void uic_context_detach_document(UiContext *ctx, void *document);
127 void uic_context_attach_context(UiContext *ctx, UiContext *doc_ctx); // TODO
128 void uic_context_detach_context(UiContext *ctx, UiContext *doc_ctx); // TODO
120 void uic_context_detach_all(UiContext *ctx); 129 void uic_context_detach_all(UiContext *ctx);
121 130
122 UiVar* uic_get_var(UiContext *ctx, const char *name); 131 UiVar* uic_get_var(UiContext *ctx, const char *name);
123 UiVar* uic_create_var(UiContext *ctx, const char *name, UiVarType type); 132 UiVar* uic_create_var(UiContext *ctx, const char *name, UiVarType type);
124 UiVar* uic_create_value_var(UiContext *ctx, void *value); 133 UiVar* uic_create_value_var(UiContext *ctx, void *value);
128 137
129 void uic_copy_binding(UiVar *from, UiVar *to, UiBool copytodoc); 138 void uic_copy_binding(UiVar *from, UiVar *to, UiBool copytodoc);
130 void uic_save_var2(UiVar *var); 139 void uic_save_var2(UiVar *var);
131 void uic_unbind_var(UiVar *var); 140 void uic_unbind_var(UiVar *var);
132 141
133 void uic_reg_var(UiContext *ctx, char *name, UiVarType type, void *value); 142 void uic_reg_var(UiContext *ctx, const char *name, UiVarType type, void *value);
134 143
135 void uic_remove_bound_var(UiContext *ctx, UiVar *var); 144 void uic_remove_bound_var(UiContext *ctx, UiVar *var);
136 145
137 size_t uic_group_array_size(const int *groups); 146 size_t uic_group_array_size(const int *groups);
138 void uic_check_group_widgets(UiContext *ctx); 147 void uic_check_group_widgets(UiContext *ctx);

mercurial