2 Copyright (c) 1997 Douglas Keller
4 This file is part of SXEmacs
6 SXEmacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 SXEmacs 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.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* Synched up with: Not in FSF. */
25 #include "ui/device.h"
26 #include "console-x.h"
28 #include "balloon_help.h"
30 /* #### start of hack */
33 alloc_color(Display * dpy, const char *colorname, int light)
35 Colormap cmap = DEVICE_X_COLORMAP(XDEVICE(Vdefault_x_device));
36 unsigned long pixel = 0;
39 if (XParseColor(dpy, cmap, colorname, &color)
40 && XAllocColor(dpy, cmap, &color)) {
45 ("Warning: could not allocate color \"%s\", using \"white\"\n",
47 pixel = alloc_color(dpy, "white", True);
50 ("Warning: could not allocate color \"%s\", using \"black\"\n",
52 pixel = alloc_color(dpy, "black", True);
58 static XFontStruct *open_font(Display * dpy, const char *font_name)
60 XFontStruct *fontStruct = NULL;
62 fontStruct = XLoadQueryFont(dpy, font_name ? font_name : "fixed");
63 if (fontStruct == NULL) {
65 ("Warning: could not load font \"%s\", using \"fixed\".\n",
67 fontStruct = XLoadQueryFont(dpy, "fixed");
68 assert(fontStruct != NULL);
73 static void init(void)
75 static int init_p = 0;
78 Pixel fg, bg, shine, shadow;
80 Display *dpy = DEVICE_X_DISPLAY(XDEVICE(Vdefault_x_device));
82 fg = alloc_color(dpy, "grey60", 1);
83 bg = alloc_color(dpy, "black", 0);
85 shine = alloc_color(dpy, "grey80", 1);
86 shadow = alloc_color(dpy, "grey40", 0);
88 font = open_font(dpy, "-adobe-helvetica-medium-r-normal--12-*");
90 balloon_help_create(dpy, bg, fg, shine, shadow, font);
95 /* #### end of hack */
97 DEFUN("show-balloon-help", Fshow_balloon_help, 1, 1, 0, /*
103 CHECK_STRING(string);
105 p = (char *)XSTRING_DATA(string);
109 balloon_help_show(p);
114 DEFUN("hide-balloon-help", Fhide_balloon_help, 0, 0, 0, /*
126 DEFUN("balloon-help-move-to-pointer", Fballoon_help_move_to_pointer, 0, 0, 0, /*
127 Move the balloon help to the place where the pointer currently
134 balloon_help_move_to_pointer();
139 /************************************************************************/
141 /************************************************************************/
143 void syms_of_balloon_x(void)
145 DEFSUBR(Fshow_balloon_help);
146 DEFSUBR(Fhide_balloon_help);
147 DEFSUBR(Fballoon_help_move_to_pointer);
150 void vars_of_balloon_x(void)
152 Fprovide(intern("c-balloon-help"));