80 doc->t1 = ui_string_new(ctx, "t1"); |
82 doc->t1 = ui_string_new(ctx, "t1"); |
81 doc->t2 = ui_string_new(ctx, "t2"); |
83 doc->t2 = ui_string_new(ctx, "t2"); |
82 doc->t3 = ui_string_new(ctx, "t3"); |
84 doc->t3 = ui_string_new(ctx, "t3"); |
83 |
85 |
84 doc->i = ui_int_new(ctx, "int"); |
86 doc->i = ui_int_new(ctx, "int"); |
|
87 doc->d = ui_double_new(ctx, "d"); |
|
88 doc->r = ui_range_new(ctx, "r"); |
85 return doc; |
89 return doc; |
86 } |
90 } |
87 |
91 |
88 void action_newdoc(UiEvent *event, void *data) { |
92 void action_newdoc(UiEvent *event, void *data) { |
89 printf("new doc\n"); |
93 printf("new doc\n"); |
93 ui_set_document(event->obj, newd); |
97 ui_set_document(event->obj, newd); |
94 } |
98 } |
95 |
99 |
96 void observ(UiEvent *event, void *data) { |
100 void observ(UiEvent *event, void *data) { |
97 printf("observ: %s\n", (char*)data); |
101 printf("observ: %s\n", (char*)data); |
|
102 } |
|
103 |
|
104 void doublechanged(UiEvent *event, void *data) { |
|
105 UiDouble *d = event->eventdata; |
|
106 printf("d: %f\n", (float)d->get(d)); |
98 } |
107 } |
99 |
108 |
100 void application_startup(UiEvent *event, void *data) { |
109 void application_startup(UiEvent *event, void *data) { |
101 //Document *doc = create_doc(); |
110 //Document *doc = create_doc(); |
102 d1 = create_doc(); |
111 d1 = create_doc(); |
112 |
121 |
113 ui_textfield_nv(obj, "t1"); |
122 ui_textfield_nv(obj, "t1"); |
114 ui_textarea_nv(obj, "text"); |
123 ui_textarea_nv(obj, "text"); |
115 d1->t1->observers = ui_add_observer(d1->t1->observers, observ, "t1"); |
124 d1->t1->observers = ui_add_observer(d1->t1->observers, observ, "t1"); |
116 d1->text->observers = ui_add_observer(d1->text->observers, observ, "text"); |
125 d1->text->observers = ui_add_observer(d1->text->observers, observ, "text"); |
|
126 |
|
127 //ui_spinner_setrange(ui_spinnerf_nv(obj, 1, 0, "d"), 0, 1000); |
|
128 ui_spinnerr_nv(obj, "r"); |
|
129 d1->r->setrange(d1->r, 0, 10); |
|
130 d1->r->setextent(d1->r, 1); |
|
131 d1->d->observers = ui_add_observer(d1->d->observers, doublechanged, NULL); |
117 |
132 |
118 ui_button(obj, "Switch Document", action_newdoc, NULL); |
133 ui_button(obj, "Switch Document", action_newdoc, NULL); |
119 |
134 |
120 ui_show(obj); |
135 ui_show(obj); |
121 } |
136 } |