annotate lwlib/lwlib-Xm.c @ 169:15872534500d r20-3b11

Import from CVS: tag r20-3b11
author cvs
date Mon, 13 Aug 2007 09:46:53 +0200
parents 5a88923fcbfe
children 929b76928fce
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>
157
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 80
diff changeset
26 #ifdef HAVE_LIMITS_H
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 #include <limits.h>
157
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 80
diff changeset
28 #endif
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 80
diff changeset
29 #ifdef HAVE_UNISTD_H
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 80
diff changeset
30 #include <unistd.h>
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 80
diff changeset
31 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include <X11/StringDefs.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include <X11/IntrinsicP.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #include <X11/ObjectP.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #include <X11/CoreP.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #include <X11/CompositeP.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 #include "lwlib-Xm.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 #include "lwlib-utils.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 #include <Xm/Xm.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 #include <Xm/BulletinB.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 #include <Xm/CascadeB.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 #include <Xm/DrawingA.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 #include <Xm/FileSB.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 #include <Xm/Label.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 #include <Xm/List.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 #include <Xm/MenuShell.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 #include <Xm/MessageB.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 #include <Xm/PushB.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 #include <Xm/PushBG.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 #include <Xm/ArrowB.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 #include <Xm/ScrollBar.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 #include <Xm/SelectioB.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 #include <Xm/Text.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 #include <Xm/TextF.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 #include <Xm/ToggleB.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 #include <Xm/ToggleBG.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 #include <Xm/RowColumn.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 #include <Xm/ScrolledW.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 #include <Xm/Separator.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 #include <Xm/DialogS.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 #include <Xm/Form.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 #ifdef MENUBARS_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 static void xm_pull_down_callback (Widget, XtPointer, XtPointer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 static void xm_pop_down_callback (Widget, XtPointer, XtPointer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 static void xm_internal_update_other_instances (Widget, XtPointer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 XtPointer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 static void xm_generic_callback (Widget, XtPointer, XtPointer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 #ifdef DIALOGS_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 static void xm_nosel_callback (Widget, XtPointer, XtPointer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 #ifdef SCROLLBARS_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 static void xm_scrollbar_callback (Widget, XtPointer, XtPointer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 #ifdef MENUBARS_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 xm_update_menu (widget_instance* instance, Widget widget, widget_value* val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 Boolean deep_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 /* Structures to keep destroyed instances */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 typedef struct _destroyed_instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 char* name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 char* type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 Widget widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 Widget parent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 Boolean pop_up_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 struct _destroyed_instance* next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 } destroyed_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 static destroyed_instance*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 all_destroyed_instances = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 /* Utility function. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 safe_strdup (char* s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 char *result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 if (! s) return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 result = (char *) malloc (strlen (s) + 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 if (! result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 strcpy (result, s);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 static destroyed_instance*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 make_destroyed_instance (char* name, char* type, Widget widget, Widget parent,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 Boolean pop_up_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
119 destroyed_instance* instance =
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
120 (destroyed_instance*) malloc (sizeof (destroyed_instance));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 instance->name = safe_strdup (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 instance->type = safe_strdup (type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 instance->widget = widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 instance->parent = parent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 instance->pop_up_p = pop_up_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 instance->next = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 return instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 free_destroyed_instance (destroyed_instance* instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 free (instance->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 free (instance->type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 free (instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 /* motif utility functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 Widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 first_child (Widget widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 return ((CompositeWidget)widget)->composite.children [0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 Boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 lw_motif_widget_p (Widget widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 #ifdef DIALOGS_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 XtClass (widget) == xmDialogShellWidgetClass ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 XmIsPrimitive (widget) || XmIsManager (widget) || XmIsGadget (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 resource_string (Widget widget, char *name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 XtResource resource;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 char *result = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
161 resource.resource_name = "labelString";
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
162 resource.resource_class = "LabelString"; /* #### should be Xmsomething... */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 resource.resource_type = XtRString;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 resource.resource_size = sizeof (String);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 resource.resource_offset = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 resource.default_type = XtRImmediate;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 resource.default_addr = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 XtGetSubresources (widget, (XtPointer)&result, name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 name, &resource, 1, NULL, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 #ifdef MENUBARS_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 destroy_all_children (Widget widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 Widget* children;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 unsigned int number;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 children = XtCompositeChildren (widget, &number);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 if (children)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 /* Unmanage all children and destroy them. They will only be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 * really destroyed when we get out of DispatchEvent. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 for (i = 0; i < number; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 Widget child = children [i];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 if (!child->core.being_destroyed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 XtUnmanageChild (child);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 XtDestroyWidget (child);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 XtFree ((char *) children);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 #endif /* MENUBARS_MOTIF */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 #ifdef DIALOGS_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 static Boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 is_in_dialog_box (Widget w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 Widget wmshell;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 wmshell = XtParent (w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 while (wmshell && (XtClass (wmshell) != xmDialogShellWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 wmshell = XtParent (wmshell);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 if (wmshell && XtClass (wmshell) == xmDialogShellWidgetClass)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 return True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 return False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 #endif /* DIALOGS_MOTIF */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 #if defined (DIALOGS_MOTIF) || defined (MENUBARS_MOTIF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 /* update the label of anything subclass of a label */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 xm_update_label (widget_instance* instance, Widget widget, widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 {
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
230 XmString built_string = NULL;
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
231 XmString key_string = NULL;
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
232 XmString val_string = NULL;
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
233 XmString name_string = NULL;
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
234 Arg al [20];
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
235 int ac = 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 if (val->value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 #ifdef DIALOGS_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 * Sigh. The main text of a label is the name field for menubar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 * entries. The value field is a possible additional field to be
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
243 * concatenated on to the name field. HOWEVER, with dialog boxes
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 * the value field is the complete text which is supposed to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 * displayed as the label. Yuck.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 if (is_in_dialog_box (widget))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 char *value_name = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 value_name = resource_string (widget, val->value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 if (!value_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 value_name = val->value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 built_string =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 XmStringCreateLtoR (value_name, XmSTRING_DEFAULT_CHARSET);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 else
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
259 #endif /* DIALOGS_MOTIF */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 char *value_name = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 char *res_name = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 res_name = resource_string (widget, val->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 if (!res_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 res_name = val->name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 name_string =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 XmStringCreateLtoR (res_name, XmSTRING_DEFAULT_CHARSET);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 value_name = XtMalloc (strlen (val->value) + 2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 *value_name = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 strcat (value_name, " ");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 strcat (value_name, val->value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 val_string =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 XmStringCreateLtoR (value_name, XmSTRING_DEFAULT_CHARSET);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 built_string =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 XmStringConcat (name_string, val_string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 XtFree (value_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 XtSetArg (al [ac], XmNlabelString, built_string); ac++;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
286 XtSetArg (al [ac], XmNlabelType, XmSTRING); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 if (val->key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 key_string = XmStringCreateLtoR (val->key, XmSTRING_DEFAULT_CHARSET);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 XtSetArg (al [ac], XmNacceleratorText, key_string); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 if (ac)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 XtSetValues (widget, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 if (built_string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 XmStringFree (built_string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 if (key_string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 XmStringFree (key_string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 if (name_string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 XmStringFree (name_string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 #endif /* defined (DIALOGS_MOTIF) || defined (MENUBARS_MOTIF) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 /* update of list */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 xm_update_list (widget_instance* instance, Widget widget, widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 widget_value* cur;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 XtRemoveAllCallbacks (widget, XmNsingleSelectionCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 XtAddCallback (widget, XmNsingleSelectionCallback, xm_generic_callback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 for (cur = val->contents, i = 0; cur; cur = cur->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 if (cur->value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 XmString xmstr = XmStringCreate (cur->value, XmSTRING_DEFAULT_CHARSET);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 i += 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 XmListAddItem (widget, xmstr, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 if (cur->selected)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 XmListSelectPos (widget, i, False);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 XmStringFree (xmstr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 /* update of buttons */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 xm_update_pushbutton (widget_instance* instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 {
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
336 Arg al [1];
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
337 XtSetArg (al [0], XmNalignment, XmALIGNMENT_CENTER);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
338 XtSetValues (widget, al, 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 XtRemoveAllCallbacks (widget, XmNactivateCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 XtAddCallback (widget, XmNactivateCallback, xm_generic_callback, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 #ifdef MENUBARS_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 xm_update_cascadebutton (widget_instance* instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 /* Should also rebuild the menu by calling ...update_menu... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 if (val
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 && val->type == CASCADE_TYPE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 && val->contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 && val->contents->type == INCREMENTAL_TYPE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 /* okay, we're now doing a lisp callback to incrementally generate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 more of the menu. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 XtRemoveAllCallbacks (widget, XmNcascadingCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 XtAddCallback (widget, XmNcascadingCallback, xm_pull_down_callback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 XtCallCallbacks ((Widget)widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 XmNcascadingCallback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (XtPointer)val->contents);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 } else {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 XtRemoveAllCallbacks (widget, XmNcascadingCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 XtAddCallback (widget, XmNcascadingCallback, xm_pull_down_callback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 #endif /* MENUBARS_MOTIF */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 /* update toggle and radiobox */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 xm_update_toggle (widget_instance* instance, Widget widget, widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 {
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
377 Arg al [2];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 XtRemoveAllCallbacks (widget, XmNvalueChangedCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 #ifndef ENERGIZE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 XtAddCallback (widget, XmNvalueChangedCallback, xm_generic_callback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 #else
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
383 XtAddCallback (widget, XmNvalueChangedCallback,
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
384 xm_internal_update_other_instances, instance);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
385 #endif
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
386 XtSetArg (al [0], XmNset, val->selected);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
387 XtSetArg (al [1], XmNalignment, XmALIGNMENT_BEGINNING);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
388 XtSetValues (widget, al, 2);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 xm_update_radiobox (widget_instance* instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 Widget toggle;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 widget_value* cur;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 /* update the callback */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 XtRemoveAllCallbacks (widget, XmNentryCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 XtAddCallback (widget, XmNentryCallback, xm_generic_callback, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 /* first update all the toggles */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 /* Energize kernel interface is currently bad. It sets the selected widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 with the selected flag but returns it by its name. So we currently
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 have to support both setting the selection with the selected slot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 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
407 has a higher priority. This to be removed when the kernel is fixed. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 for (cur = val->contents; cur; cur = cur->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 toggle = XtNameToWidget (widget, cur->value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 if (toggle)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 {
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
413 Arg al [2];
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
414 XtSetArg (al [0], XmNsensitive, cur->enabled);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
415 XtSetArg (al [1], XmNset, (!val->value && cur->selected ? cur->selected : False));
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
416 XtSetValues (toggle, al, 2);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 /* The selected was specified by the value slot */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 if (val->value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 toggle = XtNameToWidget (widget, val->value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 if (toggle)
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
425 {
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
426 Arg al [1];
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
427 XtSetArg (al [0], XmNset, True);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
428 XtSetValues (toggle, al, 1);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
429 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 #ifdef MENUBARS_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 /* update a popup menu, pulldown menu or a menubar */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 make_menu_in_widget (widget_instance* instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 Widget* children = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 int num_children;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 int child_index;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 widget_value* cur;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 Widget button = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 Widget menu;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 Arg al [256];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 int ac;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
448 Boolean menubar_p = False;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 /* Allocate the children array */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 for (num_children = 0, cur = val; cur; num_children++, cur = cur->next);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 children = (Widget*)XtMalloc (num_children * sizeof (Widget));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 /* 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
455 XtSetArg (al [0], XmNisHomogeneous, &menubar_p);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
456 XtGetValues (widget, al, 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 /* add the unmap callback for popups and pulldowns */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 /*** this sounds bogus ***/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 /* probably because it is -- cet */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 if (!menubar_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 XtAddCallback (XtParent (widget), XmNpopdownCallback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 xm_pop_down_callback, (XtPointer)instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 num_children = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 for (child_index = 0, cur = val; cur; child_index++, cur = cur->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ac = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 button = 0;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
472 XtSetArg (al [ac], XmNsensitive, cur->enabled); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
473 XtSetArg (al [ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
474 XtSetArg (al [ac], XmNuserData, cur->call_data); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 switch (cur->type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 case PUSHRIGHT_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 /* A pushright marker which is not needed for the real Motif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 menubar. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 case SEPARATOR_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ac = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 if (cur->value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 /* #### - xlwmenu.h supports several types that motif does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 not. Also, motif supports pixmaps w/ type NO_LINE and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 lwlib provides no way to access that functionality. --Stig */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 XtSetArg (al [ac], XmNseparatorType, cur->value), ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 button = XmCreateSeparator (widget, "separator", al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 case CASCADE_TYPE:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 menu = XmCreatePulldownMenu (widget, "pulldown", NULL, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 make_menu_in_widget (instance, menu, cur->contents);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 XtSetArg (al [ac], XmNsubMenuId, menu); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 button = XmCreateCascadeButton (widget, cur->name, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 xm_update_label (instance, button, cur);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 XtAddCallback (button, XmNcascadingCallback, xm_pull_down_callback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (XtPointer)instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 if (menubar_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 button = XmCreateCascadeButton (widget, cur->name, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 else if (!cur->call_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 button = XmCreateLabel (widget, cur->name, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 else if (cur->type == TOGGLE_TYPE || cur->type == RADIO_TYPE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 {
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
511 XtSetArg (al [ac], XmNindicatorType,
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
512 (cur->type == TOGGLE_TYPE ?
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
513 XmN_OF_MANY : XmONE_OF_MANY)); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 XtSetArg (al [ac], XmNvisibleWhenOff, True); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 button = XmCreateToggleButtonGadget (widget, cur->name, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 button = XmCreatePushButtonGadget (widget, cur->name, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 xm_update_label (instance, button, cur);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 /* don't add a callback to a simple label */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 if (cur->type == TOGGLE_TYPE || cur->type == RADIO_TYPE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 xm_update_toggle (instance, button, cur);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 else if (cur->call_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 XtAddCallback (button, XmNactivateCallback, xm_generic_callback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (XtPointer)instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 } /* switch (cur->type) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 if (button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 children [num_children++] = button;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 /* Last entry is the help button. This used be done after managing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 the buttons. The comment claimed that it had to be done this way
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 otherwise the menubar ended up only 4 pixels high. That must
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 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
538 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
539 bonus the Help menu ends up where it is supposed to. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 if (button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 ac = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 XtSetArg (al [ac], XmNmenuHelpWidget, button); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 XtSetValues (widget, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 if (num_children)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 XtManageChildren (children, num_children);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 XtFree ((char *) children);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 update_one_menu_entry (widget_instance* instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 widget_value* val, Boolean deep_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 {
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
557 Arg al [2];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 Widget menu;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 widget_value* contents;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 if (val->change == NO_CHANGE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 return;
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 sensitivity and userdata */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 /* Common to all widget types */
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
566 XtSetArg (al [0], XmNsensitive, val->enabled);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
567 XtSetArg (al [1], XmNuserData, val->call_data);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
568 XtSetValues (widget, al, 2);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 /* update the menu button as a label. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 if (val->change >= VISIBLE_CHANGE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 xm_update_label (instance, widget, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 if (XtClass (widget) == xmToggleButtonWidgetClass
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 || XtClass (widget) == xmToggleButtonGadgetClass)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 xm_update_toggle (instance, widget, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 /* update the pulldown/pullaside as needed */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 menu = NULL;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
584 XtSetArg (al [0], XmNsubMenuId, &menu);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
585 XtGetValues (widget, al, 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 contents = val->contents;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 if (!menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 if (contents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 menu = XmCreatePulldownMenu (widget, "pulldown", NULL, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 make_menu_in_widget (instance, menu, contents);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 ac = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 XtSetArg (al [ac], XmNsubMenuId, menu); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 XtSetValues (widget, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 else if (!contents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 ac = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 XtSetArg (al [ac], XmNsubMenuId, NULL); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 XtSetValues (widget, al, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 XtDestroyWidget (menu);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 else if (deep_p && contents->change != NO_CHANGE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 xm_update_menu (instance, menu, val, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 xm_update_menu (widget_instance* instance, Widget widget, widget_value* val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 Boolean deep_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 /* Widget is a RowColumn widget whose contents have to be updated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 * to reflect the list of items in val->contents */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 if (val->contents->change == STRUCTURAL_CHANGE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 destroy_all_children (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 make_menu_in_widget (instance, widget, val->contents);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 /* Update all the buttons of the RowColumn in order. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 Widget* children;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 unsigned int num_children;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 widget_value *cur = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 children = XtCompositeChildren (widget, &num_children);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 if (children)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 for (i = 0, cur = val->contents; i < num_children; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 if (!cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 /* skip if this is a pushright marker or a separator */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 if (cur->type == PUSHRIGHT_TYPE || cur->type == SEPARATOR_TYPE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 cur = cur->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 /* #### - this could puke if you have a separator as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 last item on a pullright menu. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 if (!cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 if (!cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 if (children [i]->core.being_destroyed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 || strcmp (XtName (children [i]), cur->name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 update_one_menu_entry (instance, children [i], cur, deep_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 cur = cur->next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 XtFree ((char *) children);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 if (cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 #endif /* MENUBARS_MOTIF */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 #ifdef DIALOGS_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 /* update text widgets */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 xm_update_text (widget_instance* instance, Widget widget, widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
674 XmTextSetString (widget, val->value ? val->value : "");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 XtRemoveAllCallbacks (widget, XmNactivateCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 XtAddCallback (widget, XmNactivateCallback, xm_generic_callback, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 XtRemoveAllCallbacks (widget, XmNvalueChangedCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 XtAddCallback (widget, XmNvalueChangedCallback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 xm_internal_update_other_instances, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 xm_update_text_field (widget_instance* instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 widget_value* val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
686 XmTextFieldSetString (widget, val->value ? val->value : "");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 XtRemoveAllCallbacks (widget, XmNactivateCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 XtAddCallback (widget, XmNactivateCallback, xm_generic_callback, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 XtRemoveAllCallbacks (widget, XmNvalueChangedCallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 XtAddCallback (widget, XmNvalueChangedCallback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 xm_internal_update_other_instances, instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 #endif /* DIALOGS_MOTIF */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 #ifdef SCROLLBARS_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 * 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
700 * you're right. Blame the Motif scrollbar for not being smart about
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 * updating its appearance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 xm_update_scrollbar (widget_instance *instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 widget_value *val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 if (val->scrollbar_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 scrollbar_values *data = val->scrollbar_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 int widget_sliderSize, widget_val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 int new_sliderSize, new_value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 double percent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 double h_water, l_water;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
714 Arg al [4];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
716 /* First size and position the scrollbar widget. */
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
717 XtSetArg (al [0], XtNx, data->scrollbar_x);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
718 XtSetArg (al [1], XtNy, data->scrollbar_y);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
719 XtSetArg (al [2], XtNwidth, data->scrollbar_width);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
720 XtSetArg (al [3], XtNheight, data->scrollbar_height);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
721 XtSetValues (widget, al, 4);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
723 /* Now size the scrollbar's slider. */
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
724 XtSetArg (al [0], XmNsliderSize, &widget_sliderSize);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
725 XtSetArg (al [1], XmNvalue, &widget_val);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
726 XtGetValues (widget, al, 2);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 percent = (double) data->slider_size /
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (double) (data->maximum - data->minimum);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 new_sliderSize = (int) ((double) (INT_MAX - 1) * percent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 percent = (double) (data->slider_position - data->minimum) /
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (double) (data->maximum - data->minimum);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 new_value = (int) ((double) (INT_MAX - 1) * percent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 if (new_sliderSize > (INT_MAX - 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 new_sliderSize = INT_MAX - 1;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
738 else if (new_sliderSize < 1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 new_sliderSize = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 if (new_value > (INT_MAX - new_sliderSize))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 new_value = INT_MAX - new_sliderSize;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 else if (new_value < 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 new_value = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 h_water = 1.05;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 l_water = 0.95;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 if (new_sliderSize != widget_sliderSize || new_value != widget_val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 int force = ((INT_MAX - widget_sliderSize - widget_val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 ? 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 : (INT_MAX - new_sliderSize - new_value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 if (force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 || (double)new_sliderSize < (l_water * (double)widget_sliderSize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 || (double)new_sliderSize > (h_water * (double)widget_sliderSize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 || (double)new_value < (l_water * (double)widget_val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 || (double)new_value > (h_water * (double)widget_val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 XmScrollBarSetValues (widget, new_value, new_sliderSize, 1, 1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 False);
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 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 #endif /* SCROLLBARS_MOTIF */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 /* update a motif widget */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 xm_update_one_widget (widget_instance* instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 widget_value* val, Boolean deep_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 WidgetClass class;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
777 Arg al [2];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 /* Mark as not edited */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 val->edited = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 /* Common to all widget types */
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
783 XtSetArg (al [0], XmNsensitive, val->enabled);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
784 XtSetArg (al [1], XmNuserData, val->call_data);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
785 XtSetValues (widget, al, 2);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 #if defined (DIALOGS_MOTIF) || defined (MENUBARS_MOTIF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 /* Common to all label like widgets */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 if (XtIsSubclass (widget, xmLabelWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 xm_update_label (instance, widget, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 class = XtClass (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 /* Class specific things */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 if (class == xmPushButtonWidgetClass ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 class == xmArrowButtonWidgetClass)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 xm_update_pushbutton (instance, widget, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 }