ui/common/document.c

changeset 33
458831c574f4
parent 3
c1a75454b444
child 37
56016468753d
--- a/ui/common/document.c	Sat Apr 12 13:44:53 2014 +0200
+++ b/ui/common/document.c	Sat May 10 15:43:22 2014 +0200
@@ -248,6 +248,32 @@
             break;
         }
         case UI_VAR_STRING: {
+            // TODO
+            break;
+        }
+        case UI_VAR_TEXT: {
+            UiText *f = from->value;
+            UiText *t = to->value;
+            char *tvalue = t->value;
+            memcpy(t, f, sizeof(UiText));
+            if(set) {
+                t->set(t, tvalue);
+            } else {
+                f->value = f->get(f);
+            }
+            break;
+        }
+        case UI_VAR_LIST: {
+            UiListVar *f = from->value;
+            UiListVar *t = to->value;
+            UiList *list = t->listptr->list;
+            UiObserver *observers = f->listptr->list->observers;
+            t->listptr = f->listptr;
+            if(set) {
+                t->listptr->list = list;
+                list->observers = observers;
+                ui_notify(observers, list);
+            }
             break;
         }
     }
@@ -261,3 +287,14 @@
     uic_document_regvar(doc, name, UI_VAR_INTEGER, sizeof(UiInteger), i);
 }
 
+void ui_document_regtext(void *doc, char *name, UiText *text) {
+    uic_document_regvar(doc, name, UI_VAR_TEXT, sizeof(UiText), text);
+}
+
+void ui_document_reglist(void *doc, char *name, UiList *list) {
+    UiListVar *lv = ui_document_malloc(doc, sizeof(UiListVar));
+    UiListPtr *lp = ui_document_malloc(doc, sizeof(UiListPtr));
+    lv->listptr = lp;
+    lp->list = list;
+    uic_document_regvar(doc, name, UI_VAR_LIST, sizeof(UiListPtr), lv);
+}

mercurial