annotate lwlib/lwlib-Xm.c @ 342:b036ce23deaa

Added tag r21-1-0 for changeset 2538ab34df21
author cvs
date Mon, 13 Aug 2007 10:52:06 +0200
parents f220cc83d72e
children 74fd4e045ea6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* The lwlib interface to Motif widgets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1992, 1993, 1994 Lucid, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This file is part of the Lucid Widget Library.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 The Lucid Widget Library is free software; you can redistribute it and/or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 modify it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 The Lucid Widget Library is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
20 Boston, MA 02111-1307, USA. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
157
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 80
diff changeset
22 #include <config.h>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 #include <stdlib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 #include <string.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 #include <limits.h>
157
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 80
diff changeset
27 #ifdef HAVE_UNISTD_H
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 80
diff changeset
28 #include <unistd.h>
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 80
diff changeset
29 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include <X11/StringDefs.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #include <X11/IntrinsicP.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include <X11/ObjectP.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include <X11/CoreP.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #include <X11/CompositeP.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #include "lwlib-Xm.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 #include "lwlib-utils.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 #include <Xm/Xm.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 #include <Xm/BulletinB.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 #include <Xm/CascadeB.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 #include <Xm/DrawingA.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 #include <Xm/FileSB.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 #include <Xm/Label.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 #include <Xm/List.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 #include <Xm/MenuShell.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 #include <Xm/MessageB.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 #include <Xm/PushB.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 #include <Xm/PushBG.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 #include <Xm/ArrowB.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 #include <Xm/ScrollBar.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 #include <Xm/SelectioB.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 #include <Xm/Text.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 #include <Xm/TextF.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 #include <Xm/ToggleB.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 #include <Xm/ToggleBG.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 #include <Xm/RowColumn.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 #include <Xm/ScrolledW.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 #include <Xm/Separator.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 #include <Xm/DialogS.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 #include <Xm/Form.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
64 #ifdef LWLIB_MENUBARS_MOTIF
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 static void xm_pull_down_callback (Widget, XtPointer, XtPointer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 static void xm_pop_down_callback (Widget, XtPointer, XtPointer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 static void xm_internal_update_other_instances (Widget, XtPointer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 XtPointer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 static void xm_generic_callback (Widget, XtPointer, XtPointer);
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
73 #ifdef LWLIB_DIALOGS_MOTIF
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 static void xm_nosel_callback (Widget, XtPointer, XtPointer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 #endif
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
76 #ifdef LWLIB_SCROLLBARS_MOTIF
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 static void xm_scrollbar_callback (Widget, XtPointer, XtPointer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
80 #ifdef LWLIB_MENUBARS_MOTIF
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 xm_update_menu (widget_instance* instance, Widget widget, widget_value* val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 Boolean deep_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 /* Structures to keep destroyed instances */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 typedef struct _destroyed_instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 char* name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 char* type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 Widget widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 Widget parent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 Boolean pop_up_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 struct _destroyed_instance* next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 } destroyed_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 static destroyed_instance*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 all_destroyed_instances = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 /* Utility function. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 safe_strdup (char* s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 char *result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 if (! s) return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 result = (char *) malloc (strlen (s) + 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 if (! result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 strcpy (result, s);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 static destroyed_instance*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 make_destroyed_instance (char* name, char* type, Widget widget, Widget parent,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 Boolean pop_up_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
117 destroyed_instance* instance =
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
118 (destroyed_instance*) malloc (sizeof (destroyed_instance));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 instance->name = safe_strdup (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 instance->type = safe_strdup (type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 instance->widget = widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 instance->parent = parent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 instance->pop_up_p = pop_up_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 instance->next = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 return instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 free_destroyed_instance (destroyed_instance* instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 free (instance->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 free (instance->type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 free (instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 /* motif utility functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 Widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 first_child (Widget widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 return ((CompositeWidget)widget)->composite.children [0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 Boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 lw_motif_widget_p (Widget widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 return
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
147 #ifdef LWLIB_DIALOGS_MOTIF
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 XtClass (widget) == xmDialogShellWidgetClass ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 XmIsPrimitive (widget) || XmIsManager (widget) || XmIsGadget (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 resource_string (Widget widget, char *name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 XtResource resource;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 char *result = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
159 resource.resource_name = "labelString";
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
160 resource.resource_class = "LabelString"; /* #### should be Xmsomething... */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 resource.resource_type = XtRString;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 resource.resource_size = sizeof (String);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 resource.resource_offset = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 resource.default_type = XtRImmediate;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 resource.default_addr = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 XtGetSubresources (widget, (XtPointer)&result, name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 name, &resource, 1, NULL, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
172 #ifdef LWLIB_MENUBARS_MOTIF
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 destroy_all_children (Widget widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 Widget* children;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 unsigned int number;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 children = XtCompositeChildren (widget, &number);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 if (children)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 /* Unmanage all children and destroy them. They will only be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 * really destroyed when we get out of DispatchEvent. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 for (i = 0; i < number; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 Widget child = children [i];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 if (!child->core.being_destroyed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 XtUnmanageChild (child);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 XtDestroyWidget (child);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 XtFree ((char *) children);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
199 #endif /* LWLIB_MENUBARS_MOTIF */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
203 #ifdef LWLIB_DIALOGS_MOTIF
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 static Boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 is_in_dialog_box (Widget w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 Widget wmshell;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 wmshell = XtParent (w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 while (wmshell && (XtClass (wmshell) != xmDialogShellWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 wmshell = XtParent (wmshell);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 if (wmshell && XtClass (wmshell) == xmDialogShellWidgetClass)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 return True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 return False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
220 #endif /* LWLIB_DIALOGS_MOTIF */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
222 #if defined (LWLIB_DIALOGS_MOTIF) || defined (LWLIB_MENUBARS_MOTIF)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 /* update the label of anything subclass of a label */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 xm_update_label (widget_instance* instance, Widget widget, widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 {
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
228 XmString built_string = NULL;
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
229 XmString key_string = NULL;
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
230 XmString val_string = NULL;
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
231 XmString name_string = NULL;
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
232 Arg al [20];
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
233 int ac = 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 if (val->value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 {
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
237 #ifdef LWLIB_DIALOGS_MOTIF
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 * Sigh. The main text of a label is the name field for menubar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 * entries. The value field is a possible additional field to be
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
241 * concatenated on to the name field. HOWEVER, with dialog boxes
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 * the value field is the complete text which is supposed to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 * displayed as the label. Yuck.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 if (is_in_dialog_box (widget))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 char *value_name = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 value_name = resource_string (widget, val->value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 if (!value_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 value_name = val->value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 built_string =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 XmStringCreateLtoR (value_name, XmSTRING_DEFAULT_CHARSET);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 else
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
257 #endif /* LWLIB_DIALOGS_MOTIF */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 char *value_name = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 char *res_name = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 res_name = resource_string (widget, val->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 if (!res_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 res_name = val->name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 name_string =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 XmStringCreateLtoR (res_name, XmSTRING_DEFAULT_CHARSET);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 value_name = XtMalloc (strlen (val->value) + 2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 *value_name = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 strcat (value_name, " ");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 strcat (value_name, val->value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 val_string =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 XmStringCreateLtoR (value_name, XmSTRING_DEFAULT_CHARSET);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 built_string =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 XmStringConcat (name_string, val_string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 XtFree (value_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 XtSetArg (al [ac], XmNlabelString, built_string); ac++;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
284 XtSetArg (al [ac], XmNlabelType, XmSTRING); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 if (val->key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 key_string = XmStringCreateLtoR (val->key, XmSTRING_DEFAULT_CHARSET);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 XtSetArg (al [ac], XmNacceleratorText, key_string); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 if (ac)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 XtSetValues (widget, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 if (built_string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 XmStringFree (built_string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 if (key_string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 XmStringFree (key_string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 if (name_string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 XmStringFree (name_string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
306 #endif /* defined (LWLIB_DIALOGS_MOTIF) || defined (LWLIB_MENUBARS_MOTIF) */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 /* update of list */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 xm_update_list (widget_instance* instance, Widget widget, widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 widget_value* cur;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 XtRemoveAllCallbacks (widget, XmNsingleSelectionCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 XtAddCallback (widget, XmNsingleSelectionCallback, xm_generic_callback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 for (cur = val->contents, i = 0; cur; cur = cur->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 if (cur->value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 XmString xmstr = XmStringCreate (cur->value, XmSTRING_DEFAULT_CHARSET);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 i += 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 XmListAddItem (widget, xmstr, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 if (cur->selected)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 XmListSelectPos (widget, i, False);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 XmStringFree (xmstr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 /* update of buttons */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 xm_update_pushbutton (widget_instance* instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 {
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
334 Arg al [1];
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
335 XtSetArg (al [0], XmNalignment, XmALIGNMENT_CENTER);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
336 XtSetValues (widget, al, 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 XtRemoveAllCallbacks (widget, XmNactivateCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 XtAddCallback (widget, XmNactivateCallback, xm_generic_callback, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
341 #ifdef LWLIB_MENUBARS_MOTIF
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 xm_update_cascadebutton (widget_instance* instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 /* Should also rebuild the menu by calling ...update_menu... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 if (val
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 && val->type == CASCADE_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 && val->contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 && val->contents->type == INCREMENTAL_TYPE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 /* okay, we're now doing a lisp callback to incrementally generate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 more of the menu. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 XtRemoveAllCallbacks (widget, XmNcascadingCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 XtAddCallback (widget, XmNcascadingCallback, xm_pull_down_callback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 XtCallCallbacks ((Widget)widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 XmNcascadingCallback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (XtPointer)val->contents);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 } else {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 XtRemoveAllCallbacks (widget, XmNcascadingCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 XtAddCallback (widget, XmNcascadingCallback, xm_pull_down_callback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
369 #endif /* LWLIB_MENUBARS_MOTIF */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 /* update toggle and radiobox */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 xm_update_toggle (widget_instance* instance, Widget widget, widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 {
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
375 Arg al [2];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 XtRemoveAllCallbacks (widget, XmNvalueChangedCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 XtAddCallback (widget, XmNvalueChangedCallback, xm_generic_callback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 instance);
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
379 XtSetArg (al [0], XmNset, val->selected);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
380 XtSetArg (al [1], XmNalignment, XmALIGNMENT_BEGINNING);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
381 XtSetValues (widget, al, 2);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 xm_update_radiobox (widget_instance* instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 Widget toggle;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 widget_value* cur;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 /* update the callback */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 XtRemoveAllCallbacks (widget, XmNentryCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 XtAddCallback (widget, XmNentryCallback, xm_generic_callback, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 /* first update all the toggles */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 /* Energize kernel interface is currently bad. It sets the selected widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 with the selected flag but returns it by its name. So we currently
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 have to support both setting the selection with the selected slot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 of val contents and setting it with the "value" slot of val. The latter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 has a higher priority. This to be removed when the kernel is fixed. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 for (cur = val->contents; cur; cur = cur->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 toggle = XtNameToWidget (widget, cur->value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 if (toggle)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 {
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
406 Arg al [2];
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
407 XtSetArg (al [0], XmNsensitive, cur->enabled);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
408 XtSetArg (al [1], XmNset, (!val->value && cur->selected ? cur->selected : False));
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
409 XtSetValues (toggle, al, 2);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 /* The selected was specified by the value slot */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 if (val->value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 toggle = XtNameToWidget (widget, val->value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 if (toggle)
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
418 {
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
419 Arg al [1];
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
420 XtSetArg (al [0], XmNset, True);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
421 XtSetValues (toggle, al, 1);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
422 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
426 #ifdef LWLIB_MENUBARS_MOTIF
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 /* update a popup menu, pulldown menu or a menubar */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 make_menu_in_widget (widget_instance* instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 Widget* children = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 int num_children;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 int child_index;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 widget_value* cur;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 Widget button = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 Widget menu;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 Arg al [256];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 int ac;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
441 Boolean menubar_p = False;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 /* Allocate the children array */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 for (num_children = 0, cur = val; cur; num_children++, cur = cur->next);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 children = (Widget*)XtMalloc (num_children * sizeof (Widget));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 /* tricky way to know if this RowColumn is a menubar or a pulldown... */
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
448 XtSetArg (al [0], XmNisHomogeneous, &menubar_p);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
449 XtGetValues (widget, al, 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 /* add the unmap callback for popups and pulldowns */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 /*** this sounds bogus ***/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 /* probably because it is -- cet */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 if (!menubar_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 XtAddCallback (XtParent (widget), XmNpopdownCallback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 xm_pop_down_callback, (XtPointer)instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 num_children = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 for (child_index = 0, cur = val; cur; child_index++, cur = cur->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 ac = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 button = 0;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
465 XtSetArg (al [ac], XmNsensitive, cur->enabled); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
466 XtSetArg (al [ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
467 XtSetArg (al [ac], XmNuserData, cur->call_data); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 switch (cur->type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 case PUSHRIGHT_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 /* A pushright marker which is not needed for the real Motif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 menubar. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 case SEPARATOR_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 ac = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 if (cur->value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 /* #### - xlwmenu.h supports several types that motif does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 not. Also, motif supports pixmaps w/ type NO_LINE and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 lwlib provides no way to access that functionality. --Stig */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 XtSetArg (al [ac], XmNseparatorType, cur->value), ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 button = XmCreateSeparator (widget, "separator", al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 case CASCADE_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 menu = XmCreatePulldownMenu (widget, "pulldown", NULL, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 make_menu_in_widget (instance, menu, cur->contents);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 XtSetArg (al [ac], XmNsubMenuId, menu); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 button = XmCreateCascadeButton (widget, cur->name, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 xm_update_label (instance, button, cur);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 XtAddCallback (button, XmNcascadingCallback, xm_pull_down_callback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (XtPointer)instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 if (menubar_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 button = XmCreateCascadeButton (widget, cur->name, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 else if (!cur->call_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 button = XmCreateLabel (widget, cur->name, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 else if (cur->type == TOGGLE_TYPE || cur->type == RADIO_TYPE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 {
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
504 XtSetArg (al [ac], XmNindicatorType,
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
505 (cur->type == TOGGLE_TYPE ?
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
506 XmN_OF_MANY : XmONE_OF_MANY)); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 XtSetArg (al [ac], XmNvisibleWhenOff, True); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 button = XmCreateToggleButtonGadget (widget, cur->name, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 button = XmCreatePushButtonGadget (widget, cur->name, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 xm_update_label (instance, button, cur);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 /* don't add a callback to a simple label */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 if (cur->type == TOGGLE_TYPE || cur->type == RADIO_TYPE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 xm_update_toggle (instance, button, cur);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 else if (cur->call_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 XtAddCallback (button, XmNactivateCallback, xm_generic_callback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (XtPointer)instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 } /* switch (cur->type) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 if (button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 children [num_children++] = button;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 /* Last entry is the help button. This used be done after managing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 the buttons. The comment claimed that it had to be done this way
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 otherwise the menubar ended up only 4 pixels high. That must
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 have been in the Old World. In the New World it stays the proper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 height if you don't manage them until after you set this and as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 bonus the Help menu ends up where it is supposed to. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 if (button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 ac = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 XtSetArg (al [ac], XmNmenuHelpWidget, button); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 XtSetValues (widget, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 if (num_children)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 XtManageChildren (children, num_children);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 XtFree ((char *) children);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 update_one_menu_entry (widget_instance* instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 widget_value* val, Boolean deep_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 {
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
550 Arg al [2];
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 171
diff changeset
551 int ac;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 Widget menu;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 widget_value* contents;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 if (val->change == NO_CHANGE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 /* update the sensitivity and userdata */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 /* Common to all widget types */
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
560 XtSetArg (al [0], XmNsensitive, val->enabled);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
561 XtSetArg (al [1], XmNuserData, val->call_data);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
562 XtSetValues (widget, al, 2);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 /* update the menu button as a label. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 if (val->change >= VISIBLE_CHANGE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 xm_update_label (instance, widget, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 if (XtClass (widget) == xmToggleButtonWidgetClass
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 || XtClass (widget) == xmToggleButtonGadgetClass)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 xm_update_toggle (instance, widget, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 /* update the pulldown/pullaside as needed */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 menu = NULL;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
578 XtSetArg (al [0], XmNsubMenuId, &menu);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
579 XtGetValues (widget, al, 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 contents = val->contents;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 if (!menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 if (contents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 menu = XmCreatePulldownMenu (widget, "pulldown", NULL, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 make_menu_in_widget (instance, menu, contents);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 ac = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 XtSetArg (al [ac], XmNsubMenuId, menu); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 XtSetValues (widget, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 else if (!contents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 ac = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 XtSetArg (al [ac], XmNsubMenuId, NULL); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 XtSetValues (widget, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 XtDestroyWidget (menu);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 else if (deep_p && contents->change != NO_CHANGE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 xm_update_menu (instance, menu, val, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 xm_update_menu (widget_instance* instance, Widget widget, widget_value* val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 Boolean deep_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 /* Widget is a RowColumn widget whose contents have to be updated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 * to reflect the list of items in val->contents */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 if (val->contents->change == STRUCTURAL_CHANGE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 destroy_all_children (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 make_menu_in_widget (instance, widget, val->contents);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 /* Update all the buttons of the RowColumn in order. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 Widget* children;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 unsigned int num_children;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 widget_value *cur = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 children = XtCompositeChildren (widget, &num_children);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 if (children)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 for (i = 0, cur = val->contents; i < num_children; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 if (!cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 /* skip if this is a pushright marker or a separator */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 if (cur->type == PUSHRIGHT_TYPE || cur->type == SEPARATOR_TYPE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 cur = cur->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 /* #### - this could puke if you have a separator as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 last item on a pullright menu. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 if (!cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 if (!cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 if (children [i]->core.being_destroyed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 || strcmp (XtName (children [i]), cur->name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 update_one_menu_entry (instance, children [i], cur, deep_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 cur = cur->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 XtFree ((char *) children);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 if (cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
658 #endif /* LWLIB_MENUBARS_MOTIF */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
661 #ifdef LWLIB_DIALOGS_MOTIF
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 /* update text widgets */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 xm_update_text (widget_instance* instance, Widget widget, widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
668 XmTextSetString (widget, val->value ? val->value : "");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 XtRemoveAllCallbacks (widget, XmNactivateCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 XtAddCallback (widget, XmNactivateCallback, xm_generic_callback, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 XtRemoveAllCallbacks (widget, XmNvalueChangedCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 XtAddCallback (widget, XmNvalueChangedCallback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 xm_internal_update_other_instances, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 xm_update_text_field (widget_instance* instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
680 XmTextFieldSetString (widget, val->value ? val->value : "");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 XtRemoveAllCallbacks (widget, XmNactivateCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 XtAddCallback (widget, XmNactivateCallback, xm_generic_callback, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 XtRemoveAllCallbacks (widget, XmNvalueChangedCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 XtAddCallback (widget, XmNvalueChangedCallback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 xm_internal_update_other_instances, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
688 #endif /* LWLIB_DIALOGS_MOTIF */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
690 #ifdef LWLIB_SCROLLBARS_MOTIF
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 * If this function looks like it does a lot more work than it needs to,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 * you're right. Blame the Motif scrollbar for not being smart about
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 * updating its appearance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 xm_update_scrollbar (widget_instance *instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 widget_value *val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 if (val->scrollbar_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 scrollbar_values *data = val->scrollbar_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 int widget_sliderSize, widget_val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 int new_sliderSize, new_value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 double percent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 double h_water, l_water;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
708 Arg al [4];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
710 /* First size and position the scrollbar widget. */
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
711 XtSetArg (al [0], XtNx, data->scrollbar_x);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
712 XtSetArg (al [1], XtNy, data->scrollbar_y);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
713 XtSetArg (al [2], XtNwidth, data->scrollbar_width);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
714 XtSetArg (al [3], XtNheight, data->scrollbar_height);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
715 XtSetValues (widget, al, 4);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
717 /* Now size the scrollbar's slider. */
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
718 XtSetArg (al [0], XmNsliderSize, &widget_sliderSize);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
719 XtSetArg (al [1], XmNvalue, &widget_val);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
720 XtGetValues (widget, al, 2);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 percent = (double) data->slider_size /
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (double) (data->maximum - data->minimum);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 new_sliderSize = (int) ((double) (INT_MAX - 1) * percent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 percent = (double) (data->slider_position - data->minimum) /
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (double) (data->maximum - data->minimum);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 new_value = (int) ((double) (INT_MAX - 1) * percent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 if (new_sliderSize > (INT_MAX - 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 new_sliderSize = INT_MAX - 1;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
732 else if (new_sliderSize < 1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 new_sliderSize = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 if (new_value > (INT_MAX - new_sliderSize))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 new_value = INT_MAX - new_sliderSize;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 else if (new_value < 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 new_value = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 h_water = 1.05;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 l_water = 0.95;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 if (new_sliderSize != widget_sliderSize || new_value != widget_val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 int force = ((INT_MAX - widget_sliderSize - widget_val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 ? 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 : (INT_MAX - new_sliderSize - new_value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 if (force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 || (double)new_sliderSize < (l_water * (double)widget_sliderSize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 || (double)new_sliderSize > (h_water * (double)widget_sliderSize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 || (double)new_value < (l_water * (double)widget_val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 || (double)new_value > (h_water * (double)widget_val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 XmScrollBarSetValues (widget, new_value, new_sliderSize, 1, 1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 False);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
761 #endif /* LWLIB_SCROLLBARS_MOTIF */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 /* update a motif widget */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 xm_update_one_widget (widget_instance* instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 widget_value* val, Boolean deep_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 WidgetClass class;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
771 Arg al [2];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 /* Mark as not edited */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 val->edited = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 /* Common to all widget types */
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
777 XtSetArg (al [0], XmNsensitive, val->enabled);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
778 XtSetArg (al [1], XmNuserData, val->call_data);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
779 XtSetValues (widget, al, 2);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
781 #if defined (LWLIB_DIALOGS_MOTIF) || defined (LWLIB_MENUBARS_MOTIF)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 /* Common to all label like widgets */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 if (XtIsSubclass (widget, xmLabelWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 xm_update_label (instance, widget, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 class = XtClass (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 /* Class specific things */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 if (class == xmPushButtonWidgetClass ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 class == xmArrowButtonWidgetClass)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 xm_update_pushbutton (instance, widget, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 }
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
794 #ifdef LWLIB_MENUBARS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
795 else if (class == xmCascadeButtonWidgetClass)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
796 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
797 xm_update_cascadebutton (instance, widget, val);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
798 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
799 #endif
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
800 else if (class == xmToggleButtonWidgetClass
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
801 || class == xmToggleButtonGadgetClass)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
802 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
803 xm_update_toggle (instance, widget, val);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
804 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
805 else if (class == xmRowColumnWidgetClass)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
806 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
807 Boolean radiobox = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
808
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
809 XtSetArg (al [0], XmNradioBehavior, &radiobox);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
810 XtGetValues (widget, al, 1);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
811
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
812 if (radiobox)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
813 xm_update_radiobox (instance, widget, val);
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
814 #ifdef LWLIB_MENUBARS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
815 else
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
816 xm_update_menu (instance, widget, val, deep_p);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
817 #endif
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
818 }
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
819 #ifdef LWLIB_DIALOGS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
820 else if (class == xmTextWidgetClass)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
821 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
822 xm_update_text (instance, widget, val);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
823 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
824 else if (class == xmTextFieldWidgetClass)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
825 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
826 xm_update_text_field (instance, widget, val);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
827 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
828 #endif
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
829 else if (class == xmListWidgetClass)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
830 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
831 xm_update_list (instance, widget, val);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
832 }
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
833 #ifdef LWLIB_SCROLLBARS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
834 else if (class == xmScrollBarWidgetClass)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
835 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
836 xm_update_scrollbar (instance, widget, val);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
837 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
838 #endif
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
839 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
840
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
841 /* getting the value back */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
842 void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
843 xm_update_one_value (widget_instance* instance, Widget widget,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
844 widget_value* val)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
845 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
846 WidgetClass class = XtClass (widget);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
847 widget_value *old_wv;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
848
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
849 /* copy the call_data slot into the "return" widget_value */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
850 for (old_wv = instance->info->val->contents; old_wv; old_wv = old_wv->next)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
851 if (!strcmp (val->name, old_wv->name))
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
852 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
853 val->call_data = old_wv->call_data;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
854 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
855 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
856
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
857 if (class == xmToggleButtonWidgetClass || class == xmToggleButtonGadgetClass)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
858 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
859 Arg al [1];
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
860 XtSetArg (al [0], XmNset, &val->selected);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
861 XtGetValues (widget, al, 1);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
862 val->edited = True;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
863 }
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
864 #ifdef LWLIB_DIALOGS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
865 else if (class == xmTextWidgetClass)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
866 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
867 if (val->value)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
868 free (val->value);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
869 val->value = XmTextGetString (widget);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
870 val->edited = True;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
871 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
872 else if (class == xmTextFieldWidgetClass)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
873 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
874 if (val->value)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
875 free (val->value);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
876 val->value = XmTextFieldGetString (widget);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
877 val->edited = True;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
878 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
879 #endif
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
880 else if (class == xmRowColumnWidgetClass)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
881 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
882 Boolean radiobox = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
883 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
884 Arg al [1];
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
885 XtSetArg (al [0], XmNradioBehavior, &radiobox);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
886 XtGetValues (widget, al, 1);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
887 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
888
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
889 if (radiobox)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
890 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
891 CompositeWidget radio = (CompositeWidget)widget;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
892 int i;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
893 for (i = 0; i < radio->composite.num_children; i++)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
894 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
895 int set = False;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
896 Widget toggle = radio->composite.children [i];
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
897 Arg al [1];
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
898
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
899 XtSetArg (al [0], XmNset, &set);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
900 XtGetValues (toggle, al, 1);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
901 if (set)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
902 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
903 if (val->value)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
904 free (val->value);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
905 val->value = safe_strdup (XtName (toggle));
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
906 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
907 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
908 val->edited = True;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
909 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
910 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
911 else if (class == xmListWidgetClass)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
912 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
913 int pos_cnt;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
914 int* pos_list;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
915 if (XmListGetSelectedPos (widget, &pos_list, &pos_cnt))
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
916 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
917 int i;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
918 widget_value* cur;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
919 for (cur = val->contents, i = 0; cur; cur = cur->next)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
920 if (cur->value)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
921 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
922 int j;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
923 cur->selected = False;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
924 i += 1;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
925 for (j = 0; j < pos_cnt; j++)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
926 if (pos_list [j] == i)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
927 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
928 cur->selected = True;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
929 val->value = safe_strdup (cur->name);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
930 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
931 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
932 val->edited = 1;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
933 XtFree ((char *) pos_list);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
934 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
935 }
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
936 #ifdef LWLIB_SCROLLBARS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
937 else if (class == xmScrollBarWidgetClass)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
938 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
939 /* This function is not used by the scrollbar. */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
940 return;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
941 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
942 #endif
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
943 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
944
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
945
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
946 /* This function is for activating a button from a program. It's wrong because
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
947 we pass a NULL argument in the call_data which is not Motif compatible.
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
948 This is used from the XmNdefaultAction callback of the List widgets to
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
949 have a dble-click put down a dialog box like the button woudl do.
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
950 I could not find a way to do that with accelerators.
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
951 */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
952 static void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
953 activate_button (Widget widget, XtPointer closure, XtPointer call_data)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
954 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
955 Widget button = (Widget)closure;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
956 XtCallCallbacks (button, XmNactivateCallback, NULL);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
957 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
958
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
959 /* creation functions */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
960
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
961 #ifdef LWLIB_DIALOGS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
962
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
963 /* dialogs */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
964
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
965 #if (XmVersion >= 1002)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
966 # define ARMANDACTIVATE_KLUDGE
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
967 # define DND_KLUDGE
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
968 #endif
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
969
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
970 #ifdef ARMANDACTIVATE_KLUDGE
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
971 /* We want typing Return at a dialog box to select the default button; but
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
972 we're satisfied with having it select the leftmost button instead.
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
973
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
974 In Motif 1.1.5 we could do this by putting this resource in the
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
975 app-defaults file:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
976
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
977 *dialog*button1.accelerators:#override\
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
978 <KeyPress>Return: ArmAndActivate()\n\
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
979 <KeyPress>KP_Enter: ArmAndActivate()\n\
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
980 Ctrl<KeyPress>m: ArmAndActivate()\n
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
981
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
982 but that doesn't work with 1.2.1 and I don't understand why. However,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
983 doing the equivalent C code does work, with the notable disadvantage that
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
984 the user can't override it. So that's what we do until we figure out
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
985 something better....
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
986 */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
987 static char button_trans[] = "\
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
988 <KeyPress>Return: ArmAndActivate()\n\
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
989 <KeyPress>KP_Enter: ArmAndActivate()\n\
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
990 Ctrl<KeyPress>m: ArmAndActivate()\n";
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
991
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
992 #endif /* ARMANDACTIVATE_KLUDGE */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
993
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
994
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
995 #ifdef DND_KLUDGE
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
996 /* This is a kludge to disable drag-and-drop in dialog boxes. The symptom
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
997 was a segv down in libXm somewhere if you used the middle button on a
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
998 dialog box to begin a drag; when you released the button to make a drop
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
999 things would lose if you were not over the button where you started the
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1000 drag (canceling the operation). This was probably due to the fact that
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1001 the dialog boxes were not set up to handle a drag but were trying to do
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1002 so anyway for some reason.
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1003
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1004 So we disable drag-and-drop in dialog boxes by turning off the binding for
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1005 Btn2Down which, by default, initiates a drag. Clearly this is a shitty
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1006 solution as it only works in default configurations, but...
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1007 */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1008 static char disable_dnd_trans[] = "<Btn2Down>: ";
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1009 #endif /* DND_KLUDGE */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1010
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1011
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1012 static Widget
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1013 make_dialog (char* name, Widget parent, Boolean pop_up_p,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1014 CONST char* shell_title, CONST char* icon_name,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1015 Boolean text_input_slot, Boolean radio_box, Boolean list,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1016 int left_buttons, int right_buttons)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1017 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1018 Widget result;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1019 Widget form;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1020 Widget row;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1021 Widget icon;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1022 Widget icon_separator;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1023 Widget message;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1024 Widget value = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1025 Widget separator;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1026 Widget button = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1027 Widget children [16]; /* for the final XtManageChildren */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1028 int n_children;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1029 Arg al[64]; /* Arg List */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1030 int ac; /* Arg Count */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1031 int i;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1032
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1033 #ifdef DND_KLUDGE
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1034 XtTranslations dnd_override = XtParseTranslationTable (disable_dnd_trans);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1035 # define DO_DND_KLUDGE(widget) XtOverrideTranslations ((widget), dnd_override)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1036 #else /* ! DND_KLUDGE */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1037 # define DO_DND_KLUDGE(widget)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1038 #endif /* ! DND_KLUDGE */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1039
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1040 if (pop_up_p)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1041 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1042 ac = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1043 XtSetArg(al[ac], XmNtitle, shell_title); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1044 XtSetArg(al[ac], XtNallowShellResize, True); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1045 XtSetArg(al[ac], XmNdeleteResponse, XmUNMAP); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1046 result = XmCreateDialogShell (parent, "dialog", al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1047
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1048 XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1049 /* XtSetArg(al[ac], XmNautoUnmanage, TRUE); ac++; */ /* ####is this ok? */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1050 XtSetArg(al[ac], XmNnavigationType, XmTAB_GROUP); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1051 form = XmCreateForm (result, (char *) shell_title, al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1052 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1053 else
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1054 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1055 ac = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1056 XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1057 XtSetArg(al[ac], XmNnavigationType, XmTAB_GROUP); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1058 form = XmCreateForm (parent, (char *) shell_title, al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1059 result = form;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1060 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1061
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1062 ac = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1063 XtSetArg(al[ac], XmNpacking, XmPACK_COLUMN); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1064 XtSetArg(al[ac], XmNorientation, XmVERTICAL); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1065 XtSetArg(al[ac], XmNnumColumns, left_buttons + right_buttons + 1); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1066 XtSetArg(al[ac], XmNmarginWidth, 0); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1067 XtSetArg(al[ac], XmNmarginHeight, 0); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1068 XtSetArg(al[ac], XmNspacing, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1069 XtSetArg(al[ac], XmNadjustLast, False); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1070 XtSetArg(al[ac], XmNalignment, XmALIGNMENT_CENTER); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1071 XtSetArg(al[ac], XmNisAligned, True); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1072 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1073 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1074 XtSetArg(al[ac], XmNbottomOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1075 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1076 XtSetArg(al[ac], XmNleftOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1077 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1078 XtSetArg(al[ac], XmNrightOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1079 row = XmCreateRowColumn (form, "row", al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1080
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1081 n_children = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1082 for (i = 0; i < left_buttons; i++)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1083 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1084 char button_name [16];
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1085 sprintf (button_name, "button%d", i + 1);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1086 ac = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1087 if (i == 0)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1088 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1089 XtSetArg(al[ac], XmNhighlightThickness, 1); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1090 XtSetArg(al[ac], XmNshowAsDefault, TRUE); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1091 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1092 XtSetArg(al[ac], XmNnavigationType, XmTAB_GROUP); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1093 children [n_children] = XmCreatePushButton (row, button_name, al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1094 DO_DND_KLUDGE (children [n_children]);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1095
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1096 if (i == 0)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1097 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1098 button = children [n_children];
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1099 ac = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1100 XtSetArg(al[ac], XmNdefaultButton, button); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1101 XtSetValues (row, al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1102
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1103 #ifdef ARMANDACTIVATE_KLUDGE /* See comment above */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1104 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1105 XtTranslations losers = XtParseTranslationTable (button_trans);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1106 XtOverrideTranslations (button, losers);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1107 XtFree ((char *) losers);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1108 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1109 #endif /* ARMANDACTIVATE_KLUDGE */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1110 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1111
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1112 n_children++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1113 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1114
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1115 /* invisible seperator button */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1116 ac = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1117 XtSetArg (al[ac], XmNmappedWhenManaged, FALSE); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1118 children [n_children] = XmCreateLabel (row, "separator_button",
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1119 al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1120 DO_DND_KLUDGE (children [n_children]);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1121 n_children++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1122
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1123 for (i = 0; i < right_buttons; i++)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1124 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1125 char button_name [16];
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1126 sprintf (button_name, "button%d", left_buttons + i + 1);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1127 ac = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1128 XtSetArg(al[ac], XmNnavigationType, XmTAB_GROUP); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1129 children [n_children] = XmCreatePushButton (row, button_name, al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1130 DO_DND_KLUDGE (children [n_children]);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1131 if (! button) button = children [n_children];
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1132 n_children++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1133 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1134
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1135 XtManageChildren (children, n_children);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1136
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1137 ac = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1138 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1139 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1140 XtSetArg(al[ac], XmNbottomOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1141 XtSetArg(al[ac], XmNbottomWidget, row); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1142 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1143 XtSetArg(al[ac], XmNleftOffset, 0); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1144 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1145 XtSetArg(al[ac], XmNrightOffset, 0); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1146 separator = XmCreateSeparator (form, "", al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1147
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1148 ac = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1149 XtSetArg(al[ac], XmNlabelType, XmPIXMAP); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1150 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1151 XtSetArg(al[ac], XmNtopOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1152 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1153 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1154 XtSetArg(al[ac], XmNleftOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1155 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1156 icon = XmCreateLabel (form, (char *) icon_name, al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1157 DO_DND_KLUDGE (icon);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1158
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1159 ac = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1160 XtSetArg(al[ac], XmNmappedWhenManaged, FALSE); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1161 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1162 XtSetArg(al[ac], XmNtopOffset, 6); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1163 XtSetArg(al[ac], XmNtopWidget, icon); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1164 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1165 XtSetArg(al[ac], XmNbottomOffset, 6); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1166 XtSetArg(al[ac], XmNbottomWidget, separator); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1167 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_NONE); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1168 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1169 icon_separator = XmCreateLabel (form, "", al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1170 DO_DND_KLUDGE (icon_separator);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1172 if (text_input_slot)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1173 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1174 ac = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1175 XtSetArg(al[ac], XmNcolumns, 50); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1176 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1177 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1178 XtSetArg(al[ac], XmNbottomOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1179 XtSetArg(al[ac], XmNbottomWidget, separator); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1180 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1181 XtSetArg(al[ac], XmNleftOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1182 XtSetArg(al[ac], XmNleftWidget, icon); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1183 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1184 XtSetArg(al[ac], XmNrightOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1185 value = XmCreateTextField (form, "value", al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1186 DO_DND_KLUDGE (value);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1187 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1188 else if (radio_box)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1189 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1190 Widget radio_butt;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1191 ac = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1192 XtSetArg(al[ac], XmNmarginWidth, 0); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1193 XtSetArg(al[ac], XmNmarginHeight, 0); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1194 XtSetArg(al[ac], XmNspacing, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1195 XtSetArg(al[ac], XmNalignment, XmALIGNMENT_CENTER); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1196 XtSetArg(al[ac], XmNorientation, XmHORIZONTAL); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1197 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1198 XtSetArg(al[ac], XmNbottomOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1199 XtSetArg(al[ac], XmNbottomWidget, separator); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1200 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1201 XtSetArg(al[ac], XmNleftOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1202 XtSetArg(al[ac], XmNleftWidget, icon); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1203 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1204 XtSetArg(al[ac], XmNrightOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1205 value = XmCreateRadioBox (form, "radiobutton1", al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1206 ac = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1207 i = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1208 radio_butt = XmCreateToggleButtonGadget (value, "radio1", al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1209 children [i++] = radio_butt;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1210 radio_butt = XmCreateToggleButtonGadget (value, "radio2", al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1211 children [i++] = radio_butt;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1212 radio_butt = XmCreateToggleButtonGadget (value, "radio3", al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1213 children [i++] = radio_butt;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1214 XtManageChildren (children, i);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1215 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1216 else if (list)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1217 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1218 ac = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1219 XtSetArg(al[ac], XmNvisibleItemCount, 5); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1220 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1221 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1222 XtSetArg(al[ac], XmNbottomOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1223 XtSetArg(al[ac], XmNbottomWidget, separator); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1224 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1225 XtSetArg(al[ac], XmNleftOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1226 XtSetArg(al[ac], XmNleftWidget, icon); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1227 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1228 XtSetArg(al[ac], XmNrightOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1229 value = XmCreateScrolledList (form, "list", al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1230
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1231 /* this is the easiest way I found to have the dble click in the
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1232 list activate the default button */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1233 XtAddCallback (value, XmNdefaultActionCallback, activate_button, button);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1234 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1235
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1236 ac = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1237 XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1238 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1239 XtSetArg(al[ac], XmNtopOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1240 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1241 XtSetArg(al[ac], XmNbottomOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1242 XtSetArg(al[ac], XmNbottomWidget,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1243 text_input_slot || radio_box || list ? value : separator); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1244 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1245 XtSetArg(al[ac], XmNleftOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1246 XtSetArg(al[ac], XmNleftWidget, icon); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1247 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1248 XtSetArg(al[ac], XmNrightOffset, 13); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1249 message = XmCreateLabel (form, "message", al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1250 DO_DND_KLUDGE (message);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1251
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1252 if (list)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1253 XtManageChild (value);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1254
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1255 i = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1256 children [i] = row; i++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1257 children [i] = separator; i++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1258 if (text_input_slot || radio_box)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1259 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1260 children [i] = value; i++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1261 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1262 children [i] = message; i++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1263 children [i] = icon; i++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1264 children [i] = icon_separator; i++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1265 XtManageChildren (children, i);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1266
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1267 if (text_input_slot || list)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1268 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1269 XtInstallAccelerators (value, button);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1270 XmProcessTraversal(value, XmTRAVERSE_CURRENT);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1271 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1272 else
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1273 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1274 XtInstallAccelerators (form, button);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1275 XmProcessTraversal(value, XmTRAVERSE_CURRENT);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1276 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1277
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1278 #ifdef DND_KLUDGE
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1279 XtFree ((char *) dnd_override);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1280 #endif
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1281 #undef DO_DND_KLUDGE
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1282
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1283 return result;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1284 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1285
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1286 static destroyed_instance*
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1287 find_matching_instance (widget_instance* instance)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1288 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1289 destroyed_instance* cur;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1290 destroyed_instance* prev;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1291 char* type = instance->info->type;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1292 char* name = instance->info->name;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1293
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1294 for (prev = NULL, cur = all_destroyed_instances;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1295 cur;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1296 prev = cur, cur = cur->next)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1297 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1298 if (!strcmp (cur->name, name)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1299 && !strcmp (cur->type, type)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1300 && cur->parent == instance->parent
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1301 && cur->pop_up_p == instance->pop_up_p)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1302 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1303 if (prev)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1304 prev->next = cur->next;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1305 else
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1306 all_destroyed_instances = cur->next;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1307 return cur;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1308 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1309 /* do some cleanup */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1310 else if (!cur->widget)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1311 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1312 if (prev)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1313 prev->next = cur->next;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1314 else
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1315 all_destroyed_instances = cur->next;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1316 free_destroyed_instance (cur);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1317 cur = prev ? prev : all_destroyed_instances;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1318 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1319 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1320 return NULL;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1321 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1322
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1323 static void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1324 mark_dead_instance_destroyed (Widget widget, XtPointer closure,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1325 XtPointer call_data)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1326 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1327 destroyed_instance* instance = (destroyed_instance*)closure;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1328 instance->widget = NULL;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1329 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1330
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1331 static void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1332 recenter_widget (Widget widget)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1333 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1334 Widget parent = XtParent (widget);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1335 Screen* screen = XtScreen (widget);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1336 Dimension screen_width = WidthOfScreen (screen);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1337 Dimension screen_height = HeightOfScreen (screen);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1338 Dimension parent_width = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1339 Dimension parent_height = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1340 Dimension child_width = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1341 Dimension child_height = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1342 Position x;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1343 Position y;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1344 Arg al [2];
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1345
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1346 XtSetArg (al [0], XtNwidth, &child_width);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1347 XtSetArg (al [1], XtNheight, &child_height);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1348 XtGetValues (widget, al, 2);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1349
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1350 XtSetArg (al [0], XtNwidth, &parent_width);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1351 XtSetArg (al [1], XtNheight, &parent_height);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1352 XtGetValues (parent, al, 2);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1353
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1354 x = (Position) ((parent_width - child_width) / 2);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1355 y = (Position) ((parent_height - child_height) / 2);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1356
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1357 XtTranslateCoords (parent, x, y, &x, &y);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1358
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1359 if ((Dimension) (x + child_width) > screen_width)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1360 x = screen_width - child_width;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1361 if (x < 0)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1362 x = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1363
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1364 if ((Dimension) (y + child_height) > screen_height)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1365 y = screen_height - child_height;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1366 if (y < 0)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1367 y = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1368
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1369 XtSetArg (al [0], XtNx, x);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1370 XtSetArg (al [1], XtNy, y);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1371 XtSetValues (widget, al, 2);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1372 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1373
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1374 static Widget
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1375 recycle_instance (destroyed_instance* instance)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1376 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1377 Widget widget = instance->widget;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1378
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1379 /* widget is NULL if the parent was destroyed. */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1380 if (widget)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1381 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1382 Widget focus;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1383 Widget separator;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1384
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1385 /* Remove the destroy callback as the instance is not in the list
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1386 anymore */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1387 XtRemoveCallback (instance->parent, XtNdestroyCallback,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1388 mark_dead_instance_destroyed,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1389 (XtPointer)instance);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1390
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1391 /* Give the focus to the initial item */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1392 focus = XtNameToWidget (widget, "*value");
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1393 if (!focus)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1394 focus = XtNameToWidget (widget, "*button1");
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1395 if (focus)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1396 XmProcessTraversal(focus, XmTRAVERSE_CURRENT);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1397
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1398 /* shrink the separator label back to their original size */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1399 separator = XtNameToWidget (widget, "*separator_button");
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1400 if (separator)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1401 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1402 Arg al [2];
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1403 XtSetArg (al [0], XtNwidth, 5);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1404 XtSetArg (al [1], XtNheight, 5);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1405 XtSetValues (separator, al, 2);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1406 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1407
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1408 /* Center the dialog in its parent */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1409 recenter_widget (widget);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1410 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1411 free_destroyed_instance (instance);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1412 return widget;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1413 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1414
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1415 Widget
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1416 xm_create_dialog (widget_instance* instance)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1417 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1418 char* name = instance->info->type;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1419 Widget parent = instance->parent;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1420 Widget widget;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1421 Boolean pop_up_p = instance->pop_up_p;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1422 CONST char* shell_name = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1423 CONST char* icon_name = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1424 Boolean text_input_slot = False;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1425 Boolean radio_box = False;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1426 Boolean list = False;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1427 int total_buttons;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1428 int left_buttons = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1429 int right_buttons = 1;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1430 destroyed_instance* dead_one;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1431
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1432 /* try to find a widget to recycle */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1433 dead_one = find_matching_instance (instance);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1434 if (dead_one)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1435 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1436 Widget recycled_widget = recycle_instance (dead_one);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1437 if (recycled_widget)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1438 return recycled_widget;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1439 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1440
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1441 switch (name [0]){
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1442 case 'E': case 'e':
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1443 icon_name = "dbox-error";
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1444 shell_name = "Error";
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1445 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1446
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1447 case 'I': case 'i':
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1448 icon_name = "dbox-info";
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1449 shell_name = "Information";
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1450 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1451
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1452 case 'L': case 'l':
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1453 list = True;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1454 icon_name = "dbox-question";
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1455 shell_name = "Prompt";
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1456 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1457
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1458 case 'P': case 'p':
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1459 text_input_slot = True;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1460 icon_name = "dbox-question";
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1461 shell_name = "Prompt";
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1462 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1463
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1464 case 'Q': case 'q':
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1465 icon_name = "dbox-question";
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1466 shell_name = "Question";
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1467 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1468 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1469
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1470 total_buttons = name [1] - '0';
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1471
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1472 if (name [3] == 'T' || name [3] == 't')
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1473 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1474 text_input_slot = False;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1475 radio_box = True;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1476 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1477 else if (name [3])
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1478 right_buttons = name [4] - '0';
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1479
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1480 left_buttons = total_buttons - right_buttons;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1481
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1482 widget = make_dialog (name, parent, pop_up_p,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1483 shell_name, icon_name, text_input_slot, radio_box,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1484 list, left_buttons, right_buttons);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1485
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1486 XtAddCallback (widget, XmNpopdownCallback, xm_nosel_callback,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1487 (XtPointer) instance);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1488 return widget;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1489 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1490
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1491 #endif /* LWLIB_DIALOGS_MOTIF */
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1492
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1493 #ifdef LWLIB_MENUBARS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1494 static Widget
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1495 make_menubar (widget_instance* instance)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1496 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1497 Arg al[10];
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1498 int ac = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1499
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1500 XtSetArg(al[ac], XmNmarginHeight, 0); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1501 XtSetArg(al[ac], XmNshadowThickness, 3); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1502
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1503 return XmCreateMenuBar (instance->parent, instance->info->name, al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1504 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1505
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1506 static void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1507 remove_grabs (Widget shell, XtPointer closure, XtPointer call_data)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1508 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1509 Widget menu = (Widget) closure;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1510 XmRemoveFromPostFromList (menu, XtParent (XtParent ((Widget) menu)));
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1511 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1512
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1513 static Widget
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1514 make_popup_menu (widget_instance* instance)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1515 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1516 Widget parent = instance->parent;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1517 Window parent_window = parent->core.window;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1518 Widget result;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1519
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1520 /* sets the parent window to 0 to fool Motif into not generating a grab */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1521 parent->core.window = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1522 result = XmCreatePopupMenu (parent, instance->info->name, NULL, 0);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1523 XtAddCallback (XtParent (result), XmNpopdownCallback, remove_grabs,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1524 (XtPointer)result);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1525 parent->core.window = parent_window;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1526 return result;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1527 }
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1528 #endif /* LWLIB_MENUBARS_MOTIF */
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1529
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1530 #ifdef LWLIB_SCROLLBARS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1531 static Widget
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1532 make_scrollbar (widget_instance *instance, int vertical)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1533 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1534 Arg al[20];
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1535 int ac = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1536 static XtCallbackRec callbacks[2] =
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1537 { {xm_scrollbar_callback, NULL}, {NULL, NULL} };
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1538
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1539 callbacks[0].closure = (XtPointer) instance;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1540
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1541 XtSetArg (al[ac], XmNminimum, 1); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1542 XtSetArg (al[ac], XmNmaximum, INT_MAX); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1543 XtSetArg (al[ac], XmNincrement, 1); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1544 XtSetArg (al[ac], XmNpageIncrement, 1); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1545 XtSetArg (al[ac], XmNborderWidth, 0); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1546 XtSetArg (al[ac], XmNorientation, vertical ? XmVERTICAL : XmHORIZONTAL); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1547
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1548 XtSetArg (al[ac], XmNdecrementCallback, callbacks); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1549 XtSetArg (al[ac], XmNdragCallback, callbacks); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1550 XtSetArg (al[ac], XmNincrementCallback, callbacks); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1551 XtSetArg (al[ac], XmNpageDecrementCallback, callbacks); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1552 XtSetArg (al[ac], XmNpageIncrementCallback, callbacks); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1553 XtSetArg (al[ac], XmNtoBottomCallback, callbacks); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1554 XtSetArg (al[ac], XmNtoTopCallback, callbacks); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1555 XtSetArg (al[ac], XmNvalueChangedCallback, callbacks); ac++;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1556
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1557 return XmCreateScrollBar (instance->parent, instance->info->name, al, ac);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1558 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1559
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1560 static Widget
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1561 make_vertical_scrollbar (widget_instance *instance)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1562 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1563 return make_scrollbar (instance, 1);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1564 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1565
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1566 static Widget
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1567 make_horizontal_scrollbar (widget_instance *instance)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1568 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1569 return make_scrollbar (instance, 0);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1570 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1571
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1572 #endif /* LWLIB_SCROLLBARS_MOTIF */
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1573
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1574 /* Table of functions to create widgets */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1575
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1576 widget_creation_entry
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1577 xm_creation_table [] =
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1578 {
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1579 #ifdef LWLIB_MENUBARS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1580 {"menubar", make_menubar},
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1581 {"popup", make_popup_menu},
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1582 #endif
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1583 #ifdef LWLIB_SCROLLBARS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1584 {"vertical-scrollbar", make_vertical_scrollbar},
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1585 {"horizontal-scrollbar", make_horizontal_scrollbar},
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1586 #endif
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1587 {NULL, NULL}
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1588 };
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1589
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1590 /* Destruction of instances */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1591 void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1592 xm_destroy_instance (widget_instance* instance)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1593 {
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1594 #ifdef LWLIB_DIALOGS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1595 /* It appears that this is used only for dialog boxes. */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1596 Widget widget = instance->widget;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1597 /* recycle the dialog boxes */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1598 /* Disable the recycling until we can find a way to have the dialog box
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1599 get reasonable layout after we modify its contents. */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1600 if (0
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1601 && XtClass (widget) == xmDialogShellWidgetClass)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1602 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1603 destroyed_instance* dead_instance =
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1604 make_destroyed_instance (instance->info->name,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1605 instance->info->type,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1606 instance->widget,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1607 instance->parent,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1608 instance->pop_up_p);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1609 dead_instance->next = all_destroyed_instances;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1610 all_destroyed_instances = dead_instance;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1611 XtUnmanageChild (first_child (instance->widget));
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1612 XFlush (XtDisplay (instance->widget));
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1613 XtAddCallback (instance->parent, XtNdestroyCallback,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1614 mark_dead_instance_destroyed, (XtPointer)dead_instance);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1615 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1616 else
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1617 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1618 /* This might not be necessary now that the nosel is attached to
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1619 popdown instead of destroy, but it can't hurt. */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1620 XtRemoveCallback (instance->widget, XtNdestroyCallback,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1621 xm_nosel_callback, (XtPointer)instance);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1622
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1623 XtDestroyWidget (instance->widget);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1624 }
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1625 #endif /* LWLIB_DIALOGS_MOTIF */
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1626 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1627
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1628 /* popup utility */
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1629 #ifdef LWLIB_MENUBARS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1630
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1631 void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1632 xm_popup_menu (Widget widget, XEvent *event)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1633 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1634 if (event->type == ButtonPress || event->type == ButtonRelease)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1635 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1636 /* This is so totally ridiculous: there's NO WAY to tell Motif
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1637 that *any* button can select a menu item. Only one button
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1638 can have that honor.
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1639 */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1640 char *trans = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1641 if (event->xbutton.state & Button5Mask) trans = "<Btn5Down>";
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1642 else if (event->xbutton.state & Button4Mask) trans = "<Btn4Down>";
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1643 else if (event->xbutton.state & Button3Mask) trans = "<Btn3Down>";
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1644 else if (event->xbutton.state & Button2Mask) trans = "<Btn2Down>";
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1645 else if (event->xbutton.state & Button1Mask) trans = "<Btn1Down>";
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1646 if (trans)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1647 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1648 Arg al [1];
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1649 XtSetArg (al [0], XmNmenuPost, trans);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1650 XtSetValues (widget, al, 1);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1651 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1652 XmMenuPosition (widget, (XButtonPressedEvent *) event);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1653 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1654 XtManageChild (widget);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1655 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1656
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1657 #endif
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1658
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1659 #ifdef LWLIB_DIALOGS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1660
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1661 static void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1662 set_min_dialog_size (Widget w)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1663 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1664 short width;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1665 short height;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1666 Arg al [2];
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1667
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1668 XtSetArg (al [0], XmNwidth, &width);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1669 XtSetArg (al [1], XmNheight, &height);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1670 XtGetValues (w, al, 2);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1671
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1672 XtSetArg (al [0], XmNminWidth, width);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1673 XtSetArg (al [1], XmNminHeight, height);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1674 XtSetValues (w, al, 2);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1675 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1676
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1677 #endif
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1678
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1679 void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1680 xm_pop_instance (widget_instance* instance, Boolean up)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1681 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1682 Widget widget = instance->widget;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1683
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1684 #ifdef LWLIB_DIALOGS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1685 if (XtClass (widget) == xmDialogShellWidgetClass)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1686 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1687 Widget widget_to_manage = first_child (widget);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1688 if (up)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1689 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1690 XtManageChild (widget_to_manage);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1691 set_min_dialog_size (widget);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1692 XmProcessTraversal(widget, XmTRAVERSE_CURRENT);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1693 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1694 else
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1695 XtUnmanageChild (widget_to_manage);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1696 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1697 else
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1698 #endif
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1699 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1700 if (up)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1701 XtManageChild (widget);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1702 else
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1703 XtUnmanageChild (widget);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1704 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1705 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1706
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1707
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1708 /* motif callback */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1709
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1710 enum do_call_type { pre_activate, selection, no_selection, post_activate };
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1711
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1712 static void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1713 do_call (Widget widget, XtPointer closure, enum do_call_type type)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1714 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1715 XtPointer user_data;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1716 widget_instance* instance = (widget_instance*)closure;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1717 Widget instance_widget;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1718 LWLIB_ID id;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1719 Arg al [1];
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1720
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1721 if (!instance)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1722 return;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1723 if (widget->core.being_destroyed)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1724 return;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1725
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1726 instance_widget = instance->widget;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1727 if (!instance_widget)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1728 return;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1729
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1730 id = instance->info->id;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1731 user_data = NULL;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1732 XtSetArg(al [0], XmNuserData, &user_data);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1733 XtGetValues (widget, al, 1);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1734 switch (type)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1735 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1736 case pre_activate:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1737 if (instance->info->pre_activate_cb)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1738 instance->info->pre_activate_cb (widget, id, user_data);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1739 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1740 case selection:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1741 if (instance->info->selection_cb)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1742 instance->info->selection_cb (widget, id, user_data);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1743 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1744 case no_selection:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1745 if (instance->info->selection_cb)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1746 instance->info->selection_cb (widget, id, (XtPointer) -1);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1747 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1748 case post_activate:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1749 if (instance->info->post_activate_cb)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1750 instance->info->post_activate_cb (widget, id, user_data);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1751 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1752 default:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1753 abort ();
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1754 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1755 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1756
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1757 /* Like lw_internal_update_other_instances except that it does not do
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1758 anything if its shell parent is not managed. This is to protect
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1759 lw_internal_update_other_instances to dereference freed memory
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1760 if the widget was ``destroyed'' by caching it in the all_destroyed_instances
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1761 list */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1762 static void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1763 xm_internal_update_other_instances (Widget widget, XtPointer closure,
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1764 XtPointer call_data)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1765 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1766 Widget parent;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1767 for (parent = widget; parent; parent = XtParent (parent))
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1768 if (XtIsShell (parent))
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1769 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1770 else if (!XtIsManaged (parent))
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1771 return;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1772 lw_internal_update_other_instances (widget, closure, call_data);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1773 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1774
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1775 static void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1776 xm_generic_callback (Widget widget, XtPointer closure, XtPointer call_data)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1777 {
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1778 #if (defined (LWLIB_MENUBARS_MOTIF) || defined (LWLIB_DIALOGS_MOTIF))
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1779 /* We want the selected status to change only when we decide it
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1780 should change. Yuck but correct. */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1781 if (XtClass (widget) == xmToggleButtonWidgetClass
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1782 || XtClass (widget) == xmToggleButtonGadgetClass)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1783 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1784 Boolean check;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1785 Arg al [1];
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1786
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1787 XtSetArg (al [0], XmNset, &check);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1788 XtGetValues (widget, al, 1);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1789
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1790 XtSetArg (al [0], XmNset, !check);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1791 XtSetValues (widget, al, 1);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1792 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1793 #endif
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1794 lw_internal_update_other_instances (widget, closure, call_data);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1795 do_call (widget, closure, selection);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1796 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1797
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1798 #ifdef LWLIB_DIALOGS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1799
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1800 static void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1801 xm_nosel_callback (Widget widget, XtPointer closure, XtPointer call_data)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1802 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1803 /* This callback is only called when a dialog box is dismissed with the wm's
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1804 destroy button (WM_DELETE_WINDOW.) We want the dialog box to be destroyed
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1805 in that case, not just unmapped, so that it releases its keyboard grabs.
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1806 But there are problems with running our callbacks while the widget is in
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1807 the process of being destroyed, so we set XmNdeleteResponse to XmUNMAP
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1808 instead of XmDESTROY and then destroy it ourself after having run the
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1809 callback.
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1810 */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1811 do_call (widget, closure, no_selection);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1812 XtDestroyWidget (widget);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1813 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1814
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1815 #endif
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1816
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1817 #ifdef LWLIB_MENUBARS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1818
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1819 static void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1820 xm_pull_down_callback (Widget widget, XtPointer closure, XtPointer call_data)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1821 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1822 #if 0
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1823 if (call_data)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1824 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1825 /* new behavior for incremental menu construction */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1826
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1827 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1828 else
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1829 #endif
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1830 do_call (widget, closure, pre_activate);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1831 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1832
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1833 #if 0
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1834 static void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1835 xm_pop_down_callback (Widget widget, XtPointer closure, XtPointer call_data)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1836 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1837 do_call (widget, closure, post_activate);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1838 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1839 #endif /* 0 */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1840
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1841 #endif /* LWLIB_MENUBARS_MOTIF */
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1842
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1843 #ifdef LWLIB_SCROLLBARS_MOTIF
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1844 static void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1845 xm_scrollbar_callback (Widget widget, XtPointer closure, XtPointer call_data)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1846 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1847 widget_instance *instance = (widget_instance *) closure;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1848 LWLIB_ID id;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1849 XmScrollBarCallbackStruct *data =
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1850 (XmScrollBarCallbackStruct *) call_data;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1851 scroll_event event_data;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1852 scrollbar_values *val =
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1853 (scrollbar_values *) instance->info->val->scrollbar_data;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1854 double percent;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1855
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1856 if (!instance || widget->core.being_destroyed)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1857 return;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1858
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1859 id = instance->info->id;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1860
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1861 percent = (double) (data->value - 1) / (double) (INT_MAX - 1);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1862 event_data.slider_value =
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1863 (int) (percent * (double) (val->maximum - val->minimum)) + val->minimum;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1864
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1865 if (event_data.slider_value > (val->maximum - val->slider_size))
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1866 event_data.slider_value = val->maximum - val->slider_size;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1867 else if (event_data.slider_value < 1)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1868 event_data.slider_value = 1;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1869
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1870 if (data->event)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1871 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1872 switch (data->event->xany.type)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1873 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1874 case KeyPress:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1875 case KeyRelease:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1876 event_data.time = data->event->xkey.time;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1877 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1878 case ButtonPress:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1879 case ButtonRelease:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1880 event_data.time = data->event->xbutton.time;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1881 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1882 case MotionNotify:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1883 event_data.time = data->event->xmotion.time;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1884 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1885 case EnterNotify:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1886 case LeaveNotify:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1887 event_data.time = data->event->xcrossing.time;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1888 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1889 default:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1890 event_data.time = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1891 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1892 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1893 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1894 else
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1895 event_data.time = 0;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1896
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1897 switch (data->reason)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1898 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1899 case XmCR_DECREMENT:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1900 event_data.action = SCROLLBAR_LINE_UP;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1901 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1902 case XmCR_INCREMENT:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1903 event_data.action = SCROLLBAR_LINE_DOWN;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1904 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1905 case XmCR_PAGE_DECREMENT:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1906 event_data.action = SCROLLBAR_PAGE_UP;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1907 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1908 case XmCR_PAGE_INCREMENT:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1909 event_data.action = SCROLLBAR_PAGE_DOWN;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1910 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1911 case XmCR_TO_TOP:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1912 event_data.action = SCROLLBAR_TOP;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1913 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1914 case XmCR_TO_BOTTOM:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1915 event_data.action = SCROLLBAR_BOTTOM;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1916 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1917 case XmCR_DRAG:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1918 event_data.action = SCROLLBAR_DRAG;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1919 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1920 case XmCR_VALUE_CHANGED:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1921 event_data.action = SCROLLBAR_CHANGE;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1922 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1923 default:
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1924 event_data.action = SCROLLBAR_CHANGE;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1925 break;
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1926 }
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1927
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1928 if (instance->info->pre_activate_cb)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1929 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1930 }
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 217
diff changeset
1931 #endif /* LWLIB_SCROLLBARS_MOTIF */
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1932
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1933
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1934 /* set the keyboard focus */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1935 void
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1936 xm_set_keyboard_focus (Widget parent, Widget w)
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1937 {
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1938 XmProcessTraversal (w, XmTRAVERSE_CURRENT);
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1939 /* At some point we believed that it was necessary to use XtSetKeyboardFocus
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1940 instead of XmProcessTraversal when using Motif >= 1.2.1, but that's bogus.
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1941 Presumably the problem was elsewhere, and is now gone...
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1942 */
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 169
diff changeset
1943 }