Sat, 05 Dec 2020 10:32:49 +0100
Motif: enable xft text rendering by default
0 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
144
29d98cff4f56
UiInteger uses int64 now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
4 | * Copyright 2017 Olaf Wintermann. All rights reserved. |
0 | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions are met: | |
8 | * | |
9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | |
11 | * | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | |
15 | * | |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | |
28 | ||
29 | #include <stdio.h> | |
30 | #include <stdlib.h> | |
31 | ||
32 | #include <ui/ui.h> | |
28
794a5c91c479
added open/save dialogs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
33 | #include <ucx/buffer.h> |
794a5c91c479
added open/save dialogs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
34 | #include <ucx/utils.h> |
0 | 35 | |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
36 | typedef struct Document { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
37 | UiText *text; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
38 | UiString *t1; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
39 | UiString *t2; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
40 | UiString *t3; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
41 | UiInteger *i; |
145
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
144
diff
changeset
|
42 | UiDouble *d; |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
144
diff
changeset
|
43 | UiRange *r; |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
44 | UiList *list; |
149
479209198de3
adds progressbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
45 | UiDouble *progress; |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
46 | } Document; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
47 | |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
48 | typedef struct Entry { |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
49 | char *name; |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
50 | char *desc; |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
51 | } Entry; |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
52 | |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
53 | Document *d1; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
54 | Document *d2; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
55 | int n = 1; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
56 | |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
57 | UiImage *img; |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
58 | |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
59 | Document* create_doc(char *str); |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
60 | |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
61 | Document* next_doc(void) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
62 | Document *doc = d1; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
63 | if(n == 1) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
64 | doc = d2; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
65 | printf("doc2\n"); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
66 | } else { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
67 | printf("doc1\n"); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
68 | } |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
69 | n++; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
70 | n = n%2; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
71 | return doc; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
72 | } |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
73 | |
82
0cdb8089a29f
added event handler for menus (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
81
diff
changeset
|
74 | void action_menu(UiEvent *event, void *data) { |
133
6dd780cbc8c6
using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
75 | printf("action_menu\n"); |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
76 | |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
77 | Document *doc = event->document; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
78 | char *s = doc->text->get(doc->text); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
79 | printf("text: {\n%s\n}\n", s); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
80 | //int i = doc->i->get(doc->i); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
81 | //printf("i: %d\n", i); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
82 | |
137
c9b8b9e0cfe8
adds drawingarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
83 | fflush(stdout); |
118
bb21210e9cac
added scrollbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
84 | } |
bb21210e9cac
added scrollbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
85 | |
147
2e384acc89a6
adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
146
diff
changeset
|
86 | void list_data_get(UiEvent *event, UiSelection *selection, UiList *l, int i) { |
2e384acc89a6
adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
146
diff
changeset
|
87 | ui_selection_settext(selection, "Hello World!", -1); |
2e384acc89a6
adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
146
diff
changeset
|
88 | } |
2e384acc89a6
adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
146
diff
changeset
|
89 | |
2e384acc89a6
adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
146
diff
changeset
|
90 | void list_drop(UiEvent *event, UiSelection *selection, UiList *l, int i) { |
2e384acc89a6
adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
146
diff
changeset
|
91 | char *text = ui_selection_gettext(selection); |
2e384acc89a6
adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
146
diff
changeset
|
92 | printf("dnd drop: {%s}\n", text); |
2e384acc89a6
adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
146
diff
changeset
|
93 | free(text); |
2e384acc89a6
adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
146
diff
changeset
|
94 | } |
2e384acc89a6
adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
146
diff
changeset
|
95 | |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
96 | Document* create_doc(char *str) { |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
97 | Document *doc = ui_document_new(sizeof(Document)); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
98 | UiContext *ctx = ui_document_context(doc); |
137
c9b8b9e0cfe8
adds drawingarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
99 | |
155
b907d8059290
fixes document switching with textareas (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
154
diff
changeset
|
100 | doc->text = ui_text_new(ctx, "text"); |
143
d499b29d7cb6
adds observer support for textarea and textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
101 | doc->t1 = ui_string_new(ctx, "t1"); |
155
b907d8059290
fixes document switching with textareas (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
154
diff
changeset
|
102 | doc->t2 = ui_string_new(ctx, "t2"); |
b907d8059290
fixes document switching with textareas (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
154
diff
changeset
|
103 | doc->t3 = ui_string_new(ctx, "t3"); |
137
c9b8b9e0cfe8
adds drawingarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
104 | |
155
b907d8059290
fixes document switching with textareas (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
154
diff
changeset
|
105 | doc->i = ui_int_new(ctx, "int"); |
b907d8059290
fixes document switching with textareas (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
154
diff
changeset
|
106 | doc->d = ui_double_new(ctx, "d"); |
b907d8059290
fixes document switching with textareas (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
154
diff
changeset
|
107 | doc->r = ui_range_new(ctx, "r"); |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
108 | |
155
b907d8059290
fixes document switching with textareas (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
154
diff
changeset
|
109 | doc->progress = ui_double_new(ctx, "progress"); |
149
479209198de3
adds progressbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
110 | |
155
b907d8059290
fixes document switching with textareas (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
154
diff
changeset
|
111 | doc->list = ui_list_new(ctx, "list"); |
150
5cee4cb5ad79
fixes uic_copy_binding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
149
diff
changeset
|
112 | Entry *e1 = calloc(1, sizeof(Entry)); |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
113 | e1->name = "test"; |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
114 | e1->desc = "test file"; |
150
5cee4cb5ad79
fixes uic_copy_binding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
149
diff
changeset
|
115 | Entry *e2 = calloc(1, sizeof(Entry)); |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
116 | e2->name = str; |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
117 | e2->desc = "important document"; |
155
b907d8059290
fixes document switching with textareas (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
154
diff
changeset
|
118 | ui_list_append(doc->list, e1); |
b907d8059290
fixes document switching with textareas (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
154
diff
changeset
|
119 | ui_list_append(doc->list, e2); |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
120 | |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
121 | return doc; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
122 | } |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
123 | |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
124 | void* model_get(Entry *e, int col) { |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
125 | if(col == 0) { |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
126 | return img; |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
127 | } else if(col == 1) { |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
128 | return e->name; |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
129 | } else if(col == 2) { |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
130 | return e->desc; |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
131 | } |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
132 | return NULL; |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
133 | } |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
134 | |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
135 | void action_newdoc(UiEvent *event, void *data) { |
150
5cee4cb5ad79
fixes uic_copy_binding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
149
diff
changeset
|
136 | printf("new doc;\n "); |
137
c9b8b9e0cfe8
adds drawingarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
137 | |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
138 | Document *newd = next_doc(); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
139 | ui_set_document(event->obj, newd); |
137
c9b8b9e0cfe8
adds drawingarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
140 | } |
127
ce342364fad5
added drawingarea (Cocoa)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
126
diff
changeset
|
141 | |
143
d499b29d7cb6
adds observer support for textarea and textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
142 | void observ(UiEvent *event, void *data) { |
d499b29d7cb6
adds observer support for textarea and textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
143 | printf("observ: %s\n", (char*)data); |
d499b29d7cb6
adds observer support for textarea and textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
144 | } |
d499b29d7cb6
adds observer support for textarea and textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
145 | |
145
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
144
diff
changeset
|
146 | void doublechanged(UiEvent *event, void *data) { |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
144
diff
changeset
|
147 | UiDouble *d = event->eventdata; |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
144
diff
changeset
|
148 | printf("d: %f\n", (float)d->get(d)); |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
144
diff
changeset
|
149 | } |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
144
diff
changeset
|
150 | |
133
6dd780cbc8c6
using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
151 | void application_startup(UiEvent *event, void *data) { |
152
62921b370c60
fixes use after free when a GtkTreeView was destroyed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
151
diff
changeset
|
152 | UiIcon *icon = ui_icon("folder", 16); |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
153 | img = ui_icon_image(icon); |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
154 | if(!img) { |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
155 | fprintf(stderr, "Cannot load folder icon\n"); |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
156 | } |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
157 | |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
158 | //Document *doc = create_doc(); |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
159 | d1 = create_doc("doc1"); |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
160 | d2 = create_doc("doc2"); |
136
1df2fb3d079c
adds gridwidth layout option (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
161 | |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
162 | UiObject *obj = ui_window("Test", NULL); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
163 | ui_set_document(obj, d1); |
137
c9b8b9e0cfe8
adds drawingarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
164 | |
155
b907d8059290
fixes document switching with textareas (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
154
diff
changeset
|
165 | ui_textarea_nv(obj, "text"); |
153
ee49d1852a5f
applies value binding refactoring and text refactoring to motif implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
152
diff
changeset
|
166 | //ui_radiobutton_nv(obj, "1", "int"); |
ee49d1852a5f
applies value binding refactoring and text refactoring to motif implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
152
diff
changeset
|
167 | //ui_radiobutton_nv(obj, "2", "int"); |
ee49d1852a5f
applies value binding refactoring and text refactoring to motif implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
152
diff
changeset
|
168 | //ui_radiobutton_nv(obj, "3", "int"); |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
169 | |
143
d499b29d7cb6
adds observer support for textarea and textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
170 | ui_textfield_nv(obj, "t1"); |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
171 | //ui_textarea_nv(obj, "text"); |
149
479209198de3
adds progressbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
172 | //d1->t1->observers = ui_add_observer(d1->t1->observers, observ, "t1"); |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
173 | //d1->text->observers = ui_add_observer(d1->text->observers, observ, "text"); |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
174 | |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
175 | UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "name", UI_STRING, "desc", -1); |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
176 | model->getvalue = (ui_getvaluefunc)model_get; |
147
2e384acc89a6
adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
146
diff
changeset
|
177 | model->drop = list_drop; |
2e384acc89a6
adds simple drag and drop support (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
146
diff
changeset
|
178 | model->data_get = list_data_get; |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
179 | UiListCallbacks cb = {NULL, NULL, NULL}; |
153
ee49d1852a5f
applies value binding refactoring and text refactoring to motif implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
152
diff
changeset
|
180 | //UIWIDGET table = ui_table_nv(obj, "list", model, cb); |
ee49d1852a5f
applies value binding refactoring and text refactoring to motif implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
152
diff
changeset
|
181 | //ui_table_dragsource(table, 0, "text/plain", NULL); |
143
d499b29d7cb6
adds observer support for textarea and textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
182 | |
145
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
144
diff
changeset
|
183 | //ui_spinner_setrange(ui_spinnerf_nv(obj, 1, 0, "d"), 0, 1000); |
153
ee49d1852a5f
applies value binding refactoring and text refactoring to motif implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
152
diff
changeset
|
184 | //ui_spinnerr_nv(obj, "r"); |
ee49d1852a5f
applies value binding refactoring and text refactoring to motif implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
152
diff
changeset
|
185 | //d1->r->setrange(d1->r, 0, 10); |
ee49d1852a5f
applies value binding refactoring and text refactoring to motif implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
152
diff
changeset
|
186 | //d1->r->setextent(d1->r, 1); |
ee49d1852a5f
applies value binding refactoring and text refactoring to motif implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
152
diff
changeset
|
187 | //d1->d->observers = ui_add_observer(d1->d->observers, doublechanged, NULL); |
145
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
144
diff
changeset
|
188 | |
153
ee49d1852a5f
applies value binding refactoring and text refactoring to motif implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
152
diff
changeset
|
189 | //ui_progressbar_nv(obj, "progress"); |
158
4bde241c49b1
update build system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
155
diff
changeset
|
190 | |
4bde241c49b1
update build system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
155
diff
changeset
|
191 | ui_textfield(obj, NULL); |
4bde241c49b1
update build system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
155
diff
changeset
|
192 | |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
193 | ui_button(obj, "Switch Document", action_newdoc, NULL); |
136
1df2fb3d079c
adds gridwidth layout option (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
194 | |
133
6dd780cbc8c6
using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
195 | ui_show(obj); |
95
29f5cd5f5367
added drawing area (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
196 | } |
111
40dbf1a7526a
added close handler to UiContext (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
197 | |
29
c96169444d88
added locale support (Cocoa) and ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
198 | int main(int argc, char** argv) { |
88
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
86
diff
changeset
|
199 | ui_init("app1", argc, argv); |
133
6dd780cbc8c6
using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
200 | ui_onstartup(application_startup, NULL); |
88
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
86
diff
changeset
|
201 | |
133
6dd780cbc8c6
using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
202 | // menu |
88
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
86
diff
changeset
|
203 | ui_menu("File"); |
133
6dd780cbc8c6
using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
204 | ui_menuitem("Hello", action_menu, NULL); |
88
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
86
diff
changeset
|
205 | ui_submenu("Submenu1"); |
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
86
diff
changeset
|
206 | ui_submenu("Submenu2"); |
133
6dd780cbc8c6
using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
207 | ui_menuitem("item2", action_menu, NULL); |
6dd780cbc8c6
using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
208 | ui_submenu_end(); |
6dd780cbc8c6
using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
209 | ui_menuitem("item3", action_menu, NULL); |
88
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
86
diff
changeset
|
210 | ui_submenu_end(); |
133
6dd780cbc8c6
using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
211 | ui_menuitem("item4", action_menu, NULL); |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
139
diff
changeset
|
212 | |
89
9a7e4a335b2b
added toolbar (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
88
diff
changeset
|
213 | |
88
04c81be1c5a0
added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
86
diff
changeset
|
214 | ui_main(); |
29
c96169444d88
added locale support (Cocoa) and ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
215 | |
0 | 216 | return (EXIT_SUCCESS); |
217 | } |