Mercurial > hg > xemacs-beta
comparison src/balloon-x.c @ 136:b980b6286996 r20-2b2
Import from CVS: tag r20-2b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:31:12 +0200 |
parents | 34a5b81f86ba |
children | 6608ceec7cf8 |
comparison
equal
deleted
inserted
replaced
135:4636a6841cd6 | 136:b980b6286996 |
---|---|
1 /* | |
2 Copyright (c) 1997 Douglas Keller | |
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: Not in FSF. */ | |
22 | |
23 | |
1 #include <config.h> | 24 #include <config.h> |
2 #include "lisp.h" | 25 #include "lisp.h" |
3 | 26 |
4 #include "device.h" | 27 #include "device.h" |
5 #include "console-x.h" | 28 #include "console-x.h" |
6 | 29 |
7 #include "balloon_help.h" | 30 #include "balloon_help.h" |
8 | 31 |
9 /* ### start of hack */ | 32 /* ### start of hack */ |
10 | 33 |
11 static unsigned long alloc_color( Display* dpy, const char* colorname, int light ) | 34 static unsigned long |
35 alloc_color (Display* dpy, const char* colorname, int light) | |
12 { | 36 { |
13 Colormap cmap = DefaultColormap( dpy, DefaultScreen(dpy) ); | 37 Colormap cmap = DefaultColormap (dpy, DefaultScreen(dpy)); |
14 unsigned long pixel = 0; | 38 unsigned long pixel = 0; |
15 XColor color; | 39 XColor color; |
16 | 40 |
17 if( XParseColor(dpy, cmap, colorname, &color) && XAllocColor(dpy, cmap, &color) ) | 41 if (XParseColor(dpy, cmap, colorname, &color) && XAllocColor(dpy, cmap, &color)) |
18 { | 42 { |
19 pixel = color.pixel; | 43 pixel = color.pixel; |
20 } | 44 } |
21 else | 45 else |
22 { | |
23 if( light ) | |
24 { | 46 { |
25 printf("Warning: could not allocate color \"%s\", using \"white\"\n", colorname); | 47 if (light) |
26 pixel = alloc_color( dpy, "white", True ); | 48 { |
49 printf ("Warning: could not allocate color \"%s\", using \"white\"\n", | |
50 colorname); | |
51 pixel = alloc_color (dpy, "white", True); | |
52 } | |
53 else | |
54 { | |
55 printf ("Warning: could not allocate color \"%s\", using \"black\"\n", | |
56 colorname); | |
57 pixel = alloc_color (dpy, "black", True); | |
58 } | |
27 } | 59 } |
28 else | |
29 { | |
30 printf("Warning: could not allocate color \"%s\", using \"black\"\n", colorname); | |
31 pixel = alloc_color( dpy, "black", True ); | |
32 } | |
33 } | |
34 return pixel; | 60 return pixel; |
35 } | 61 } |
36 | 62 |
37 static XFontStruct* open_font( Display* dpy, const char* font_name ) | 63 static XFontStruct * |
64 open_font (Display* dpy, const char* font_name) | |
38 { | 65 { |
39 XFontStruct* fontStruct = NULL; | 66 XFontStruct* fontStruct = NULL; |
40 | 67 |
41 fontStruct = XLoadQueryFont( dpy, font_name ? font_name : "fixed" ); | 68 fontStruct = XLoadQueryFont (dpy, font_name ? font_name : "fixed"); |
42 if( fontStruct == NULL ) | 69 if (fontStruct == NULL) |
43 { | 70 { |
44 printf("Warning: could not load font \"%s\", using \"fixed\".\n", font_name); | 71 printf ("Warning: could not load font \"%s\", using \"fixed\".\n", font_name); |
45 fontStruct = XLoadQueryFont( dpy, "fixed" ); | 72 fontStruct = XLoadQueryFont (dpy, "fixed"); |
46 assert( fontStruct != NULL ); | 73 assert (fontStruct != NULL); |
47 } | 74 } |
48 return fontStruct; | 75 return fontStruct; |
49 } | 76 } |
50 | 77 |
51 static void init( void ) | 78 static void |
79 init (void) | |
52 { | 80 { |
53 static int init; | 81 static int init; |
54 | 82 |
55 if( !init ) | 83 if (!init) |
56 { | 84 { |
57 Pixel fg, bg, shine, shadow; | 85 Pixel fg, bg, shine, shadow; |
58 XFontStruct* font; | 86 XFontStruct* font; |
59 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (Vdefault_x_device)); | 87 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (Vdefault_x_device)); |
60 | 88 |
61 fg = alloc_color( dpy, "grey60", 1 ); | 89 fg = alloc_color (dpy, "grey60", 1); |
62 bg = alloc_color( dpy, "black", 0 ); | 90 bg = alloc_color (dpy, "black", 0); |
63 | |
64 shine = alloc_color( dpy, "grey80", 1 ); | |
65 shadow = alloc_color( dpy, "grey40", 0 ); | |
66 | 91 |
67 font = open_font( dpy, "-adobe-helvetica-medium-r-normal--12-*" ); | 92 shine = alloc_color (dpy, "grey80", 1); |
93 shadow = alloc_color (dpy, "grey40", 0); | |
68 | 94 |
69 balloon_help_create( dpy, bg, fg, shine, shadow, font ); | 95 font = open_font (dpy, "-adobe-helvetica-medium-r-normal--12-*"); |
70 init = 1; | 96 |
71 } | 97 balloon_help_create (dpy, bg, fg, shine, shadow, font); |
98 init = 1; | |
99 } | |
72 } | 100 } |
73 | 101 |
74 /* ### end of hack */ | 102 /* ### end of hack */ |
75 | 103 |
76 DEFUN( "show-balloon-help", Fshow_balloon_help, 1, 1, 0, /* | 104 DEFUN ("show-balloon-help", Fshow_balloon_help, 1, 1, 0, /* |
77 Show balloon help. | 105 Show balloon help. |
78 */ | 106 */ |
79 (string)) | 107 (string)) |
80 { | 108 { |
81 char *p; | 109 char *p; |
82 CHECK_STRING (string); | 110 CHECK_STRING (string); |
83 | 111 |
84 p = (char *) XSTRING_DATA (string); | 112 p = (char *) XSTRING_DATA (string); |
85 | 113 |
86 init(); | 114 init (); |
87 | 115 |
88 balloon_help_show( p ); | 116 balloon_help_show (p); |
89 | 117 |
90 return Qnil; | 118 return Qnil; |
91 } | 119 } |
92 | 120 |
93 DEFUN( "hide-balloon-help", Fhide_balloon_help, 0, 0, 0, /* | 121 DEFUN ("hide-balloon-help", Fhide_balloon_help, 0, 0, 0, /* |
94 Hide balloon help. | 122 Hide balloon help. |
95 */ | 123 */ |
96 ()) | 124 ()) |
97 { | 125 { |
98 init(); | 126 init (); |
99 | 127 |
100 balloon_help_hide(); | 128 balloon_help_hide (); |
101 | 129 |
102 return Qnil; | 130 return Qnil; |
103 } | 131 } |
104 | 132 |
105 DEFUN( "balloon-help-move-to-pointer", Fballoon_help_move_to_pointer, 0, 0, 0, /* | 133 DEFUN ("balloon-help-move-to-pointer", Fballoon_help_move_to_pointer, 0, 0, 0, /* |
106 Hide balloon help. | 134 Hide balloon help. |
107 */ | 135 */ |
108 ()) | 136 ()) |
109 { | 137 { |
110 init(); | 138 init (); |
111 | 139 |
112 balloon_help_move_to_pointer(); | 140 balloon_help_move_to_pointer (); |
113 | 141 |
114 return Qnil; | 142 return Qnil; |
115 } | 143 } |
116 | 144 |
117 | 145 |
121 /************************************************************************/ | 149 /************************************************************************/ |
122 | 150 |
123 void | 151 void |
124 syms_of_balloon_x (void) | 152 syms_of_balloon_x (void) |
125 { | 153 { |
126 DEFSUBR( Fshow_balloon_help ); | 154 DEFSUBR (Fshow_balloon_help); |
127 DEFSUBR( Fhide_balloon_help ); | 155 DEFSUBR (Fhide_balloon_help); |
128 DEFSUBR( Fballoon_help_move_to_pointer ); | 156 DEFSUBR (Fballoon_help_move_to_pointer); |
129 } | 157 } |
130 | 158 |
131 void | 159 void |
132 vars_of_balloon_x (void) | 160 vars_of_balloon_x (void) |
133 { | 161 { |