annotate lwlib/lwlib-Xaw.c @ 453:270b05afd845

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