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