annotate lwlib/lwlib-Xaw.c @ 406:b8cc9ab3f761 r21-2-33

Import from CVS: tag r21-2-33
author cvs
date Mon, 13 Aug 2007 11:17:09 +0200
parents 5a2589c672dc
children de805c49cfc1
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)
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
72 #ifndef NEED_MOTIF
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
73 || XtIsSubclass (widget, asciiTextWidgetClass)
398
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 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 if (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
131 #ifdef LWLIB_SCROLLBARS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 else if (XtIsSubclass (widget, scrollbarWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 xaw_update_scrollbar (instance, widget, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 #endif
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
137 #ifdef LWLIB_WIDGETS_ATHENA
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
138 #ifndef NEED_MOTIF
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
139 else if (XtIsSubclass (widget, asciiTextWidgetClass))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
140 {
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
141 }
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
142 #endif
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
143 #endif
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
144 #ifdef LWLIB_DIALOGS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 else if (XtIsSubclass (widget, dialogWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 {
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
147 Arg al [1];
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
148 XtSetArg (al [0], XtNlabel, val->contents->value);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
149 XtSetValues (widget, al, 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
151 #endif /* LWLIB_DIALOGS_ATHENA */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
152 #ifdef LWLIB_WIDGETS_ATHENA
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
153 else if (XtClass (widget) == labelWidgetClass)
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 Arg al [1];
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
156 XtSetArg (al [0], XtNlabel, val->value);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
157 XtSetValues (widget, al, 1);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
158 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
159 #endif /* LWLIB_WIDGETS_ATHENA */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
160 #if defined (LWLIB_DIALOGS_ATHENA) || defined (LWLIB_WIDGETS_ATHENA)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 else if (XtIsSubclass (widget, commandWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 Dimension bw = 0;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
164 Arg al [3];
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
165 XtSetArg (al [0], XtNborderWidth, &bw);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
166 XtGetValues (widget, al, 1);
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
167
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
168 #ifndef LWLIB_DIALOGS_ATHENA3D
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 if (bw == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 /* Don't let buttons end up with 0 borderwidth, that's ugly...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 Yeah, all this should really be done through app-defaults files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 or fallback resources, but that's a whole different can of worms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 that I don't feel like opening right now. Making Athena widgets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 not look like shit is just entirely too much work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 */
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
176 {
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
177 XtSetArg (al [0], XtNborderWidth, 1);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
178 XtSetValues (widget, al, 1);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
179 }
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
180 #endif /* ! LWLIB_DIALOGS_ATHENA3D */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
182 XtSetArg (al [0], XtNlabel, val->value);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
183 XtSetArg (al [1], XtNsensitive, val->enabled);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
184 /* Force centered button text. See above. */
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
185 XtSetArg (al [2], XtNjustify, XtJustifyCenter);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
186 XtSetValues (widget, al, 3);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 XtRemoveAllCallbacks (widget, XtNcallback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 XtAddCallback (widget, XtNcallback, xaw_generic_callback, instance);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
190 #ifdef LWLIB_WIDGETS_ATHENA
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
191 /* set the selected state */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
192 if (XtIsSubclass (widget, toggleWidgetClass))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
193 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
194 XtSetArg (al [0], XtNstate, val->selected);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
195 XtSetValues (widget, al, 1);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
196 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
197 #endif /* LWLIB_WIDGETS_ATHENA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 }
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
199 #endif /* LWLIB_DIALOGS_ATHENA */
402
5a2589c672dc Import from CVS: tag r21-2-31
cvs
parents: 400
diff changeset
200 /* Lastly update our global arg values. */
5a2589c672dc Import from CVS: tag r21-2-31
cvs
parents: 400
diff changeset
201 if (val->args && val->args->nargs)
5a2589c672dc Import from CVS: tag r21-2-31
cvs
parents: 400
diff changeset
202 XtSetValues (widget, val->args->args, val->args->nargs);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 xaw_update_one_value (widget_instance *instance, Widget widget,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 widget_value *val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
209 #ifdef LWLIB_WIDGETS_ATHENA
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
210 widget_value *old_wv;
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 /* copy the call_data slot into the "return" widget_value */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
213 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
214 if (!strcmp (val->name, old_wv->name))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
215 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
216 val->call_data = old_wv->call_data;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
217 break;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
218 }
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 if (XtIsSubclass (widget, toggleWidgetClass))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
221 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
222 Arg al [1];
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
223 XtSetArg (al [0], XtNstate, &val->selected);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
224 XtGetValues (widget, al, 1);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
225 val->edited = True;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
226 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
227 #ifndef NEED_MOTIF
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
228 else if (XtIsSubclass (widget, asciiTextWidgetClass))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
229 {
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
230 Arg al [2];
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
231 String buf = 0;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
232 XtSetArg (al [0], XtNstring, &buf);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
233 XtGetValues (widget, al, 2);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
234
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
235 if (val->value)
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
236 {
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
237 free (val->value);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
238 val->value = 0;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
239 }
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
240 /* I don't think this causes a leak. */
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
241 if (buf)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
242 val->value = strdup (buf);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
243 val->edited = True;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
244 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
245 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
246 #endif /* LWLIB_WIDGETS_ATHENA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 xaw_destroy_instance (widget_instance *instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 {
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
252 #ifdef LWLIB_DIALOGS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 if (XtIsSubclass (instance->widget, dialogWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 /* Need to destroy the Shell too. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 XtDestroyWidget (XtParent (instance->widget));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 XtDestroyWidget (instance->widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 xaw_popup_menu (Widget widget, XEvent *event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 /* An Athena menubar has not been implemented. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 xaw_pop_instance (widget_instance *instance, Boolean up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 Widget widget = instance->widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 if (up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 {
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
275 #ifdef LWLIB_DIALOGS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 if (XtIsSubclass (widget, dialogWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 /* For dialogs, we need to call XtPopup on the parent instead
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 of calling XtManageChild on the widget.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 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
281 understand what the close box is supposed to do!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 Display *dpy = XtDisplay (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 Widget shell = XtParent (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 Atom props [2];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 int i = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 props [i++] = XInternAtom (dpy, "WM_DELETE_WINDOW", False);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 XChangeProperty (dpy, XtWindow (shell),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 XInternAtom (dpy, "WM_PROTOCOLS", False),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 XA_ATOM, 32, PropModeAppend,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (unsigned char *) props, i);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 /* Center the widget in its parent. Why isn't this kind of crap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 done automatically? I thought toolkits were supposed to make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 life easier?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 unsigned int x, y, w, h;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 Widget topmost = instance->parent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 w = shell->core.width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 h = shell->core.height;
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 165
diff changeset
302 while (topmost->core.parent &&
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 165
diff changeset
303 XtIsRealized (topmost->core.parent) &&
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 165
diff changeset
304 /* HAVE_SESSION adds an unmapped parent widget that
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 165
diff changeset
305 we should ignore here. */
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 165
diff changeset
306 topmost->core.parent->core.mapped_when_managed)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 topmost = topmost->core.parent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 if (topmost->core.width < w) x = topmost->core.x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 else x = topmost->core.x + ((topmost->core.width - w) / 2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 if (topmost->core.height < h) y = topmost->core.y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 else y = topmost->core.y + ((topmost->core.height - h) / 2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 XtMoveWidget (shell, x, y);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 /* Finally, pop it up. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 XtPopup (shell, XtGrabNonexclusive);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 else
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
319 #endif /* LWLIB_DIALOGS_ATHENA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 XtManageChild (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 {
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
324 #ifdef LWLIB_DIALOGS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 if (XtIsSubclass (widget, dialogWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 XtUnmanageChild (XtParent (widget));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 XtUnmanageChild (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
334 #ifdef LWLIB_DIALOGS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 /* Dialog boxes */
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 char overrideTrans[] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 "<Message>WM_PROTOCOLS: lwlib_delete_dialog()";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 static XtActionProc wm_delete_window (Widget shell, XtPointer closure,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 XtPointer call_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 static XtActionsRec xaw_actions [] = {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 {"lwlib_delete_dialog", (XtActionProc) wm_delete_window}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 static Boolean actions_initted = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 static Widget
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
347 make_dialog (const char* name, Widget parent, Boolean pop_up_p,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
348 const char* shell_title, const char* icon_name,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 Boolean text_input_slot,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 Boolean radio_box, Boolean list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 int left_buttons, int right_buttons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 Arg av [20];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 int ac = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 int i, bc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 char button_name [255];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 Widget shell;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 Widget dialog;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 Widget button;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 XtTranslations override;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 if (! pop_up_p) abort (); /* not implemented */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 if (text_input_slot) abort (); /* not implemented */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 if (radio_box) abort (); /* not implemented */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 if (list) abort (); /* not implemented */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 if (! actions_initted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 XtAppContext app = XtWidgetToApplicationContext (parent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 XtAppAddActions (app, xaw_actions,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 sizeof (xaw_actions) / sizeof (xaw_actions[0]));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 actions_initted = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 override = XtParseTranslationTable (overrideTrans);
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], XtNtitle, shell_title); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 XtSetArg (av[ac], XtNallowShellResize, True); ac++;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
380 XtSetArg (av[ac], XtNtransientFor, parent); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 shell = XtCreatePopupShell ("dialog", transientShellWidgetClass,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 parent, av, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 XtOverrideTranslations (shell, override);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 ac = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 dialog = XtCreateManagedWidget (name, dialogWidgetClass, shell, 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 bc = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 button = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 for (i = 0; i < left_buttons; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 ac = 0;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
393 XtSetArg (av [ac], XtNfromHoriz, button); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
394 XtSetArg (av [ac], XtNleft, XtChainLeft); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
395 XtSetArg (av [ac], XtNright, XtChainLeft); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
396 XtSetArg (av [ac], XtNtop, XtChainBottom); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
398 XtSetArg (av [ac], XtNresizable, True); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 sprintf (button_name, "button%d", ++bc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 button = XtCreateManagedWidget (button_name, commandWidgetClass,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 dialog, av, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 if (right_buttons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 /* Create a separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 I want the separator to take up the slack between the buttons on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 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
409 after the separator to be packed against the right edge of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 window) but I can't seem to make it do it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ac = 0;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
413 XtSetArg (av [ac], XtNfromHoriz, button); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 /* XtSetArg (av [ac], XtNfromVert, XtNameToWidget (dialog, "label")); ac++; */
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
415 XtSetArg (av [ac], XtNleft, XtChainLeft); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
416 XtSetArg (av [ac], XtNright, XtChainRight); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
417 XtSetArg (av [ac], XtNtop, XtChainBottom); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 XtSetArg (av [ac], XtNlabel, ""); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 XtSetArg (av [ac], XtNwidth, 30); ac++; /* #### aaack!! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 XtSetArg (av [ac], XtNborderWidth, 0); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 XtSetArg (av [ac], XtNshapeStyle, XmuShapeRectangle); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 XtSetArg (av [ac], XtNresizable, False); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 XtSetArg (av [ac], XtNsensitive, False); ac++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 button = XtCreateManagedWidget ("separator",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 /* labelWidgetClass, */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 /* This has to be Command to fake out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 the Dialog widget... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 commandWidgetClass,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 dialog, av, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 for (i = 0; i < right_buttons; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ac = 0;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
435 XtSetArg (av [ac], XtNfromHoriz, button); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
436 XtSetArg (av [ac], XtNleft, XtChainRight); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
437 XtSetArg (av [ac], XtNright, XtChainRight); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
438 XtSetArg (av [ac], XtNtop, XtChainBottom); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
440 XtSetArg (av [ac], XtNresizable, True); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 sprintf (button_name, "button%d", ++bc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 button = XtCreateManagedWidget (button_name, commandWidgetClass,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 dialog, av, ac);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 return dialog;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 Widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 xaw_create_dialog (widget_instance* instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 char *name = instance->info->type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 Widget parent = instance->parent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 Widget widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 Boolean pop_up_p = instance->pop_up_p;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
456 const char *shell_name = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
457 const char *icon_name = 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 Boolean text_input_slot = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 Boolean radio_box = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 Boolean list = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 int total_buttons;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 int left_buttons = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 int right_buttons = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 switch (name [0]) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 case 'E': case 'e':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 icon_name = "dbox-error";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 shell_name = "Error";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 case 'I': case 'i':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 icon_name = "dbox-info";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 shell_name = "Information";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 case 'L': case 'l':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 list = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 icon_name = "dbox-question";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 shell_name = "Prompt";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 case 'P': case 'p':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 text_input_slot = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 icon_name = "dbox-question";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 shell_name = "Prompt";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 break;
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 'Q': case 'q':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 icon_name = "dbox-question";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 shell_name = "Question";
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 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 total_buttons = name [1] - '0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 if (name [3] == 'T' || name [3] == 't')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 text_input_slot = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 radio_box = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 else if (name [3])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 right_buttons = name [4] - '0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 left_buttons = total_buttons - right_buttons;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 widget = make_dialog (name, parent, pop_up_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 shell_name, icon_name, text_input_slot, radio_box,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 list, left_buttons, right_buttons);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 return widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 }
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
512 #endif /* LWLIB_DIALOGS_ATHENA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 xaw_generic_callback (Widget widget, XtPointer closure, XtPointer call_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 widget_instance *instance = (widget_instance *) closure;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 Widget instance_widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 LWLIB_ID id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 XtPointer user_data;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
522 #ifdef LWLIB_WIDGETS_ATHENA
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
523 /* 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
524 should change. Yuck but correct. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
525 if (XtIsSubclass (widget, toggleWidgetClass))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
526 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
527 Boolean check;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
528 Arg al [1];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
530 XtSetArg (al [0], XtNstate, &check);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
531 XtGetValues (widget, al, 1);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
532
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
533 XtSetArg (al [0], XtNstate, !check);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
534 XtSetValues (widget, al, 1);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
535 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
536 #endif /* LWLIB_WIDGETS_ATHENA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 lw_internal_update_other_instances (widget, closure, call_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 if (! instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 if (widget->core.being_destroyed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 instance_widget = instance->widget;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 if (!instance_widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 id = instance->info->id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 user_data = NULL;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
552 {
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
553 Arg al [1];
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
554 XtSetArg (al [0], XtNuserData, &user_data);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
555 XtGetValues (widget, al, 1);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
556 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 /* 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
559 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
560 all instances of a button have the same call data.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
561
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
562 ... Which is a totally bogus assumption --andyp */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
564 widget_value *val = instance->info->val;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
565 /* 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
566 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
567 tree. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
568 if (val->contents)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
570 char *name = XtName (widget);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
571 val = val->contents;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
572 while (val)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
573 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
574 if (val->name && !strcmp (val->name, name))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
575 break;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
576 val = val->next;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
577 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
578 if (! val) abort ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 user_data = val->call_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 if (instance->info->selection_cb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 instance->info->selection_cb (widget, id, user_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
588 #ifdef LWLIB_DIALOGS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 static XtActionProc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 wm_delete_window (Widget shell, XtPointer closure, XtPointer call_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 LWLIB_ID id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 Widget *kids = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 Widget widget;
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
596 Arg al [1];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 if (! XtIsSubclass (shell, shellWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 abort ();
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
599 XtSetArg (al [0], XtNchildren, &kids);
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
600 XtGetValues (shell, al, 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 if (!kids || !*kids)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 widget = kids [0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 if (! XtIsSubclass (widget, dialogWidgetClass))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 id = lw_get_widget_id (widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 if (! id) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 widget_info *info = lw_get_widget_info (id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 if (! info) abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 if (info->selection_cb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 info->selection_cb (widget, id, (XtPointer) -1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 lw_destroy_all_widgets (id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
620 #endif /* LWLIB_DIALOGS_ATHENA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 /* Scrollbars */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
625 #ifdef LWLIB_SCROLLBARS_ATHENA
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 xaw_scrollbar_scroll (Widget widget, XtPointer closure, XtPointer call_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 widget_instance *instance = (widget_instance *) closure;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 LWLIB_ID id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 scroll_event event_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 if (!instance || widget->core.being_destroyed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 id = instance->info->id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 event_data.slider_value = (int) call_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 event_data.time = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 if ((int) call_data > 0)
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
641 /* event_data.action = SCROLLBAR_PAGE_DOWN;*/
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
642 event_data.action = SCROLLBAR_LINE_DOWN;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 else
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
644 /* event_data.action = SCROLLBAR_PAGE_UP;*/
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
645 event_data.action = SCROLLBAR_LINE_UP;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 if (instance->info->pre_activate_cb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 xaw_scrollbar_jump (Widget widget, XtPointer closure, XtPointer call_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 widget_instance *instance = (widget_instance *) closure;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 LWLIB_ID id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 scroll_event event_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 scrollbar_values *val =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (scrollbar_values *) instance->info->val->scrollbar_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 float percent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 if (!instance || widget->core.being_destroyed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 id = instance->info->id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 percent = * (float *) call_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 event_data.slider_value =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (int) (percent * (float) (val->maximum - val->minimum)) + val->minimum;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 event_data.time = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 event_data.action = SCROLLBAR_DRAG;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 if (instance->info->pre_activate_cb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 static Widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 xaw_create_scrollbar (widget_instance *instance, int vertical)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 {
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
680 Arg av[10];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 int ac = 0;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
682
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
683 static XtCallbackRec jumpCallbacks[2] =
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
684 { {xaw_scrollbar_jump, NULL}, {NULL, NULL} };
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
685
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
686 static XtCallbackRec scrollCallbacks[2] =
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
687 { {xaw_scrollbar_scroll, NULL}, {NULL, NULL} };
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
688
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
689 jumpCallbacks[0].closure = scrollCallbacks[0].closure = (XtPointer) instance;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 /* #### This is tacked onto the with and height and completely
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 screws our geometry management. We should probably make the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 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
694 few people use the Athena scrollbar now that it really isn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 worth the effort, at least not at the moment. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 XtSetArg (av [ac], XtNborderWidth, 0); ac++;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
697 XtSetArg (av [ac], XtNorientation,
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
698 vertical ? XtorientVertical : XtorientHorizontal); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
699 XtSetArg (av [ac], "jumpProc", jumpCallbacks); ac++;
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
700 XtSetArg (av [ac], "scrollProc", scrollCallbacks); ac++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
702 return XtCreateWidget (instance->info->name, scrollbarWidgetClass,
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
703 instance->parent, av, ac);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 static Widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 xaw_create_vertical_scrollbar (widget_instance *instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 return xaw_create_scrollbar (instance, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 static Widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 xaw_create_horizontal_scrollbar (widget_instance *instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 return xaw_create_scrollbar (instance, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 }
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
717 #endif /* LWLIB_SCROLLBARS_ATHENA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
719 #ifdef LWLIB_WIDGETS_ATHENA
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
720 /* glyph widgets */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
721 static Widget
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
722 xaw_create_button (widget_instance *instance)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
723 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
724 Arg al[20];
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
725 int ac = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
726 Widget button = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
727 widget_value* val = instance->info->val;
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 XtSetArg (al [ac], XtNsensitive, val->enabled); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
730 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
731 XtSetArg (al [ac], XtNjustify, XtJustifyCenter); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
732 /* 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
733 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
734 get rid of it. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
735 XtSetArg (al [ac], XtNhighlightThickness, (Dimension)0);ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
736
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
737 /* add any args the user supplied for creation time */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
738 lw_add_value_args_to_args (val, al, &ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
739
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
740 if (!val->call_data)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
741 button = XtCreateManagedWidget (val->name, labelWidgetClass,
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 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
745 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
746 if (val->type == TOGGLE_TYPE || val->type == RADIO_TYPE)
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 XtSetArg (al [ac], XtNstate, val->selected); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
749 button = XtCreateManagedWidget
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
750 (val->name,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
751 val->type == TOGGLE_TYPE ? checkboxWidgetClass : radioWidgetClass,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
752 instance->parent, al, ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
753 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
754 else
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 button = XtCreateManagedWidget (val->name, commandWidgetClass,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
757 instance->parent, al, ac);
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 XtRemoveAllCallbacks (button, XtNcallback);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
760 XtAddCallback (button, XtNcallback, xaw_generic_callback, (XtPointer)instance);
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
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
763 XtManageChild (button);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
764
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
765 return button;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
766 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
767
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
768 static Widget
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
769 xaw_create_label_field (widget_instance *instance)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
770 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
771 return xaw_create_label (instance->parent, instance->info->val);
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
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
774 Widget
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
775 xaw_create_label (Widget parent, widget_value* val)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
776 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
777 Arg al[20];
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
778 int ac = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
779 Widget label = 0;
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 XtSetArg (al [ac], XtNsensitive, val->enabled); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
782 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
783 XtSetArg (al [ac], XtNjustify, XtJustifyCenter); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
784
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
785 /* add any args the user supplied for creation time */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
786 lw_add_value_args_to_args (val, al, &ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
787
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
788 label = XtCreateManagedWidget (val->name, labelWidgetClass,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
789 parent, al, ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
790
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
791 /* 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
792 ac = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
793 lw_add_value_args_to_args (val, al, &ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
794 XtSetValues (label, al, 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 return label;
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
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
799 static Widget
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
800 xaw_create_progress (widget_instance *instance)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
801 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
802 Arg al[20];
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
803 int ac = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
804 Widget scale = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
805 widget_value* val = instance->info->val;
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
806 #if 0 /* This looks too awful, although more correct. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
807 if (!val->call_data)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
808 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
809 XtSetArg (al [ac], XtNsensitive, False); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
810 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
811 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
812 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
813 XtSetArg (al [ac], XtNsensitive, val->enabled); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
814 }
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
815 #else
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
816 XtSetArg (al [ac], XtNsensitive, True); ac++;
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
817 #endif
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
818
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
819 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
820 XtSetArg (al [ac], XtNorientation, XtorientHorizontal); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
821 XtSetArg (al [ac], XtNhighlightThickness, (Dimension)0);ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
822 XtSetArg (al [ac], XtNntics, (Cardinal)10);ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
823
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
824 /* add any args the user supplied for creation time */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
825 lw_add_value_args_to_args (val, al, &ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
826
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
827 scale = XtCreateManagedWidget (val->name, gaugeWidgetClass,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
828 instance->parent, al, ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
829 /* add the callback */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
830 if (val->call_data)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
831 XtAddCallback (scale, XtNgetValue, xaw_generic_callback, (XtPointer)instance);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
832
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
833 XtManageChild (scale);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
834
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
835 return scale;
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
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
838 #ifndef NEED_MOTIF
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
839 #define TEXT_BUFFER_SIZE 128
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
840 static Widget
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
841 xaw_create_text_field (widget_instance *instance)
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 Arg al[20];
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
844 int ac = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
845 Widget text = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
846 widget_value* val = instance->info->val;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
847
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
848 XtSetArg (al [ac], XtNsensitive, val->enabled); ac++;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
849 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
850 XtSetArg (al [ac], XtNhighlightThickness, (Dimension)0); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
851 XtSetArg (al [ac], XtNtype, XawAsciiString); ac++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
852 XtSetArg (al [ac], XtNeditType, XawtextEdit); ac++;
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
853 XtSetArg (al [ac], XtNuseStringInPlace, False); ac++;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
854 #if 0
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
855 XtSetArg (al [ac], XtNlength, TEXT_BUFFER_SIZE); ac++;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
856 #endif
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
857 if (val->value)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
858 {
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
859 XtSetArg (al [ac], XtNstring, val->value); ac++;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
860 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
861
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
862 /* add any args the user supplied for creation time */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
863 lw_add_value_args_to_args (val, al, &ac);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
864
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
865 text = XtCreateManagedWidget (val->name, asciiTextWidgetClass,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
866 instance->parent, al, ac);
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
867
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
868 /* add the callback */
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
869 if (val->call_data)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
870 XtAddCallback (text, XtNgetValue, xaw_generic_callback, (XtPointer)instance);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
871
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
872 XtManageChild (text);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
873
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
874 return text;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
875 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
876 #endif
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 402
diff changeset
877
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
878 #endif /* LWLIB_WIDGETS_ATHENA */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
879
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 widget_creation_entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 xaw_creation_table [] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 {
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 209
diff changeset
883 #ifdef LWLIB_SCROLLBARS_ATHENA
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
884 {"vertical-scrollbar", xaw_create_vertical_scrollbar },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
885 {"horizontal-scrollbar", xaw_create_horizontal_scrollbar },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
886 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
887 #ifdef LWLIB_WIDGETS_ATHENA
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
888 {"button", xaw_create_button },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
889 { "label", xaw_create_label_field },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
890 #ifndef NEED_MOTIF
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
891 {"text-field", xaw_create_text_field },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
892 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
893 {"progress", xaw_create_progress },
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 {NULL, NULL}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 };
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 243
diff changeset
897