ui/motif/button.c

Fri, 13 Dec 2024 10:59:31 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 13 Dec 2024 10:59:31 +0100
branch
newapi
changeset 415
e35cdf33998c
parent 406
0ebf9d7b23e8
child 419
7d15cad351fc
permissions
-rw-r--r--

finish motif path bar implementation

0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
4 * Copyright 2024 Olaf Wintermann. All rights reserved.
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1f419bd32da1 added files
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
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include "button.h"
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
33 #include "container.h"
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
34 #include "../common/context.h"
176
bc63cb601f6d port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
35 #include <cx/mempool.h>
bc63cb601f6d port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
36
bc63cb601f6d port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
37 #include <cx/linked_list.h>
bc63cb601f6d port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
38 #include <cx/array_list.h>
bc63cb601f6d port motif code to ucx 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
39 #include <cx/compare.h>
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
40
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
41 #include <Xm/XmAll.h>
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
42
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
43
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
44 UIWIDGET ui_button_create(UiObject* obj, UiButtonArgs args) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
45 Arg xargs[16];
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
46 int n = 0;
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
47
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
48 UiContainerPrivate *ctn = ui_obj_container(obj);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
49 UI_APPLY_LAYOUT(ctn->layout, args);
60
7cd1b8890302 added vbox container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 52
diff changeset
50
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
51 Widget parent = ctn->prepare(ctn, xargs, &n);
62
70d2aee84432 added grid container (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
52
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
53 XmString label = NULL;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
54 if(args.label) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
55 label = XmStringCreateLocalized((char*)args.label);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
56 XtSetArg(xargs[n], XmNlabelString, label); n++;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
57 }
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
58
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
59 char *name = args.name ? (char*)args.name : "button";
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
60 Widget button = XmCreatePushButton(parent, name, xargs, n);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
61 XtManageChild(button);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
62 ctn->add(ctn, button);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
63
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
64 ui_set_widget_groups(obj->ctx, button, args.groups);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
65
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
66 if(args.onclick) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
67 UiEventData *eventdata = malloc(sizeof(UiEventData));
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
68 eventdata->callback = args.onclick;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
69 eventdata->userdata = args.onclickdata;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
70 eventdata->obj = obj;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
71 eventdata->value = 0;
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
72 XtAddCallback(
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
73 button,
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
74 XmNactivateCallback,
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
75 (XtCallbackProc)ui_push_button_callback,
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
76 eventdata);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
77 XtAddCallback(
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
78 button,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
79 XmNdestroyCallback,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
80 (XtCallbackProc)ui_destroy_eventdata,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
81 eventdata);
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
82 }
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
83
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
84
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
85 XmStringFree(label);
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
86 return button;
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 3
diff changeset
87 }
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
89 void ui_push_button_callback(Widget widget, UiEventData *event, XtPointer d) {
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
90 UiEvent e;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
91 e.obj = event->obj;
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
92 e.window = event->obj->window;
52
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
93 e.document = event->obj->ctx->document;
17
db95c0104937 added menu item lists (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 5
diff changeset
94 e.intval = event->value;
98
efaae97bd95b added mouse event handler (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 62
diff changeset
95 event->callback(&e, event->userdata);
3
c1a75454b444 added toolbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
96 }
112
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
97
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
98 UIWIDGET ui_togglebutton_create(UiObject* obj, UiToggleArgs args) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
99 Arg xargs[16];
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
100 int n = 0;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
101
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
102 UiContainerPrivate *ctn = ui_obj_container(obj);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
103 UI_APPLY_LAYOUT(ctn->layout, args);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
104
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
105 Widget parent = ctn->prepare(ctn, xargs, &n);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
106 XtSetArg(xargs[n], XmNfillOnSelect, True); n++;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
107 XtSetArg(xargs[n], XmNindicatorOn, False); n++;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
108
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
109 XmString label = NULL;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
110 if(args.label) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
111 label = XmStringCreateLocalized((char*)args.label);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
112 XtSetArg(xargs[n], XmNlabelString, label); n++;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
113 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
114
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
115 char *name = args.name ? (char*)args.name : "togglebutton";
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
116 Widget button = XmCreateToggleButton(parent, name, xargs, n);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
117 XtManageChild(button);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
118 ctn->add(ctn, button);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
119
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
120 ui_set_widget_groups(obj->ctx, button, args.groups);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
121
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
122 ui_bind_togglebutton(obj, button, args.varname, args.value, args.onchange, args.onchangedata, args.enable_group);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
123
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
124 XmStringFree(label);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
125 return button;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
126 }
112
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
127
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
128 UIWIDGET ui_checkbox_create(UiObject* obj, UiToggleArgs args) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
129 Arg xargs[16];
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
130 int n = 0;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
131
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
132 UiContainerPrivate *ctn = ui_obj_container(obj);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
133 UI_APPLY_LAYOUT(ctn->layout, args);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
134
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
135 Widget parent = ctn->prepare(ctn, xargs, &n);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
136
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
137 XmString label = NULL;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
138 if(args.label) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
139 label = XmStringCreateLocalized((char*)args.label);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
140 XtSetArg(xargs[n], XmNlabelString, label); n++;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
141 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
142
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
143 char *name = args.name ? (char*)args.name : "button";
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
144 Widget button = XmCreateToggleButton(parent, name, xargs, n);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
145 XtManageChild(button);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
146 ctn->add(ctn, button);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
147
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
148 ui_set_widget_groups(obj->ctx, button, args.groups);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
149
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
150 ui_bind_togglebutton(obj, button, args.varname, args.value, args.onchange, args.onchangedata, args.enable_group);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
151
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
152 XmStringFree(label);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
153 return button;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
154 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
155
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
156 UIWIDGET ui_switch_create(UiObject* obj, UiToggleArgs args) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
157 return ui_checkbox_create(obj, args);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
158 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
159
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
160 static void togglebutton_changed(Widget w, UiVarEventData *event, XmToggleButtonCallbackStruct *tb) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
161 if(event->value > 0) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
162 // button in configured to enable/disable states
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
163 if(tb->set) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
164 ui_set_group(event->obj->ctx, event->value);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
165 } else {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
166 ui_unset_group(event->obj->ctx, event->value);
112
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
167 }
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
168 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
169
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
170 UiEvent e;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
171 e.obj = event->obj;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
172 e.window = e.obj->window;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
173 e.document = e.obj->ctx->document;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
174 e.eventdata = NULL;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
175 e.intval = XmToggleButtonGetState(w);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
176
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
177 if(event->callback) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
178 event->callback(&e, event->userdata);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
179 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
180
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
181 if(event->var && event->var->value) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
182 UiInteger *v = event->var->value;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
183 v->value = e.intval;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
184 ui_notify_evt(v->observers, &e);
112
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
185 }
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
186 }
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
187
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
188 void ui_bind_togglebutton(
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
189 UiObject *obj,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
190 Widget widget,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
191 const char *varname,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
192 UiInteger *value,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
193 ui_callback onchange,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
194 void *onchangedata,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
195 int enable_state)
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
196 {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
197 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, value, varname, UI_VAR_INTEGER);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
198 if(var) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
199 value = (UiInteger*)var->value;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
200 value->obj = widget;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
201 value->get = ui_togglebutton_get;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
202 value->set = ui_togglebutton_set;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
203
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
204 if(value->value) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
205 XmToggleButtonSetState(widget, True, False);
112
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
206 }
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
207 }
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
208
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
209 UiVarEventData *event = malloc(sizeof(UiVarEventData));
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
210 event->obj = obj;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
211 event->callback = onchange;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
212 event->userdata = onchangedata;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
213 event->var = var;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
214 event->observers = NULL;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
215 event->value = enable_state;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
216 XtAddCallback(
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
217 widget,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
218 XmNvalueChangedCallback,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
219 (XtCallbackProc)togglebutton_changed,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
220 event);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
221 XtAddCallback(
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
222 widget,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
223 XmNdestroyCallback,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
224 (XtCallbackProc)ui_destroy_eventdata,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
225 event);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
226 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
227
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
228 int64_t ui_togglebutton_get(UiInteger *i) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
229 Widget togglebutton = i->obj;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
230 Boolean state = XmToggleButtonGetState(togglebutton);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
231 i->value = state;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
232 return state;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
233 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
234
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
235 void ui_togglebutton_set(UiInteger *i, int64_t value) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
236 Widget togglebutton = i->obj;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
237 i->value = value;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
238 XmToggleButtonSetState(togglebutton, (Boolean)value, False);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
239 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
240
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
241 static void destroy_list(Widget w, CxList *list, XtPointer d) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
242 cxListDestroy(list);
112
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
243 }
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
244
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
245 static void radiobutton_changed(Widget w, UiVarEventData *event, XmToggleButtonCallbackStruct *tb) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
246 if(event->value > 0) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
247 // button in configured to enable/disable states
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
248 if(tb->set) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
249 ui_set_group(event->obj->ctx, event->value);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
250 } else {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
251 ui_unset_group(event->obj->ctx, event->value);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
252 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
253 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
254
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
255 if(!tb->set) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
256 return; // only handle set-events
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
257 }
112
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
258
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
259 UiInteger *value = NULL;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
260 int64_t v = 0;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
261 if(event->var) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
262 value = event->var->value;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
263 // find widget index and update all radiobuttons
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
264 // the UiInteger value must always be up-to-date
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
265 CxList *list = value->obj;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
266 CxIterator i = cxListIterator(list);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
267 cx_foreach(Widget, button, i) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
268 Boolean state = False;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
269 if(button == w) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
270 value->value = i.index+1; // update value
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
271 state = True;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
272 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
273 XmToggleButtonSetState(button, state, False);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
274 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
275 v = value->value;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
276 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
277
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
278 UiEvent e;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
279 e.obj = event->obj;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
280 e.window = e.obj->window;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
281 e.document = e.obj->ctx->document;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
282 e.eventdata = value;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
283 e.intval = v;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
284
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
285 if(event->callback) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
286 event->callback(&e, event->userdata);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
287 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
288
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
289 if(value) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
290 ui_notify_evt(value->observers, &e);
112
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
291 }
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
292 }
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
293
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
294 UIWIDGET ui_radiobutton_create(UiObject* obj, UiToggleArgs args) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
295 Arg xargs[16];
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
296 int n = 0;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
297
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
298 UiContainerPrivate *ctn = ui_obj_container(obj);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
299 UI_APPLY_LAYOUT(ctn->layout, args);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
300
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
301 Widget parent = ctn->prepare(ctn, xargs, &n);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
302 XtSetArg(xargs[n], XmNindicatorType, XmONE_OF_MANY_ROUND); n++;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
303 XmString label = NULL;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
304 if(args.label) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
305 label = XmStringCreateLocalized((char*)args.label);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
306 XtSetArg(xargs[n], XmNlabelString, label); n++;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
307 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
308
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
309 char *name = args.name ? (char*)args.name : "button";
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
310 Widget button = XmCreateToggleButton(parent, name, xargs, n);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
311 XtManageChild(button);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
312 ctn->add(ctn, button);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
313
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
314 ui_set_widget_groups(obj->ctx, button, args.groups);
112
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
315
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
316 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args.value, args.varname, UI_VAR_INTEGER);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
317 if(var) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
318 UiInteger *value = var->value;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
319 CxList *rb = value->obj;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
320 if(!rb) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
321 // first button in the radiobutton group
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
322 // create a list for all buttons and use the list as value obj
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
323 rb = cxArrayListCreateSimple(CX_STORE_POINTERS, 4);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
324 value->obj = rb;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
325 value->get = ui_radiobutton_get;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
326 value->set = ui_radiobutton_set;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
327
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
328 // the first radio button is also responsible for cleanup
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
329 XtAddCallback(
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
330 button,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
331 XmNdestroyCallback,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
332 (XtCallbackProc)destroy_list,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
333 rb);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
334 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
335 cxListAdd(rb, button);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
336
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
337 // set the radiobutton state, if the value is already set
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
338 if(cxListSize(rb) == value->value) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
339 XmToggleButtonSetState(button, True, False);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
340 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
341 }
112
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
342
406
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
343 // the radio button needs to handle change events to update all
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
344 // other buttons in the radio button group
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
345 UiVarEventData *event = malloc(sizeof(UiVarEventData));
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
346 event->obj = obj;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
347 event->callback = args.onchange;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
348 event->userdata = args.onchangedata;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
349 event->observers = NULL;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
350 event->var = var;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
351 event->value = args.enable_group;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
352 XtAddCallback(
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
353 button,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
354 XmNvalueChangedCallback,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
355 (XtCallbackProc)radiobutton_changed,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
356 event);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
357 XtAddCallback(
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
358 button,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
359 XmNdestroyCallback,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
360 (XtCallbackProc)ui_destroy_eventdata,
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
361 event);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
362
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
363 XmStringFree(label);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
364 return button;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
365
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
366
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
367 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
368
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
369 int64_t ui_radiobutton_get(UiInteger *i) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
370 // the UiInteger should be updated automatically by change events
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
371 return i->value;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
372 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
373
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
374 void ui_radiobutton_set(UiInteger *i, int64_t value) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
375 CxList *list = i->obj;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
376 if(i->value > 0) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
377 Widget current = cxListAt(list, i->value-1);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
378 if(current) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
379 XmToggleButtonSetState(current, False, False);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
380 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
381 }
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
382 if(value > 0 && value <= cxListSize(list)) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
383 Widget button = cxListAt(list, value-1);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
384 if(button) {
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
385 XmToggleButtonSetState(button, True, False);
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
386 i->value = value;
0ebf9d7b23e8 add first code of the new Motif implementation, implement buttons
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 176
diff changeset
387 }
112
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
388 }
fdd33964b35f added radio buttons (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 98
diff changeset
389 }

mercurial