annotate src/balloon-x.c @ 157:6b37e6ddd302 r20-3b5

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