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