ui/motif/toolbar.c

Sun, 24 Jan 2016 19:57:16 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 24 Jan 2016 19:57:16 +0100
changeset 113
500c085d2133
parent 98
efaae97bd95b
child 117
38c53b8a6139
permissions
-rw-r--r--

added box spacing (Motif)

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"
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 #include "../../ucx/mempool.h"
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 #include "../common/context.h"
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 static UcxMap *toolbar_items;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 static UcxList *defaults;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 void ui_toolbar_init() {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 toolbar_items = ucx_map_new(16);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47
27
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
48 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
49 UiToolItem *item = malloc(sizeof(UiToolItem));
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 item->item.add_to = (ui_toolbar_add_f)add_toolitem_widget;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 item->label = label;
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
52 item->image = NULL;
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 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
54 item->userdata = userdata;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
55 item->groups = NULL;
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
56 item->isimportant = FALSE;
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 ucx_map_cstr_put(toolbar_items, name, item);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60
27
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
61 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
62 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
63 }
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
64
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
65 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
66 UiStToolItem *item = malloc(sizeof(UiStToolItem));
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 item->item.add_to = (ui_toolbar_add_f)add_toolitem_st_widget;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 item->stockid = stockid;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 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
70 item->userdata = userdata;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
71 item->groups = NULL;
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
72 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
73
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
74 // add groups
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
75 va_list ap;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
76 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
77 int group;
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
78 while((group = va_arg(ap, int)) != -1) {
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
79 item->groups = ucx_list_append(item->groups, (void*)(intptr_t)group);
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
80 }
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
81 va_end(ap);
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 ucx_map_cstr_put(toolbar_items, name, item);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
86 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
87 // TODO
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
88
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
89 UiToolItem *item = malloc(sizeof(UiToolItem));
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
90 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
91 item->label = label;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
92 item->image = img;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
93 item->callback = f;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
94 item->userdata = udata;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
95 item->groups = NULL;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
96 item->isimportant = FALSE;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
97
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
98 ucx_map_cstr_put(toolbar_items, name, item);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
99 }
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
100
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
101
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
102 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
103 // TODO
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
104
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
105 UiStToolItem *item = malloc(sizeof(UiStToolItem));
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
106 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
107 item->stockid = stockid;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
108 item->callback = f;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
109 item->userdata = udata;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
110 item->groups = NULL;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
111 item->isimportant = FALSE;
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 // add groups
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
114 va_list ap;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
115 va_start(ap, udata);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
116 int group;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
117 while((group = va_arg(ap, int)) != -1) {
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
118 item->groups = ucx_list_append(item->groups, (void*)(intptr_t)group);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
119 }
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
120 va_end(ap);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
121
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
122 ucx_map_cstr_put(toolbar_items, name, item);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
123 }
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
124
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
125 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
126 // TODO
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
127
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
128 UiToolItem *item = malloc(sizeof(UiToolItem));
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
129 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
130 item->label = label;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
131 item->image = img;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
132 item->callback = f;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
133 item->userdata = udata;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
134 item->groups = NULL;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
135 item->isimportant = FALSE;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
136
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
137 // add groups
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
138 va_list ap;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
139 va_start(ap, udata);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
140 int group;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
141 while((group = va_arg(ap, int)) != -1) {
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
142 item->groups = ucx_list_append(item->groups, (void*)(intptr_t)group);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
143 }
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
144 va_end(ap);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
145
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
146 ucx_map_cstr_put(toolbar_items, name, item);
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
87
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
149 void ui_toolbar_combobox(
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
150 char *name,
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
151 UiList *list,
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
152 ui_model_getvalue_f getvalue,
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
153 ui_callback f,
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
154 void *udata)
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
155 {
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
156 UiToolbarComboBox *cb = malloc(sizeof(UiToolbarComboBox));
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
157 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
158 cb->list = list;
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
159 cb->getvalue = getvalue;
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
160 cb->callback = f;
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
161 cb->userdata = udata;
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
162
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
163 ucx_map_cstr_put(toolbar_items, name, cb);
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
164 }
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
165
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
166 void ui_toolbar_combobox_str(
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
167 char *name,
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
168 UiList *list,
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
169 ui_callback f,
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
170 void *udata)
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
171 {
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
172 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
173 }
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
174
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
175 void ui_toolbar_combobox_nv(
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
176 char *name,
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
177 char *listname,
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
178 ui_model_getvalue_f getvalue,
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
179 ui_callback f,
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
180 void *udata)
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
181 {
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
182 UiToolbarComboBoxNV *cb = malloc(sizeof(UiToolbarComboBoxNV));
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
183 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
184 cb->listname = listname;
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
185 cb->getvalue = getvalue;
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
186 cb->callback = f;
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
187 cb->userdata = udata;
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 ucx_map_cstr_put(toolbar_items, name, cb);
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
190 }
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
191
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
192
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
193 void ui_toolbar_add_default(char *name) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
194 char *s = strdup(name);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
195 defaults = ucx_list_append(defaults, s);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
196 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
197
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
198 Widget ui_create_toolbar(UiObject *obj, Widget parent) {
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
199 if(!defaults) {
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
200 return NULL;
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
201 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203 Arg args[8];
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 XtSetArg(args[0], XmNshadowType, XmSHADOW_ETCHED_OUT);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205 XtSetArg(args[1], XmNshadowThickness, 1);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
206 XtSetArg(args[2], XmNtopAttachment, XmATTACH_FORM);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
207 XtSetArg(args[3], XmNleftAttachment, XmATTACH_FORM);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208 XtSetArg(args[4], XmNrightAttachment, XmATTACH_FORM);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 Widget frame = XmCreateFrame(parent, "toolbar_frame", args, 5);
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 XtSetArg(args[0], XmNorientation, XmHORIZONTAL);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
212 XtSetArg(args[1], XmNpacking, XmPACK_TIGHT);
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
213 XtSetArg(args[2], XmNspacing, 1);
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
214 Widget toolbar = XmCreateRowColumn (frame, "toolbar", args, 3);
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 UCX_FOREACH(elm, defaults) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217 UiToolItemI *item = ucx_map_cstr_get(toolbar_items, elm->data);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218 if(item) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219 item->add_to(toolbar, item, obj);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 } else if(!strcmp(elm->data, "@separator")) {
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
221 // TODO
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222 } else {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
223 fprintf(stderr, "UI Error: Unknown toolbar item: %s\n", elm->data);
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 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227 XtManageChild(toolbar);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
228 XtManageChild(frame);
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
229
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
230 return frame;
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 void add_toolitem_widget(Widget parent, UiToolItem *item, UiObject *obj) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234 Arg args[4];
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
236 XmString label = XmStringCreateLocalized(item->label);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
237 XtSetArg(args[0], XmNlabelString, label);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
238 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
239 XtSetArg(args[2], XmNtraversalOn, FALSE);
e4198fc2ead4 fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 34
diff changeset
240 Widget button = XmCreatePushButton(parent, "toolbar_button", args, 3);
3
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 XmStringFree(label);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
243
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
244 if(item->callback) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
245 UiEventData *event = ucx_mempool_malloc(
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
246 obj->ctx->mempool,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
247 sizeof(UiEventData));
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248 event->obj = obj;
98
efaae97bd95b added mouse event handler (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 87
diff changeset
249 event->userdata = item->userdata;
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
250 event->callback = item->callback;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
251 XtAddCallback(
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
252 button,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
253 XmNactivateCallback,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
254 (XtCallbackProc)ui_push_button_callback,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
255 event);
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
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
258 XtManageChild(button);
27
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
259
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
260 if(item->groups) {
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
261 uic_add_group_widget(obj->ctx, button, item->groups);
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
262 }
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
263 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
264
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
265 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
266 Arg args[8];
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
267
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
268 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
269
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
270 XmString label = XmStringCreateLocalized(stock_item->label);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
271 XtSetArg(args[0], XmNlabelString, label);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
272 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
273 XtSetArg(args[2], XmNtraversalOn, FALSE);
e4198fc2ead4 fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 34
diff changeset
274 Widget button = XmCreatePushButton(parent, "toolbar_button", args, 3);
39
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 36
diff changeset
275
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
276 XmStringFree(label);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
277
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
278 if(item->callback) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
279 UiEventData *event = ucx_mempool_malloc(
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
280 obj->ctx->mempool,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
281 sizeof(UiEventData));
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
282 event->obj = obj;
98
efaae97bd95b added mouse event handler (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 87
diff changeset
283 event->userdata = item->userdata;
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
284 event->callback = item->callback;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285 XtAddCallback(
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
286 button,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
287 XmNactivateCallback,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
288 (XtCallbackProc)ui_push_button_callback,
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
289 event);
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
290 }
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
292 XtManageChild(button);
27
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
293
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
294 if(item->groups) {
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
295 uic_add_group_widget(obj->ctx, button, item->groups);
77b09bb52ca0 added groups for toolbar items and copy & paste (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
296 }
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
297 }
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
298
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
299 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
300 Arg args[8];
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
301
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
302 XmString label = XmStringCreateLocalized(item->label);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
303 XtSetArg(args[0], XmNlabelString, label);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
304 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
305 XtSetArg(args[2], XmNtraversalOn, FALSE);
e4198fc2ead4 fixed list, text and added ui_close (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 34
diff changeset
306 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
307 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
308
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
309 XmStringFree(label);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
310
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
311 if(item->callback) {
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
312 UiEventData *event = ucx_mempool_malloc(
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
313 obj->ctx->mempool,
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
314 sizeof(UiEventData));
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
315 event->obj = obj;
98
efaae97bd95b added mouse event handler (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 87
diff changeset
316 event->userdata = item->userdata;
34
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
317 event->callback = item->callback;
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
318 XtAddCallback(
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
319 button,
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
320 XmNvalueChangedCallback,
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
321 (XtCallbackProc)ui_toggle_button_callback,
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
322 event);
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
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
325 XtManageChild(button);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
326
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
327 if(item->groups) {
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
328 uic_add_group_widget(obj->ctx, button, item->groups);
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
329 }
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
330 }
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
331
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
332 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
333
0ec8a5f17782 added listview and sidebar (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 27
diff changeset
334 }
87
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
335
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
336 void add_toolbar_combobox(Widget tb, UiToolbarComboBox *item, UiObject *obj) {
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
337 UiListPtr *listptr = ucx_mempool_malloc(
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
338 obj->ctx->mempool,
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
339 sizeof(UiListPtr));
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
340 UiListView *listview = ucx_mempool_malloc(
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
341 obj->ctx->mempool,
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
342 sizeof(UiListView));
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
343 listptr->list = item->list;
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
344
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
345 Arg args[8];
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
346 XtSetArg(args[0], XmNshadowThickness, 1);
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
347 XtSetArg(args[1], XmNindicatorOn, XmINDICATOR_NONE);
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
348 XtSetArg(args[2], XmNtraversalOn, FALSE);
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
349 XtSetArg(args[3], XmNwidth, 120);
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
350 Widget combobox = XmCreateDropDownList(tb, "toolbar_combobox", args, 4);
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
351 XtManageChild(combobox);
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
352 listview->widget = combobox;
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
353 listview->list = listptr;
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
354 listview->getvalue = item->getvalue;
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
355
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
356 ui_listview_update(NULL, listview);
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
357
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
358 listptr->list->observers = ui_add_observer(
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
359 listptr->list->observers,
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
360 (ui_callback)ui_listview_update,
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
361 listview);
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
362
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
363 if(item->callback) {
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
364 // TODO:
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
365
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
366 }
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
367 }
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
368
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
369 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
370
e624b6fa4c78 added toolbar combobox (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
371 }

mercurial