annotate lwlib/lwlib-Xaw.c @ 2920:54175590d006

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