ui/common/context.h

changeset 115
e57ca2747782
parent 110
c00e968d018b
equal deleted inserted replaced
114:3da24640513a 115:e57ca2747782
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 UiStateWidget UiStateWidget;
47 typedef struct UiDestroyHandler UiDestroyHandler; 47 typedef struct UiDestroyHandler UiDestroyHandler;
48 48
49 typedef enum UiVarType { 49 typedef enum UiVarType {
50 UI_VAR_SPECIAL = 0, 50 UI_VAR_SPECIAL = 0,
51 UI_VAR_INTEGER, 51 UI_VAR_INTEGER,
67 void *document; 67 void *document;
68 CxList *documents; 68 CxList *documents;
69 69
70 CxMap *vars; 70 CxMap *vars;
71 71
72 CxList *groups; // int list 72 CxList *states; // int list
73 CxList *group_widgets; // UiGroupWidget list 73 CxList *state_widgets; // UiGroupWidget list
74 74
75 void (*attach_document)(UiContext *ctx, void *document); 75 void (*attach_document)(UiContext *ctx, void *document);
76 void (*detach_document2)(UiContext *ctx, void *document); 76 void (*detach_document2)(UiContext *ctx, void *document);
77 77
78 char *title; 78 char *title;
82 GActionMap *action_map; 82 GActionMap *action_map;
83 #elif UI_GTK2 || UI_GTK3 83 #elif UI_GTK2 || UI_GTK3
84 GtkAccelGroup *accel_group; 84 GtkAccelGroup *accel_group;
85 #endif 85 #endif
86 #endif 86 #endif
87 87
88 88 // allow only one document to be attached
89 // attaching a document will automatically detach the current document
90 UiBool single_document_mode;
89 91
90 ui_callback close_callback; 92 ui_callback close_callback;
91 void *close_data; 93 void *close_data;
92 }; 94 };
93 95
95 void *value; 97 void *value;
96 void *original_value; 98 void *original_value;
97 UiVarType type; 99 UiVarType type;
98 UiVar *from; 100 UiVar *from;
99 UiContext *from_ctx; 101 UiContext *from_ctx;
102 UiBool bound;
100 }; 103 };
101 104
102 struct UiGroupWidget { 105 struct UiStateWidget {
103 void *widget; 106 void *widget;
104 ui_enablefunc enable; 107 ui_enablefunc enable;
105 int *groups; 108 int *states;
106 int numgroups; 109 int numstates;
107 }; 110 };
108 111
109 struct UiDestroyHandler { 112 struct UiDestroyHandler {
110 cx_destructor_func destructor; 113 cx_destructor_func destructor;
111 void *data; 114 void *data;
125 void uic_context_attach_context(UiContext *ctx, UiContext *doc_ctx); // TODO 128 void uic_context_attach_context(UiContext *ctx, UiContext *doc_ctx); // TODO
126 void uic_context_detach_context(UiContext *ctx, UiContext *doc_ctx); // TODO 129 void uic_context_detach_context(UiContext *ctx, UiContext *doc_ctx); // TODO
127 void uic_context_detach_all(UiContext *ctx); 130 void uic_context_detach_all(UiContext *ctx);
128 131
129 UiVar* uic_get_var(UiContext *ctx, const char *name); 132 UiVar* uic_get_var(UiContext *ctx, const char *name);
133 UiVar* uic_get_var_t(UiContext *ctx, const char *name, UiVarType type);
130 UiVar* uic_create_var(UiContext *ctx, const char *name, UiVarType type); 134 UiVar* uic_create_var(UiContext *ctx, const char *name, UiVarType type);
131 UiVar* uic_create_value_var(UiContext *ctx, void *value); 135 UiVar* uic_create_value_var(UiContext *ctx, void *value);
132 void* uic_create_value(UiContext *ctx, UiVarType type); 136 void* uic_create_value(UiContext *ctx, UiVarType type);
137 void uic_destroy_value(UiContext *ctx, UiVarType type, void *value);
133 138
134 UiVar* uic_widget_var(UiContext *toplevel, UiContext *current, void *value, const char *varname, UiVarType type); 139 UiVar* uic_widget_var(UiContext *toplevel, UiContext *current, void *value, const char *varname, UiVarType type);
135 140
136 void uic_copy_binding(UiVar *from, UiVar *to, UiBool copytodoc); 141 void uic_copy_var_binding(UiVar *from, UiVar *to, UiBool copytodoc);
142 void uic_copy_value_binding(UiVarType type, void *from, void *to);
137 void uic_save_var(UiVar *var); 143 void uic_save_var(UiVar *var);
138 void uic_unbind_var(UiVar *var); 144 void uic_unbind_var(UiVar *var);
145 const char *uic_type2str(UiVarType type);
139 146
140 void uic_reg_var(UiContext *ctx, const char *name, UiVarType type, void *value); 147 void uic_reg_var(UiContext *ctx, const char *name, UiVarType type, void *value);
141 148
142 void uic_remove_bound_var(UiContext *ctx, UiVar *var); 149 size_t uic_state_array_size(const int *states);
143 150 void uic_check_state_widgets(UiContext *ctx);
144 size_t uic_group_array_size(const int *groups); 151 void uic_add_state_widget(UiContext *ctx, void *widget, ui_enablefunc enable, CxList *states);
145 void uic_check_group_widgets(UiContext *ctx); 152 void uic_add_state_widget_i(UiContext *ctx, void *widget, ui_enablefunc enable, const int *states, size_t numstates);
146 void uic_add_group_widget(UiContext *ctx, void *widget, ui_enablefunc enable, CxList *groups); 153 void uic_remove_state_widget(UiContext *ctx, void *widget);
147 void uic_add_group_widget_i(UiContext *ctx, void *widget, ui_enablefunc enable, const int *groups, size_t numgroups);
148 void uic_remove_group_widget(UiContext *ctx, void *widget);
149 154
150 #ifdef __cplusplus 155 #ifdef __cplusplus
151 } 156 }
152 #endif 157 #endif
153 158

mercurial