Mercurial > hg > xemacs-beta
annotate lwlib/xlwcheckbox.c @ 4595:a1a8728fec10
Distinguish between special forms and subrs, #'describe-function-1.
lisp/ChangeLog addition:
2009-02-04 Aidan Kehoe <kehoea@parhasard.net>
* help.el (describe-function-1):
Distinguish between special forms and subrs; don't bind
autoload-file, #'symbol-file returns it like any other function
file name.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Wed, 04 Feb 2009 11:38:25 +0000 |
parents | 726060ee587c |
children | 5460287a3327 |
rev | line source |
---|---|
424 | 1 /* Checkbox Widget for XEmacs. |
2 Copyright (C) 1999 Edward A. Falk | |
3 | |
4 This file is part of XEmacs. | |
5 | |
6 XEmacs is free software; you can redistribute it and/or modify it | |
7 under the terms of the GNU General Public License as published by the | |
8 Free Software Foundation; either version 2, or (at your option) any | |
9 later version. | |
10 | |
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with XEmacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
19 Boston, MA 02111-1307, USA. */ | |
20 | |
21 /* Synched up with: Checkbox.c 1.1 */ | |
22 | |
23 /* | |
24 * Checkbox.c - Checkbox button widget | |
25 * | |
26 * Author: Edward A. Falk | |
27 * falk@falconer.vip.best.com | |
442 | 28 * |
424 | 29 * Date: June 30, 1997 |
30 * | |
31 * Overview: This widget is identical to the Radio widget in behavior, | |
32 * except that the button is square and has a check mark. | |
33 */ | |
34 | |
35 | |
36 #include <config.h> | |
37 #include <stdio.h> | |
38 | |
39 #include <X11/IntrinsicP.h> | |
40 #include <X11/StringDefs.h> | |
442 | 41 #include ATHENA_XawInit_h_ |
424 | 42 #include "../src/xmu.h" |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
43 #include "xt-wrappers.h" |
424 | 44 #include "xlwcheckboxP.h" |
45 | |
46 | |
47 /* by using the same size for the checkbox as for the diamond box, | |
48 * we can let the Radio widget do the vast majority of the work. | |
49 */ | |
50 | |
51 #define BOX_SIZE 8 | |
52 #define DRAW_CHECK 0 /* don't draw the check mark */ | |
53 | |
54 #define cclass(w) ((CheckboxWidgetClass)((w)->core.widget_class)) | |
55 | |
56 #ifdef _ThreeDP_h | |
57 #define swid(cw) ((cw)->threeD.shadow_width) | |
58 #else | |
59 #define swid(cw) ((cw)->core.border_width) | |
60 #endif | |
61 | |
62 #define bsize(cw) (cclass(cw)->radio_class.dsize) | |
63 #define bs(cw) (bsize(cw) + 2*swid(cw)) | |
64 | |
65 | |
66 #if DRAW_CHECK | |
67 #define check_width 14 | |
68 #define check_height 14 | |
458 | 69 static unsigned char check_bits[] = { |
424 | 70 0x00, 0x00, 0x00, 0x20, 0x00, 0x18, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x03, |
71 0x8c, 0x03, 0xde, 0x01, 0xff, 0x01, 0xfe, 0x00, 0xfc, 0x00, 0x78, 0x00, | |
72 0x70, 0x00, 0x20, 0x00}; | |
73 #endif | |
74 | |
75 | |
76 /**************************************************************** | |
77 * | |
78 * Full class record constant | |
79 * | |
80 ****************************************************************/ | |
81 | |
82 | |
83 #if DRAW_CHECK | |
84 static char defaultTranslations[] = | |
85 "<EnterWindow>: highlight()\n\ | |
86 <LeaveWindow>: unpress(draw) unhighlight()\n\ | |
87 <Btn1Down>: press()\n\ | |
88 <Btn1Down>,<Btn1Up>: unpress(nodraw) toggle() notify()"; | |
89 #endif | |
90 | |
91 | |
92 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
93 #define offset(field) XtOffsetOf(CheckboxRec, checkbox.field) |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
94 #define res(name,_class,intrepr,type,member,extrepr,value) \ |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
95 Xt_RESOURCE (name, _class, intrepr, type, offset(member), extrepr, value) |
424 | 96 static XtResource resources[] = { |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
97 res (XtNtristate, XtCTristate, XtRBoolean, Boolean, tristate, |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
98 XtRImmediate, FALSE), |
424 | 99 } ; |
100 #undef offset | |
101 | |
102 /* Member functions */ | |
103 | |
104 static void CheckboxClassInit (void); | |
105 static void CheckboxInit (Widget, Widget, ArgList, Cardinal *); | |
106 #if DRAW_CHECK | |
107 static void CheckboxRealize (Widget, Mask *, XSetWindowAttributes *); | |
108 #endif | |
109 static void DrawCheck (Widget); | |
110 | |
111 | |
112 /* Action procs */ | |
113 #if DRAW_CHECK | |
114 static void CheckboxPress (Widget, XEvent *, String *, Cardinal *); | |
115 static void CheckboxUnpress (Widget, XEvent *, String *, Cardinal *); | |
116 #endif | |
117 | |
118 /* internal privates */ | |
119 | |
120 #if DRAW_CHECK | |
121 static XtActionsRec actionsList[] = | |
122 { | |
123 {"press", CheckboxPress}, | |
124 {"unpress", CheckboxUnpress}, | |
125 } ; | |
126 #endif | |
127 | |
128 #define SuperClass ((RadioWidgetClass)&radioClassRec) | |
129 | |
130 CheckboxClassRec checkboxClassRec = { | |
131 { | |
442 | 132 (WidgetClass) SuperClass, /* superclass */ |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
133 (String) "Checkbox", /* class_name */ |
424 | 134 sizeof(CheckboxRec), /* size */ |
135 CheckboxClassInit, /* class_initialize */ | |
136 NULL, /* class_part_initialize */ | |
137 FALSE, /* class_inited */ | |
138 CheckboxInit, /* initialize */ | |
139 NULL, /* initialize_hook */ | |
140 #if DRAW_CHECK | |
141 CheckboxRealize, /* realize */ | |
142 actionsList, /* actions */ | |
143 XtNumber(actionsList), /* num_actions */ | |
144 #else | |
145 XtInheritRealize, /* realize */ | |
146 NULL, /* actions */ | |
147 0, /* num_actions */ | |
148 #endif | |
149 resources, /* resources */ | |
150 XtNumber(resources), /* resource_count */ | |
151 NULLQUARK, /* xrm_class */ | |
152 TRUE, /* compress_motion */ | |
153 TRUE, /* compress_exposure */ | |
154 TRUE, /* compress_enterleave */ | |
155 FALSE, /* visible_interest */ | |
156 NULL, /* destroy */ | |
157 XtInheritResize, /* resize */ | |
158 XtInheritExpose, /* expose */ | |
159 NULL, /* set_values */ | |
160 NULL, /* set_values_hook */ | |
161 XtInheritSetValuesAlmost, /* set_values_almost */ | |
162 NULL, /* get_values_hook */ | |
163 NULL, /* accept_focus */ | |
164 XtVersion, /* version */ | |
165 NULL, /* callback_private */ | |
166 #if DRAW_CHECK | |
167 defaultTranslations, /* tm_table */ | |
168 #else | |
169 XtInheritTranslations, /* tm_table */ | |
170 #endif | |
171 XtInheritQueryGeometry, /* query_geometry */ | |
172 XtInheritDisplayAccelerator, /* display_accelerator */ | |
173 NULL /* extension */ | |
174 }, /* CoreClass fields initialization */ | |
175 { | |
442 | 176 XtInheritChangeSensitive /* change_sensitive */ |
424 | 177 }, /* SimpleClass fields initialization */ |
178 #ifdef _ThreeDP_h | |
179 { | |
180 XtInheritXaw3dShadowDraw /* field not used */ | |
181 }, /* ThreeDClass fields initialization */ | |
182 #endif | |
183 { | |
184 0 /* field not used */ | |
185 }, /* LabelClass fields initialization */ | |
186 { | |
187 0 /* field not used */ | |
188 }, /* CommandClass fields initialization */ | |
189 { | |
190 RadioSet, /* Set Procedure. */ | |
191 RadioUnset, /* Unset Procedure. */ | |
192 NULL /* extension. */ | |
193 }, /* ToggleClass fields initialization */ | |
194 { | |
195 BOX_SIZE, | |
196 DrawCheck, /* draw procedure */ | |
197 NULL /* extension. */ | |
198 }, /* RadioClass fields initialization */ | |
199 { | |
200 NULL /* extension. */ | |
201 }, /* CheckboxClass fields initialization */ | |
202 }; | |
203 | |
204 /* for public consumption */ | |
205 WidgetClass checkboxWidgetClass = (WidgetClass) &checkboxClassRec; | |
206 | |
207 | |
208 | |
209 | |
210 | |
211 | |
212 /**************************************************************** | |
213 * | |
214 * Class Methods | |
215 * | |
216 ****************************************************************/ | |
217 | |
218 static void | |
219 CheckboxClassInit (void) | |
220 { | |
221 XawInitializeWidgetSet(); | |
222 } | |
223 | |
224 | |
225 /*ARGSUSED*/ | |
226 static void | |
2286 | 227 CheckboxInit (Widget UNUSED (request), |
228 #if DRAW_CHECK | |
424 | 229 Widget new, |
2286 | 230 #else |
3072 | 231 Widget UNUSED (new_), |
2286 | 232 #endif |
233 ArgList UNUSED (args), | |
234 Cardinal *UNUSED (num_args)) | |
424 | 235 { |
236 #if DRAW_CHECK | |
3072 | 237 CheckboxWidget cw = (CheckboxWidget) new_; |
424 | 238 cw->checkbox.checkmark = None ; |
239 cw->checkbox.checkmark_GC = None ; | |
240 #endif | |
241 } | |
242 | |
243 | |
244 #if DRAW_CHECK | |
245 static void | |
246 CheckboxRealize(Widget w, | |
247 Mask *valueMask, | |
248 XSetWindowAttributes *attributes) | |
249 { | |
250 CheckboxWidget cw = (CheckboxWidget) w; | |
251 XtGCMask value_mask, dynamic_mask, dontcare_mask ; | |
252 XGCValues values ; | |
253 | |
254 /* first, call superclass realize */ | |
255 (*checkboxWidgetClass->core_class.superclass->core_class.realize) | |
256 (w, valueMask, attributes); | |
257 | |
258 /* TODO: cache this via xmu */ | |
259 if( cw->checkbox.checkmark == None ) | |
260 cw->checkbox.checkmark = | |
261 XCreateBitmapFromData( XtDisplay(w), XtWindow(w), | |
262 check_bits,check_width,check_height); | |
263 | |
264 values.fill_style = FillStippled ; | |
265 values.stipple = cw->checkbox.checkmark ; | |
266 values.foreground = cw->label.foreground ; | |
267 value_mask = GCFillStyle | GCStipple | GCForeground ; | |
268 dynamic_mask = GCTileStipXOrigin | GCTileStipYOrigin ; | |
269 dontcare_mask = GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle | | |
270 GCFont | GCSubwindowMode | GCGraphicsExposures | | |
271 GCDashOffset | GCDashList | GCArcMode ; | |
272 cw->checkbox.checkmark_GC = | |
273 XtAllocateGC(w, 0, value_mask, &values, dynamic_mask, dontcare_mask) ; | |
274 } | |
275 #endif | |
276 | |
277 | |
278 /* Function Name: CheckboxDestroy | |
279 * Description: Destroy Callback for checkbox widget. | |
280 * Arguments: w - the checkbox widget that is being destroyed. | |
442 | 281 * junk, garbage - not used. |
424 | 282 * Returns: none. |
283 */ | |
284 | |
285 /* ARGSUSED */ | |
3072 | 286 #if DRAW_CHECK |
424 | 287 static void |
2286 | 288 CheckboxDestroy ( |
289 Widget w, | |
290 XtPointer UNUSED (junk), | |
291 XtPointer UNUSED (garbage)) | |
424 | 292 { |
293 CheckboxWidget cw = (CheckboxWidget) w; | |
294 | |
295 /* TODO: cache this via xmu */ | |
296 if( cw->checkbox.checkmark != None ) | |
297 XFreePixmap( XtDisplay(w), cw->checkbox.checkmark ) ; | |
298 if( cw->checkbox.checkmark_GC != None ) | |
299 XtReleaseGC(w, cw->checkbox.checkmark_GC) ; | |
300 } | |
3072 | 301 #endif /* DRAW_CHECK */ |
424 | 302 |
303 | |
304 | |
305 #if DRAW_CHECK | |
306 /************************************************************ | |
307 * | |
308 * Actions Procedures | |
309 * | |
310 ************************************************************/ | |
311 | |
312 /* ARGSUSED */ | |
313 static void | |
314 CheckboxPress (Widget w, | |
315 XEvent *event, | |
316 String *params, /* unused */ | |
317 Cardinal *num_params) /* unused */ | |
318 { | |
319 CheckboxWidget cw = (CheckboxWidget) w ; | |
320 if( !cw->checkbox.pressed ) { | |
321 cw->checkbox.pressed = TRUE ; | |
322 ((CheckboxWidgetClass)(w->core.widget_class))->radio_class.drawDiamond(w) ; | |
323 } | |
324 } | |
325 | |
326 static void | |
327 CheckboxUnpress (Widget w, | |
328 XEvent *event, | |
329 String *params, /* unused */ | |
330 Cardinal *num_params) /* unused */ | |
331 { | |
332 CheckboxWidget cw = (CheckboxWidget) w ; | |
333 int i ; | |
334 | |
335 if( cw->checkbox.pressed ) { | |
336 cw->checkbox.pressed = FALSE ; | |
337 if( *num_params > 0 && **params == 'd' ) | |
338 ((CheckboxWidgetClass)(w->core.widget_class))->radio_class.drawDiamond(w); | |
339 } | |
340 } | |
341 #endif | |
342 | |
343 | |
344 | |
345 | |
346 | |
347 /************************************************************ | |
348 * | |
349 * Internal Procedures | |
350 * | |
351 ************************************************************/ | |
352 | |
353 static void | |
354 DrawCheck (Widget w) | |
355 { | |
356 CheckboxWidget cw = (CheckboxWidget) w ; | |
357 Display *dpy = XtDisplay(w) ; | |
358 Window win = XtWindow(w) ; | |
359 GC gc ; | |
360 | |
361 #ifdef _ThreeDP_h | |
362 XPoint pts[6] ; | |
363 #endif | |
364 Dimension s = swid(cw); | |
365 Dimension bsz = bsize(cw); | |
366 Position bx,by ; /* Check upper-left */ | |
2286 | 367 Dimension bh ; |
424 | 368 #ifdef _ThreeDP_h |
2286 | 369 Dimension bw; |
424 | 370 GC top, bot; |
371 #endif | |
372 GC ctr ; | |
373 | |
374 /* foreground GC */ | |
375 gc = XtIsSensitive(w) ? cw->command.normal_GC : cw->label.gray_GC ; | |
376 | |
2286 | 377 bh = bs(cw) ; |
424 | 378 bx = cw->label.internal_width ; |
379 by = cw->core.height/2 - bh/2 ; | |
380 | |
381 #ifdef _ThreeDP_h | |
2286 | 382 bw = bh ; |
383 | |
424 | 384 if( !cw->command.set ) { |
385 top = cw->threeD.top_shadow_GC ; | |
386 bot = cw->threeD.bot_shadow_GC ; | |
387 } else { | |
388 top = cw->threeD.bot_shadow_GC ; | |
389 bot = cw->threeD.top_shadow_GC ; | |
390 } | |
391 ctr = cw->command.inverse_GC ; | |
392 #else | |
393 ctr = cw->command.set ? cw->command.normal_GC : cw->command.inverse_GC ; | |
394 #endif | |
395 | |
396 XFillRectangle(dpy,win,ctr, bx+s,by+s, bsz,bsz) ; | |
397 | |
398 #ifdef _ThreeDP_h | |
399 /* top-left shadow */ | |
400 pts[0].x = bx ; pts[0].y = by ; | |
401 pts[1].x = bw ; pts[1].y = 0 ; | |
402 pts[2].x = -s ; pts[2].y = s ; | |
403 pts[3].x = -bsz ; pts[3].y = 0 ; | |
404 pts[4].x = 0 ; pts[4].y = bsz ; | |
405 pts[5].x = -s ; pts[5].y = s ; | |
406 XFillPolygon(dpy,win,top, pts,6, Nonconvex,CoordModePrevious) ; | |
407 /* bottom-right shadow */ | |
408 pts[0].x = bx+bw ; pts[0].y = by+bh ; | |
409 pts[1].x = -bw ; pts[1].y = 0 ; | |
410 pts[2].x = s ; pts[2].y = -s ; | |
411 pts[3].x = bsz ; pts[3].y = 0 ; | |
412 pts[4].x = 0 ; pts[4].y = -bsz ; | |
413 pts[5].x = s ; pts[5].y = -s ; | |
414 XFillPolygon(dpy,win,bot, pts,6, Nonconvex,CoordModePrevious) ; | |
415 #else | |
416 XDrawRectangle(dpy,win,gc, bx+s,by+s, bsz,bsz) ; | |
417 #endif | |
418 | |
419 #if DRAW_CHECK | |
420 if( cw->command.set && cw->checkbox.checkmark_GC != None ) { | |
421 XSetTSOrigin(dpy,cw->checkbox.checkmark_GC, bx+s, by+s) ; | |
422 XFillRectangle(dpy,win,cw->checkbox.checkmark_GC, | |
423 bx+s, by+s, check_width,check_height) ; | |
424 } | |
425 #endif | |
426 } |