annotate lwlib/lwlib-Xlw.c @ 3016:f252275fb013

[xemacs-hg @ 2005-10-24 08:12:59 by ben] refactor mc-alloc dependencies next-error.el, occur.el: Fix some byte-compile warnings. alloc.c, buffer.c, buffer.h, casetab.c, casetab.h, charset.h, chartab.c, chartab.h, console-impl.h, console-msw-impl.h, console.c, data.c, database.c, device-impl.h, device-msw.c, device.c, dialog-msw.c, elhash.c, events.h, extents-impl.h, extents.c, faces.c, faces.h, file-coding.c, file-coding.h, frame-impl.h, frame.c, glyphs.c, glyphs.h, gui.c, gui.h, keymap.c, lisp.h, lrecord.h, lstream.c, lstream.h, mule-charset.c, objects-impl.h, objects.c, opaque.c, opaque.h, print.c, process.c, procimpl.h, rangetab.c, rangetab.h, scrollbar-gtk.c, scrollbar-msw.c, scrollbar-x.c, scrollbar.c, scrollbar.h, specifier.c, specifier.h, symbols.c, symeval.h, toolbar.c, toolbar.h, tooltalk.c, ui-gtk.c, ui-gtk.h, unicode.c, window-impl.h, window.c: Eliminate the majority of #ifdef MC_ALLOC occurrences through macros LCRECORD_HEADER, ALLOC_LCRECORD_TYPE, MALLOCED_STORAGE_SIZE, etc. (defined in lrecord.h).
author ben
date Mon, 24 Oct 2005 08:12:59 +0000
parents f7e2b977e15c
children ad2f4ae9895b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* The lwlib interface to "xlwmenu" menus.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1992, 1994 Lucid, 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 2, 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 <stdlib.h> /* for abort () */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 #include <stdio.h> /* for abort () */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 #include <limits.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 #include "lwlib-Xlw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 #include "lwlib-utils.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #include <X11/StringDefs.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 #include <X11/IntrinsicP.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #include <X11/ObjectP.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #include <X11/CompositeP.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include <X11/Shell.h>
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
33 #ifdef HAVE_X_WIDGETS
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include "../src/EmacsManager.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #ifdef LWLIB_MENUBARS_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #include "xlwmenu.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #ifdef LWLIB_SCROLLBARS_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #include "xlwscrollbar.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 #ifdef LWLIB_TABS_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 #include "lwlib-Xm.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 #ifdef NEED_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 #include "lwlib-Xaw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 #include "../src/xmu.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 #include "xlwtabs.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 #ifdef LWLIB_MENUBARS_LUCID
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 /* Menu callbacks */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 pre_hook (Widget w, XtPointer client_data, XtPointer call_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 widget_instance* instance = (widget_instance*)client_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 widget_value* val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 if (w->core.being_destroyed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 val = lw_get_widget_value_for_widget (instance, w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 /* #### - this code used to (for some random back_asswards reason) pass
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 the expression below in the call_data slot. For incremental menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 construction, this needs to go. I can't even figure out why it was done
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 this way in the first place...it's just a historical weirdism. --Stig */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 call_data = (val ? val->call_data : NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 if (val && val->call_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 abort(); /* #### - the call_data for the top_level
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 "menubar" widget_value used to be passed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 back to the pre_hook. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 if (instance->info->pre_activate_cb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 instance->info->pre_activate_cb (w, instance->info->id, call_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 pick_hook (Widget w, XtPointer client_data, XtPointer call_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 widget_instance* instance = (widget_instance*)client_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 widget_value* contents_val = (widget_value*)call_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 widget_value* widget_val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 XtPointer widget_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 LWLIB_ID id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 lw_callback post_activate_cb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 if (w->core.being_destroyed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 /* Grab these values before running any functions, in case running
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 the selection_cb causes the widget to be destroyed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 id = instance->info->id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 post_activate_cb = instance->info->post_activate_cb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 widget_val = lw_get_widget_value_for_widget (instance, w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 widget_arg = widget_val ? widget_val->call_data : NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 if (instance->info->selection_cb &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 contents_val &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 contents_val->enabled &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 !contents_val->contents)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 instance->info->selection_cb (w, id, contents_val->call_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 if (post_activate_cb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 post_activate_cb (w, id, widget_arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 /* creation functions */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 static Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 xlw_create_menubar (widget_instance* instance)
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 Arg al [1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 Widget widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 XtSetArg (al [0], XtNmenu, instance->info->val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 widget = XtCreateWidget (instance->info->name, xlwMenuWidgetClass,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 instance->parent, al, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 XtAddCallback (widget, XtNopen, pre_hook, (XtPointer)instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 return widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 static Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 xlw_create_popup_menu (widget_instance* instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 Arg al [2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 Widget popup_shell, widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 popup_shell = XtCreatePopupShell (instance->info->name,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 overrideShellWidgetClass,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 instance->parent, NULL, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 XtSetArg (al [0], XtNmenu, instance->info->val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 XtSetArg (al [1], XtNhorizontal, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 widget = XtCreateManagedWidget ("popup", xlwMenuWidgetClass,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 popup_shell, al, 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 return popup_shell;
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_MENUBARS_LUCID */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 #ifdef LWLIB_SCROLLBARS_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 xlw_scrollbar_callback (Widget widget, XtPointer closure, XtPointer call_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 widget_instance *instance = (widget_instance *) closure;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 LWLIB_ID id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 XlwScrollBarCallbackStruct *data =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 (XlwScrollBarCallbackStruct *) call_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 scroll_event event_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 scrollbar_values *val =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 (scrollbar_values *) instance->info->val->scrollbar_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 double percent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 if (!instance || widget->core.being_destroyed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 id = instance->info->id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 percent = (double) (data->value - 1) / (double) (INT_MAX - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 event_data.slider_value =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 (int) (percent * (double) (val->maximum - val->minimum)) + val->minimum;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 if (event_data.slider_value > val->maximum - val->slider_size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 event_data.slider_value = val->maximum - val->slider_size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 else if (event_data.slider_value < val->minimum)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 event_data.slider_value = val->minimum;
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 if (data->event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 switch (data->event->type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 case KeyPress:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 case KeyRelease:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 event_data.time = data->event->xkey.time;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 case ButtonPress:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 case ButtonRelease:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 event_data.time = data->event->xbutton.time;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 case MotionNotify:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 event_data.time = data->event->xmotion.time;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 case EnterNotify:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 case LeaveNotify:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 event_data.time = data->event->xcrossing.time;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 event_data.time = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 event_data.time = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 switch (data->reason)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 case XmCR_DECREMENT: event_data.action = SCROLLBAR_LINE_UP; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 case XmCR_INCREMENT: event_data.action = SCROLLBAR_LINE_DOWN; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 case XmCR_PAGE_DECREMENT: event_data.action = SCROLLBAR_PAGE_UP; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 case XmCR_PAGE_INCREMENT: event_data.action = SCROLLBAR_PAGE_DOWN; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 case XmCR_TO_TOP: event_data.action = SCROLLBAR_TOP; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 case XmCR_TO_BOTTOM: event_data.action = SCROLLBAR_BOTTOM; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 case XmCR_DRAG: event_data.action = SCROLLBAR_DRAG; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 case XmCR_VALUE_CHANGED: event_data.action = SCROLLBAR_CHANGE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 default: event_data.action = SCROLLBAR_CHANGE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 if (instance->info->pre_activate_cb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 #define add_scrollbar_callback(resource) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 XtAddCallback (scrollbar, resource, xlw_scrollbar_callback, (XtPointer) instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 /* #### Does not yet support horizontal scrollbars. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 static Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 xlw_create_scrollbar (widget_instance *instance, int vertical)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 Arg al[20];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 int ac = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 static XtCallbackRec callbacks[2] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 { {xlw_scrollbar_callback, NULL}, {NULL, NULL} };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 callbacks[0].closure = (XtPointer) instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 XtSetArg (al[ac], XmNminimum, 1); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 XtSetArg (al[ac], XmNmaximum, INT_MAX); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 XtSetArg (al[ac], XmNincrement, 1); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 XtSetArg (al[ac], XmNpageIncrement, 1); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 XtSetArg (al[ac], XmNorientation, (vertical ? XmVERTICAL : XmHORIZONTAL)); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 XtSetArg (al[ac], XmNdecrementCallback, callbacks); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 XtSetArg (al[ac], XmNdragCallback, callbacks); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 XtSetArg (al[ac], XmNincrementCallback, callbacks); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 XtSetArg (al[ac], XmNpageDecrementCallback, callbacks); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 XtSetArg (al[ac], XmNpageIncrementCallback, callbacks); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 XtSetArg (al[ac], XmNtoBottomCallback, callbacks); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 XtSetArg (al[ac], XmNtoTopCallback, callbacks); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 XtSetArg (al[ac], XmNvalueChangedCallback, callbacks); ac++;
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 return XtCreateWidget (instance->info->name, xlwScrollBarWidgetClass,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 instance->parent, al, ac);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 static Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 xlw_create_vertical_scrollbar (widget_instance *instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 return xlw_create_scrollbar (instance, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 static Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 xlw_create_horizontal_scrollbar (widget_instance *instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 return xlw_create_scrollbar (instance, 0);
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 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1201
diff changeset
269 xlw_update_scrollbar (widget_instance *UNUSED (instance), Widget widget,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 widget_value *val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 if (val->scrollbar_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 scrollbar_values *data = val->scrollbar_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 int widget_sliderSize, widget_val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 int new_sliderSize, new_value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 double percent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 Arg al [4];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 /* First size and position the scrollbar widget. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 XtSetArg (al [0], XtNx, data->scrollbar_x);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 XtSetArg (al [1], XtNy, data->scrollbar_y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 XtSetArg (al [2], XtNwidth, data->scrollbar_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 XtSetArg (al [3], XtNheight, data->scrollbar_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 XtSetValues (widget, al, 4);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 /* Now size the scrollbar's slider. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 XtSetArg (al [0], XmNsliderSize, &widget_sliderSize);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 XtSetArg (al [1], XmNvalue, &widget_val);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 XtGetValues (widget, al, 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 percent = (double) data->slider_size /
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 (double) (data->maximum - data->minimum);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 percent = (percent > 1.0 ? 1.0 : percent);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 new_sliderSize = (int) ((double) (INT_MAX - 1) * percent);
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 percent = (double) (data->slider_position - data->minimum) /
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 (double) (data->maximum - data->minimum);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 percent = (percent > 1.0 ? 1.0 : percent);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 new_value = (int) ((double) (INT_MAX - 1) * percent);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 if (new_sliderSize > INT_MAX - 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 new_sliderSize = INT_MAX - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 else if (new_sliderSize < 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 new_sliderSize = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 if (new_value > (INT_MAX - new_sliderSize))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 new_value = INT_MAX - new_sliderSize;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 else if (new_value < 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 new_value = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 if (new_sliderSize != widget_sliderSize || new_value != widget_val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 XlwScrollBarSetValues (widget, new_value, new_sliderSize, 1, 1, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 #endif /* LWLIB_SCROLLBARS_LUCID */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 #ifdef LWLIB_TABS_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 /* tab control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321
2641
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
322 [[ lwlib is such an incredible hairy crock. I just cannot believe
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 it! There are random dependencies between functions, there is a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 total lack of genericity, even though it initially appears to be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 generic. It should all be junked and begun again. Building tabs are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 an example - in theory we should be able to reuse a lot of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 general stuff because we want to put labels of whatever toolkit we
2641
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
328 are using in the tab. Instead we have to hack it by hand. ]]
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
329 While lwlib is a hairy crock, whoever wrote that seems to misunderstand
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
330 Falk's tab control widget. The tab control widget has *two* kinds of
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
331 children: *widgets*, which all occupy a *single* pane below the row of
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
332 tabs---this is where the labels created in build_tabs_in_widget go, and
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
333 *gadgets*, the tabs themselves, which do *not* draw themselves, but
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
334 rather are drawn by the control. In fact, in XEmacs the true widget
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
335 children are *never* visible! So this case is not a problem in the
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
336 design of lwlib, but rather of Falk's widget. -- sjt */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 xlw_tab_control_callback (Widget w, XtPointer client_data, XtPointer call_data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 /* call data is the topmost widget */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 widget_instance* instance = (widget_instance*)client_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 Widget top = (Widget)call_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 char *name = XtName (top);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 widget_value* widget_val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 XtPointer widget_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 LWLIB_ID id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 lw_callback post_activate_cb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 if (w->core.being_destroyed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 /* Grab these values before running any functions, in case running
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 the selection_cb causes the widget to be destroyed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 id = instance->info->id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 post_activate_cb = instance->info->post_activate_cb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 /* search for the widget_val for the selected tab */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 for (widget_val = instance->info->val->contents; widget_val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 widget_val = widget_val->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 if (!strcmp (widget_val->name, name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 widget_arg = widget_val ? widget_val->call_data : NULL;
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 (instance->info->selection_cb &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 widget_val &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 widget_val->enabled &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 !widget_val->contents)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 instance->info->selection_cb (w, id, widget_arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 if (post_activate_cb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 post_activate_cb (w, id, widget_arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 static Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 xlw_create_tab_control (widget_instance *instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 Arg al[20];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 int ac = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 Widget tab = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 widget_value* val = instance->info->val;
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 XtSetArg (al [ac], XtNsensitive, val->enabled); ac++;
2641
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
386 XtSetArg (al [ac], XtNmappedWhenManaged, False); ac++;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 XtSetArg (al [ac], XtNorientation, XtorientHorizontal); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 /* add any args the user supplied for creation time */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 lw_add_value_args_to_args (val, al, &ac);
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 tab = XtCreateManagedWidget (val->name, tabsWidgetClass,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 instance->parent, al, ac);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 XtRemoveAllCallbacks (tab, XtNcallback);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 XtAddCallback (tab, XtNcallback, xlw_tab_control_callback, (XtPointer)instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 XtManageChild (tab);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 return tab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1201
diff changeset
402 static void build_tabs_in_widget (widget_instance* UNUSED (instance),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1201
diff changeset
403 Widget widget, widget_value* val)
428
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 widget_value* cur = val;
2641
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
406 Arg al[1];
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
407
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
408 /* Children are always invisible, don't permit resizing. */
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
409 XtSetArg (al[0], XtNresizable, False);
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
410
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 for (cur = val; cur; cur = cur->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 if (cur->value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 {
2641
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
415 Widget w;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 #ifdef LWLIB_WIDGETS_MOTIF
2641
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
417 w = xm_create_label (widget, cur);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 #else
2641
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
419 w = xaw_create_label (widget, cur);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 #endif
2641
f7e2b977e15c [xemacs-hg @ 2005-03-09 05:58:54 by stephent]
stephent
parents: 2286
diff changeset
421 XtSetValues (w, al, 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 cur->change = NO_CHANGE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 xlw_update_tab_control (widget_instance* instance, Widget widget, widget_value* val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 Widget* children;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 unsigned int num_children;
639
4b7d425dd3c2 [xemacs-hg @ 2001-07-28 05:08:58 by andyp]
andyp
parents: 450
diff changeset
432 Dimension i;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 widget_value *cur = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 XtRemoveAllCallbacks (widget, XtNcallback);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 XtAddCallback (widget, XtNcallback, xlw_tab_control_callback, (XtPointer)instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 if (val->change == STRUCTURAL_CHANGE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 (val->contents && val->contents->change == STRUCTURAL_CHANGE))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 destroy_all_children (widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 build_tabs_in_widget (instance, widget, val->contents);
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 children = XtCompositeChildren (widget, &num_children);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 if (children)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 639
diff changeset
449 for (i = 0, cur = val->contents; i < (int) num_children; i++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 if (!cur)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 if (children [i]->core.being_destroyed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 || strcmp (XtName (children [i]), cur->name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 #ifdef NEED_MOTIF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 if (lw_motif_widget_p (children [i]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 xm_update_one_widget (instance, children [i], cur, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 #ifdef NEED_ATHENA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 if (lw_xaw_widget_p (children [i]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 xaw_update_one_widget (instance, children [i], cur, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 cur = cur->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 XtFree ((char *) children);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 if (cur)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 abort ();
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 #endif /* LWLIB_TABS_LUCID */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
473 #ifdef HAVE_X_WIDGETS
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 static Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 xlw_create_clip_window (widget_instance *instance)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 Arg al[20];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 int ac = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 Widget clip = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 widget_value* val = instance->info->val;
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 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 XtSetArg (al [ac], XtNsensitive, TRUE); ac++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 /* add any args the user supplied for creation time */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 lw_add_value_args_to_args (val, al, &ac);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 /* Create a clip window to contain the subwidget. Incredibly the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 XEmacs manager seems to be the most appropriate widget for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 this. Nothing else is simple enough and yet does what is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 required. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 clip = XtCreateManagedWidget (val->name,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 emacsManagerWidgetClass,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 instance->parent, al, ac);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 return clip;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498
450
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 446
diff changeset
499 const widget_creation_entry
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 xlw_creation_table [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 #ifdef LWLIB_MENUBARS_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 {"menubar", xlw_create_menubar},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 {"popup", xlw_create_popup_menu},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 #ifdef LWLIB_SCROLLBARS_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 {"vertical-scrollbar", xlw_create_vertical_scrollbar},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 {"horizontal-scrollbar", xlw_create_horizontal_scrollbar},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 #ifdef LWLIB_TABS_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 {"tab-control", xlw_create_tab_control},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 #endif
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
513 #ifdef HAVE_X_WIDGETS
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 {"clip-window", xlw_create_clip_window},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 {NULL, NULL}
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 Boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 lw_lucid_widget_p (Widget widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 WidgetClass the_class = XtClass (widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 #ifdef LWLIB_MENUBARS_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 if (the_class == xlwMenuWidgetClass)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 return True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 #ifdef LWLIB_SCROLLBARS_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 if (the_class == xlwScrollBarWidgetClass)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 return True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 #ifdef LWLIB_TABS_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 if (the_class == tabsWidgetClass)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 return True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 #ifdef LWLIB_MENUBARS_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 if (the_class == overrideShellWidgetClass)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 return
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 XtClass (((CompositeWidget)widget)->composite.children [0])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 == xlwMenuWidgetClass;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 #endif
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
541 #ifdef HAVE_X_WIDGETS
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 428
diff changeset
542 if (the_class == emacsManagerWidgetClass)
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 428
diff changeset
543 return True;
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 428
diff changeset
544 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 return False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 xlw_update_one_widget (widget_instance* instance, Widget widget,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1201
diff changeset
550 widget_value* val, Boolean UNUSED (deep_p))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 {
1201
c2569faae8ed [xemacs-hg @ 2003-01-12 10:45:53 by michaels]
michaels
parents: 771
diff changeset
552 WidgetClass class_ = XtClass (widget);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 if (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 #ifdef LWLIB_MENUBARS_LUCID
1201
c2569faae8ed [xemacs-hg @ 2003-01-12 10:45:53 by michaels]
michaels
parents: 771
diff changeset
557 else if (class_ == xlwMenuWidgetClass)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 XlwMenuWidget mw;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 Arg al [1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 if (XtIsShell (widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 mw = (XlwMenuWidget)((CompositeWidget)widget)->composite.children [0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 mw = (XlwMenuWidget)widget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 XtSetArg (al [0], XtNmenu, val);
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
566 XtSetValues (widget, al, 1); /* #### mw unused! */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 #ifdef LWLIB_SCROLLBARS_LUCID
1201
c2569faae8ed [xemacs-hg @ 2003-01-12 10:45:53 by michaels]
michaels
parents: 771
diff changeset
570 else if (class_ == xlwScrollBarWidgetClass)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 xlw_update_scrollbar (instance, widget, 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 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 #ifdef LWLIB_TABS_LUCID
1201
c2569faae8ed [xemacs-hg @ 2003-01-12 10:45:53 by michaels]
michaels
parents: 771
diff changeset
576 else if (class_ == tabsWidgetClass)
428
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 xlw_update_tab_control (instance, widget, val);
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 #endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
581 /* Lastly update our global arg values. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
582 if (val->args && val->args->nargs)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
583 XtSetValues (widget, val->args->args, val->args->nargs);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1201
diff changeset
587 xlw_update_one_value (widget_instance* UNUSED (instance),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1201
diff changeset
588 Widget UNUSED (widget), widget_value* UNUSED (val))
428
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1201
diff changeset
593 xlw_pop_instance (widget_instance* UNUSED (instance), Boolean UNUSED (up))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 #ifdef LWLIB_MENUBARS_LUCID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 xlw_popup_menu (Widget widget, XEvent *event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 XlwMenuWidget mw;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 if (!XtIsShell (widget))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 if (event->type == ButtonPress || event->type == ButtonRelease)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 mw = (XlwMenuWidget)((CompositeWidget)widget)->composite.children [0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 xlw_pop_up_menu (mw, (XButtonPressedEvent *)event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 abort ();
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 #endif /* LWLIB_MENUBARS_LUCID */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 /* Destruction of instances */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 xlw_destroy_instance (widget_instance* instance)
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 if (instance->widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 XtDestroyWidget (instance->widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 }