annotate lwlib/lwlib-Xaw.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 Athena widgets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 This file is part of the Lucid Widget Library.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 The Lucid Widget Library is free software; you can redistribute it and/or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 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
8 the Free Software Foundation; either version 1, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 The Lucid Widget Library is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 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
17 along with XEmacs; see the file COPYING. If not, write to
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
19 Boston, MA 02111-1307, USA. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
157
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 82
diff changeset
21 #include <config.h>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 157
diff changeset
24 #ifdef STDC_HEADERS
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 157
diff changeset
25 #include <stdlib.h>
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 157
diff changeset
26 #endif
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 157
diff changeset
27
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include "lwlib-Xaw.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 #include <X11/StringDefs.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include <X11/IntrinsicP.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #include <X11/CoreP.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include <X11/Shell.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
35 #ifdef LWLIB_SCROLLBARS_ATHENA
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
36 #include ATHENA_INCLUDE(Scrollbar.h)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #endif
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
38 #ifdef LWLIB_DIALOGS_ATHENA
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
39 #include ATHENA_INCLUDE(Dialog.h)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
40 #include ATHENA_INCLUDE(Form.h)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
41 #include ATHENA_INCLUDE(Command.h)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
42 #include ATHENA_INCLUDE(Label.h)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 #endif
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
44 #ifdef LWLIB_WIDGETS_ATHENA
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
45 #include ATHENA_INCLUDE(Toggle.h)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
46 #include "xlwradio.h"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
47 #include "xlwcheckbox.h"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
48 #include "xlwgauge.h"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
49 #ifndef NEED_MOTIF
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
50 #include ATHENA_INCLUDE(AsciiText.h)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
51 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
52 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 #include <X11/Xatom.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 static void xaw_generic_callback (Widget, XtPointer, XtPointer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 Boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 lw_xaw_widget_p (Widget widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 return (0
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
62 #ifdef LWLIB_SCROLLBARS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 || XtIsSubclass (widget, scrollbarWidgetClass)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 #endif
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
65 #ifdef LWLIB_DIALOGS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 || XtIsSubclass (widget, dialogWidgetClass)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 #endif
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
68 #ifdef LWLIB_WIDGETS_ATHENA
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
69 || XtIsSubclass (widget, labelWidgetClass)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
70 || XtIsSubclass (widget, toggleWidgetClass)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
71 || XtIsSubclass (widget, gaugeWidgetClass)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
72 #if 0
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
73 || XtIsSubclass (widget, textWidgetClass)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
74 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
75 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
79 #ifdef LWLIB_SCROLLBARS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 xaw_update_scrollbar (widget_instance *instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 widget_value *val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 if (val->scrollbar_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 scrollbar_values *data = val->scrollbar_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 float widget_shown, widget_topOfThumb;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 float new_shown, new_topOfThumb;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
89 Arg al [10];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
91 /* First size and position the scrollbar widget. */
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
92 XtSetArg (al [0], XtNx, data->scrollbar_x);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
93 XtSetArg (al [1], XtNy, data->scrollbar_y);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
94 XtSetArg (al [2], XtNwidth, data->scrollbar_width);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
95 XtSetArg (al [3], XtNheight, data->scrollbar_height);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
96 XtSetValues (widget, al, 4);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
98 /* Now size the scrollbar's slider. */
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
99 XtSetArg (al [0], XtNtopOfThumb, &widget_topOfThumb);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
100 XtSetArg (al [1], XtNshown, &widget_shown);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
101 XtGetValues (widget, al, 2);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 new_shown = (double) data->slider_size /
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (double) (data->maximum - data->minimum);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 new_topOfThumb = (double) (data->slider_position - data->minimum) /
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (double) (data->maximum - data->minimum);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 if (new_shown > 1.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 new_shown = 1.0;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
111 else if (new_shown < 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 new_shown = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 if (new_topOfThumb > 1.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 new_topOfThumb = 1.0;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
116 else if (new_topOfThumb < 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 new_topOfThumb = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 if (new_shown != widget_shown || new_topOfThumb != widget_topOfThumb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 XawScrollbarSetThumb (widget, new_topOfThumb, new_shown);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 }
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
123 #endif /* LWLIB_SCROLLBARS_ATHENA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 xaw_update_one_widget (widget_instance *instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 widget_value *val, Boolean deep_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
129 if (val->args && val->args->nargs)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
130 XtSetValues (widget, val->args->args, val->args->nargs);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
131
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 if (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
134 #ifdef LWLIB_SCROLLBARS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 else if (XtIsSubclass (widget, scrollbarWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 xaw_update_scrollbar (instance, widget, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 #endif
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
140 #ifdef LWLIB_DIALOGS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 else if (XtIsSubclass (widget, dialogWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 {
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
143 Arg al [1];
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
144 XtSetArg (al [0], XtNlabel, val->contents->value);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
145 XtSetValues (widget, al, 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
147 #endif /* LWLIB_DIALOGS_ATHENA */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
148 #ifdef LWLIB_WIDGETS_ATHENA
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
149 else if (XtClass (widget) == labelWidgetClass)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
150 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
151 Arg al [1];
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
152 XtSetArg (al [0], XtNlabel, val->value);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
153 XtSetValues (widget, al, 1);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
154 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
155 #endif /* LWLIB_WIDGETS_ATHENA */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
156 #if defined (LWLIB_DIALOGS_ATHENA) || defined (LWLIB_WIDGETS_ATHENA)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 else if (XtIsSubclass (widget, commandWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 Dimension bw = 0;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
160 Arg al [3];
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
161 XtSetArg (al [0], XtNborderWidth, &bw);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
162 XtGetValues (widget, al, 1);
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
163
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
164 #ifndef LWLIB_DIALOGS_ATHENA3D
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 if (bw == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 /* Don't let buttons end up with 0 borderwidth, that's ugly...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 Yeah, all this should really be done through app-defaults files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 or fallback resources, but that's a whole different can of worms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 that I don't feel like opening right now. Making Athena widgets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 not look like shit is just entirely too much work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 */
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
172 {
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
173 XtSetArg (al [0], XtNborderWidth, 1);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
174 XtSetValues (widget, al, 1);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
175 }
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
176 #endif /* ! LWLIB_DIALOGS_ATHENA3D */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
178 XtSetArg (al [0], XtNlabel, val->value);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
179 XtSetArg (al [1], XtNsensitive, val->enabled);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
180 /* Force centered button text. See above. */
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
181 XtSetArg (al [2], XtNjustify, XtJustifyCenter);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
182 XtSetValues (widget, al, 3);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 XtRemoveAllCallbacks (widget, XtNcallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 XtAddCallback (widget, XtNcallback, xaw_generic_callback, instance);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
186 #ifdef LWLIB_WIDGETS_ATHENA
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
187 /* set the selected state */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
188 if (XtIsSubclass (widget, toggleWidgetClass))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
189 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
190 XtSetArg (al [0], XtNstate, val->selected);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
191 XtSetValues (widget, al, 1);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
192 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
193 #endif /* LWLIB_WIDGETS_ATHENA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 }
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
195 #endif /* LWLIB_DIALOGS_ATHENA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 xaw_update_one_value (widget_instance *instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 widget_value *val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
202 #ifdef LWLIB_WIDGETS_ATHENA
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
203 widget_value *old_wv;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
204
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
205 /* copy the call_data slot into the "return" widget_value */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
206 for (old_wv = instance->info->val->contents; old_wv; old_wv = old_wv->next)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
207 if (!strcmp (val->name, old_wv->name))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
208 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
209 val->call_data = old_wv->call_data;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
210 break;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
211 }
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 if (XtIsSubclass (widget, toggleWidgetClass))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
214 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
215 Arg al [1];
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
216 XtSetArg (al [0], XtNstate, &val->selected);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
217 XtGetValues (widget, al, 1);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
218 val->edited = True;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
219 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
220 #ifndef NEED_MOTIF
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
221 else if (XtIsSubclass (widget, asciiTextWidgetClass))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
222 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
223 Arg al [1];
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
224 if (val->value)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
225 free (val->value);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
226 XtSetArg (al [0], XtNstring, &val->value);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
227 XtGetValues (widget, al, 1);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
228 val->edited = True;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
229 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
230 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
231 #endif /* LWLIB_WIDGETS_ATHENA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 xaw_destroy_instance (widget_instance *instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 {
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
237 #ifdef LWLIB_DIALOGS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 if (XtIsSubclass (instance->widget, dialogWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 /* Need to destroy the Shell too. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 XtDestroyWidget (XtParent (instance->widget));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 XtDestroyWidget (instance->widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 xaw_popup_menu (Widget widget, XEvent *event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 /* An Athena menubar has not been implemented. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 xaw_pop_instance (widget_instance *instance, Boolean up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 Widget widget = instance->widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 if (up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 {
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
260 #ifdef LWLIB_DIALOGS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 if (XtIsSubclass (widget, dialogWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 /* For dialogs, we need to call XtPopup on the parent instead
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 of calling XtManageChild on the widget.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 Also we need to hack the shell's WM_PROTOCOLS to get it to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 understand what the close box is supposed to do!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 Display *dpy = XtDisplay (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 Widget shell = XtParent (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 Atom props [2];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 int i = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 props [i++] = XInternAtom (dpy, "WM_DELETE_WINDOW", False);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 XChangeProperty (dpy, XtWindow (shell),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 XInternAtom (dpy, "WM_PROTOCOLS", False),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 XA_ATOM, 32, PropModeAppend,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (unsigned char *) props, i);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 /* Center the widget in its parent. Why isn't this kind of crap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 done automatically? I thought toolkits were supposed to make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 life easier?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 unsigned int x, y, w, h;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 Widget topmost = instance->parent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 w = shell->core.width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 h = shell->core.height;
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 165
diff changeset
287 while (topmost->core.parent &&
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 165
diff changeset
288 XtIsRealized (topmost->core.parent) &&
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 165
diff changeset
289 /* HAVE_SESSION adds an unmapped parent widget that
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 165
diff changeset
290 we should ignore here. */
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 165
diff changeset
291 topmost->core.parent->core.mapped_when_managed)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 topmost = topmost->core.parent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 if (topmost->core.width < w) x = topmost->core.x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 else x = topmost->core.x + ((topmost->core.width - w) / 2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 if (topmost->core.height < h) y = topmost->core.y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 else y = topmost->core.y + ((topmost->core.height - h) / 2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 XtMoveWidget (shell, x, y);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 /* Finally, pop it up. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 XtPopup (shell, XtGrabNonexclusive);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 else
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
304 #endif /* LWLIB_DIALOGS_ATHENA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 XtManageChild (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 {
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
309 #ifdef LWLIB_DIALOGS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 if (XtIsSubclass (widget, dialogWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 XtUnmanageChild (XtParent (widget));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 XtUnmanageChild (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
319 #ifdef LWLIB_DIALOGS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 /* Dialog boxes */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 static char overrideTrans[] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 "<Message>WM_PROTOCOLS: lwlib_delete_dialog()";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 static XtActionProc wm_delete_window (Widget shell, XtPointer closure,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 XtPointer call_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 static XtActionsRec xaw_actions [] = {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 {"lwlib_delete_dialog", (XtActionProc) wm_delete_window}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 static Boolean actions_initted = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 static Widget
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
332 make_dialog (const char* name, Widget parent, Boolean pop_up_p,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
333 const char* shell_title, const char* icon_name,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 Boolean text_input_slot,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 Boolean radio_box, Boolean list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 int left_buttons, int right_buttons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 Arg av [20];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 int ac = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 int i, bc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 char button_name [255];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 Widget shell;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 Widget dialog;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 Widget button;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 XtTranslations override;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 if (! pop_up_p) abort (); /* not implemented */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 if (text_input_slot) abort (); /* not implemented */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 if (radio_box) abort (); /* not implemented */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 if (list) abort (); /* not implemented */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 if (! actions_initted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 XtAppContext app = XtWidgetToApplicationContext (parent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 XtAppAddActions (app, xaw_actions,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 sizeof (xaw_actions) / sizeof (xaw_actions[0]));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 actions_initted = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 override = XtParseTranslationTable (overrideTrans);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ac = 0;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
363 XtSetArg (av[ac], XtNtitle, shell_title); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 XtSetArg (av[ac], XtNallowShellResize, True); ac++;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
365 XtSetArg (av[ac], XtNtransientFor, parent); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 shell = XtCreatePopupShell ("dialog", transientShellWidgetClass,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 parent, av, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 XtOverrideTranslations (shell, override);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 ac = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 dialog = XtCreateManagedWidget (name, dialogWidgetClass, shell, av, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 bc = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 button = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 for (i = 0; i < left_buttons; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 ac = 0;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
378 XtSetArg (av [ac], XtNfromHoriz, button); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
379 XtSetArg (av [ac], XtNleft, XtChainLeft); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
380 XtSetArg (av [ac], XtNright, XtChainLeft); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
381 XtSetArg (av [ac], XtNtop, XtChainBottom); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
383 XtSetArg (av [ac], XtNresizable, True); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 sprintf (button_name, "button%d", ++bc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 button = XtCreateManagedWidget (button_name, commandWidgetClass,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 dialog, av, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 if (right_buttons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 /* Create a separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 I want the separator to take up the slack between the buttons on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 the right and the buttons on the left (that is I want the buttons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 after the separator to be packed against the right edge of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 window) but I can't seem to make it do it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ac = 0;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
398 XtSetArg (av [ac], XtNfromHoriz, button); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 /* XtSetArg (av [ac], XtNfromVert, XtNameToWidget (dialog, "label")); ac++; */
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
400 XtSetArg (av [ac], XtNleft, XtChainLeft); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
401 XtSetArg (av [ac], XtNright, XtChainRight); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
402 XtSetArg (av [ac], XtNtop, XtChainBottom); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 XtSetArg (av [ac], XtNlabel, ""); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 XtSetArg (av [ac], XtNwidth, 30); ac++; /* #### aaack!! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 XtSetArg (av [ac], XtNborderWidth, 0); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 XtSetArg (av [ac], XtNshapeStyle, XmuShapeRectangle); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 XtSetArg (av [ac], XtNresizable, False); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 XtSetArg (av [ac], XtNsensitive, False); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 button = XtCreateManagedWidget ("separator",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 /* labelWidgetClass, */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 /* This has to be Command to fake out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 the Dialog widget... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 commandWidgetClass,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 dialog, av, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 for (i = 0; i < right_buttons; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 ac = 0;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
420 XtSetArg (av [ac], XtNfromHoriz, button); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
421 XtSetArg (av [ac], XtNleft, XtChainRight); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
422 XtSetArg (av [ac], XtNright, XtChainRight); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
423 XtSetArg (av [ac], XtNtop, XtChainBottom); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
425 XtSetArg (av [ac], XtNresizable, True); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 sprintf (button_name, "button%d", ++bc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 button = XtCreateManagedWidget (button_name, commandWidgetClass,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 dialog, av, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 return dialog;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 Widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 xaw_create_dialog (widget_instance* instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 char *name = instance->info->type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 Widget parent = instance->parent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 Widget widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 Boolean pop_up_p = instance->pop_up_p;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
441 const char *shell_name = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
442 const char *icon_name = 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 Boolean text_input_slot = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 Boolean radio_box = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 Boolean list = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 int total_buttons;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 int left_buttons = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 int right_buttons = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 switch (name [0]) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 case 'E': case 'e':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 icon_name = "dbox-error";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 shell_name = "Error";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 case 'I': case 'i':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 icon_name = "dbox-info";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 shell_name = "Information";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 case 'L': case 'l':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 list = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 icon_name = "dbox-question";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 shell_name = "Prompt";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 case 'P': case 'p':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 text_input_slot = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 icon_name = "dbox-question";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 shell_name = "Prompt";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 case 'Q': case 'q':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 icon_name = "dbox-question";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 shell_name = "Question";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 total_buttons = name [1] - '0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 if (name [3] == 'T' || name [3] == 't')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 text_input_slot = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 radio_box = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 else if (name [3])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 right_buttons = name [4] - '0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 left_buttons = total_buttons - right_buttons;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 widget = make_dialog (name, parent, pop_up_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 shell_name, icon_name, text_input_slot, radio_box,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 list, left_buttons, right_buttons);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 return widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 }
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
497 #endif /* LWLIB_DIALOGS_ATHENA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 xaw_generic_callback (Widget widget, XtPointer closure, XtPointer call_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 widget_instance *instance = (widget_instance *) closure;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 Widget instance_widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 LWLIB_ID id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 XtPointer user_data;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
507 #ifdef LWLIB_WIDGETS_ATHENA
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
508 /* We want the selected status to change only when we decide it
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
509 should change. Yuck but correct. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
510 if (XtIsSubclass (widget, toggleWidgetClass))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
511 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
512 Boolean check;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
513 Arg al [1];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
515 XtSetArg (al [0], XtNstate, &check);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
516 XtGetValues (widget, al, 1);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
517
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
518 XtSetArg (al [0], XtNstate, !check);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
519 XtSetValues (widget, al, 1);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
520 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
521 #endif /* LWLIB_WIDGETS_ATHENA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 lw_internal_update_other_instances (widget, closure, call_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 if (! instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 if (widget->core.being_destroyed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 instance_widget = instance->widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 if (!instance_widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 id = instance->info->id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 user_data = NULL;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
537 {
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
538 Arg al [1];
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
539 XtSetArg (al [0], XtNuserData, &user_data);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
540 XtGetValues (widget, al, 1);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
541 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 /* Damn! Athena doesn't give us a way to hang our own data on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 buttons, so we have to go find it... I guess this assumes that
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
545 all instances of a button have the same call data.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
546
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
547 ... Which is a totally bogus assumption --andyp */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
549 widget_value *val = instance->info->val;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
550 /* If the widget is a buffer/gutter widget then we already have
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
551 the one we are looking for, so don't try and descend the widget
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
552 tree. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
553 if (val->contents)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
555 char *name = XtName (widget);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
556 val = val->contents;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
557 while (val)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
558 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
559 if (val->name && !strcmp (val->name, name))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
560 break;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
561 val = val->next;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
562 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
563 if (! val) abort ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 user_data = val->call_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 if (instance->info->selection_cb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 instance->info->selection_cb (widget, id, user_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
573 #ifdef LWLIB_DIALOGS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 static XtActionProc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 wm_delete_window (Widget shell, XtPointer closure, XtPointer call_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 LWLIB_ID id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 Widget *kids = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 Widget widget;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
581 Arg al [1];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 if (! XtIsSubclass (shell, shellWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 abort ();
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
584 XtSetArg (al [0], XtNchildren, &kids);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
585 XtGetValues (shell, al, 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 if (!kids || !*kids)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 widget = kids [0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 if (! XtIsSubclass (widget, dialogWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 id = lw_get_widget_id (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 if (! id) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 widget_info *info = lw_get_widget_info (id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 if (! info) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 if (info->selection_cb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 info->selection_cb (widget, id, (XtPointer) -1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 lw_destroy_all_widgets (id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
605 #endif /* LWLIB_DIALOGS_ATHENA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 /* Scrollbars */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
610 #ifdef LWLIB_SCROLLBARS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 xaw_scrollbar_scroll (Widget widget, XtPointer closure, XtPointer call_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 widget_instance *instance = (widget_instance *) closure;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 LWLIB_ID id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 scroll_event event_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 if (!instance || widget->core.being_destroyed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 id = instance->info->id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 event_data.slider_value = (int) call_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 event_data.time = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 if ((int) call_data > 0)
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
626 /* event_data.action = SCROLLBAR_PAGE_DOWN;*/
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
627 event_data.action = SCROLLBAR_LINE_DOWN;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 else
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
629 /* event_data.action = SCROLLBAR_PAGE_UP;*/
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
630 event_data.action = SCROLLBAR_LINE_UP;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 if (instance->info->pre_activate_cb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 xaw_scrollbar_jump (Widget widget, XtPointer closure, XtPointer call_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 widget_instance *instance = (widget_instance *) closure;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 LWLIB_ID id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 scroll_event event_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 scrollbar_values *val =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (scrollbar_values *) instance->info->val->scrollbar_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 float percent;
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 (!instance || widget->core.being_destroyed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 id = instance->info->id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 percent = * (float *) call_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 event_data.slider_value =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (int) (percent * (float) (val->maximum - val->minimum)) + val->minimum;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 event_data.time = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 event_data.action = SCROLLBAR_DRAG;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 if (instance->info->pre_activate_cb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 static Widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 xaw_create_scrollbar (widget_instance *instance, int vertical)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 {
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
665 Arg av[10];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 int ac = 0;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
667
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
668 static XtCallbackRec jumpCallbacks[2] =
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
669 { {xaw_scrollbar_jump, NULL}, {NULL, NULL} };
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
670
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
671 static XtCallbackRec scrollCallbacks[2] =
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
672 { {xaw_scrollbar_scroll, NULL}, {NULL, NULL} };
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
673
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
674 jumpCallbacks[0].closure = scrollCallbacks[0].closure = (XtPointer) instance;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 /* #### This is tacked onto the with and height and completely
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 screws our geometry management. We should probably make the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 top-level aware of this so that people could have a border but so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 few people use the Athena scrollbar now that it really isn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 worth the effort, at least not at the moment. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 XtSetArg (av [ac], XtNborderWidth, 0); ac++;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
682 XtSetArg (av [ac], XtNorientation,
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
683 vertical ? XtorientVertical : XtorientHorizontal); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
684 XtSetArg (av [ac], "jumpProc", jumpCallbacks); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
685 XtSetArg (av [ac], "scrollProc", scrollCallbacks); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
687 return XtCreateWidget (instance->info->name, scrollbarWidgetClass,
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
688 instance->parent, av, ac);
0
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 Widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 xaw_create_vertical_scrollbar (widget_instance *instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 return xaw_create_scrollbar (instance, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 static Widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 xaw_create_horizontal_scrollbar (widget_instance *instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 return xaw_create_scrollbar (instance, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 }
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
702 #endif /* LWLIB_SCROLLBARS_ATHENA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
704 #ifdef LWLIB_WIDGETS_ATHENA
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
705 /* glyph widgets */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
706 static Widget
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
707 xaw_create_button (widget_instance *instance)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
708 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
709 Arg al[20];
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
710 int ac = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
711 Widget button = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
712 widget_value* val = instance->info->val;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
713
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
714 XtSetArg (al [ac], XtNsensitive, val->enabled); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
715 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
716 XtSetArg (al [ac], XtNjustify, XtJustifyCenter); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
717 /* 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
718 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
719 get rid of it. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
720 XtSetArg (al [ac], XtNhighlightThickness, (Dimension)0);ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
721
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
722 /* add any args the user supplied for creation time */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
723 lw_add_value_args_to_args (val, al, &ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
724
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
725 if (!val->call_data)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
726 button = XtCreateManagedWidget (val->name, labelWidgetClass,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
727 instance->parent, al, ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
728
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
729 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
730 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
731 if (val->type == TOGGLE_TYPE || val->type == RADIO_TYPE)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
732 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
733 XtSetArg (al [ac], XtNstate, val->selected); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
734 button = XtCreateManagedWidget
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
735 (val->name,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
736 val->type == TOGGLE_TYPE ? checkboxWidgetClass : radioWidgetClass,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
737 instance->parent, al, ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
738 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
739 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
740 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
741 button = XtCreateManagedWidget (val->name, commandWidgetClass,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
742 instance->parent, al, ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
743 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
744 XtRemoveAllCallbacks (button, XtNcallback);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
745 XtAddCallback (button, XtNcallback, xaw_generic_callback, (XtPointer)instance);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
746 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
747
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
748 XtManageChild (button);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
749
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
750 return button;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
751 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
752
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
753 static Widget
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
754 xaw_create_label_field (widget_instance *instance)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
755 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
756 return xaw_create_label (instance->parent, instance->info->val);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
757 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
758
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
759 Widget
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
760 xaw_create_label (Widget parent, widget_value* val)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
761 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
762 Arg al[20];
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
763 int ac = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
764 Widget label = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
765
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
766 XtSetArg (al [ac], XtNsensitive, val->enabled); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
767 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
768 XtSetArg (al [ac], XtNjustify, XtJustifyCenter); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
769
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
770 /* add any args the user supplied for creation time */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
771 lw_add_value_args_to_args (val, al, &ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
772
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
773 label = XtCreateManagedWidget (val->name, labelWidgetClass,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
774 parent, al, ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
775
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
776 /* 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
777 ac = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
778 lw_add_value_args_to_args (val, al, &ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
779 XtSetValues (label, al, ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
780
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
781 return label;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
782 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
783
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
784 static Widget
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
785 xaw_create_progress (widget_instance *instance)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
786 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
787 Arg al[20];
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
788 int ac = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
789 Widget scale = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
790 widget_value* val = instance->info->val;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
791
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
792 if (!val->call_data)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
793 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
794 XtSetArg (al [ac], XtNsensitive, False); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
795 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
796 else
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 XtSetArg (al [ac], XtNsensitive, val->enabled); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
799 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
800 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
801 XtSetArg (al [ac], XtNorientation, XtorientHorizontal); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
802 XtSetArg (al [ac], XtNhighlightThickness, (Dimension)0);ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
803 XtSetArg (al [ac], XtNntics, (Cardinal)10);ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
804
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
805 /* add any args the user supplied for creation time */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
806 lw_add_value_args_to_args (val, al, &ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
807
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
808 scale = XtCreateManagedWidget (val->name, gaugeWidgetClass,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
809 instance->parent, al, ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
810 /* add the callback */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
811 if (val->call_data)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
812 XtAddCallback (scale, XtNgetValue, xaw_generic_callback, (XtPointer)instance);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
813
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
814 XtManageChild (scale);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
815
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
816 return scale;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
817 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
818
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
819 #ifndef NEED_MOTIF
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
820 static Widget
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
821 xaw_create_text_field (widget_instance *instance)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
822 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
823 Arg al[20];
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
824 int ac = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
825 Widget text = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
826 widget_value* val = instance->info->val;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
827
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
828 XtSetArg (al [ac], XtNsensitive, val->enabled && val->call_data); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
829 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
830 XtSetArg (al [ac], XtNhighlightThickness, (Dimension)0); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
831 XtSetArg (al [ac], XtNtype, XawAsciiString); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
832 XtSetArg (al [ac], XtNeditType, XawtextEdit); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
833
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
834 /* add any args the user supplied for creation time */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
835 lw_add_value_args_to_args (val, al, &ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
836
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
837 text = XtCreateManagedWidget (val->name, asciiTextWidgetClass,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
838 instance->parent, al, ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
839 XtManageChild (text);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
840
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
841 return text;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
842 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
843 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
844 #endif /* LWLIB_WIDGETS_ATHENA */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
845
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 widget_creation_entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 xaw_creation_table [] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 {
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
849 #ifdef LWLIB_SCROLLBARS_ATHENA
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
850 {"vertical-scrollbar", xaw_create_vertical_scrollbar },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
851 {"horizontal-scrollbar", xaw_create_horizontal_scrollbar },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
852 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
853 #ifdef LWLIB_WIDGETS_ATHENA
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
854 {"button", xaw_create_button },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
855 { "label", xaw_create_label_field },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
856 #ifndef NEED_MOTIF
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
857 {"text-field", xaw_create_text_field },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
858 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
859 {"progress", xaw_create_progress },
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 {NULL, NULL}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 };
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
863