Mercurial > emacs
annotate lwlib/lwlib-utils.c @ 19286:64f0f84b04f3
(CPPFLAGS, LDFLAGS): Edit to empty.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 11 Aug 1997 00:18:52 +0000 |
parents | ee40177f6c68 |
children | f4e5f2c2900e |
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" | |
36 | |
37 /* Redisplay the contents of the widget, without first clearing it. */ | |
38 void | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
39 XtNoClearRefreshWidget (widget) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
40 Widget widget; |
5626 | 41 { |
42 XEvent event; | |
43 | |
44 event.type = Expose; | |
45 event.xexpose.serial = 0; | |
46 event.xexpose.send_event = 0; | |
47 event.xexpose.display = XtDisplay (widget); | |
48 event.xexpose.window = XtWindow (widget); | |
49 event.xexpose.x = 0; | |
50 event.xexpose.y = 0; | |
51 event.xexpose.width = widget->core.width; | |
52 event.xexpose.height = widget->core.height; | |
53 event.xexpose.count = 0; | |
54 | |
55 (*widget->core.widget_class->core_class.expose) | |
56 (widget, &event, (Region)NULL); | |
57 } | |
58 | |
59 | |
60 /* | |
61 * Apply a function to all the subwidgets of a given widget recursively. | |
62 */ | |
63 void | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
64 XtApplyToWidgets (w, proc, arg) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
65 Widget w; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
66 XtApplyToWidgetsProc proc; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
67 XtPointer arg; |
5626 | 68 { |
69 if (XtIsComposite (w)) | |
70 { | |
71 CompositeWidget cw = (CompositeWidget) w; | |
72 /* We have to copy the children list before mapping over it, because | |
73 the procedure might add/delete elements, which would lose badly. | |
74 */ | |
75 int nkids = cw->composite.num_children; | |
76 Widget *kids = (Widget *) malloc (sizeof (Widget) * nkids); | |
77 int i; | |
7514 | 78 lwlib_bcopy (cw->composite.children, kids, sizeof (Widget) * nkids); |
5626 | 79 for (i = 0; i < nkids; i++) |
80 /* This prevent us from using gadgets, why is it here? */ | |
81 /* if (XtIsWidget (kids [i])) */ | |
82 { | |
83 /* do the kiddies first in case we're destroying */ | |
84 XtApplyToWidgets (kids [i], proc, arg); | |
85 proc (kids [i], arg); | |
86 } | |
87 free (kids); | |
88 } | |
89 } | |
90 | |
91 | |
92 /* | |
93 * Apply a function to all the subwidgets of a given widget recursively. | |
94 * Stop as soon as the function returns non NULL and returns this as a value. | |
95 */ | |
96 void * | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
97 XtApplyUntilToWidgets (w, proc, arg) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
98 Widget w; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
99 XtApplyUntilToWidgetsProc proc; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
100 XtPointer arg; |
5626 | 101 { |
102 void* result; | |
103 if (XtIsComposite (w)) | |
104 { | |
105 CompositeWidget cw = (CompositeWidget)w; | |
106 int i; | |
107 for (i = 0; i < cw->composite.num_children; i++) | |
108 if (XtIsWidget (cw->composite.children [i])){ | |
109 result = proc (cw->composite.children [i], arg); | |
110 if (result) | |
111 return result; | |
112 result = XtApplyUntilToWidgets (cw->composite.children [i], proc, | |
113 arg); | |
114 if (result) | |
115 return result; | |
116 } | |
117 } | |
118 return NULL; | |
119 } | |
120 | |
121 | |
122 /* | |
123 * Returns a copy of the list of all children of a composite widget | |
124 */ | |
125 Widget * | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
126 XtCompositeChildren (widget, number) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
127 Widget widget; |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
128 unsigned int* number; |
5626 | 129 { |
130 CompositeWidget cw = (CompositeWidget)widget; | |
131 Widget* result; | |
132 int n; | |
133 int i; | |
134 | |
135 if (!XtIsComposite (widget)) | |
136 { | |
137 *number = 0; | |
138 return NULL; | |
139 } | |
140 n = cw->composite.num_children; | |
141 result = (Widget*)XtMalloc (n * sizeof (Widget)); | |
142 *number = n; | |
143 for (i = 0; i < n; i++) | |
144 result [i] = cw->composite.children [i]; | |
145 return result; | |
146 } | |
147 | |
148 Boolean | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
149 XtWidgetBeingDestroyedP (widget) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
150 Widget widget; |
5626 | 151 { |
152 return widget->core.being_destroyed; | |
153 } | |
154 | |
155 void | |
5708
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
156 XtSafelyDestroyWidget (widget) |
4870efc489ea
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
5626
diff
changeset
|
157 Widget widget; |
5626 | 158 { |
159 #if 0 | |
160 | |
161 /* this requires IntrinsicI.h (actually, InitialI.h) */ | |
162 | |
163 XtAppContext app = XtWidgetToApplicationContext(widget); | |
164 | |
165 if (app->dispatch_level == 0) | |
166 { | |
167 app->dispatch_level = 1; | |
168 XtDestroyWidget (widget); | |
169 /* generates an event so that the event loop will be called */ | |
170 XChangeProperty (XtDisplay (widget), XtWindow (widget), | |
171 XA_STRING, XA_STRING, 32, PropModeAppend, NULL, 0); | |
172 app->dispatch_level = 0; | |
173 } | |
174 else | |
175 XtDestroyWidget (widget); | |
176 | |
177 #else | |
178 abort (); | |
179 #endif | |
180 } |