Fri, 16 Feb 2024 19:37:51 +0100
port textfield to new API (GTK)
3 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
4 | * Copyright 2014 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 | #include <string.h> | |
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
32 | #include <stdarg.h> |
3 | 33 | |
34 | #include "toolbar.h" | |
35 | #include "button.h" | |
36 | #include "stock.h" | |
87
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
37 | #include "list.h" |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
38 | |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
39 | #include <cx/hash_map.h> |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
40 | #include <cx/linked_list.h> |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
41 | #include <cx/array_list.h> |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
42 | |
3 | 43 | #include "../common/context.h" |
44 | ||
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
45 | static CxMap *toolbar_items; |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
46 | static CxList *defaults; |
3 | 47 | |
48 | void ui_toolbar_init() { | |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
49 | toolbar_items = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 16); |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
50 | defaults = cxLinkedListCreateSimple(CX_STORE_POINTERS); |
3 | 51 | } |
52 | ||
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
53 | void ui_toolitem(char *name, char *label, ui_callback f, void *userdata) { |
3 | 54 | UiToolItem *item = malloc(sizeof(UiToolItem)); |
55 | item->item.add_to = (ui_toolbar_add_f)add_toolitem_widget; | |
56 | item->label = label; | |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
57 | item->image = NULL; |
3 | 58 | item->callback = f; |
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
59 | item->userdata = userdata; |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
60 | item->groups = NULL; |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
61 | item->isimportant = FALSE; |
3 | 62 | |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
63 | cxMapPut(toolbar_items, name, item); |
3 | 64 | } |
65 | ||
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
66 | void ui_toolitem_st(char *name, char *stockid, ui_callback f, void *userdata) { |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
67 | ui_toolitem_stgr(name, stockid, f, userdata, -1); |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
68 | } |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
69 | |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
70 | void ui_toolitem_stgr(char *name, char *stockid, ui_callback f, void *userdata, ...) { |
3 | 71 | UiStToolItem *item = malloc(sizeof(UiStToolItem)); |
72 | item->item.add_to = (ui_toolbar_add_f)add_toolitem_st_widget; | |
73 | item->stockid = stockid; | |
74 | item->callback = f; | |
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
75 | item->userdata = userdata; |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
76 | item->groups = NULL; |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
77 | item->isimportant = FALSE; |
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
78 | |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
79 | // add groups |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
80 | va_list ap; |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
81 | va_start(ap, userdata); |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
82 | int group; |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
83 | while((group = va_arg(ap, int)) != -1) { |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
84 | if(!item->groups) { |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
85 | item->groups = cxArrayListCreateSimple(sizeof(int), 16); |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
86 | } |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
87 | cxListAdd(item->groups, &group); |
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
88 | } |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
89 | va_end(ap); |
3 | 90 | |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
91 | cxMapPut(toolbar_items, name, item); |
3 | 92 | } |
93 | ||
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
94 | void ui_toolitem_img(char *name, char *label, char *img, ui_callback f, void *udata) { |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
95 | // TODO |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
96 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
97 | UiToolItem *item = malloc(sizeof(UiToolItem)); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
98 | item->item.add_to = (ui_toolbar_add_f)add_toolitem_widget; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
99 | item->label = label; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
100 | item->image = img; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
101 | item->callback = f; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
102 | item->userdata = udata; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
103 | item->groups = NULL; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
104 | item->isimportant = FALSE; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
105 | |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
106 | cxMapPut(toolbar_items, name, item); |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
107 | } |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
108 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
109 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
110 | void ui_toolitem_toggle_stgr(char *name, char *stockid, ui_callback f, void *udata, ...) { |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
111 | // TODO |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
112 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
113 | UiStToolItem *item = malloc(sizeof(UiStToolItem)); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
114 | item->item.add_to = (ui_toolbar_add_f)add_toolitem_st_toggle_widget; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
115 | item->stockid = stockid; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
116 | item->callback = f; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
117 | item->userdata = udata; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
118 | item->groups = NULL; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
119 | item->isimportant = FALSE; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
120 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
121 | // add groups |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
122 | va_list ap; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
123 | va_start(ap, udata); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
124 | int group; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
125 | while((group = va_arg(ap, int)) != -1) { |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
126 | if(!item->groups) { |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
127 | item->groups = cxArrayListCreateSimple(sizeof(int), 16); |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
128 | } |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
129 | cxListAdd(item->groups, &group); |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
130 | } |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
131 | va_end(ap); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
132 | |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
133 | cxMapPut(toolbar_items, name, item); |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
134 | } |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
135 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
136 | void ui_toolitem_toggle_imggr(char *name, char *label, char *img, ui_callback f, void *udata, ...) { |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
137 | // TODO |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
138 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
139 | UiToolItem *item = malloc(sizeof(UiToolItem)); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
140 | item->item.add_to = (ui_toolbar_add_f)add_toolitem_toggle_widget; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
141 | item->label = label; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
142 | item->image = img; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
143 | item->callback = f; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
144 | item->userdata = udata; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
145 | item->groups = NULL; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
146 | item->isimportant = FALSE; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
147 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
148 | // add groups |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
149 | va_list ap; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
150 | va_start(ap, udata); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
151 | int group; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
152 | while((group = va_arg(ap, int)) != -1) { |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
153 | if(!item->groups) { |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
154 | item->groups = cxArrayListCreateSimple(sizeof(int), 16); |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
155 | } |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
156 | cxListAdd(item->groups, &group); |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
157 | } |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
158 | va_end(ap); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
159 | |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
160 | cxMapPut(toolbar_items, name, item); |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
161 | } |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
162 | |
87
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
163 | void ui_toolbar_combobox( |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
164 | char *name, |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
165 | UiList *list, |
153
ee49d1852a5f
applies value binding refactoring and text refactoring to motif implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
166 | ui_getvaluefunc getvalue, |
87
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
167 | ui_callback f, |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
168 | void *udata) |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
169 | { |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
170 | UiToolbarComboBox *cb = malloc(sizeof(UiToolbarComboBox)); |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
171 | cb->item.add_to = (ui_toolbar_add_f)add_toolbar_combobox; |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
172 | cb->list = list; |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
173 | cb->getvalue = getvalue; |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
174 | cb->callback = f; |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
175 | cb->userdata = udata; |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
176 | |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
177 | cxMapPut(toolbar_items, name, cb); |
87
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
178 | } |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
179 | |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
180 | void ui_toolbar_combobox_str( |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
181 | char *name, |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
182 | UiList *list, |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
183 | ui_callback f, |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
184 | void *udata) |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
185 | { |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
186 | ui_toolbar_combobox(name, list, ui_strmodel_getvalue, f, udata); |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
187 | } |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
188 | |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
189 | void ui_toolbar_combobox_nv( |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
190 | char *name, |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
191 | char *listname, |
153
ee49d1852a5f
applies value binding refactoring and text refactoring to motif implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
192 | ui_getvaluefunc getvalue, |
87
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
193 | ui_callback f, |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
194 | void *udata) |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
195 | { |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
196 | UiToolbarComboBoxNV *cb = malloc(sizeof(UiToolbarComboBoxNV)); |
117
38c53b8a6139
added combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
98
diff
changeset
|
197 | cb->item.add_to = (ui_toolbar_add_f)add_toolbar_combobox_nv; |
87
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
198 | cb->listname = listname; |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
199 | cb->getvalue = getvalue; |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
200 | cb->callback = f; |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
201 | cb->userdata = udata; |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
202 | |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
203 | cxMapPut(toolbar_items, name, cb); |
87
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
204 | } |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
205 | |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
206 | |
3 | 207 | void ui_toolbar_add_default(char *name) { |
208 | char *s = strdup(name); | |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
209 | cxListAdd(defaults, s); |
3 | 210 | } |
211 | ||
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
212 | Widget ui_create_toolbar(UiObject *obj, Widget parent) { |
3 | 213 | if(!defaults) { |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
214 | return NULL; |
3 | 215 | } |
216 | ||
217 | Arg args[8]; | |
218 | XtSetArg(args[0], XmNshadowType, XmSHADOW_ETCHED_OUT); | |
219 | XtSetArg(args[1], XmNshadowThickness, 1); | |
220 | XtSetArg(args[2], XmNtopAttachment, XmATTACH_FORM); | |
221 | XtSetArg(args[3], XmNleftAttachment, XmATTACH_FORM); | |
222 | XtSetArg(args[4], XmNrightAttachment, XmATTACH_FORM); | |
223 | Widget frame = XmCreateFrame(parent, "toolbar_frame", args, 5); | |
224 | ||
225 | XtSetArg(args[0], XmNorientation, XmHORIZONTAL); | |
226 | XtSetArg(args[1], XmNpacking, XmPACK_TIGHT); | |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
227 | XtSetArg(args[2], XmNspacing, 1); |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
228 | Widget toolbar = XmCreateRowColumn (frame, "toolbar", args, 3); |
3 | 229 | |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
230 | CxIterator i = cxListIterator(defaults); |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
231 | cx_foreach(char *, def, i) { |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
232 | UiToolItemI *item = cxMapGet(toolbar_items, def); |
3 | 233 | if(item) { |
234 | item->add_to(toolbar, item, obj); | |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
235 | } else if(!strcmp(def, "@separator")) { |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
236 | // TODO |
3 | 237 | } else { |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
238 | fprintf(stderr, "UI Error: Unknown toolbar item: %s\n", def); |
3 | 239 | } |
240 | } | |
241 | ||
242 | XtManageChild(toolbar); | |
243 | XtManageChild(frame); | |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
244 | |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
245 | return frame; |
3 | 246 | } |
247 | ||
248 | void add_toolitem_widget(Widget parent, UiToolItem *item, UiObject *obj) { | |
249 | Arg args[4]; | |
250 | ||
251 | XmString label = XmStringCreateLocalized(item->label); | |
252 | XtSetArg(args[0], XmNlabelString, label); | |
253 | XtSetArg(args[1], XmNshadowThickness, 1); | |
36
e4198fc2ead4
fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
34
diff
changeset
|
254 | XtSetArg(args[2], XmNtraversalOn, FALSE); |
e4198fc2ead4
fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
34
diff
changeset
|
255 | Widget button = XmCreatePushButton(parent, "toolbar_button", args, 3); |
3 | 256 | |
257 | XmStringFree(label); | |
258 | ||
259 | if(item->callback) { | |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
260 | UiEventData *event = cxMalloc( |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
261 | obj->ctx->allocator, |
3 | 262 | sizeof(UiEventData)); |
263 | event->obj = obj; | |
98
efaae97bd95b
added mouse event handler (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
264 | event->userdata = item->userdata; |
3 | 265 | event->callback = item->callback; |
266 | XtAddCallback( | |
267 | button, | |
268 | XmNactivateCallback, | |
269 | (XtCallbackProc)ui_push_button_callback, | |
270 | event); | |
271 | } | |
272 | ||
273 | XtManageChild(button); | |
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
274 | |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
275 | if(item->groups) { |
169
fe49cff3c571
refactor widget groups/document tree (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
157
diff
changeset
|
276 | uic_add_group_widget(obj->ctx, button, (ui_enablefunc)XtSetSensitive, item->groups); |
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
277 | } |
3 | 278 | } |
279 | ||
280 | void add_toolitem_st_widget(Widget parent, UiStToolItem *item, UiObject *obj) { | |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
281 | Arg args[8]; |
3 | 282 | |
283 | UiStockItem *stock_item = ui_get_stock_item(item->stockid); | |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
284 | |
3 | 285 | XmString label = XmStringCreateLocalized(stock_item->label); |
286 | XtSetArg(args[0], XmNlabelString, label); | |
287 | XtSetArg(args[1], XmNshadowThickness, 1); | |
36
e4198fc2ead4
fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
34
diff
changeset
|
288 | XtSetArg(args[2], XmNtraversalOn, FALSE); |
e4198fc2ead4
fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
34
diff
changeset
|
289 | Widget button = XmCreatePushButton(parent, "toolbar_button", args, 3); |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
290 | |
3 | 291 | XmStringFree(label); |
292 | ||
293 | if(item->callback) { | |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
294 | UiEventData *event = cxMalloc( |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
295 | obj->ctx->allocator, |
3 | 296 | sizeof(UiEventData)); |
297 | event->obj = obj; | |
98
efaae97bd95b
added mouse event handler (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
298 | event->userdata = item->userdata; |
3 | 299 | event->callback = item->callback; |
300 | XtAddCallback( | |
301 | button, | |
302 | XmNactivateCallback, | |
303 | (XtCallbackProc)ui_push_button_callback, | |
304 | event); | |
305 | } | |
306 | ||
307 | XtManageChild(button); | |
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
308 | |
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
309 | if(item->groups) { |
169
fe49cff3c571
refactor widget groups/document tree (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
157
diff
changeset
|
310 | uic_add_group_widget(obj->ctx, button, (ui_enablefunc)XtSetSensitive, item->groups); |
27
77b09bb52ca0
added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
311 | } |
3 | 312 | } |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
313 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
314 | void add_toolitem_toggle_widget(Widget parent, UiToolItem *item, UiObject *obj) { |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
315 | Arg args[8]; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
316 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
317 | XmString label = XmStringCreateLocalized(item->label); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
318 | XtSetArg(args[0], XmNlabelString, label); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
319 | XtSetArg(args[1], XmNshadowThickness, 1); |
36
e4198fc2ead4
fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
34
diff
changeset
|
320 | XtSetArg(args[2], XmNtraversalOn, FALSE); |
e4198fc2ead4
fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
34
diff
changeset
|
321 | XtSetArg(args[3], XmNindicatorOn, XmINDICATOR_NONE); |
e4198fc2ead4
fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
34
diff
changeset
|
322 | Widget button = XmCreateToggleButton(parent, "toolbar_toggle_button", args, 4); |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
323 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
324 | XmStringFree(label); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
325 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
326 | if(item->callback) { |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
327 | UiEventData *event = cxMalloc( |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
328 | obj->ctx->allocator, |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
329 | sizeof(UiEventData)); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
330 | event->obj = obj; |
98
efaae97bd95b
added mouse event handler (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
331 | event->userdata = item->userdata; |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
332 | event->callback = item->callback; |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
333 | XtAddCallback( |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
334 | button, |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
335 | XmNvalueChangedCallback, |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
336 | (XtCallbackProc)ui_toggle_button_callback, |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
337 | event); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
338 | } |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
339 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
340 | XtManageChild(button); |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
341 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
342 | if(item->groups) { |
169
fe49cff3c571
refactor widget groups/document tree (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
157
diff
changeset
|
343 | uic_add_group_widget(obj->ctx, button, (ui_enablefunc)XtSetSensitive, item->groups); |
34
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
344 | } |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
345 | } |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
346 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
347 | void add_toolitem_st_toggle_widget(Widget parent, UiStToolItem *item, UiObject *obj) { |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
348 | |
0ec8a5f17782
added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
27
diff
changeset
|
349 | } |
87
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
350 | |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
351 | void add_toolbar_combobox(Widget tb, UiToolbarComboBox *item, UiObject *obj) { |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
352 | UiListView *listview = cxMalloc( |
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
353 | obj->ctx->allocator, |
87
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
354 | sizeof(UiListView)); |
153
ee49d1852a5f
applies value binding refactoring and text refactoring to motif implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
355 | |
176
bc63cb601f6d
port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
169
diff
changeset
|
356 | UiVar *var = cxMalloc(obj->ctx->allocator, sizeof(UiVar)); |
153
ee49d1852a5f
applies value binding refactoring and text refactoring to motif implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
357 | var->value = item->list; |
ee49d1852a5f
applies value binding refactoring and text refactoring to motif implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
358 | var->type = UI_VAR_SPECIAL; |
87
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
359 | |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
360 | Arg args[8]; |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
361 | XtSetArg(args[0], XmNshadowThickness, 1); |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
362 | XtSetArg(args[1], XmNindicatorOn, XmINDICATOR_NONE); |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
363 | XtSetArg(args[2], XmNtraversalOn, FALSE); |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
364 | XtSetArg(args[3], XmNwidth, 120); |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
365 | Widget combobox = XmCreateDropDownList(tb, "toolbar_combobox", args, 4); |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
366 | XtManageChild(combobox); |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
367 | listview->widget = combobox; |
153
ee49d1852a5f
applies value binding refactoring and text refactoring to motif implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
368 | listview->list = var; |
87
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
369 | listview->getvalue = item->getvalue; |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
370 | |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
371 | ui_listview_update(NULL, listview); |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
372 | |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
373 | if(item->callback) { |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
374 | // TODO: |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
375 | |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
376 | } |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
377 | } |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
378 | |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
379 | void add_toolbar_combobox_nv(Widget tb, UiToolbarComboBoxNV *item, UiObject *obj) { |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
380 | |
e624b6fa4c78
added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
39
diff
changeset
|
381 | } |