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