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