Mercurial > emacs
annotate lwlib/lwlib-utils.c @ 112453:06719a229a46 default tip
* calc/calc.el (calc-default-power-reference-level)
(calc-default-field-reference-level): New variables.
* calc/calc-units.el (math-standard-units): Add dB and Np.
(math-logunits): New variable.
(math-extract-logunits, math-logcombine, calcFunc-luplus)
(calcFunc-luminus, calc-luplus, calc-luminus, math-logunit-level)
(calcFunc-fieldlevel, calcFunc-powerlevel, calc-level): New
functions.
(math-find-base-units-rec): Add entry for ln(10).
* calc/calc-help.el (calc-u-prefix-help): Add logarithmic help.
(calc-ul-prefix-help): New function.
* calc/calc-ext.el (calc-init-extensions): Autoload new units
functions. Add keybindings for new units functions.
| author | Jay Belanger <jay.p.belanger@gmail.com> |
|---|---|
| date | Sun, 23 Jan 2011 23:08:04 -0600 |
| parents | ef719132ddfa |
| children |
| rev | line source |
|---|---|
| 5626 | 1 /* Defines some widget utility functions. |
| 76177 | 2 Copyright (C) 1992 Lucid, Inc. |
| 106815 | 3 Copyright (C) 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, |
|
112218
376148b31b5e
Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
4 2010, 2011 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 |
|
105669
68dd71358159
* alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100957
diff
changeset
|
34 #include <setjmp.h> |
| 41767 | 35 #include "../src/lisp.h" |
| 36 | |
| 5626 | 37 #include <X11/Xatom.h> |
| 38 #include <X11/IntrinsicP.h> | |
| 39 #include <X11/ObjectP.h> | |
| 40 #include "lwlib-utils.h" | |
| 29891 | 41 #include "lwlib.h" |
| 5626 | 42 |
| 43 /* Redisplay the contents of the widget, without first clearing it. */ | |
| 44 void | |
|
109123
384b3408c143
Convert function definitions in lwlib files to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
45 XtNoClearRefreshWidget (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 | |
|
109123
384b3408c143
Convert function definitions in lwlib files to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
69 XtApplyToWidgets (Widget w, XtApplyToWidgetsProc proc, XtPointer arg) |
| 5626 | 70 { |
| 71 if (XtIsComposite (w)) | |
| 72 { | |
| 73 CompositeWidget cw = (CompositeWidget) w; | |
| 74 /* We have to copy the children list before mapping over it, because | |
| 75 the procedure might add/delete elements, which would lose badly. | |
| 76 */ | |
| 77 int nkids = cw->composite.num_children; | |
| 78 Widget *kids = (Widget *) malloc (sizeof (Widget) * nkids); | |
| 79 int i; | |
|
109165
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109123
diff
changeset
|
80 memcpy ((char *) kids, (char *) cw->composite.children, |
|
750db9f3e6d8
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents:
109123
diff
changeset
|
81 sizeof (Widget) * nkids); |
| 5626 | 82 for (i = 0; i < nkids; i++) |
| 83 /* This prevent us from using gadgets, why is it here? */ | |
| 84 /* if (XtIsWidget (kids [i])) */ | |
| 85 { | |
| 86 /* do the kiddies first in case we're destroying */ | |
| 87 XtApplyToWidgets (kids [i], proc, arg); | |
| 88 proc (kids [i], arg); | |
| 89 } | |
| 90 free (kids); | |
| 91 } | |
| 92 } | |
| 93 | |
| 94 | |
| 95 /* | |
| 96 * Apply a function to all the subwidgets of a given widget recursively. | |
| 97 * Stop as soon as the function returns non NULL and returns this as a value. | |
| 98 */ | |
| 99 void * | |
|
109123
384b3408c143
Convert function definitions in lwlib files to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
100 XtApplyUntilToWidgets (Widget w, XtApplyUntilToWidgetsProc proc, XtPointer arg) |
| 5626 | 101 { |
| 102 void* result; | |
| 103 if (XtIsComposite (w)) | |
| 104 { | |
| 105 CompositeWidget cw = (CompositeWidget)w; | |
| 106 int i; | |
| 107 for (i = 0; i < cw->composite.num_children; i++) | |
| 108 if (XtIsWidget (cw->composite.children [i])){ | |
| 109 result = proc (cw->composite.children [i], arg); | |
| 110 if (result) | |
| 111 return result; | |
| 112 result = XtApplyUntilToWidgets (cw->composite.children [i], proc, | |
| 113 arg); | |
| 114 if (result) | |
| 115 return result; | |
| 116 } | |
| 117 } | |
| 118 return NULL; | |
| 119 } | |
| 120 | |
| 121 | |
| 122 /* | |
| 123 * Returns a copy of the list of all children of a composite widget | |
| 124 */ | |
| 125 Widget * | |
|
109123
384b3408c143
Convert function definitions in lwlib files to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
126 XtCompositeChildren (Widget widget, unsigned int *number) |
| 5626 | 127 { |
| 128 CompositeWidget cw = (CompositeWidget)widget; | |
| 129 Widget* result; | |
| 130 int n; | |
| 131 int i; | |
| 132 | |
| 133 if (!XtIsComposite (widget)) | |
| 134 { | |
| 135 *number = 0; | |
| 136 return NULL; | |
| 137 } | |
| 138 n = cw->composite.num_children; | |
| 139 result = (Widget*)XtMalloc (n * sizeof (Widget)); | |
| 140 *number = n; | |
| 141 for (i = 0; i < n; i++) | |
| 142 result [i] = cw->composite.children [i]; | |
| 143 return result; | |
| 144 } | |
| 145 | |
| 146 Boolean | |
|
109123
384b3408c143
Convert function definitions in lwlib files to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
147 XtWidgetBeingDestroyedP (Widget widget) |
| 5626 | 148 { |
| 149 return widget->core.being_destroyed; | |
| 150 } | |
| 151 | |
| 152 void | |
|
109123
384b3408c143
Convert function definitions in lwlib files to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
153 XtSafelyDestroyWidget (Widget widget) |
| 5626 | 154 { |
| 155 #if 0 | |
| 156 | |
| 157 /* this requires IntrinsicI.h (actually, InitialI.h) */ | |
| 158 | |
| 159 XtAppContext app = XtWidgetToApplicationContext(widget); | |
| 160 | |
| 161 if (app->dispatch_level == 0) | |
| 162 { | |
| 163 app->dispatch_level = 1; | |
| 164 XtDestroyWidget (widget); | |
| 165 /* generates an event so that the event loop will be called */ | |
| 166 XChangeProperty (XtDisplay (widget), XtWindow (widget), | |
| 167 XA_STRING, XA_STRING, 32, PropModeAppend, NULL, 0); | |
| 168 app->dispatch_level = 0; | |
| 169 } | |
| 170 else | |
| 171 XtDestroyWidget (widget); | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
41767
diff
changeset
|
172 |
| 5626 | 173 #else |
| 174 abort (); | |
| 175 #endif | |
| 176 } | |
| 52401 | 177 |
