annotate lwlib/lwlib-Xaw.c @ 4557:790bd95b84c1

Automated merge with file:/Sources/xemacs-21.5-checked-out
author Aidan Kehoe <kehoea@parhasard.net>
date Tue, 13 May 2008 20:26:47 +0200
parents 7bc12bb1a2cf
children 383ab474a241
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
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
55 extern int debug_xft;
428
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 Boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 lw_xaw_widget_p (Widget widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 return (0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 #ifdef LWLIB_SCROLLBARS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 || XtIsSubclass (widget, scrollbarWidgetClass)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 #ifdef LWLIB_DIALOGS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 || XtIsSubclass (widget, dialogWidgetClass)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 #ifdef LWLIB_WIDGETS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 || XtIsSubclass (widget, labelWidgetClass)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 || XtIsSubclass (widget, toggleWidgetClass)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 || XtIsSubclass (widget, gaugeWidgetClass)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
71 #ifndef NEED_MOTIF
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
72 || XtIsSubclass (widget, asciiTextWidgetClass)
428
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 #endif
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 #ifdef LWLIB_SCROLLBARS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 xaw_update_scrollbar (widget_instance *instance, Widget widget,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 widget_value *val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 if (val->scrollbar_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 scrollbar_values *data = val->scrollbar_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 float widget_shown, widget_topOfThumb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 float new_shown, new_topOfThumb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 Arg al [10];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 /* First size and position the scrollbar widget. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 XtSetArg (al [0], XtNx, data->scrollbar_x);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 XtSetArg (al [1], XtNy, data->scrollbar_y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 XtSetArg (al [2], XtNwidth, data->scrollbar_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 XtSetArg (al [3], XtNheight, data->scrollbar_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 XtSetValues (widget, al, 4);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 /* Now size the scrollbar's slider. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 XtSetArg (al [0], XtNtopOfThumb, &widget_topOfThumb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 XtSetArg (al [1], XtNshown, &widget_shown);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 XtGetValues (widget, al, 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 new_shown = (double) data->slider_size /
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 (double) (data->maximum - data->minimum);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 new_topOfThumb = (double) (data->slider_position - data->minimum) /
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 (double) (data->maximum - data->minimum);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 if (new_shown > 1.0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 new_shown = 1.0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 else if (new_shown < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 new_shown = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 if (new_topOfThumb > 1.0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 new_topOfThumb = 1.0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 else if (new_topOfThumb < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 new_topOfThumb = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 if (new_shown != widget_shown || new_topOfThumb != widget_topOfThumb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 XawScrollbarSetThumb (widget, new_topOfThumb, new_shown);
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 #endif /* LWLIB_SCROLLBARS_ATHENA */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 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
126 widget_value *val, Boolean UNUSED (deep_p))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 if (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 #ifdef LWLIB_SCROLLBARS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 else if (XtIsSubclass (widget, scrollbarWidgetClass))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 xaw_update_scrollbar (instance, widget, val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 #endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
136 #ifdef LWLIB_WIDGETS_ATHENA
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
137 #ifndef NEED_MOTIF
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
138 else if (XtIsSubclass (widget, asciiTextWidgetClass))
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 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
141 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
142 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 #ifdef LWLIB_DIALOGS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 else if (XtIsSubclass (widget, dialogWidgetClass))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 Arg al [1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 XtSetArg (al [0], XtNlabel, val->contents->value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 XtSetValues (widget, al, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 #endif /* LWLIB_DIALOGS_ATHENA */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 #ifdef LWLIB_WIDGETS_ATHENA
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 434
diff changeset
152 else if (XtClass (widget) == labelWidgetClass)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 Arg al [1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 XtSetArg (al [0], XtNlabel, val->value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 XtSetValues (widget, al, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 #endif /* LWLIB_WIDGETS_ATHENA */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 #if defined (LWLIB_DIALOGS_ATHENA) || defined (LWLIB_WIDGETS_ATHENA)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 else if (XtIsSubclass (widget, commandWidgetClass))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 Dimension bw = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 Arg al [3];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 XtSetArg (al [0], XtNborderWidth, &bw);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 XtGetValues (widget, al, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 #ifndef LWLIB_DIALOGS_ATHENA3D
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 if (bw == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 /* Don't let buttons end up with 0 borderwidth, that's ugly...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 Yeah, all this should really be done through app-defaults files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 or fallback resources, but that's a whole different can of worms
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 that I don't feel like opening right now. Making Athena widgets
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 not look like shit is just entirely too much work.
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 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 XtSetArg (al [0], XtNborderWidth, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 XtSetValues (widget, al, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 #endif /* ! LWLIB_DIALOGS_ATHENA3D */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
181 lw_remove_accelerator_spec (val->value);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 XtSetArg (al [0], XtNlabel, val->value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 XtSetArg (al [1], XtNsensitive, val->enabled);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 /* Force centered button text. See above. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 XtSetArg (al [2], XtNjustify, XtJustifyCenter);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 XtSetValues (widget, al, 3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 XtRemoveAllCallbacks (widget, XtNcallback);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 XtAddCallback (widget, XtNcallback, xaw_generic_callback, instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 #ifdef LWLIB_WIDGETS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 /* set the selected state */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 if (XtIsSubclass (widget, toggleWidgetClass))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 XtSetArg (al [0], XtNstate, val->selected);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 XtSetValues (widget, al, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 #endif /* LWLIB_WIDGETS_ATHENA */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 #endif /* LWLIB_DIALOGS_ATHENA */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
200 /* Lastly update our global arg values. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
201 if (val->args && val->args->nargs)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
202 XtSetValues (widget, val->args->args, val->args->nargs);
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 xaw_update_one_value (widget_instance *instance, Widget widget,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 widget_value *val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 #ifdef LWLIB_WIDGETS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 widget_value *old_wv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 /* copy the call_data slot into the "return" widget_value */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 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
214 if (!strcmp (val->name, old_wv->name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 val->call_data = old_wv->call_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 break;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 if (XtIsSubclass (widget, toggleWidgetClass))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 Arg al [1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 XtSetArg (al [0], XtNstate, &val->selected);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 XtGetValues (widget, al, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 val->edited = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 #ifndef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 else if (XtIsSubclass (widget, asciiTextWidgetClass))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
230 Arg al [2];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
231 String buf = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
232 XtSetArg (al [0], XtNstring, &buf);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
233 XtGetValues (widget, al, 1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
234
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 if (val->value)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
236 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
237 free (val->value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
238 val->value = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
239 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
240 /* I don't think this causes a leak. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
241 if (buf)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
242 val->value = strdup (buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 val->edited = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 #endif /* LWLIB_WIDGETS_ATHENA */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 xaw_destroy_instance (widget_instance *instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 #ifdef LWLIB_DIALOGS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 if (XtIsSubclass (instance->widget, dialogWidgetClass))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 /* Need to destroy the Shell too. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 XtDestroyWidget (XtParent (instance->widget));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 XtDestroyWidget (instance->widget);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 460
diff changeset
262 xaw_popup_menu (Widget UNUSED (widget), XEvent *UNUSED (event))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 /* An Athena menubar has not been implemented. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 return;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 xaw_pop_instance (widget_instance *instance, Boolean up)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 Widget widget = instance->widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 if (up)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 #ifdef LWLIB_DIALOGS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 if (XtIsSubclass (widget, dialogWidgetClass))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 /* For dialogs, we need to call XtPopup on the parent instead
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 of calling XtManageChild on the widget.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 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
281 understand what the close box is supposed to do!!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 Display *dpy = XtDisplay (widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 Widget shell = XtParent (widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 Atom props [2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 int i = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 props [i++] = XInternAtom (dpy, "WM_DELETE_WINDOW", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 XChangeProperty (dpy, XtWindow (shell),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 XInternAtom (dpy, "WM_PROTOCOLS", False),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 XA_ATOM, 32, PropModeAppend,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 (unsigned char *) props, i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 /* 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
294 done automatically? I thought toolkits were supposed to make
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 life easier?
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 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 unsigned int x, y, w, h;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 Widget topmost = instance->parent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 w = shell->core.width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 h = shell->core.height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 while (topmost->core.parent &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 XtIsRealized (topmost->core.parent) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 /* HAVE_SESSION adds an unmapped parent widget that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 we should ignore here. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 topmost->core.parent->core.mapped_when_managed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 topmost = topmost->core.parent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 if (topmost->core.width < w) x = topmost->core.x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 else x = topmost->core.x + ((topmost->core.width - w) / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 if (topmost->core.height < h) y = topmost->core.y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 else y = topmost->core.y + ((topmost->core.height - h) / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 XtMoveWidget (shell, x, y);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 /* Finally, pop it up. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 XtPopup (shell, XtGrabNonexclusive);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 #endif /* LWLIB_DIALOGS_ATHENA */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 XtManageChild (widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 #ifdef LWLIB_DIALOGS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 if (XtIsSubclass (widget, dialogWidgetClass))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 XtUnmanageChild (XtParent (widget));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 XtUnmanageChild (widget);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 #ifdef LWLIB_DIALOGS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 /* Dialog boxes */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 static char overrideTrans[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 "<Message>WM_PROTOCOLS: lwlib_delete_dialog()";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 static XtActionProc wm_delete_window (Widget shell, XtPointer closure,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 XtPointer call_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 static XtActionsRec xaw_actions [] = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 {"lwlib_delete_dialog", (XtActionProc) wm_delete_window}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 static Boolean actions_initted = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 static Widget
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
347 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
348 const char* shell_title, const char* UNUSED (icon_name),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 Boolean text_input_slot,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 Boolean radio_box, Boolean list,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 int left_buttons, int right_buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 Arg av [20];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 int ac = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 int i, bc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 char button_name [255];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 Widget shell;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 Widget dialog;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 Widget button;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 XtTranslations override;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 if (! pop_up_p) abort (); /* not implemented */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 if (text_input_slot) abort (); /* not implemented */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 if (radio_box) abort (); /* not implemented */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 if (list) abort (); /* not implemented */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 if (! actions_initted)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 XtAppContext app = XtWidgetToApplicationContext (parent);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 XtAppAddActions (app, xaw_actions,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 sizeof (xaw_actions) / sizeof (xaw_actions[0]));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 actions_initted = True;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 override = XtParseTranslationTable (overrideTrans);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 ac = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 XtSetArg (av[ac], XtNtitle, shell_title); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 XtSetArg (av[ac], XtNallowShellResize, True); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 XtSetArg (av[ac], XtNtransientFor, parent); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 shell = XtCreatePopupShell ("dialog", transientShellWidgetClass,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 parent, av, ac);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 XtOverrideTranslations (shell, override);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 ac = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 dialog = XtCreateManagedWidget (name, dialogWidgetClass, shell, av, ac);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 bc = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 button = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 for (i = 0; i < left_buttons; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 ac = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 XtSetArg (av [ac], XtNfromHoriz, button); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 XtSetArg (av [ac], XtNleft, XtChainLeft); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 XtSetArg (av [ac], XtNright, XtChainLeft); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 XtSetArg (av [ac], XtNtop, XtChainBottom); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 XtSetArg (av [ac], XtNresizable, True); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 sprintf (button_name, "button%d", ++bc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 button = XtCreateManagedWidget (button_name, commandWidgetClass,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 dialog, av, ac);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 if (right_buttons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 /* Create a separator
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 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
408 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
409 after the separator to be packed against the right edge of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 window) but I can't seem to make it do it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 ac = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 XtSetArg (av [ac], XtNfromHoriz, button); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 /* XtSetArg (av [ac], XtNfromVert, XtNameToWidget (dialog, "label")); ac++; */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 XtSetArg (av [ac], XtNleft, XtChainLeft); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 XtSetArg (av [ac], XtNright, XtChainRight); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 XtSetArg (av [ac], XtNtop, XtChainBottom); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 XtSetArg (av [ac], XtNlabel, ""); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 XtSetArg (av [ac], XtNwidth, 30); ac++; /* #### aaack!! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 XtSetArg (av [ac], XtNborderWidth, 0); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 XtSetArg (av [ac], XtNshapeStyle, XmuShapeRectangle); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 XtSetArg (av [ac], XtNresizable, False); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 XtSetArg (av [ac], XtNsensitive, False); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 button = XtCreateManagedWidget ("separator",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 /* labelWidgetClass, */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 /* This has to be Command to fake out
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 the Dialog widget... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 commandWidgetClass,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 dialog, av, ac);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 for (i = 0; i < right_buttons; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 ac = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 XtSetArg (av [ac], XtNfromHoriz, button); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 XtSetArg (av [ac], XtNleft, XtChainRight); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 XtSetArg (av [ac], XtNright, XtChainRight); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 XtSetArg (av [ac], XtNtop, XtChainBottom); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 XtSetArg (av [ac], XtNresizable, True); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 sprintf (button_name, "button%d", ++bc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 button = XtCreateManagedWidget (button_name, commandWidgetClass,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 dialog, av, ac);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 return dialog;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 xaw_create_dialog (widget_instance* instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 char *name = instance->info->type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 Widget parent = instance->parent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 Widget widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 Boolean pop_up_p = instance->pop_up_p;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
456 const char *shell_name = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
457 const char *icon_name = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 Boolean text_input_slot = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 Boolean radio_box = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 Boolean list = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 int total_buttons;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 int left_buttons = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 int right_buttons = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 switch (name [0]) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 case 'E': case 'e':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 icon_name = "dbox-error";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 shell_name = "Error";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 case 'I': case 'i':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 icon_name = "dbox-info";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 shell_name = "Information";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 case 'L': case 'l':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 list = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 icon_name = "dbox-question";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 shell_name = "Prompt";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 case 'P': case 'p':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 text_input_slot = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 icon_name = "dbox-question";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 shell_name = "Prompt";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 case 'Q': case 'q':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 icon_name = "dbox-question";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 shell_name = "Question";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 break;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 total_buttons = name [1] - '0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 if (name [3] == 'T' || name [3] == 't')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 text_input_slot = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 radio_box = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 else if (name [3])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 right_buttons = name [4] - '0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 left_buttons = total_buttons - right_buttons;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 widget = make_dialog (name, parent, pop_up_p,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 shell_name, icon_name, text_input_slot, radio_box,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 list, left_buttons, right_buttons);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 return widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 #endif /* LWLIB_DIALOGS_ATHENA */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 xaw_generic_callback (Widget widget, XtPointer closure, XtPointer call_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 widget_instance *instance = (widget_instance *) closure;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 Widget instance_widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 LWLIB_ID id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 XtPointer user_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 #ifdef LWLIB_WIDGETS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 /* We want the selected status to change only when we decide it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 should change. Yuck but correct. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 if (XtIsSubclass (widget, toggleWidgetClass))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 Boolean check;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 Arg al [1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 XtSetArg (al [0], XtNstate, &check);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 XtGetValues (widget, al, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 XtSetArg (al [0], XtNstate, !check);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 XtSetValues (widget, al, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 #endif /* LWLIB_WIDGETS_ATHENA */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 lw_internal_update_other_instances (widget, closure, call_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 if (! instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 if (widget->core.being_destroyed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 instance_widget = instance->widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 if (!instance_widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 id = instance->info->id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 user_data = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 Arg al [1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 XtSetArg (al [0], XtNuserData, &user_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 XtGetValues (widget, al, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 /* 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
559 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
560 all instances of a button have the same call data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 ... Which is a totally bogus assumption --andyp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 widget_value *val = instance->info->val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 /* If the widget is a buffer/gutter widget then we already have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 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
567 tree. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 if (val->contents)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 char *name = XtName (widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 val = val->contents;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 while (val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 if (val->name && !strcmp (val->name, name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 val = val->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 if (! val) abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 user_data = val->call_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 if (instance->info->selection_cb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 instance->info->selection_cb (widget, id, user_data);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 #ifdef LWLIB_DIALOGS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 static XtActionProc
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 460
diff changeset
591 wm_delete_window (Widget shell, XtPointer UNUSED (closure),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 460
diff changeset
592 XtPointer UNUSED (call_data))
428
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);
3958
7bc12bb1a2cf [xemacs-hg @ 2007-05-17 15:06:04 by stephent]
stephent
parents: 3374
diff changeset
602 if (!kids || !*kids) abort ();
7bc12bb1a2cf [xemacs-hg @ 2007-05-17 15:06:04 by stephent]
stephent
parents: 3374
diff changeset
603
7bc12bb1a2cf [xemacs-hg @ 2007-05-17 15:06:04 by stephent]
stephent
parents: 3374
diff changeset
604 for (widget = *kids;
7bc12bb1a2cf [xemacs-hg @ 2007-05-17 15:06:04 by stephent]
stephent
parents: 3374
diff changeset
605 widget && ! XtIsSubclass (widget, dialogWidgetClass);
7bc12bb1a2cf [xemacs-hg @ 2007-05-17 15:06:04 by stephent]
stephent
parents: 3374
diff changeset
606 widget = *++kids)
7bc12bb1a2cf [xemacs-hg @ 2007-05-17 15:06:04 by stephent]
stephent
parents: 3374
diff changeset
607 ;
7bc12bb1a2cf [xemacs-hg @ 2007-05-17 15:06:04 by stephent]
stephent
parents: 3374
diff changeset
608 if (!widget) abort ();
7bc12bb1a2cf [xemacs-hg @ 2007-05-17 15:06:04 by stephent]
stephent
parents: 3374
diff changeset
609
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 id = lw_get_widget_id (widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 if (! id) abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 widget_info *info = lw_get_widget_info (id);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 if (! info) abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 if (info->selection_cb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 info->selection_cb (widget, id, (XtPointer) -1);
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 lw_destroy_all_widgets (id);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 return NULL;
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 #endif /* LWLIB_DIALOGS_ATHENA */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 /* Scrollbars */
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 #ifdef LWLIB_SCROLLBARS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 xaw_scrollbar_scroll (Widget widget, XtPointer closure, XtPointer call_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 widget_instance *instance = (widget_instance *) closure;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 LWLIB_ID id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 scroll_event event_data;
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 if (!instance || widget->core.being_destroyed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 return;
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 id = instance->info->id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 event_data.slider_value = (int) call_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 event_data.time = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 if ((int) call_data > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 /* event_data.action = SCROLLBAR_PAGE_DOWN;*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 event_data.action = SCROLLBAR_LINE_DOWN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 /* event_data.action = SCROLLBAR_PAGE_UP;*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 event_data.action = SCROLLBAR_LINE_UP;
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 if (instance->info->pre_activate_cb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 xaw_scrollbar_jump (Widget widget, XtPointer closure, XtPointer call_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 widget_instance *instance = (widget_instance *) closure;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 LWLIB_ID id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 scroll_event event_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 scrollbar_values *val =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 (scrollbar_values *) instance->info->val->scrollbar_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 float percent;
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 if (!instance || widget->core.being_destroyed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 id = instance->info->id;
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 percent = * (float *) call_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 event_data.slider_value =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 (int) (percent * (float) (val->maximum - val->minimum)) + val->minimum;
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 event_data.time = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 event_data.action = SCROLLBAR_DRAG;
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 if (instance->info->pre_activate_cb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 static Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 xaw_create_scrollbar (widget_instance *instance, int vertical)
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 Arg av[10];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 int ac = 0;
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 jumpCallbacks[2] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 { {xaw_scrollbar_jump, 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 static XtCallbackRec scrollCallbacks[2] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 { {xaw_scrollbar_scroll, NULL}, {NULL, NULL} };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 jumpCallbacks[0].closure = scrollCallbacks[0].closure = (XtPointer) instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 /* #### This is tacked onto the with and height and completely
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 screws our geometry management. We should probably make the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 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
698 few people use the Athena scrollbar now that it really isn't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 worth the effort, at least not at the moment. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 XtSetArg (av [ac], XtNborderWidth, 0); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 XtSetArg (av [ac], XtNorientation,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 vertical ? XtorientVertical : XtorientHorizontal); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 XtSetArg (av [ac], "jumpProc", jumpCallbacks); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 XtSetArg (av [ac], "scrollProc", scrollCallbacks); 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 return XtCreateWidget (instance->info->name, scrollbarWidgetClass,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 instance->parent, av, ac);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 static Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 xaw_create_vertical_scrollbar (widget_instance *instance)
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 return xaw_create_scrollbar (instance, 1);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 static Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 xaw_create_horizontal_scrollbar (widget_instance *instance)
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 return xaw_create_scrollbar (instance, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 #endif /* LWLIB_SCROLLBARS_ATHENA */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 #ifdef LWLIB_WIDGETS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 /* glyph widgets */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 static Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 xaw_create_button (widget_instance *instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 Arg al[20];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 int ac = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 Widget button = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 widget_value* val = instance->info->val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 XtSetArg (al [ac], XtNsensitive, val->enabled); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 XtSetArg (al [ac], XtNjustify, XtJustifyCenter); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 /* The highlight doesn't appear to be dynamically set which makes it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 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
738 get rid of it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 XtSetArg (al [ac], XtNhighlightThickness, (Dimension)0);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 /* add any args the user supplied for creation time */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 lw_add_value_args_to_args (val, 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 if (!val->call_data)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
745 button = XtCreateWidget (val->name, labelWidgetClass,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 instance->parent, al, ac);
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 if (val->type == TOGGLE_TYPE || val->type == RADIO_TYPE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 XtSetArg (al [ac], XtNstate, val->selected); ac++;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
753 button = XtCreateWidget
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 (val->name,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 val->type == TOGGLE_TYPE ? checkboxWidgetClass : radioWidgetClass,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 instance->parent, al, ac);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
760 button = XtCreateWidget (val->name, commandWidgetClass,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 instance->parent, al, ac);
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 XtRemoveAllCallbacks (button, XtNcallback);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 XtAddCallback (button, XtNcallback, xaw_generic_callback, (XtPointer)instance);
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
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
767 /* #### this maybe can be folded into the XtCreateWidget calls above */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 XtManageChild (button);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 return button;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 static Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 xaw_create_label_field (widget_instance *instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 return xaw_create_label (instance->parent, instance->info->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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 xaw_create_label (Widget parent, widget_value* val)
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 Arg al[20];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 int ac = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 Widget label = 0;
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 XtSetArg (al [ac], XtNsensitive, val->enabled); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 XtSetArg (al [ac], XtNjustify, XtJustifyCenter); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 /* add any args the user supplied for creation time */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 lw_add_value_args_to_args (val, al, &ac);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 label = XtCreateManagedWidget (val->name, labelWidgetClass,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 parent, al, ac);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
796 /* Do it again for arguments that have no effect until the widget is realized.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
797 #### Uh, but the widget isn't realized until later? Do we mean "created"? */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 ac = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 lw_add_value_args_to_args (val, al, &ac);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
800 if (ac > 20)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
801 abort (); /* #### need assert macro in lwlib */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 XtSetValues (label, al, ac);
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 return label;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
807 static int debug_gauge = 0;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
808
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
809 static void
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
810 lw_debug_print_xt_arglist (ArgList al, int ac)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
811 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
812 int i;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
813 for (i = 0; i < ac; i++)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
814 fprintf (stderr, "Widget has arg %s with value %lu.\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
815 al[i].name, (unsigned long) al[i].value);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
816 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
817
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
818 static void
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
819 lw_debug_print_class_resources (WidgetClass class_)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
820 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
821 Cardinal i;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
822 do {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
823 Cardinal m, n = class_->core_class.num_resources;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
824 XtResourceList rl;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
825 fprintf (stderr, "Class is %s (%p/%p) with %d resources.\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
826 class_->core_class.class_name, class_, &(class_->core_class), n);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
827 fprintf (stderr, " Class's resources are at %p. Converting...\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
828 class_->core_class.resources);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
829 /* resources may be compiled to an internal format */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
830 XtGetResourceList (class_, &rl, &m);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
831 for (i = 0; i < m; i++)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
832 fprintf (stderr,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
833 " Class has a %s resource of type %s initialized from %s.\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
834 rl[i].resource_class, rl[i].resource_type, rl[i].default_type);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
835 /* special cases for commonly problematic resources */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
836 for (i = 0; i < m; i++)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
837 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
838 if (!strcmp (rl[i].resource_class, "Font"))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
839 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
840 fprintf (stderr, " Class has a Font resource.\n");
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
841 fprintf (stderr, " Font resource is %s.\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
842 (char *) rl[i].default_addr);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
843 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
844 if (!strcmp (rl[i].resource_class, "FontSet"))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
845 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
846 fprintf (stderr, " Class has a FontSet resource.\n");
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
847 fprintf (stderr, " FontSet resource is %s.\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
848 (char *) rl[i].default_addr);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
849 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
850 if (!strcmp (rl[i].resource_class, "International"))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
851 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
852 fprintf (stderr, " Class has an International resource.\n");
3374
174eb4da74fb [xemacs-hg @ 2006-05-02 15:30:31 by james]
james
parents: 3094
diff changeset
853 fprintf (stderr, " International resource is %p.\n",
174eb4da74fb [xemacs-hg @ 2006-05-02 15:30:31 by james]
james
parents: 3094
diff changeset
854 rl[i].default_addr);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
855 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
856 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
857 class_ = class_->core_class.superclass;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
858 } while (class_ != NULL);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
859 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
860
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 static Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 xaw_create_progress (widget_instance *instance)
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 Arg al[20];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 int ac = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 Widget scale = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 widget_value* val = instance->info->val;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
868 #if 0 /* This looks too awful, although more correct. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 if (!val->call_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 XtSetArg (al [ac], XtNsensitive, False); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 XtSetArg (al [ac], XtNsensitive, val->enabled); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
877 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
878 XtSetArg (al [ac], XtNsensitive, True); ac++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
879 #endif
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 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 XtSetArg (al [ac], XtNorientation, XtorientHorizontal); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 XtSetArg (al [ac], XtNhighlightThickness, (Dimension)0);ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 XtSetArg (al [ac], XtNntics, (Cardinal)10);ac++;
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 /* add any args the user supplied for creation time */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 lw_add_value_args_to_args (val, al, &ac);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
889 if (debug_gauge > 1)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
890 lw_debug_print_class_resources (gaugeWidgetClass);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
891 if (debug_gauge > 0)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
892 lw_debug_print_xt_arglist (al, ac);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
893
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
894 scale = XtCreateWidget (val->name, gaugeWidgetClass,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
895 instance->parent, al, ac);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
896
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 /* add the callback */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 if (val->call_data)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
899 XtAddCallback (scale, XtNgetValue, xaw_generic_callback,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
900 (XtPointer) instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
902 /* #### this maybe can be folded into the XtCreateWidget call above */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 XtManageChild (scale);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 return scale;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907
460
223736d75acb Import from CVS: tag r21-2-45
cvs
parents: 450
diff changeset
908 #if defined(LWLIB_WIDGETS_ATHENA)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
909 #define TEXT_BUFFER_SIZE 128
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 static Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 xaw_create_text_field (widget_instance *instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 Arg al[20];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 int ac = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 Widget text = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 widget_value* val = instance->info->val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
918 XtSetArg (al [ac], XtNsensitive, val->enabled); ac++;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 XtSetArg (al [ac], XtNhighlightThickness, (Dimension)0); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 XtSetArg (al [ac], XtNtype, XawAsciiString); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 XtSetArg (al [ac], XtNeditType, XawtextEdit); ac++;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
923 XtSetArg (al [ac], XtNuseStringInPlace, False); ac++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
924 #if 0
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
925 XtSetArg (al [ac], XtNlength, TEXT_BUFFER_SIZE); ac++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
926 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
927 if (val->value)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
928 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
929 XtSetArg (al [ac], XtNstring, val->value); ac++;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
930 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 /* add any args the user supplied for creation time */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 lw_add_value_args_to_args (val, al, &ac);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2286
diff changeset
935 text = XtCreateWidget (val->name, asciiTextWidgetClass,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 instance->parent, al, ac);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
937
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
938 /* add the callback */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
939 if (val->call_data)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
940 XtAddCallback (text, XtNgetValue, xaw_generic_callback, (XtPointer)instance);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
941
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 XtManageChild (text);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 return text;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 #endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
947
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 #endif /* LWLIB_WIDGETS_ATHENA */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949
450
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
950 const widget_creation_entry
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 xaw_creation_table [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 #ifdef LWLIB_SCROLLBARS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 {"vertical-scrollbar", xaw_create_vertical_scrollbar },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 {"horizontal-scrollbar", xaw_create_horizontal_scrollbar },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 #ifdef LWLIB_WIDGETS_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 {"button", xaw_create_button },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 { "label", xaw_create_label_field },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 {"text-field", xaw_create_text_field },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 {"progress", xaw_create_progress },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 {NULL, NULL}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965