1 | /*
|
---|
2 | * Copyright (c) 2021 Jiri Svoboda
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | /** @addtogroup uidemo
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 | /** @file User interface demo
|
---|
33 | */
|
---|
34 |
|
---|
35 | #include <gfx/bitmap.h>
|
---|
36 | #include <gfx/coord.h>
|
---|
37 | #include <io/pixelmap.h>
|
---|
38 | #include <stdio.h>
|
---|
39 | #include <stdlib.h>
|
---|
40 | #include <str.h>
|
---|
41 | #include <ui/entry.h>
|
---|
42 | #include <ui/filedialog.h>
|
---|
43 | #include <ui/fixed.h>
|
---|
44 | #include <ui/image.h>
|
---|
45 | #include <ui/label.h>
|
---|
46 | #include <ui/menubar.h>
|
---|
47 | #include <ui/menuentry.h>
|
---|
48 | #include <ui/menu.h>
|
---|
49 | #include <ui/msgdialog.h>
|
---|
50 | #include <ui/pbutton.h>
|
---|
51 | #include <ui/promptdialog.h>
|
---|
52 | #include <ui/resource.h>
|
---|
53 | #include <ui/ui.h>
|
---|
54 | #include <ui/window.h>
|
---|
55 | #include "uidemo.h"
|
---|
56 |
|
---|
57 | static errno_t bitmap_moire(gfx_bitmap_t *, gfx_coord_t, gfx_coord_t);
|
---|
58 |
|
---|
59 | static void wnd_close(ui_window_t *, void *);
|
---|
60 |
|
---|
61 | static ui_window_cb_t window_cb = {
|
---|
62 | .close = wnd_close
|
---|
63 | };
|
---|
64 |
|
---|
65 | static void pb_clicked(ui_pbutton_t *, void *);
|
---|
66 |
|
---|
67 | static ui_pbutton_cb_t pbutton_cb = {
|
---|
68 | .clicked = pb_clicked
|
---|
69 | };
|
---|
70 |
|
---|
71 | static void checkbox_switched(ui_checkbox_t *, void *, bool);
|
---|
72 |
|
---|
73 | static ui_checkbox_cb_t checkbox_cb = {
|
---|
74 | .switched = checkbox_switched
|
---|
75 | };
|
---|
76 |
|
---|
77 | static void rb_selected(ui_rbutton_group_t *, void *, void *);
|
---|
78 |
|
---|
79 | static ui_rbutton_group_cb_t rbutton_group_cb = {
|
---|
80 | .selected = rb_selected
|
---|
81 | };
|
---|
82 |
|
---|
83 | static void slider_moved(ui_slider_t *, void *, gfx_coord_t);
|
---|
84 |
|
---|
85 | static ui_slider_cb_t slider_cb = {
|
---|
86 | .moved = slider_moved
|
---|
87 | };
|
---|
88 |
|
---|
89 | static void uidemo_file_load(ui_menu_entry_t *, void *);
|
---|
90 | static void uidemo_file_message(ui_menu_entry_t *, void *);
|
---|
91 | static void uidemo_file_exit(ui_menu_entry_t *, void *);
|
---|
92 | static void uidemo_edit_modify(ui_menu_entry_t *, void *);
|
---|
93 |
|
---|
94 | static void file_dialog_bok(ui_file_dialog_t *, void *, const char *);
|
---|
95 | static void file_dialog_bcancel(ui_file_dialog_t *, void *);
|
---|
96 | static void file_dialog_close(ui_file_dialog_t *, void *);
|
---|
97 |
|
---|
98 | static ui_file_dialog_cb_t file_dialog_cb = {
|
---|
99 | .bok = file_dialog_bok,
|
---|
100 | .bcancel = file_dialog_bcancel,
|
---|
101 | .close = file_dialog_close
|
---|
102 | };
|
---|
103 |
|
---|
104 | static void prompt_dialog_bok(ui_prompt_dialog_t *, void *, const char *);
|
---|
105 | static void prompt_dialog_bcancel(ui_prompt_dialog_t *, void *);
|
---|
106 | static void prompt_dialog_close(ui_prompt_dialog_t *, void *);
|
---|
107 |
|
---|
108 | static ui_prompt_dialog_cb_t prompt_dialog_cb = {
|
---|
109 | .bok = prompt_dialog_bok,
|
---|
110 | .bcancel = prompt_dialog_bcancel,
|
---|
111 | .close = prompt_dialog_close
|
---|
112 | };
|
---|
113 |
|
---|
114 | static void msg_dialog_button(ui_msg_dialog_t *, void *, unsigned);
|
---|
115 | static void msg_dialog_close(ui_msg_dialog_t *, void *);
|
---|
116 |
|
---|
117 | static ui_msg_dialog_cb_t msg_dialog_cb = {
|
---|
118 | .button = msg_dialog_button,
|
---|
119 | .close = msg_dialog_close
|
---|
120 | };
|
---|
121 |
|
---|
122 | /** Horizontal alignment selected by each radio button */
|
---|
123 | static const gfx_halign_t uidemo_halign[3] = {
|
---|
124 | gfx_halign_left,
|
---|
125 | gfx_halign_center,
|
---|
126 | gfx_halign_right
|
---|
127 | };
|
---|
128 |
|
---|
129 | /** Window close button was clicked.
|
---|
130 | *
|
---|
131 | * @param window Window
|
---|
132 | * @param arg Argument (demo)
|
---|
133 | */
|
---|
134 | static void wnd_close(ui_window_t *window, void *arg)
|
---|
135 | {
|
---|
136 | ui_demo_t *demo = (ui_demo_t *) arg;
|
---|
137 |
|
---|
138 | ui_quit(demo->ui);
|
---|
139 | }
|
---|
140 |
|
---|
141 | /** Push button was clicked.
|
---|
142 | *
|
---|
143 | * @param pbutton Push button
|
---|
144 | * @param arg Argument (demo)
|
---|
145 | */
|
---|
146 | static void pb_clicked(ui_pbutton_t *pbutton, void *arg)
|
---|
147 | {
|
---|
148 | ui_demo_t *demo = (ui_demo_t *) arg;
|
---|
149 | errno_t rc;
|
---|
150 |
|
---|
151 | if (pbutton == demo->pb1) {
|
---|
152 | rc = ui_entry_set_text(demo->entry, "OK pressed");
|
---|
153 | if (rc != EOK)
|
---|
154 | printf("Error changing entry text.\n");
|
---|
155 | } else {
|
---|
156 | rc = ui_entry_set_text(demo->entry, "Cancel pressed");
|
---|
157 | if (rc != EOK)
|
---|
158 | printf("Error changing entry text.\n");
|
---|
159 | }
|
---|
160 | }
|
---|
161 |
|
---|
162 | /** Check box was switched.
|
---|
163 | *
|
---|
164 | * @param checkbox Check box
|
---|
165 | * @param arg Argument (demo)
|
---|
166 | */
|
---|
167 | static void checkbox_switched(ui_checkbox_t *checkbox, void *arg, bool enable)
|
---|
168 | {
|
---|
169 | ui_demo_t *demo = (ui_demo_t *) arg;
|
---|
170 |
|
---|
171 | ui_entry_set_read_only(demo->entry, enable);
|
---|
172 | }
|
---|
173 |
|
---|
174 | /** Radio button was selected.
|
---|
175 | *
|
---|
176 | * @param rbgroup Radio button group
|
---|
177 | * @param garg Group argument (demo)
|
---|
178 | * @param barg Button argument
|
---|
179 | */
|
---|
180 | static void rb_selected(ui_rbutton_group_t *rbgroup, void *garg, void *barg)
|
---|
181 | {
|
---|
182 | ui_demo_t *demo = (ui_demo_t *) garg;
|
---|
183 | gfx_halign_t halign = *(gfx_halign_t *) barg;
|
---|
184 |
|
---|
185 | ui_entry_set_halign(demo->entry, halign);
|
---|
186 | (void) ui_entry_paint(demo->entry);
|
---|
187 | }
|
---|
188 |
|
---|
189 | /** Slider was moved.
|
---|
190 | *
|
---|
191 | * @param slider Slider
|
---|
192 | * @param arg Argument (demo)
|
---|
193 | * @param pos Position
|
---|
194 | */
|
---|
195 | static void slider_moved(ui_slider_t *slider, void *arg, gfx_coord_t pos)
|
---|
196 | {
|
---|
197 | ui_demo_t *demo = (ui_demo_t *) arg;
|
---|
198 | char *str;
|
---|
199 | errno_t rc;
|
---|
200 | int rv;
|
---|
201 |
|
---|
202 | rv = asprintf(&str, "Slider at %d of %d", (int) pos,
|
---|
203 | ui_slider_length(slider));
|
---|
204 | if (rv < 0) {
|
---|
205 | printf("Out of memory.\n");
|
---|
206 | return;
|
---|
207 | }
|
---|
208 |
|
---|
209 | rc = ui_entry_set_text(demo->entry, str);
|
---|
210 | if (rc != EOK)
|
---|
211 | printf("Error changing entry text.\n");
|
---|
212 | (void) ui_entry_paint(demo->entry);
|
---|
213 |
|
---|
214 | free(str);
|
---|
215 | }
|
---|
216 |
|
---|
217 | /** Display a message window.
|
---|
218 | *
|
---|
219 | * @param demo UI demo
|
---|
220 | * @param caption Window caption
|
---|
221 | * @param text Message text
|
---|
222 | */
|
---|
223 | static void uidemo_show_message(ui_demo_t *demo, const char *caption,
|
---|
224 | const char *text)
|
---|
225 | {
|
---|
226 | ui_msg_dialog_params_t mdparams;
|
---|
227 | ui_msg_dialog_t *dialog;
|
---|
228 | errno_t rc;
|
---|
229 |
|
---|
230 | ui_msg_dialog_params_init(&mdparams);
|
---|
231 | mdparams.caption = caption;
|
---|
232 | mdparams.text = text;
|
---|
233 |
|
---|
234 | rc = ui_msg_dialog_create(demo->ui, &mdparams, &dialog);
|
---|
235 | if (rc != EOK) {
|
---|
236 | printf("Error creating message dialog.\n");
|
---|
237 | return;
|
---|
238 | }
|
---|
239 |
|
---|
240 | ui_msg_dialog_set_cb(dialog, &msg_dialog_cb, &demo);
|
---|
241 | }
|
---|
242 |
|
---|
243 | /** File / Load menu entry selected.
|
---|
244 | *
|
---|
245 | * @param mentry Menu entry
|
---|
246 | * @param arg Argument (demo)
|
---|
247 | */
|
---|
248 | static void uidemo_file_load(ui_menu_entry_t *mentry, void *arg)
|
---|
249 | {
|
---|
250 | ui_demo_t *demo = (ui_demo_t *) arg;
|
---|
251 | ui_file_dialog_params_t fdparams;
|
---|
252 | ui_file_dialog_t *dialog;
|
---|
253 | errno_t rc;
|
---|
254 |
|
---|
255 | ui_file_dialog_params_init(&fdparams);
|
---|
256 | fdparams.caption = "Load File";
|
---|
257 |
|
---|
258 | rc = ui_file_dialog_create(demo->ui, &fdparams, &dialog);
|
---|
259 | if (rc != EOK) {
|
---|
260 | printf("Error creating message dialog.\n");
|
---|
261 | return;
|
---|
262 | }
|
---|
263 |
|
---|
264 | ui_file_dialog_set_cb(dialog, &file_dialog_cb, demo);
|
---|
265 | }
|
---|
266 |
|
---|
267 | /** File / Message menu entry selected.
|
---|
268 | *
|
---|
269 | * @param mentry Menu entry
|
---|
270 | * @param arg Argument (demo)
|
---|
271 | */
|
---|
272 | static void uidemo_file_message(ui_menu_entry_t *mentry, void *arg)
|
---|
273 | {
|
---|
274 | ui_demo_t *demo = (ui_demo_t *) arg;
|
---|
275 | ui_msg_dialog_params_t mdparams;
|
---|
276 | ui_msg_dialog_t *dialog;
|
---|
277 | errno_t rc;
|
---|
278 |
|
---|
279 | ui_msg_dialog_params_init(&mdparams);
|
---|
280 | mdparams.caption = "Message For You";
|
---|
281 | mdparams.text = "Hello, world!";
|
---|
282 |
|
---|
283 | rc = ui_msg_dialog_create(demo->ui, &mdparams, &dialog);
|
---|
284 | if (rc != EOK) {
|
---|
285 | printf("Error creating message dialog.\n");
|
---|
286 | return;
|
---|
287 | }
|
---|
288 |
|
---|
289 | ui_msg_dialog_set_cb(dialog, &msg_dialog_cb, &demo);
|
---|
290 | }
|
---|
291 |
|
---|
292 | /** File / Exit menu entry selected.
|
---|
293 | *
|
---|
294 | * @param mentry Menu entry
|
---|
295 | * @param arg Argument (demo)
|
---|
296 | */
|
---|
297 | static void uidemo_file_exit(ui_menu_entry_t *mentry, void *arg)
|
---|
298 | {
|
---|
299 | ui_demo_t *demo = (ui_demo_t *) arg;
|
---|
300 |
|
---|
301 | ui_quit(demo->ui);
|
---|
302 | }
|
---|
303 |
|
---|
304 | /** Edit / Modify menu entry selected.
|
---|
305 | *
|
---|
306 | * @param mentry Menu entry
|
---|
307 | * @param arg Argument (demo)
|
---|
308 | */
|
---|
309 | static void uidemo_edit_modify(ui_menu_entry_t *mentry, void *arg)
|
---|
310 | {
|
---|
311 | ui_demo_t *demo = (ui_demo_t *) arg;
|
---|
312 | ui_prompt_dialog_params_t pdparams;
|
---|
313 | ui_prompt_dialog_t *dialog;
|
---|
314 | errno_t rc;
|
---|
315 |
|
---|
316 | ui_prompt_dialog_params_init(&pdparams);
|
---|
317 | pdparams.caption = "Modify Entry Text";
|
---|
318 | pdparams.prompt = "Enter New Text";
|
---|
319 |
|
---|
320 | rc = ui_prompt_dialog_create(demo->ui, &pdparams, &dialog);
|
---|
321 | if (rc != EOK) {
|
---|
322 | printf("Error creating message dialog.\n");
|
---|
323 | return;
|
---|
324 | }
|
---|
325 |
|
---|
326 | ui_prompt_dialog_set_cb(dialog, &prompt_dialog_cb, demo);
|
---|
327 | }
|
---|
328 |
|
---|
329 | /** File dialog OK button press.
|
---|
330 | *
|
---|
331 | * @param dialog File dialog
|
---|
332 | * @param arg Argument (ui_demo_t *)
|
---|
333 | * @param fname File name
|
---|
334 | */
|
---|
335 | static void file_dialog_bok(ui_file_dialog_t *dialog, void *arg,
|
---|
336 | const char *fname)
|
---|
337 | {
|
---|
338 | ui_demo_t *demo = (ui_demo_t *) arg;
|
---|
339 | char buf[128];
|
---|
340 | char *p;
|
---|
341 | FILE *f;
|
---|
342 |
|
---|
343 | ui_file_dialog_destroy(dialog);
|
---|
344 |
|
---|
345 | f = fopen(fname, "rt");
|
---|
346 | if (f == NULL) {
|
---|
347 | uidemo_show_message(demo, "Error", "Error opening file.");
|
---|
348 | return;
|
---|
349 | }
|
---|
350 |
|
---|
351 | p = fgets(buf, sizeof(buf), f);
|
---|
352 | if (p == NULL) {
|
---|
353 | uidemo_show_message(demo, "Error", "Error reading file.");
|
---|
354 | fclose(f);
|
---|
355 | return;
|
---|
356 | }
|
---|
357 |
|
---|
358 | /* Cut string off at the first non-printable character */
|
---|
359 | p = buf;
|
---|
360 | while (*p != '\0') {
|
---|
361 | if (*p < ' ') {
|
---|
362 | *p = '\0';
|
---|
363 | break;
|
---|
364 | }
|
---|
365 | ++p;
|
---|
366 | }
|
---|
367 |
|
---|
368 | ui_entry_set_text(demo->entry, buf);
|
---|
369 | fclose(f);
|
---|
370 | }
|
---|
371 |
|
---|
372 | /** File dialog cancel button press.
|
---|
373 | *
|
---|
374 | * @param dialog File dialog
|
---|
375 | * @param arg Argument (ui_demo_t *)
|
---|
376 | */
|
---|
377 | static void file_dialog_bcancel(ui_file_dialog_t *dialog, void *arg)
|
---|
378 | {
|
---|
379 | ui_demo_t *demo = (ui_demo_t *) arg;
|
---|
380 |
|
---|
381 | (void) demo;
|
---|
382 | ui_file_dialog_destroy(dialog);
|
---|
383 | }
|
---|
384 |
|
---|
385 | /** File dialog close request.
|
---|
386 | *
|
---|
387 | * @param dialog File dialog
|
---|
388 | * @param arg Argument (ui_demo_t *)
|
---|
389 | */
|
---|
390 | static void file_dialog_close(ui_file_dialog_t *dialog, void *arg)
|
---|
391 | {
|
---|
392 | ui_demo_t *demo = (ui_demo_t *) arg;
|
---|
393 |
|
---|
394 | (void) demo;
|
---|
395 | ui_file_dialog_destroy(dialog);
|
---|
396 | }
|
---|
397 |
|
---|
398 | /** Prompt dialog OK button press.
|
---|
399 | *
|
---|
400 | * @param dialog Prompt dialog
|
---|
401 | * @param arg Argument (ui_demo_t *)
|
---|
402 | * @param text Submitted text
|
---|
403 | */
|
---|
404 | static void prompt_dialog_bok(ui_prompt_dialog_t *dialog, void *arg,
|
---|
405 | const char *text)
|
---|
406 | {
|
---|
407 | ui_demo_t *demo = (ui_demo_t *) arg;
|
---|
408 |
|
---|
409 | ui_prompt_dialog_destroy(dialog);
|
---|
410 | ui_entry_set_text(demo->entry, text);
|
---|
411 | }
|
---|
412 |
|
---|
413 | /** Prompt dialog cancel button press.
|
---|
414 | *
|
---|
415 | * @param dialog File dialog
|
---|
416 | * @param arg Argument (ui_demo_t *)
|
---|
417 | */
|
---|
418 | static void prompt_dialog_bcancel(ui_prompt_dialog_t *dialog, void *arg)
|
---|
419 | {
|
---|
420 | ui_demo_t *demo = (ui_demo_t *) arg;
|
---|
421 |
|
---|
422 | (void) demo;
|
---|
423 | ui_prompt_dialog_destroy(dialog);
|
---|
424 | }
|
---|
425 |
|
---|
426 | /** Prompt dialog close request.
|
---|
427 | *
|
---|
428 | * @param dialog File dialog
|
---|
429 | * @param arg Argument (ui_demo_t *)
|
---|
430 | */
|
---|
431 | static void prompt_dialog_close(ui_prompt_dialog_t *dialog, void *arg)
|
---|
432 | {
|
---|
433 | ui_demo_t *demo = (ui_demo_t *) arg;
|
---|
434 |
|
---|
435 | (void) demo;
|
---|
436 | ui_prompt_dialog_destroy(dialog);
|
---|
437 | }
|
---|
438 |
|
---|
439 | /** Message dialog button press.
|
---|
440 | *
|
---|
441 | * @param dialog Message dialog
|
---|
442 | * @param arg Argument (ui_demo_t *)
|
---|
443 | * @param bnum Button number
|
---|
444 | */
|
---|
445 | static void msg_dialog_button(ui_msg_dialog_t *dialog, void *arg,
|
---|
446 | unsigned bnum)
|
---|
447 | {
|
---|
448 | ui_demo_t *demo = (ui_demo_t *) arg;
|
---|
449 |
|
---|
450 | (void) demo;
|
---|
451 | ui_msg_dialog_destroy(dialog);
|
---|
452 | }
|
---|
453 |
|
---|
454 | /** Message dialog close request.
|
---|
455 | *
|
---|
456 | * @param dialog Message dialog
|
---|
457 | * @param arg Argument (ui_demo_t *)
|
---|
458 | */
|
---|
459 | static void msg_dialog_close(ui_msg_dialog_t *dialog, void *arg)
|
---|
460 | {
|
---|
461 | ui_demo_t *demo = (ui_demo_t *) arg;
|
---|
462 |
|
---|
463 | (void) demo;
|
---|
464 | ui_msg_dialog_destroy(dialog);
|
---|
465 | }
|
---|
466 |
|
---|
467 | /** Run UI demo on display server. */
|
---|
468 | static errno_t ui_demo(const char *display_spec)
|
---|
469 | {
|
---|
470 | ui_t *ui = NULL;
|
---|
471 | ui_wnd_params_t params;
|
---|
472 | ui_window_t *window = NULL;
|
---|
473 | ui_demo_t demo;
|
---|
474 | gfx_rect_t rect;
|
---|
475 | gfx_context_t *gc;
|
---|
476 | ui_resource_t *ui_res;
|
---|
477 | gfx_bitmap_params_t bparams;
|
---|
478 | gfx_bitmap_t *bitmap;
|
---|
479 | gfx_coord2_t off;
|
---|
480 | ui_menu_entry_t *mmsg;
|
---|
481 | ui_menu_entry_t *mload;
|
---|
482 | ui_menu_entry_t *mfoo;
|
---|
483 | ui_menu_entry_t *mbar;
|
---|
484 | ui_menu_entry_t *mfoobar;
|
---|
485 | ui_menu_entry_t *msep;
|
---|
486 | ui_menu_entry_t *mexit;
|
---|
487 | ui_menu_entry_t *mmodify;
|
---|
488 | ui_menu_entry_t *mabout;
|
---|
489 | errno_t rc;
|
---|
490 |
|
---|
491 | rc = ui_create(display_spec, &ui);
|
---|
492 | if (rc != EOK) {
|
---|
493 | printf("Error creating UI on display %s.\n", display_spec);
|
---|
494 | return rc;
|
---|
495 | }
|
---|
496 |
|
---|
497 | memset((void *) &demo, 0, sizeof(demo));
|
---|
498 | demo.ui = ui;
|
---|
499 |
|
---|
500 | ui_wnd_params_init(¶ms);
|
---|
501 | params.caption = "UI Demo";
|
---|
502 | params.style |= ui_wds_resizable;
|
---|
503 |
|
---|
504 | /* FIXME: Auto layout */
|
---|
505 | if (ui_is_textmode(ui)) {
|
---|
506 | params.rect.p0.x = 0;
|
---|
507 | params.rect.p0.y = 0;
|
---|
508 | params.rect.p1.x = 44;
|
---|
509 | params.rect.p1.y = 21;
|
---|
510 | } else {
|
---|
511 | params.rect.p0.x = 0;
|
---|
512 | params.rect.p0.y = 0;
|
---|
513 | params.rect.p1.x = 220;
|
---|
514 | params.rect.p1.y = 350;
|
---|
515 | }
|
---|
516 |
|
---|
517 | rc = ui_window_create(ui, ¶ms, &window);
|
---|
518 | if (rc != EOK) {
|
---|
519 | printf("Error creating window.\n");
|
---|
520 | return rc;
|
---|
521 | }
|
---|
522 |
|
---|
523 | ui_window_set_cb(window, &window_cb, (void *) &demo);
|
---|
524 | demo.window = window;
|
---|
525 |
|
---|
526 | ui_res = ui_window_get_res(window);
|
---|
527 | gc = ui_window_get_gc(window);
|
---|
528 |
|
---|
529 | rc = ui_fixed_create(&demo.fixed);
|
---|
530 | if (rc != EOK) {
|
---|
531 | printf("Error creating fixed layout.\n");
|
---|
532 | return rc;
|
---|
533 | }
|
---|
534 |
|
---|
535 | rc = ui_menu_bar_create(ui, window, &demo.mbar);
|
---|
536 | if (rc != EOK) {
|
---|
537 | printf("Error creating menu bar.\n");
|
---|
538 | return rc;
|
---|
539 | }
|
---|
540 |
|
---|
541 | rc = ui_menu_create(demo.mbar, "File", &demo.mfile);
|
---|
542 | if (rc != EOK) {
|
---|
543 | printf("Error creating menu.\n");
|
---|
544 | return rc;
|
---|
545 | }
|
---|
546 |
|
---|
547 | rc = ui_menu_entry_create(demo.mfile, "Message", "", &mmsg);
|
---|
548 | if (rc != EOK) {
|
---|
549 | printf("Error creating menu.\n");
|
---|
550 | return rc;
|
---|
551 | }
|
---|
552 |
|
---|
553 | ui_menu_entry_set_cb(mmsg, uidemo_file_message, (void *) &demo);
|
---|
554 |
|
---|
555 | rc = ui_menu_entry_create(demo.mfile, "Load", "", &mload);
|
---|
556 | if (rc != EOK) {
|
---|
557 | printf("Error creating menu.\n");
|
---|
558 | return rc;
|
---|
559 | }
|
---|
560 |
|
---|
561 | ui_menu_entry_set_cb(mload, uidemo_file_load, (void *) &demo);
|
---|
562 |
|
---|
563 | rc = ui_menu_entry_create(demo.mfile, "Foo", "Ctrl-Alt-Del", &mfoo);
|
---|
564 | if (rc != EOK) {
|
---|
565 | printf("Error creating menu.\n");
|
---|
566 | return rc;
|
---|
567 | }
|
---|
568 |
|
---|
569 | rc = ui_menu_entry_create(demo.mfile, "Bar", "", &mbar);
|
---|
570 | if (rc != EOK) {
|
---|
571 | printf("Error creating menu.\n");
|
---|
572 | return rc;
|
---|
573 | }
|
---|
574 |
|
---|
575 | rc = ui_menu_entry_create(demo.mfile, "Foobar", "", &mfoobar);
|
---|
576 | if (rc != EOK) {
|
---|
577 | printf("Error creating menu.\n");
|
---|
578 | return rc;
|
---|
579 | }
|
---|
580 |
|
---|
581 | rc = ui_menu_entry_sep_create(demo.mfile, &msep);
|
---|
582 | if (rc != EOK) {
|
---|
583 | printf("Error creating menu.\n");
|
---|
584 | return rc;
|
---|
585 | }
|
---|
586 |
|
---|
587 | rc = ui_menu_entry_create(demo.mfile, "Exit", "Alt-F4", &mexit);
|
---|
588 | if (rc != EOK) {
|
---|
589 | printf("Error creating menu.\n");
|
---|
590 | return rc;
|
---|
591 | }
|
---|
592 |
|
---|
593 | ui_menu_entry_set_cb(mexit, uidemo_file_exit, (void *) &demo);
|
---|
594 |
|
---|
595 | rc = ui_menu_create(demo.mbar, "Edit", &demo.medit);
|
---|
596 | if (rc != EOK) {
|
---|
597 | printf("Error creating menu.\n");
|
---|
598 | return rc;
|
---|
599 | }
|
---|
600 |
|
---|
601 | rc = ui_menu_entry_create(demo.medit, "Modify", "", &mmodify);
|
---|
602 | if (rc != EOK) {
|
---|
603 | printf("Error creating menu.\n");
|
---|
604 | return rc;
|
---|
605 | }
|
---|
606 |
|
---|
607 | ui_menu_entry_set_cb(mmodify, uidemo_edit_modify, (void *) &demo);
|
---|
608 |
|
---|
609 | rc = ui_menu_create(demo.mbar, "Preferences", &demo.mpreferences);
|
---|
610 | if (rc != EOK) {
|
---|
611 | printf("Error creating menu.\n");
|
---|
612 | return rc;
|
---|
613 | }
|
---|
614 |
|
---|
615 | rc = ui_menu_create(demo.mbar, "Help", &demo.mhelp);
|
---|
616 | if (rc != EOK) {
|
---|
617 | printf("Error creating menu.\n");
|
---|
618 | return rc;
|
---|
619 | }
|
---|
620 |
|
---|
621 | rc = ui_menu_entry_create(demo.mhelp, "About", "Ctrl-H, F1", &mabout);
|
---|
622 | if (rc != EOK) {
|
---|
623 | printf("Error creating menu.\n");
|
---|
624 | return rc;
|
---|
625 | }
|
---|
626 |
|
---|
627 | /* FIXME: Auto layout */
|
---|
628 | if (ui_is_textmode(ui)) {
|
---|
629 | rect.p0.x = 1;
|
---|
630 | rect.p0.y = 1;
|
---|
631 | rect.p1.x = 43;
|
---|
632 | rect.p1.y = 2;
|
---|
633 | } else {
|
---|
634 | rect.p0.x = 4;
|
---|
635 | rect.p0.y = 30;
|
---|
636 | rect.p1.x = 216;
|
---|
637 | rect.p1.y = 52;
|
---|
638 | }
|
---|
639 | ui_menu_bar_set_rect(demo.mbar, &rect);
|
---|
640 |
|
---|
641 | rc = ui_fixed_add(demo.fixed, ui_menu_bar_ctl(demo.mbar));
|
---|
642 | if (rc != EOK) {
|
---|
643 | printf("Error adding control to layout.\n");
|
---|
644 | return rc;
|
---|
645 | }
|
---|
646 |
|
---|
647 | rc = ui_entry_create(window, "", &demo.entry);
|
---|
648 | if (rc != EOK) {
|
---|
649 | printf("Error creating entry.\n");
|
---|
650 | return rc;
|
---|
651 | }
|
---|
652 |
|
---|
653 | /* FIXME: Auto layout */
|
---|
654 | if (ui_is_textmode(ui)) {
|
---|
655 | rect.p0.x = 2;
|
---|
656 | rect.p0.y = 3;
|
---|
657 | rect.p1.x = 42;
|
---|
658 | rect.p1.y = 4;
|
---|
659 | } else {
|
---|
660 | rect.p0.x = 15;
|
---|
661 | rect.p0.y = 53;
|
---|
662 | rect.p1.x = 205;
|
---|
663 | rect.p1.y = 78;
|
---|
664 | }
|
---|
665 |
|
---|
666 | ui_entry_set_rect(demo.entry, &rect);
|
---|
667 | ui_entry_set_halign(demo.entry, gfx_halign_center);
|
---|
668 |
|
---|
669 | rc = ui_fixed_add(demo.fixed, ui_entry_ctl(demo.entry));
|
---|
670 | if (rc != EOK) {
|
---|
671 | printf("Error adding control to layout.\n");
|
---|
672 | return rc;
|
---|
673 | }
|
---|
674 |
|
---|
675 | rc = ui_label_create(ui_res, "Text label", &demo.label);
|
---|
676 | if (rc != EOK) {
|
---|
677 | printf("Error creating label.\n");
|
---|
678 | return rc;
|
---|
679 | }
|
---|
680 |
|
---|
681 | /* FIXME: Auto layout */
|
---|
682 | if (ui_is_textmode(ui)) {
|
---|
683 | rect.p0.x = 2;
|
---|
684 | rect.p0.y = 5;
|
---|
685 | rect.p1.x = 42;
|
---|
686 | rect.p1.y = 6;
|
---|
687 | } else {
|
---|
688 | rect.p0.x = 60;
|
---|
689 | rect.p0.y = 88;
|
---|
690 | rect.p1.x = 160;
|
---|
691 | rect.p1.y = 101;
|
---|
692 | }
|
---|
693 |
|
---|
694 | ui_label_set_rect(demo.label, &rect);
|
---|
695 | ui_label_set_halign(demo.label, gfx_halign_center);
|
---|
696 |
|
---|
697 | rc = ui_fixed_add(demo.fixed, ui_label_ctl(demo.label));
|
---|
698 | if (rc != EOK) {
|
---|
699 | printf("Error adding control to layout.\n");
|
---|
700 | return rc;
|
---|
701 | }
|
---|
702 |
|
---|
703 | rc = ui_pbutton_create(ui_res, "OK", &demo.pb1);
|
---|
704 | if (rc != EOK) {
|
---|
705 | printf("Error creating button.\n");
|
---|
706 | return rc;
|
---|
707 | }
|
---|
708 |
|
---|
709 | ui_pbutton_set_cb(demo.pb1, &pbutton_cb, (void *) &demo);
|
---|
710 |
|
---|
711 | /* FIXME: Auto layout */
|
---|
712 | if (ui_is_textmode(ui)) {
|
---|
713 | rect.p0.x = 2;
|
---|
714 | rect.p0.y = 7;
|
---|
715 | rect.p1.x = 12;
|
---|
716 | rect.p1.y = 8;
|
---|
717 | } else {
|
---|
718 | rect.p0.x = 15;
|
---|
719 | rect.p0.y = 111;
|
---|
720 | rect.p1.x = 105;
|
---|
721 | rect.p1.y = 139;
|
---|
722 | }
|
---|
723 |
|
---|
724 | ui_pbutton_set_rect(demo.pb1, &rect);
|
---|
725 |
|
---|
726 | ui_pbutton_set_default(demo.pb1, true);
|
---|
727 |
|
---|
728 | rc = ui_fixed_add(demo.fixed, ui_pbutton_ctl(demo.pb1));
|
---|
729 | if (rc != EOK) {
|
---|
730 | printf("Error adding control to layout.\n");
|
---|
731 | return rc;
|
---|
732 | }
|
---|
733 |
|
---|
734 | rc = ui_pbutton_create(ui_res, "Cancel", &demo.pb2);
|
---|
735 | if (rc != EOK) {
|
---|
736 | printf("Error creating button.\n");
|
---|
737 | return rc;
|
---|
738 | }
|
---|
739 |
|
---|
740 | ui_pbutton_set_cb(demo.pb2, &pbutton_cb, (void *) &demo);
|
---|
741 |
|
---|
742 | if (ui_is_textmode(ui)) {
|
---|
743 | rect.p0.x = 32;
|
---|
744 | rect.p0.y = 7;
|
---|
745 | rect.p1.x = 42;
|
---|
746 | rect.p1.y = 8;
|
---|
747 | } else {
|
---|
748 | rect.p0.x = 115;
|
---|
749 | rect.p0.y = 111;
|
---|
750 | rect.p1.x = 205;
|
---|
751 | rect.p1.y = 139;
|
---|
752 | }
|
---|
753 |
|
---|
754 | ui_pbutton_set_rect(demo.pb2, &rect);
|
---|
755 |
|
---|
756 | rc = ui_fixed_add(demo.fixed, ui_pbutton_ctl(demo.pb2));
|
---|
757 | if (rc != EOK) {
|
---|
758 | printf("Error adding control to layout.\n");
|
---|
759 | return rc;
|
---|
760 | }
|
---|
761 |
|
---|
762 | gfx_bitmap_params_init(&bparams);
|
---|
763 | if (ui_is_textmode(ui)) {
|
---|
764 | bparams.rect.p0.x = 0;
|
---|
765 | bparams.rect.p0.y = 0;
|
---|
766 | bparams.rect.p1.x = 40;
|
---|
767 | bparams.rect.p1.y = 2;
|
---|
768 | } else {
|
---|
769 | bparams.rect.p0.x = 0;
|
---|
770 | bparams.rect.p0.y = 0;
|
---|
771 | bparams.rect.p1.x = 188;
|
---|
772 | bparams.rect.p1.y = 24;
|
---|
773 | }
|
---|
774 |
|
---|
775 | rc = gfx_bitmap_create(gc, &bparams, NULL, &bitmap);
|
---|
776 | if (rc != EOK)
|
---|
777 | return rc;
|
---|
778 |
|
---|
779 | rc = bitmap_moire(bitmap, bparams.rect.p1.x, bparams.rect.p1.y);
|
---|
780 | if (rc != EOK)
|
---|
781 | return rc;
|
---|
782 |
|
---|
783 | rc = ui_image_create(ui_res, bitmap, ¶ms.rect, &demo.image);
|
---|
784 | if (rc != EOK) {
|
---|
785 | printf("Error creating label.\n");
|
---|
786 | return rc;
|
---|
787 | }
|
---|
788 |
|
---|
789 | if (ui_is_textmode(ui)) {
|
---|
790 | off.x = 2;
|
---|
791 | off.y = 9;
|
---|
792 | } else {
|
---|
793 | off.x = 15;
|
---|
794 | off.y = 155;
|
---|
795 | }
|
---|
796 |
|
---|
797 | gfx_rect_translate(&off, &bparams.rect, &rect);
|
---|
798 |
|
---|
799 | /* Adjust for frame width (2 x 1 pixel) */
|
---|
800 | if (!ui_is_textmode(ui)) {
|
---|
801 | ui_image_set_flags(demo.image, ui_imgf_frame);
|
---|
802 | rect.p1.x += 2;
|
---|
803 | rect.p1.y += 2;
|
---|
804 | }
|
---|
805 |
|
---|
806 | ui_image_set_rect(demo.image, &rect);
|
---|
807 |
|
---|
808 | rc = ui_fixed_add(demo.fixed, ui_image_ctl(demo.image));
|
---|
809 | if (rc != EOK) {
|
---|
810 | printf("Error adding control to layout.\n");
|
---|
811 | return rc;
|
---|
812 | }
|
---|
813 |
|
---|
814 | rc = ui_checkbox_create(ui_res, "Read only", &demo.checkbox);
|
---|
815 | if (rc != EOK) {
|
---|
816 | printf("Error creating check box.\n");
|
---|
817 | return rc;
|
---|
818 | }
|
---|
819 |
|
---|
820 | ui_checkbox_set_cb(demo.checkbox, &checkbox_cb, (void *) &demo);
|
---|
821 |
|
---|
822 | /* FIXME: Auto layout */
|
---|
823 | if (ui_is_textmode(ui)) {
|
---|
824 | rect.p0.x = 2;
|
---|
825 | rect.p0.y = 12;
|
---|
826 | rect.p1.x = 12;
|
---|
827 | rect.p1.y = 13;
|
---|
828 | } else {
|
---|
829 | rect.p0.x = 15;
|
---|
830 | rect.p0.y = 190;
|
---|
831 | rect.p1.x = 140;
|
---|
832 | rect.p1.y = 210;
|
---|
833 | }
|
---|
834 |
|
---|
835 | ui_checkbox_set_rect(demo.checkbox, &rect);
|
---|
836 |
|
---|
837 | rc = ui_fixed_add(demo.fixed, ui_checkbox_ctl(demo.checkbox));
|
---|
838 | if (rc != EOK) {
|
---|
839 | printf("Error adding control to layout.\n");
|
---|
840 | return rc;
|
---|
841 | }
|
---|
842 |
|
---|
843 | rc = ui_rbutton_group_create(ui_res, &demo.rbgroup);
|
---|
844 | if (rc != EOK) {
|
---|
845 | printf("Error creating radio button group.\n");
|
---|
846 | return rc;
|
---|
847 | }
|
---|
848 |
|
---|
849 | rc = ui_rbutton_create(demo.rbgroup, "Left", (void *) &uidemo_halign[0],
|
---|
850 | &demo.rbleft);
|
---|
851 | if (rc != EOK) {
|
---|
852 | printf("Error creating radio button.\n");
|
---|
853 | return rc;
|
---|
854 | }
|
---|
855 |
|
---|
856 | ui_rbutton_group_set_cb(demo.rbgroup, &rbutton_group_cb,
|
---|
857 | (void *) &demo);
|
---|
858 |
|
---|
859 | /* FIXME: Auto layout */
|
---|
860 | if (ui_is_textmode(ui)) {
|
---|
861 | rect.p0.x = 2;
|
---|
862 | rect.p0.y = 14;
|
---|
863 | rect.p1.x = 12;
|
---|
864 | rect.p1.y = 15;
|
---|
865 | } else {
|
---|
866 | rect.p0.x = 15;
|
---|
867 | rect.p0.y = 220;
|
---|
868 | rect.p1.x = 140;
|
---|
869 | rect.p1.y = 240;
|
---|
870 | }
|
---|
871 | ui_rbutton_set_rect(demo.rbleft, &rect);
|
---|
872 |
|
---|
873 | rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rbleft));
|
---|
874 | if (rc != EOK) {
|
---|
875 | printf("Error adding control to layout.\n");
|
---|
876 | return rc;
|
---|
877 | }
|
---|
878 |
|
---|
879 | rc = ui_rbutton_create(demo.rbgroup, "Center", (void *) &uidemo_halign[1],
|
---|
880 | &demo.rbcenter);
|
---|
881 | if (rc != EOK) {
|
---|
882 | printf("Error creating radio button.\n");
|
---|
883 | return rc;
|
---|
884 | }
|
---|
885 |
|
---|
886 | /* FIXME: Auto layout */
|
---|
887 | if (ui_is_textmode(ui)) {
|
---|
888 | rect.p0.x = 2;
|
---|
889 | rect.p0.y = 15;
|
---|
890 | rect.p1.x = 12;
|
---|
891 | rect.p1.y = 16;
|
---|
892 | } else {
|
---|
893 | rect.p0.x = 15;
|
---|
894 | rect.p0.y = 250;
|
---|
895 | rect.p1.x = 140;
|
---|
896 | rect.p1.y = 270;
|
---|
897 | }
|
---|
898 | ui_rbutton_set_rect(demo.rbcenter, &rect);
|
---|
899 | ui_rbutton_select(demo.rbcenter);
|
---|
900 |
|
---|
901 | rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rbcenter));
|
---|
902 | if (rc != EOK) {
|
---|
903 | printf("Error adding control to layout.\n");
|
---|
904 | return rc;
|
---|
905 | }
|
---|
906 |
|
---|
907 | rc = ui_rbutton_create(demo.rbgroup, "Right", (void *) &uidemo_halign[2],
|
---|
908 | &demo.rbright);
|
---|
909 | if (rc != EOK) {
|
---|
910 | printf("Error creating radio button.\n");
|
---|
911 | return rc;
|
---|
912 | }
|
---|
913 |
|
---|
914 | /* FIXME: Auto layout */
|
---|
915 | if (ui_is_textmode(ui)) {
|
---|
916 | rect.p0.x = 2;
|
---|
917 | rect.p0.y = 16;
|
---|
918 | rect.p1.x = 12;
|
---|
919 | rect.p1.y = 17;
|
---|
920 | } else {
|
---|
921 | rect.p0.x = 15;
|
---|
922 | rect.p0.y = 280;
|
---|
923 | rect.p1.x = 140;
|
---|
924 | rect.p1.y = 300;
|
---|
925 | }
|
---|
926 | ui_rbutton_set_rect(demo.rbright, &rect);
|
---|
927 |
|
---|
928 | rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rbright));
|
---|
929 | if (rc != EOK) {
|
---|
930 | printf("Error adding control to layout.\n");
|
---|
931 | return rc;
|
---|
932 | }
|
---|
933 |
|
---|
934 | rc = ui_slider_create(ui_res, "Slide!", &demo.slider);
|
---|
935 | if (rc != EOK) {
|
---|
936 | printf("Error creating button.\n");
|
---|
937 | return rc;
|
---|
938 | }
|
---|
939 |
|
---|
940 | ui_slider_set_cb(demo.slider, &slider_cb, (void *) &demo);
|
---|
941 |
|
---|
942 | /* FIXME: Auto layout */
|
---|
943 | if (ui_is_textmode(ui)) {
|
---|
944 | rect.p0.x = 2;
|
---|
945 | rect.p0.y = 18;
|
---|
946 | rect.p1.x = 12;
|
---|
947 | rect.p1.y = 19;
|
---|
948 | } else {
|
---|
949 | rect.p0.x = 15;
|
---|
950 | rect.p0.y = 310;
|
---|
951 | rect.p1.x = 130;
|
---|
952 | rect.p1.y = 330;
|
---|
953 | }
|
---|
954 |
|
---|
955 | ui_slider_set_rect(demo.slider, &rect);
|
---|
956 |
|
---|
957 | rc = ui_fixed_add(demo.fixed, ui_slider_ctl(demo.slider));
|
---|
958 | if (rc != EOK) {
|
---|
959 | printf("Error adding control to layout.\n");
|
---|
960 | return rc;
|
---|
961 | }
|
---|
962 |
|
---|
963 | ui_window_add(window, ui_fixed_ctl(demo.fixed));
|
---|
964 |
|
---|
965 | rc = ui_window_paint(window);
|
---|
966 | if (rc != EOK) {
|
---|
967 | printf("Error painting window.\n");
|
---|
968 | return rc;
|
---|
969 | }
|
---|
970 |
|
---|
971 | ui_run(ui);
|
---|
972 |
|
---|
973 | ui_window_destroy(window);
|
---|
974 | ui_destroy(ui);
|
---|
975 |
|
---|
976 | return EOK;
|
---|
977 | }
|
---|
978 |
|
---|
979 | /** Fill bitmap with moire pattern.
|
---|
980 | *
|
---|
981 | * @param bitmap Bitmap
|
---|
982 | * @param w Bitmap width
|
---|
983 | * @param h Bitmap height
|
---|
984 | * @return EOK on success or an error code
|
---|
985 | */
|
---|
986 | static errno_t bitmap_moire(gfx_bitmap_t *bitmap, gfx_coord_t w, gfx_coord_t h)
|
---|
987 | {
|
---|
988 | int i, j;
|
---|
989 | int k;
|
---|
990 | pixelmap_t pixelmap;
|
---|
991 | gfx_bitmap_alloc_t alloc;
|
---|
992 | errno_t rc;
|
---|
993 |
|
---|
994 | rc = gfx_bitmap_get_alloc(bitmap, &alloc);
|
---|
995 | if (rc != EOK)
|
---|
996 | return rc;
|
---|
997 |
|
---|
998 | /* In absence of anything else, use pixelmap */
|
---|
999 | pixelmap.width = w;
|
---|
1000 | pixelmap.height = h;
|
---|
1001 | pixelmap.data = alloc.pixels;
|
---|
1002 |
|
---|
1003 | for (i = 0; i < w; i++) {
|
---|
1004 | for (j = 0; j < h; j++) {
|
---|
1005 | k = i * i + j * j;
|
---|
1006 | pixelmap_put_pixel(&pixelmap, i, j,
|
---|
1007 | PIXEL(0, k, k, 255 - k));
|
---|
1008 | }
|
---|
1009 | }
|
---|
1010 |
|
---|
1011 | return EOK;
|
---|
1012 | }
|
---|
1013 |
|
---|
1014 | static void print_syntax(void)
|
---|
1015 | {
|
---|
1016 | printf("Syntax: uidemo [-d <display-spec>]\n");
|
---|
1017 | }
|
---|
1018 |
|
---|
1019 | int main(int argc, char *argv[])
|
---|
1020 | {
|
---|
1021 | const char *display_spec = UI_ANY_DEFAULT;
|
---|
1022 | errno_t rc;
|
---|
1023 | int i;
|
---|
1024 |
|
---|
1025 | i = 1;
|
---|
1026 | while (i < argc && argv[i][0] == '-') {
|
---|
1027 | if (str_cmp(argv[i], "-d") == 0) {
|
---|
1028 | ++i;
|
---|
1029 | if (i >= argc) {
|
---|
1030 | printf("Argument missing.\n");
|
---|
1031 | print_syntax();
|
---|
1032 | return 1;
|
---|
1033 | }
|
---|
1034 |
|
---|
1035 | display_spec = argv[i++];
|
---|
1036 | } else {
|
---|
1037 | printf("Invalid option '%s'.\n", argv[i]);
|
---|
1038 | print_syntax();
|
---|
1039 | return 1;
|
---|
1040 | }
|
---|
1041 | }
|
---|
1042 |
|
---|
1043 | if (i < argc) {
|
---|
1044 | print_syntax();
|
---|
1045 | return 1;
|
---|
1046 | }
|
---|
1047 |
|
---|
1048 | rc = ui_demo(display_spec);
|
---|
1049 | if (rc != EOK)
|
---|
1050 | return 1;
|
---|
1051 |
|
---|
1052 | return 0;
|
---|
1053 | }
|
---|
1054 |
|
---|
1055 | /** @}
|
---|
1056 | */
|
---|