Mercurial > emacs
annotate lwlib/lwlib-utils.c @ 40333:8c77ca9786a9
(Horizontal Scrolling): Add an index entry for automatic-hscrolling.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Fri, 26 Oct 2001 12:50:03 +0000 |
parents | 3f00bdb24c1f |
children | 7fb1caba0f51 |
rev | line source |
---|---|
5626 | 1 /* Defines some widget utility functions. |
2 Copyright (C) 1992 Lucid, Inc. | |
3 | |
4 This file is part of the Lucid Widget Library. | |
5 | |
6 The Lucid Widget Library is free software; you can redistribute it and/or | |
7 modify it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 1, or (at your option) | |
9 any later version. | |
10 | |
11 The Lucid Widget Library is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13758
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13758
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
5626 | 20 |
11358
cba458f0dc21
If HAVE_CONFIG_H, include config.h.
Richard M. Stallman <rms@gnu.org>
parents:
7514
diff
changeset
|
21 #ifdef HAVE_CONFIG_H |
cba458f0dc21
If HAVE_CONFIG_H, include config.h.
Richard M. Stallman <rms@gnu.org>
parents:
7514
diff
changeset
|
22 #include <config.h> |
cba458f0dc21
If HAVE_CONFIG_H, include config.h.
Richard M. Stallman <rms@gnu.org>
parents:
7514
diff
changeset
|
23 #endif |
cba458f0dc21
If HAVE_CONFIG_H, include config.h.
Richard M. Stallman <rms@gnu.org>
parents:
7514
diff
changeset
|
24 |
13758
5a7e9e98add7
Add #undef for index and rindex.
Karl Heuer <kwzh@gnu.org>
parents:
11358
diff
changeset
|
25 /* Definitions of these in config.h can cause |
5a7e9e98add7
Add #undef for index and rindex.
Karl Heuer <kwzh@gnu.org>
parents:
11358
diff
changeset
|
26 declaration conflicts later on between declarations for index |
5a7e9e98add7
Add #undef for index and rindex.
Karl Heuer <kwzh@gnu.org>
parents:
11358
diff
changeset
|
27 and declarations for strchr. This file doesn't use |
5a7e9e98add7
Add #undef for index and rindex.
Karl Heuer <kwzh@gnu.org>
parents:
11358
diff
changeset
|
28 index and rindex, so cancel them. */ |
5a7e9e98add7
Add #undef for index and rindex.
Karl Heuer <kwzh@gnu.org>
parents:
11358
diff
changeset
|
29 #undef index |
5a7e9e98add7
Add #undef for index and rindex.
Karl Heuer <kwzh@gnu.org>
parents:
11358
diff
changeset
|
30 #undef rindex |
5a7e9e98add7
Add #undef for index and rindex.
Karl Heuer <kwzh@gnu.org>
parents:
11358
diff
changeset
|
31 |
5626 | 32 #include <X11/Xatom.h> |
33 #include <X11/IntrinsicP.h> | |
34 #include <X11/ObjectP.h> | |
35 #include "lwlib-utils.h" | |
29891 | 36 #include "lwlib.h" |
5626 | 37 |
38 /* Redisplay the contents of the widget, without first clearing it. */ | |
39 void | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
40 XtNoClearRefreshWidget (widget) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
41 Widget widget; |
5626 | 42 { |
43 XEvent event; | |
44 | |
45 event.type = Expose; | |
46 event.xexpose.serial = 0; | |
47 event.xexpose.send_event = 0; | |
48 event.xexpose.display = XtDisplay (widget); | |
49 event.xexpose.window = XtWindow (widget); | |
50 event.xexpose.x = 0; | |
51 event.xexpose.y = 0; | |
52 event.xexpose.width = widget->core.width; | |
53 event.xexpose.height = widget->core.height; | |
54 event.xexpose.count = 0; | |
55 | |
56 (*widget->core.widget_class->core_class.expose) | |
57 (widget, &event, (Region)NULL); | |
58 } | |
59 | |
60 | |
61 /* | |
62 * Apply a function to all the subwidgets of a given widget recursively. | |
63 */ | |
64 void | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
65 XtApplyToWidgets (w, proc, arg) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
66 Widget w; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
67 XtApplyToWidgetsProc proc; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
68 XtPointer arg; |
5626 | 69 { |
70 if (XtIsComposite (w)) | |
71 { | |
72 CompositeWidget cw = (CompositeWidget) w; | |
73 /* We have to copy the children list before mapping over it, because | |
74 the procedure might add/delete elements, which would lose badly. | |
75 */ | |
76 int nkids = cw->composite.num_children; | |
77 Widget *kids = (Widget *) malloc (sizeof (Widget) * nkids); | |
78 int i; | |
30279
3f00bdb24c1f
(XtApplyToWidgets): Cast args of lwlib_bcopy.
Dave Love <fx@gnu.org>
parents:
29891
diff
changeset
|
79 lwlib_bcopy ((char *) cw->composite.children, (char *) kids, |
3f00bdb24c1f
(XtApplyToWidgets): Cast args of lwlib_bcopy.
Dave Love <fx@gnu.org>
parents:
29891
diff
changeset
|
80 sizeof (Widget) * nkids); |
5626 | 81 for (i = 0; i < nkids; i++) |
82 /* This prevent us from using gadgets, why is it here? */ | |
83 /* if (XtIsWidget (kids [i])) */ | |
84 { | |
85 /* do the kiddies first in case we're destroying */ | |
86 XtApplyToWidgets (kids [i], proc, arg); | |
87 proc (kids [i], arg); | |
88 } | |
89 free (kids); | |
90 } | |
91 } | |
92 | |
93 | |
94 /* | |
95 * Apply a function to all the subwidgets of a given widget recursively. | |
96 * Stop as soon as the function returns non NULL and returns this as a value. | |
97 */ | |
98 void * | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
99 XtApplyUntilToWidgets (w, proc, arg) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
100 Widget w; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
101 XtApplyUntilToWidgetsProc proc; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
102 XtPointer arg; |
5626 | 103 { |
104 void* result; | |
105 if (XtIsComposite (w)) | |
106 { | |
107 CompositeWidget cw = (CompositeWidget)w; | |
108 int i; | |
109 for (i = 0; i < cw->composite.num_children; i++) | |
110 if (XtIsWidget (cw->composite.children [i])){ | |
111 result = proc (cw->composite.children [i], arg); | |
112 if (result) | |
113 return result; | |
114 result = XtApplyUntilToWidgets (cw->composite.children [i], proc, | |
115 arg); | |
116 if (result) | |
117 return result; | |
118 } | |
119 } | |
120 return NULL; | |
121 } | |
122 | |
123 | |
124 /* | |
125 * Returns a copy of the list of all children of a composite widget | |
126 */ | |
127 Widget * | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
128 XtCompositeChildren (widget, number) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
129 Widget widget; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
130 unsigned int* number; |
5626 | 131 { |
132 CompositeWidget cw = (CompositeWidget)widget; | |
133 Widget* result; | |
134 int n; | |
135 int i; | |
136 | |
137 if (!XtIsComposite (widget)) | |
138 { | |
139 *number = 0; | |
140 return NULL; | |
141 } | |
142 n = cw->composite.num_children; | |
143 result = (Widget*)XtMalloc (n * sizeof (Widget)); | |
144 *number = n; | |
145 for (i = 0; i < n; i++) | |
146 result [i] = cw->composite.children [i]; | |
147 return result; | |
148 } | |
149 | |
150 Boolean | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
151 XtWidgetBeingDestroyedP (widget) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
152 Widget widget; |
5626 | 153 { |
154 return widget->core.being_destroyed; | |
155 } | |
156 | |
157 void | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
158 XtSafelyDestroyWidget (widget) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
159 Widget widget; |
5626 | 160 { |
161 #if 0 | |
162 | |
163 /* this requires IntrinsicI.h (actually, InitialI.h) */ | |
164 | |
165 XtAppContext app = XtWidgetToApplicationContext(widget); | |
166 | |
167 if (app->dispatch_level == 0) | |
168 { | |
169 app->dispatch_level = 1; | |
170 XtDestroyWidget (widget); | |
171 /* generates an event so that the event loop will be called */ | |
172 XChangeProperty (XtDisplay (widget), XtWindow (widget), | |
173 XA_STRING, XA_STRING, 32, PropModeAppend, NULL, 0); | |
174 app->dispatch_level = 0; | |
175 } | |
176 else | |
177 XtDestroyWidget (widget); | |
178 | |
179 #else | |
180 abort (); | |
181 #endif | |
182 } |