annotate src/balloon-x.c @ 4839:5f1c6ca4d05e

fix bad change to default_query_method, rewrite conditional for more correctness
author Ben Wing <ben@xemacs.org>
date Tue, 12 Jan 2010 23:16:33 -0600
parents 79c6ff3eef26
children 308d34e9f07d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (c) 1997 Douglas Keller
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 442
diff changeset
27 #include "device-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 442
diff changeset
28 #include "console-x-impl.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #include "balloon_help.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
32 /* #### start of hack */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 static unsigned long
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
35 alloc_color (Display* dpy, const char* colorname, int light)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 {
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 442
diff changeset
37 Colormap cmap = DEVICE_X_COLORMAP (XDEVICE (get_default_device (Qx)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 unsigned long pixel = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 XColor color;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 if (XParseColor(dpy, cmap, colorname, &color) && XAllocColor(dpy, cmap, &color))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 pixel = color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 if (light)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 printf ("Warning: could not allocate color \"%s\", using \"white\"\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 colorname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 pixel = alloc_color (dpy, "white", True);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 printf ("Warning: could not allocate color \"%s\", using \"black\"\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 colorname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 pixel = alloc_color (dpy, "black", True);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 return pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 static XFontStruct *
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
64 open_font (Display* dpy, const char* font_name)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 XFontStruct* fontStruct = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 fontStruct = XLoadQueryFont (dpy, font_name ? font_name : "fixed");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 if (fontStruct == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 printf ("Warning: could not load font \"%s\", using \"fixed\".\n", font_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 fontStruct = XLoadQueryFont (dpy, "fixed");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 assert (fontStruct != NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 return fontStruct;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 init (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 static int init_p = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 if (!init_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 Pixel fg, bg, shine, shadow;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 XFontStruct* font;
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 442
diff changeset
87 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (get_default_device (Qx)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 fg = alloc_color (dpy, "grey60", 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 bg = alloc_color (dpy, "black", 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 shine = alloc_color (dpy, "grey80", 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 shadow = alloc_color (dpy, "grey40", 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 font = open_font (dpy, "-adobe-helvetica-medium-r-normal--12-*");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 balloon_help_create (dpy, bg, fg, shine, shadow, font);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 init_p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
102 /* #### end of hack */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 DEFUN ("show-balloon-help", Fshow_balloon_help, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 Show balloon help.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 (string))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 char *p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 CHECK_STRING (string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 p = (char *) XSTRING_DATA (string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 init ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 balloon_help_show (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 DEFUN ("hide-balloon-help", Fhide_balloon_help, 0, 0, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 Hide balloon help.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 ())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 init ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 balloon_help_hide ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 DEFUN ("balloon-help-move-to-pointer", Fballoon_help_move_to_pointer, 0, 0, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 Move the balloon help to the place where the pointer currently resides.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 ())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 init ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 balloon_help_move_to_pointer ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 syms_of_balloon_x (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 DEFSUBR (Fshow_balloon_help);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 DEFSUBR (Fhide_balloon_help);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 DEFSUBR (Fballoon_help_move_to_pointer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 vars_of_balloon_x (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 Fprovide (intern ("c-balloon-help"));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 }