--- a/application/main.c Sun Dec 08 11:20:41 2013 +0000 +++ b/application/main.c Fri Mar 21 13:20:53 2014 +0100 @@ -31,6 +31,15 @@ #include <ui/ui.h> +typedef struct TestDocument { + UiInteger check1; +} TestDocument; + +typedef struct TestWindowData { + TestDocument *doc1; + TestDocument *doc2; +} TestWindowData; + UiInteger check1; void action_new(UiEvent *event, void *data) { @@ -40,13 +49,29 @@ } void action_open(UiEvent *event, void *data) { - printf("check1: %s\n", ui_window_getint(event->obj, "check1") ? "true" : "false"); + //printf("check1: %s\n", ui_getint(event->obj, "check1") ? "true" : "false"); + TestDocument *doc = event->document; + printf("check1: %s\n", ui_getval(doc->check1) ? "true" : "false"); } void action_close(UiEvent *event, void *data) { exit(0); } +void action_doc1(UiEvent *event, void *data) { + TestWindowData *wdata = event->window; + if(event->obj->document != wdata->doc1) { + ui_set_document(event->obj, wdata->doc1); + } +} + +void action_doc2(UiEvent *event, void *data) { + TestWindowData *wdata = event->window; + if(event->obj->document != wdata->doc2) { + ui_set_document(event->obj, wdata->doc2); + } +} + int main(int argc, char** argv) { ui_init("app1", argc, argv); @@ -54,12 +79,24 @@ ui_menuitem("New", action_new, NULL); ui_menuitem("Open", action_open, NULL); ui_menuseparator(); + ui_menuitem("Dokument 1", action_doc1, NULL); + ui_menuitem("Dokument 2", action_doc2, NULL); + ui_menuseparator(); ui_checkitem_nv("Check", "check1"); ui_menuitem("Close", action_close, NULL); UiObject *window = ui_window("Mod0", NULL); + TestWindowData *wdata = malloc(sizeof(TestWindowData)); + window->window = wdata; + TestDocument *doc1 = ui_document_new(sizeof(TestDocument)); + TestDocument *doc2 = ui_document_new(sizeof(TestDocument)); + ui_document_regint(doc1, "check1", &doc1->check1); + ui_document_regint(doc2, "check1", &doc2->check1); + wdata->doc1 = doc1; + wdata->doc2 = doc2; + ui_set_document(window, doc1); //ui_window_addint(window, "check1"); ui_show(window);