application/main.c

branch
newapi
changeset 266
37d5b49b1c91
parent 265
3756725aeaf4
child 267
79dd183dd4cb
equal deleted inserted replaced
265:3756725aeaf4 266:37d5b49b1c91
34 #include <cx/utils.h> 34 #include <cx/utils.h>
35 35
36 typedef struct { 36 typedef struct {
37 UiString *str1; 37 UiString *str1;
38 UiString *str2; 38 UiString *str2;
39 UiDouble *progress;
39 } MyDocument; 40 } MyDocument;
40 41
41 MyDocument *doc1; 42 MyDocument *doc1;
42 MyDocument *doc2; 43 MyDocument *doc2;
43 44
58 MyDocument* create_doc(void) { 59 MyDocument* create_doc(void) {
59 MyDocument *doc = ui_document_new(sizeof(MyDocument)); 60 MyDocument *doc = ui_document_new(sizeof(MyDocument));
60 UiContext *docctx = ui_document_context(doc); 61 UiContext *docctx = ui_document_context(doc);
61 doc->str1 = ui_string_new(docctx, "str1"); 62 doc->str1 = ui_string_new(docctx, "str1");
62 doc->str1 = ui_string_new(docctx, "str2"); 63 doc->str1 = ui_string_new(docctx, "str2");
64 doc->progress = ui_double_new(docctx, "progress");
63 return doc; 65 return doc;
64 } 66 }
65 67
66 void application_startup(UiEvent *event, void *data) { 68 void application_startup(UiEvent *event, void *data) {
67 69
68 UiObject *obj = ui_window("Test", NULL); 70 UiObject *obj = ui_window("Test", NULL);
69 71
72 MyDocument *doc = create_doc();
73 ui_attach_document(obj->ctx, doc);
74
70 ui_button(obj, .label = "Test Button", .icon = "application-x-generic"); 75 ui_button(obj, .label = "Test Button", .icon = "application-x-generic");
71 ui_togglebutton(obj, .label = "Toggle"); 76 ui_togglebutton(obj, .label = "Toggle");
72 ui_checkbox(obj, .label = "Checkbox"); 77 ui_checkbox(obj, .label = "Checkbox");
73 78
74 ui_grid(obj, .fill = 1) { 79 ui_grid(obj, .fill = 1, .spacing = 5) {
75 ui_button(obj, .label = "cell1", .hexpand = TRUE); 80 ui_button(obj, .label = "cell1", .hexpand = TRUE);
76 ui_button(obj, .label = "cell2"); 81 ui_button(obj, .label = "cell2");
77 ui_newline(obj); 82 ui_newline(obj);
78 ui_button(obj, .label = "cell_colspan2", .colspan = 2); 83 ui_button(obj, .label = "cell_colspan2", .colspan = 2);
79 ui_newline(obj); 84 ui_newline(obj);
81 ui_label(obj, .label = "Label Col 1", .align = UI_ALIGN_LEFT); 86 ui_label(obj, .label = "Label Col 1", .align = UI_ALIGN_LEFT);
82 ui_label(obj, .label = "Label Col 2", .align = UI_ALIGN_RIGHT); 87 ui_label(obj, .label = "Label Col 2", .align = UI_ALIGN_RIGHT);
83 ui_newline(obj); 88 ui_newline(obj);
84 89
85 ui_spinner(obj, .step = 5); 90 ui_spinner(obj, .step = 5);
91 ui_newline(obj);
86 92
93 ui_progressbar(obj, .colspan = 2, .varname = "progress");
94 ui_set(doc->progress, 0.75);
87 } 95 }
88 96
89 ui_show(obj); 97 ui_show(obj);
90 } 98 }
91 99

mercurial