annotate lwlib/lwlib-Xm.c @ 398:74fd4e045ea6 r21-2-29

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