Wed, 07 Jan 2015 17:25:33 +0100
added button and box container (Qt)
0 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
4 | * Copyright 2012 Olaf Wintermann. All rights reserved. | |
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 | |
2
eeb50c534497
added support for replaceable documents
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
36 | |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
37 | typedef struct Person { |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
38 | char *name; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
39 | char *mail; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
40 | } Person; |
5 | 41 | |
52
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
42 | typedef struct Document { |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
43 | UiText text; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
44 | } Document; |
25e5390cce41
added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
51
diff
changeset
|
45 | |
0 | 46 | void action_close(UiEvent *event, void *data) { |
55
9076eb40454d
added toolbar (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
47 | ui_close(event->obj); |
0 | 48 | } |
49 | ||
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
50 | char* person_getvalue(Person *p, int column) { |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
51 | switch(column) { |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
52 | case 0: return p->name; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
53 | case 1: return p->mail; |
2
eeb50c534497
added support for replaceable documents
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
54 | } |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
55 | return NULL; |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
12
diff
changeset
|
56 | } |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
12
diff
changeset
|
57 | |
64
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
58 | UiString name; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
59 | UiString mail; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
60 | |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
61 | UIWIDGET tabview = NULL; |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
62 | |
42
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
63 | void action_activate(UiEvent *event, void *data) { |
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
64 | UiListSelection *selection = event->eventdata; |
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
65 | printf("activate: %d\n", event->intval); |
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
66 | } |
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
67 | |
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
68 | void action_select(UiEvent *event, void *data) { |
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
69 | UiListSelection *selection = event->eventdata; |
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
70 | printf("selection[%d]: ", selection->count); |
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
71 | for(int i=0;i<selection->count;i++) { |
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
72 | printf("%d ", selection->rows[i]); |
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
73 | } |
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
74 | printf("\n"); |
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
75 | } |
29b2821d1262
added table view events (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
76 | |
49
a80ba8741be6
added toolbar toggle button (Cocoa)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
46
diff
changeset
|
77 | void action_button(UiEvent *event, void *data) { |
a80ba8741be6
added toolbar toggle button (Cocoa)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
46
diff
changeset
|
78 | printf("button: %d\n", event->intval); |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
79 | char *s = ui_gettext(event->obj, "text"); |
64
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
80 | printf("{%s}\n", s); |
66
8d490d97aab8
added button and box container (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
64
diff
changeset
|
81 | //printf("name: {%s}\n", ui_getval(name)); |
8d490d97aab8
added button and box container (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
64
diff
changeset
|
82 | //printf("mail: {%s}\n", ui_getval(mail)); |
8d490d97aab8
added button and box container (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
64
diff
changeset
|
83 | //ui_select_tab(tabview, 0); |
64
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
84 | } |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
85 | |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
86 | void action_test(UiEvent *event, void *data) { |
66
8d490d97aab8
added button and box container (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
64
diff
changeset
|
87 | //ui_select_tab(tabview, 1); |
49
a80ba8741be6
added toolbar toggle button (Cocoa)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
46
diff
changeset
|
88 | } |
a80ba8741be6
added toolbar toggle button (Cocoa)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
46
diff
changeset
|
89 | |
29
c96169444d88
added locale support (Cocoa) and ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
90 | int main(int argc, char** argv) { |
0 | 91 | ui_init("app1", argc, argv); |
30
34513f76d5a8
added locale support (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
92 | ui_locales_dir("/opt/app1/locales"); |
34513f76d5a8
added locale support (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
29
diff
changeset
|
93 | ui_load_lang_def(NULL, "en_EN"); |
33
458831c574f4
added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
30
diff
changeset
|
94 | //ui_openfilefunc(action_new, NULL); |
29
c96169444d88
added locale support (Cocoa) and ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
28
diff
changeset
|
95 | |
22
bcf880b29bc3
textarea automatically sets selection group (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
96 | |
7
431dde3c5fbe
added Cocoa implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
97 | |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
98 | ui_menu("File"); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
99 | ui_menuitem_st(UI_STOCK_CLOSE, action_close, NULL); |
66
8d490d97aab8
added button and box container (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
64
diff
changeset
|
100 | //ui_checkitem("Check", action_button, NULL); |
49
a80ba8741be6
added toolbar toggle button (Cocoa)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
46
diff
changeset
|
101 | |
59
eb6611be50c7
added box container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
58
diff
changeset
|
102 | ui_toolitem_st("button", UI_STOCK_GO_BACK, action_button, NULL); |
55
9076eb40454d
added toolbar (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
103 | ui_toolbar_add_default("button"); |
3 | 104 | |
7
431dde3c5fbe
added Cocoa implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
105 | printf("create window\n"); |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
106 | UiObject *window = ui_window("Mod0", NULL); |
1
eb5269000bc8
added some document functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
107 | |
66
8d490d97aab8
added button and box container (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
64
diff
changeset
|
108 | ui_button(window, "Test1", action_button, NULL); |
8d490d97aab8
added button and box container (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
64
diff
changeset
|
109 | ui_button(window, "Test2", action_button, NULL); |
45
cfeb2d5f1332
added scrolled window for table widget (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
42
diff
changeset
|
110 | |
66
8d490d97aab8
added button and box container (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
64
diff
changeset
|
111 | ui_hbox(window); |
8d490d97aab8
added button and box container (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
64
diff
changeset
|
112 | |
61
7ee124a58fe3
improved box (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
113 | ui_layout_fill(window, FALSE); |
62
70d2aee84432
added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
114 | ui_vbox(window); |
66
8d490d97aab8
added button and box container (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
64
diff
changeset
|
115 | ui_button(window, "A", NULL, NULL); |
8d490d97aab8
added button and box container (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
64
diff
changeset
|
116 | ui_button(window, "B", NULL, NULL); |
8d490d97aab8
added button and box container (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
64
diff
changeset
|
117 | ui_button(window, "C", NULL, NULL); |
64
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
118 | ui_end(window); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
119 | |
66
8d490d97aab8
added button and box container (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
64
diff
changeset
|
120 | ui_textarea_nv(window, "text"); |
64
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
121 | ui_end(window); |
6ef2c7f73a30
added simple tabview (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
63
diff
changeset
|
122 | |
66
8d490d97aab8
added button and box container (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
64
diff
changeset
|
123 | ui_button(window, "Test4", action_button, NULL); |
53
62205699cd0e
improved motif tabs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
52
diff
changeset
|
124 | |
0 | 125 | ui_show(window); |
126 | ui_main(); | |
127 | ||
128 | return (EXIT_SUCCESS); | |
129 | } |