ui/common/types.c

changeset 145
853685152c1d
parent 143
d499b29d7cb6
child 146
dd0ae1c62a72
equal deleted inserted replaced
144:29d98cff4f56 145:853685152c1d
221 uic_reg_var(ctx, name, UI_VAR_INTEGER, i); 221 uic_reg_var(ctx, name, UI_VAR_INTEGER, i);
222 } 222 }
223 return i; 223 return i;
224 } 224 }
225 225
226 UiDouble* ui_double_new(UiContext *ctx, char *name) {
227 UiDouble *d = ui_malloc(ctx, sizeof(UiDouble));
228 memset(d, 0, sizeof(UiDouble));
229 if(name) {
230 uic_reg_var(ctx, name, UI_VAR_DOUBLE, d);
231 }
232 return d;
233 }
234
226 UiString* ui_string_new(UiContext *ctx, char *name) { 235 UiString* ui_string_new(UiContext *ctx, char *name) {
227 UiString *s = ui_malloc(ctx, sizeof(UiString)); 236 UiString *s = ui_malloc(ctx, sizeof(UiString));
228 memset(s, 0, sizeof(UiString)); 237 memset(s, 0, sizeof(UiString));
229 if(name) { 238 if(name) {
230 uic_reg_var(ctx, name, UI_VAR_STRING, s); 239 uic_reg_var(ctx, name, UI_VAR_STRING, s);
239 uic_reg_var(ctx, name, UI_VAR_TEXT, t); 248 uic_reg_var(ctx, name, UI_VAR_TEXT, t);
240 } 249 }
241 return t; 250 return t;
242 } 251 }
243 252
253 UiRange* ui_range_new(UiContext *ctx, char *name) {
254 UiRange *r = ui_malloc(ctx, sizeof(UiRange));
255 memset(r, 0, sizeof(UiRange));
256 if(name) {
257 uic_reg_var(ctx, name, UI_VAR_RANGE, r);
258 }
259 return r;
260 }
261
244 262
245 // private functions 263 // private functions
246 void uic_int_copy(UiInteger *from, UiInteger *to) { 264 void uic_int_copy(UiInteger *from, UiInteger *to) {
265 to->get = from->get;
266 to->set = from->set;
267 to->obj = from->obj;
268 }
269
270 void uic_double_copy(UiDouble *from, UiDouble *to) {
247 to->get = from->get; 271 to->get = from->get;
248 to->set = from->set; 272 to->set = from->set;
249 to->obj = from->obj; 273 to->obj = from->obj;
250 } 274 }
251 275
287 void uic_int_save(UiInteger *i) { 311 void uic_int_save(UiInteger *i) {
288 if(!i->obj) return; 312 if(!i->obj) return;
289 i->value = i->get(i); 313 i->value = i->get(i);
290 } 314 }
291 315
316 void uic_double_save(UiDouble *d) {
317 if(!d->obj) return;
318 d->value = d->get(d);
319 }
320
292 void uic_string_save(UiString *s) { 321 void uic_string_save(UiString *s) {
293 if(!s->obj) return; 322 if(!s->obj) return;
294 s->get(s); 323 s->get(s);
295 } 324 }
296 325
308 337
309 void uic_int_unbind(UiInteger *i) { 338 void uic_int_unbind(UiInteger *i) {
310 i->get = NULL; 339 i->get = NULL;
311 i->set = NULL; 340 i->set = NULL;
312 i->obj = NULL; 341 i->obj = NULL;
342 }
343
344 void uic_double_unbind(UiDouble *d) {
345 d->get = NULL;
346 d->set = NULL;
347 d->obj = NULL;
313 } 348 }
314 349
315 void uic_string_unbind(UiString *s) { 350 void uic_string_unbind(UiString *s) {
316 s->get = NULL; 351 s->get = NULL;
317 s->set = NULL; 352 s->set = NULL;

mercurial