ui/motif/toolbar.c

Sun, 29 Sep 2024 19:01:47 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 29 Sep 2024 19:01:47 +0200
branch
newapi
changeset 317
b30415965ec3
parent 176
bc63cb601f6d
permissions
-rw-r--r--

implement ui_savefiledialog name parameter (GTK)

3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2014 Olaf Wintermann. All rights reserved.
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #include "toolbar.h"
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35 #include "button.h"
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 #include "../common/context.h"
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 UiToolItem *item = malloc(sizeof(UiToolItem));
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 item->item.add_to = (ui_toolbar_add_f)add_toolitem_widget;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 UiStToolItem *item = malloc(sizeof(UiStToolItem));
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 item->item.add_to = (ui_toolbar_add_f)add_toolitem_st_widget;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 item->stockid = stockid;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
207 void ui_toolbar_add_default(char *name) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
210 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
213 if(!defaults) {
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
214 return NULL;
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
216
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217 Arg args[8];
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218 XtSetArg(args[0], XmNshadowType, XmSHADOW_ETCHED_OUT);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219 XtSetArg(args[1], XmNshadowThickness, 1);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 XtSetArg(args[2], XmNtopAttachment, XmATTACH_FORM);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221 XtSetArg(args[3], XmNleftAttachment, XmATTACH_FORM);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222 XtSetArg(args[4], XmNrightAttachment, XmATTACH_FORM);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
223 Widget frame = XmCreateFrame(parent, "toolbar_frame", args, 5);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
225 XtSetArg(args[0], XmNorientation, XmHORIZONTAL);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 if(item) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
239 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
240 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
241
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
242 XtManageChild(toolbar);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
246 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
247
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248 void add_toolitem_widget(Widget parent, UiToolItem *item, UiObject *obj) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249 Arg args[4];
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
250
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
251 XmString label = XmStringCreateLocalized(item->label);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
252 XtSetArg(args[0], XmNlabelString, label);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
256
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
257 XmStringFree(label);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
258
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
262 sizeof(UiEventData));
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
265 event->callback = item->callback;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
266 XtAddCallback(
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
267 button,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
268 XmNactivateCallback,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
269 (XtCallbackProc)ui_push_button_callback,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
270 event);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
271 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
272
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
278 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
279
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
282
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285 XmString label = XmStringCreateLocalized(stock_item->label);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
286 XtSetArg(args[0], XmNlabelString, label);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291 XmStringFree(label);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
292
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
296 sizeof(UiEventData));
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
299 event->callback = item->callback;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
300 XtAddCallback(
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
301 button,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
302 XmNactivateCallback,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
303 (XtCallbackProc)ui_push_button_callback,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
304 event);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
305 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
306
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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 }

mercurial