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