47 #elif UI_MOTIF |
47 #elif UI_MOTIF |
48 |
48 |
49 #include <Xm/XmAll.h> |
49 #include <Xm/XmAll.h> |
50 #define UIWIDGET Widget |
50 #define UIWIDGET Widget |
51 |
51 |
|
52 #elif defined(UI_QT4) || defined(UI_QT5) |
|
53 #ifdef __cplusplus |
|
54 #include <QApplication> |
|
55 #include <QWidget> |
|
56 #define UIWIDGET QWidget* |
|
57 #else /* __cplusplus */ |
|
58 #define UIWIDGET void* |
|
59 #endif |
|
60 |
52 #endif |
61 #endif |
53 |
62 |
54 #ifdef __cplusplus |
63 #ifdef __cplusplus |
55 extern "C" { |
64 extern "C" { |
56 #endif |
65 #endif |
57 |
66 |
58 #define UI_GROUP_SELECTION 20000 |
67 #define UI_GROUP_SELECTION 20000 |
59 |
68 |
60 /* public types */ |
69 /* public types */ |
61 typedef struct UiObject UiObject; |
70 typedef struct UiObject UiObject; |
62 typedef struct UiEvent UiEvent; |
71 typedef struct UiEvent UiEvent; |
63 typedef struct UiObserver UiObserver; |
72 typedef struct UiObserver UiObserver; |
64 |
73 |
65 typedef struct UiInteger UiInteger; |
74 typedef struct UiInteger UiInteger; |
66 typedef struct UiString UiString; |
75 typedef struct UiString UiString; |
67 typedef struct UiText UiText; |
76 typedef struct UiText UiText; |
68 typedef struct UiList UiList; |
77 typedef struct UiList UiList; |
69 |
78 |
70 /* private types */ |
79 /* private types */ |
71 typedef struct UiContext UiContext; |
80 typedef struct UiContext UiContext; |
72 typedef struct UiContainer UiContainer; |
81 typedef struct UiContainer UiContainer; |
73 |
82 |
74 #define ui_getval(val) (val).get(&(val)) |
83 #define ui_getval(val) (val).get(&(val)) |
75 #define ui_setval(val, v) (val).set(&(val), v) |
84 #define ui_setval(val, v) (val).set(&(val), v) |
76 |
85 |
77 #define ui_getsubstr(text, begin, end) (text).getsubstr(&(val), begin, end) |
86 #define ui_getsubstr(text, begin, end) (text).getsubstr(&(text), begin, end) |
78 #define ui_insert(text, begin, str) (text).insert(&(text), begin, str) |
87 #define ui_insert(text, begin, str) (text).insert(&(text), begin, str) |
79 |
88 #define ui_length(text) (text).length(&(text)) |
80 |
89 #define ui_selection(text, begin, end) (text).selection(&(text), begin, end) |
|
90 #define ui_position(text) (text).position(&(text)) |
|
91 #define ui_remove(text, begin, end) (text).remove(&(text), begin, end) |
|
92 |
81 typedef void(*ui_callback)(UiEvent*, void*); /* event, user data */ |
93 typedef void(*ui_callback)(UiEvent*, void*); /* event, user data */ |
82 |
94 |
|
95 typedef void*(*ui_model_getvalue_f)(void*, int); |
|
96 |
|
97 typedef int(*ui_threadfunc)(void*); |
|
98 |
83 struct UiObject { |
99 struct UiObject { |
84 /* |
100 /* |
85 * native widget |
101 * native widget |
86 */ |
102 */ |
87 UIWIDGET widget; |
103 UIWIDGET widget; |
88 |
104 |
89 /* |
105 /* |
90 * user window data |
106 * user window data |
91 */ |
107 */ |
92 void *window; |
108 void *window; |
93 |
109 |
94 /* |
110 /* |
95 * current document |
111 * current document |
96 */ |
112 */ |
97 void *document; |
113 void *document; |
98 |
114 |
99 /* |
115 /* |
100 * window context (private) |
116 * window context (private) |
101 */ |
117 */ |
102 UiContext *ctx; |
118 UiContext *ctx; |
103 |
119 |
104 /* |
120 /* |
105 * container interface (private) |
121 * container interface (private) |
106 */ |
122 */ |
107 UiContainer *container; |
123 UiContainer *container; |
|
124 |
|
125 /* |
|
126 * next container object |
|
127 */ |
|
128 UiObject *next; |
108 }; |
129 }; |
109 |
130 |
110 struct UiEvent { |
131 struct UiEvent { |
111 UiObject *obj; |
132 UiObject *obj; |
112 void *document; |
133 void *document; |
141 char* (*getsubstr)(UiText*, int, int); // text, begin, end |
162 char* (*getsubstr)(UiText*, int, int); // text, begin, end |
142 void (*insert)(UiText*, int, char*); |
163 void (*insert)(UiText*, int, char*); |
143 int (*position)(UiText*); |
164 int (*position)(UiText*); |
144 void (*selection)(UiText*, int*, int*); // text, begin, end |
165 void (*selection)(UiText*, int*, int*); // text, begin, end |
145 int (*length)(UiText*); |
166 int (*length)(UiText*); |
|
167 void (*remove)(UiText*, int, int); // text, begin, end |
146 char *value; |
168 char *value; |
147 void *obj; |
169 void *obj; |
148 void *undomgr; |
170 void *undomgr; |
149 // TODO: selection, undo, replace, ... |
171 // TODO: replace, ... |
150 }; |
172 }; |
151 |
173 |
152 /* |
174 /* |
153 * abstract list |
175 * abstract list |
154 */ |
176 */ |
168 /* private - implementation dependent */ |
190 /* private - implementation dependent */ |
169 void *data; |
191 void *data; |
170 |
192 |
171 }; |
193 }; |
172 |
194 |
|
195 |
173 void ui_init(char *appname, int argc, char **argv); |
196 void ui_init(char *appname, int argc, char **argv); |
174 char* ui_appname(); |
197 char* ui_appname(); |
175 |
198 |
176 void ui_exitfunc(ui_callback f, void *userdata); |
199 void ui_exitfunc(ui_callback f, void *userdata); |
177 void ui_openfilefunc(ui_callback f, void *userdata); |
200 void ui_openfilefunc(ui_callback f, void *userdata); |
178 |
201 |
179 void ui_main(); |
202 void ui_main(); |
180 void ui_show(UiObject *obj); |
203 void ui_show(UiObject *obj); |
|
204 void ui_close(UiObject *obj); |
|
205 |
|
206 void ui_job(ui_threadfunc tf, void *td, ui_callback f, void *fd); |
|
207 |
181 void ui_set_enabled(UIWIDGET widget, int enabled); |
208 void ui_set_enabled(UIWIDGET widget, int enabled); |
|
209 void ui_set_show_all(UIWIDGET widget, int value); |
|
210 void ui_set_visible(UIWIDGET widget, int visible); |
|
211 |
|
212 UIWIDGET ui_sidebar(UiObject *obj); |
|
213 void ui_end(UiObject *obj); |
182 |
214 |
183 void ui_set_document(UiObject *obj, void *document); |
215 void ui_set_document(UiObject *obj, void *document); |
184 void ui_detach_document(UiObject *obj, void *document); |
216 void ui_detach_document(UiObject *obj, void *document); |
185 |
217 |
186 void* ui_document_new(size_t size); |
218 void* ui_document_new(size_t size); |
194 // TODO: remove (or not) |
226 // TODO: remove (or not) |
195 void ui_document_addint(void *doc, char *name); |
227 void ui_document_addint(void *doc, char *name); |
196 void ui_document_regint(void *doc, char *name, UiInteger *i); |
228 void ui_document_regint(void *doc, char *name, UiInteger *i); |
197 void ui_document_setint(void *doc, char *name, int val); |
229 void ui_document_setint(void *doc, char *name, int val); |
198 int ui_document_getint(void *doc, char *name); |
230 int ui_document_getint(void *doc, char *name); |
|
231 |
|
232 void ui_document_regtext(void *doc, char *name, UiText *text); |
|
233 void ui_document_reglist(void *doc, char *name, UiList *list); |
199 |
234 |
200 // new: |
235 // new: |
201 int ui_getint(UiObject *obj, char *name); |
236 int ui_getint(UiObject *obj, char *name); |
202 |
237 |
203 |
238 |