annotate src/balloon_help.c @ 4901:7504864a986c

Don't use Boyer-Moore if repeated octets & case-insensitive search. 2010-01-30 Aidan Kehoe <kehoea@parhasard.net> * search.c (search_buffer): Don't use Boyer-Moore for case-insensitive search if the search pattern contains repeated Ibytes and the corresponding character has case information (or, equivalently, if one of its case equivalents would contain repeated Ibytes).
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 30 Jan 2010 22:25:39 +0000
parents 04bc9d2f42c7
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 /* Balloon Help
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
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 442
diff changeset
23 /* !!#### Needs to be Mule-ized. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 442
diff changeset
24
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 * Balloon Help
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 * Version: 1.337 (Sun Apr 13 04:52:10 1997)
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 * Written by Douglas Keller <dkeller@vnet.ibm.com>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 *
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include <string.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #include <stdlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #include <assert.h>
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 #include <X11/Xlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 #include <X11/Xutil.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 #include <X11/extensions/shape.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 771
diff changeset
45 #include "compiler.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 #include "xintrinsic.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 #include "balloon_help.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
50 #ifndef max
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 #define max(x,y) (x>y?x:y)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 #undef bool
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 #define bool int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 #define MARGIN_WIDTH 4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 #define POINTER_OFFSET 8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 #define BORDER_WIDTH 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 #define BORDER_WIDTH_HALF 1
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 #define CONE_HEIGHT 20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 #define CONE_WIDTH 50
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 #define SHAPE_CONE_TOP (1<<0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 #define SHAPE_CONE_LEFT (1<<1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 #define SHAPE_CONE_TOP_LEFT (SHAPE_CONE_TOP | SHAPE_CONE_LEFT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 #define SHAPE_CONE_TOP_RIGHT (SHAPE_CONE_TOP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 #define SHAPE_CONE_BOTTOM_LEFT (SHAPE_CONE_LEFT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 #define SHAPE_CONE_BOTTOM_RIGHT (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 #define SHAPE_CONE_FREE (-1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 static Display* b_dpy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 static XFontStruct* b_fontStruct;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 static GC b_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 static GC b_shineGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 static GC b_shadowGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 static Window b_win;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 static bool b_winMapped;
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 static Pixmap b_mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 static int b_maskWidth, b_maskHeight;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 static GC b_maskGC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
89 static const char* b_text;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 static int b_width, b_height;
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 static XtIntervalId b_timer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 static unsigned long b_delay;
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 static int b_screenWidth, b_screenHeight;
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 static int b_lastShape;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98
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 ============================================================================*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 static GC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 create_gc (Display* dpy, Window win, unsigned long fg, unsigned long bg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 XFontStruct* fontStruct)
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 XGCValues gcv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 unsigned long mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 gcv.foreground = fg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 gcv.background = bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 gcv.font = fontStruct->fid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 gcv.join_style = JoinMiter;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 gcv.line_width = BORDER_WIDTH;
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 mask = GCFont | GCBackground | GCForeground | GCJoinStyle | GCLineWidth;
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 XCreateGC (dpy, win, mask, &gcv);
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 destroy_gc (Display* dpy, GC gc)
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 if (gc)
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 XFreeGC (dpy, gc);
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 }
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 /*============================================================================
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 static Window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 create_window (Display* dpy, unsigned long bg)
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 Window win;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 XSetWindowAttributes attr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 unsigned long attr_mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 attr_mask = CWOverrideRedirect | CWBackPixel | CWSaveUnder;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 attr.override_redirect = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 attr.background_pixel = bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 attr.save_under = True;
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 win =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 XCreateWindow (dpy,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 DefaultRootWindow (dpy),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 0, 0, 1, 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 CopyFromParent, InputOutput, CopyFromParent,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 attr_mask, &attr);
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 XSelectInput (dpy, win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 SubstructureRedirectMask |
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 SubstructureNotifyMask |
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 ExposureMask |
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 EnterWindowMask |
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 LeaveWindowMask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 return win;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 destroy_window (Display* dpy, Window win)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 if (win)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 XDestroyWindow (dpy, win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 /*============================================================================
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 ============================================================================*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 get_pointer_xy (Display* dpy, int* x_return, int* y_return)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 int dummy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 unsigned int mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 Window dummy_win;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 XQueryPointer (dpy, RootWindow(dpy, DefaultScreen(dpy)), &dummy_win, &dummy_win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 x_return, y_return, &dummy, &dummy, &mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 /*============================================================================
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 ============================================================================*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 create_pixmap_mask (int width, int height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 b_maskWidth = width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 b_maskHeight = height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 b_mask = XCreatePixmap (b_dpy, b_win, width, height, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 destroy_pixmap_mask(void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 XFreePixmap (b_dpy, b_mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 grow_pixmap_mask (int width, int height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 if (width > b_maskWidth || height > b_maskHeight)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 destroy_pixmap_mask ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 create_pixmap_mask (width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 /*============================================================================
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 ============================================================================*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
220 text_extent (XFontStruct* fontStruct, const char* text, int len,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 int* width, int* height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 XCharStruct extent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 int dummy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 XTextExtents (fontStruct, text, len, &dummy, &dummy, &dummy, &extent);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 *width = extent.width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 *height = fontStruct->ascent + fontStruct->descent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 771
diff changeset
233 get_text_size (Display* UNUSED (dpy), XFontStruct* fontStruct,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 771
diff changeset
234 const char* text, int* max_width, int* max_height)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 int width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 int height;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
238 const char* start;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
239 const char* end;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 *max_width = *max_height = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 start = text;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 while ((end = strchr(start, '\n')))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 text_extent (fontStruct, start, end - start, &width, &height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 *max_width = max (width, *max_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 *max_height += height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 start = end + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 text_extent (fontStruct, start, strlen (start), &width, &height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 *max_width = max (width, *max_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 *max_height += height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 /* Min width */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 *max_width = max (*max_width, CONE_WIDTH / 2 * 3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 draw_text (Display* dpy, Window win, GC gc, XFontStruct* fontStruct,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
263 int x, int y, const char* text)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
265 const char* start;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
266 const char* end;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 int font_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 y += fontStruct->ascent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 font_height = fontStruct->ascent + fontStruct->descent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 start = text;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 while ((end = strchr(start, '\n')))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 XDrawString (dpy, win, gc, x, y, start, end - start);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 start = end + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 y += font_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 XDrawString (dpy, win, gc, x, y, start, strlen (start));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 /*============================================================================
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 ============================================================================*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 get_shape (int last_shape, int x, int y, int width, int height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 int screen_width, int screen_height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 /* Can we use last_shape? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 if (((last_shape == SHAPE_CONE_TOP_LEFT) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 (x + width < screen_width) && (y + height < screen_height)) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 ((last_shape == SHAPE_CONE_TOP_RIGHT) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 (x - width > 0) && (y + height < screen_height)) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 ((last_shape == SHAPE_CONE_BOTTOM_LEFT) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 (x + width < screen_width) && (y - height > 0)) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 ((last_shape == SHAPE_CONE_BOTTOM_RIGHT) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 (x - width > 0) && (y - height > 0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 return last_shape;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 /* Try to pick a shape that will not get changed,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 e.g. if top left quadrant, top_left */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 return (x < screen_width / 2) ?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 (y < screen_height / 2 ? SHAPE_CONE_TOP_LEFT: SHAPE_CONE_BOTTOM_LEFT) :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 (y < screen_height / 2 ? SHAPE_CONE_TOP_RIGHT: SHAPE_CONE_BOTTOM_RIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 771
diff changeset
311 make_mask (int shape, int UNUSED (x), int UNUSED (y), int width, int height)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 XPoint cone[ 3 ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 grow_pixmap_mask (width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 /* Clear mask */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 XSetForeground (b_dpy, b_maskGC, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 XFillRectangle (b_dpy, b_mask, b_maskGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 0, 0, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 /* Enable text area */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 XSetForeground (b_dpy, b_maskGC, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 XFillRectangle (b_dpy, b_mask, b_maskGC, 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 shape & SHAPE_CONE_TOP ? CONE_HEIGHT : 0, width, height - CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 /* Enable for cone area */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 cone[0].x = (shape & SHAPE_CONE_LEFT) ? CONE_WIDTH / 2 : width - (CONE_WIDTH / 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 cone[0].y = (shape & SHAPE_CONE_TOP) ? CONE_HEIGHT : height - CONE_HEIGHT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 cone[1].x = (shape & SHAPE_CONE_LEFT) ? 0 : width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 cone[1].y = (shape & SHAPE_CONE_TOP) ? 0 : height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 cone[2].x = (shape & SHAPE_CONE_LEFT) ? CONE_WIDTH : width - CONE_WIDTH;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 cone[2].y = (shape & SHAPE_CONE_TOP) ? CONE_HEIGHT : height - CONE_HEIGHT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 XFillPolygon (b_dpy, b_mask, b_maskGC, cone, 3, Nonconvex, CoordModeOrigin);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 771
diff changeset
340 show_help (XtPointer UNUSED (data), XtIntervalId* id)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 int x, y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 int shape;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 XPoint border[ 3 ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 if (id == NULL || ((id && b_timer) && b_text))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 b_timer = None;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 /* size */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 get_text_size (b_dpy, b_fontStruct, b_text, &b_width, &b_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 b_width += 2 * MARGIN_WIDTH + 2 * BORDER_WIDTH;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 b_height += 2 * MARGIN_WIDTH + 2 * BORDER_WIDTH + CONE_HEIGHT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 /* origin */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 get_pointer_xy (b_dpy, &x, &y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 /* guess at shape */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 shape = get_shape(b_lastShape, x, y, b_width, b_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 b_screenWidth, b_screenHeight);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 x += (shape & SHAPE_CONE_LEFT) ? POINTER_OFFSET : -POINTER_OFFSET;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 y += (shape & SHAPE_CONE_TOP) ? POINTER_OFFSET : -POINTER_OFFSET;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 /* make sure it is still ok with offset */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 shape = get_shape (shape, x, y, b_width, b_height, b_screenWidth, b_screenHeight);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 b_lastShape = shape;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 make_mask (shape, x, y, b_width, b_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 XShapeCombineMask (b_dpy, b_win, ShapeBounding, 0, 0, b_mask, ShapeSet);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 XMoveResizeWindow(b_dpy, b_win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 (shape & SHAPE_CONE_LEFT) ? x : x - b_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 (shape & SHAPE_CONE_TOP) ? y : y - b_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 b_width, b_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 XClearWindow (b_dpy, b_win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 XMapRaised (b_dpy, b_win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 b_winMapped = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 draw_text (b_dpy, b_win, b_gc, b_fontStruct,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 BORDER_WIDTH + MARGIN_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 BORDER_WIDTH + MARGIN_WIDTH + ((shape & SHAPE_CONE_TOP) ? CONE_HEIGHT : 0),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 b_text);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 /* 3d border */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 /* shine- top left */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 border[0].x = 0 + BORDER_WIDTH_HALF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 border[0].y = ((shape & SHAPE_CONE_TOP) ? b_height : b_height - CONE_HEIGHT) - BORDER_WIDTH_HALF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 border[1].x = 0 + BORDER_WIDTH_HALF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 border[1].y = ((shape & SHAPE_CONE_TOP) ? CONE_HEIGHT : 0) + BORDER_WIDTH_HALF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 border[2].x = b_width - BORDER_WIDTH_HALF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 border[2].y = border[1].y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 XDrawLines (b_dpy, b_win, b_shineGC, border, 3, CoordModeOrigin);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 /* shadow- bottom right */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 border[0].x = 0 + BORDER_WIDTH_HALF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 border[0].y = ((shape & SHAPE_CONE_TOP) ? b_height : b_height - CONE_HEIGHT) - BORDER_WIDTH_HALF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 border[1].x = b_width - BORDER_WIDTH_HALF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 border[1].y = border[0].y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 border[2].x = b_width - BORDER_WIDTH_HALF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 border[2].y = ((shape & SHAPE_CONE_TOP) ? CONE_HEIGHT : 0) + BORDER_WIDTH_HALF;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 XDrawLines (b_dpy, b_win, b_shadowGC, border, 3, CoordModeOrigin);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 /* cone */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 if (SHAPE_CONE_TOP_LEFT == shape)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 XClearArea (b_dpy, b_win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 CONE_WIDTH / 2 + BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 CONE_HEIGHT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 CONE_WIDTH / 2 - BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 BORDER_WIDTH, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 XDrawLine (b_dpy, b_win, b_shadowGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 CONE_WIDTH / 2 + BORDER_WIDTH_HALF,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 XDrawLine (b_dpy, b_win, b_shineGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 CONE_WIDTH - BORDER_WIDTH_HALF,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 else if (SHAPE_CONE_TOP_RIGHT == shape)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 XClearArea (b_dpy, b_win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 b_width - CONE_WIDTH + BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 CONE_HEIGHT,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 CONE_WIDTH / 2 - BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 BORDER_WIDTH, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 XDrawLine (b_dpy, b_win, b_shadowGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 b_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 b_width - CONE_WIDTH / 2 - BORDER_WIDTH_HALF,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 XDrawLine (b_dpy, b_win, b_shineGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 b_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 b_width - CONE_WIDTH + BORDER_WIDTH_HALF,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 else if (SHAPE_CONE_BOTTOM_LEFT == shape)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 XClearArea (b_dpy, b_win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 CONE_WIDTH / 2 + BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 b_height - CONE_HEIGHT - BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 CONE_WIDTH / 2 - BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 BORDER_WIDTH, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 XDrawLine (b_dpy, b_win, b_shadowGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 b_height - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 CONE_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 b_height - 1 - CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 XDrawLine (b_dpy, b_win, b_shineGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 b_height - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 CONE_WIDTH / 2 + BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 b_height - 1 - CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 else if (SHAPE_CONE_BOTTOM_RIGHT == shape)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 XClearArea (b_dpy, b_win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 b_width - 1 - CONE_WIDTH + BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 b_height - CONE_HEIGHT - BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 CONE_WIDTH / 2 - BORDER_WIDTH - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 BORDER_WIDTH, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 XDrawLine (b_dpy, b_win, b_shadowGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 b_width - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 b_height - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 b_width - 1 - CONE_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 b_height - 1 - CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 XDrawLine (b_dpy, b_win, b_shineGC,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 b_width - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 b_height - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 b_width - 1 - CONE_WIDTH / 2 - BORDER_WIDTH,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 b_height - 1 - CONE_HEIGHT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 /*============================================================================
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 ============================================================================*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 balloon_help_destroy (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 assert (b_dpy != NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 b_dpy = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 destroy_window (b_dpy, b_win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 destroy_gc (b_dpy, b_gc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 destroy_gc (b_dpy, b_shineGC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 destroy_gc (b_dpy, b_shadowGC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 destroy_pixmap_mask ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 destroy_gc (b_dpy, b_maskGC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 if (b_timer) XtRemoveTimeOut (b_timer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 balloon_help_create (Display* dpy,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 Pixel fg, Pixel bg, Pixel shine, Pixel shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 XFontStruct* font)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 if (b_dpy) balloon_help_destroy ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 b_dpy = dpy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 b_fontStruct = font;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 b_win = create_window (dpy, bg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 b_gc = create_gc (dpy, b_win, fg, bg, b_fontStruct);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 b_shineGC = create_gc (dpy, b_win, shine, bg, b_fontStruct);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 b_shadowGC = create_gc (dpy, b_win, shadow, bg, b_fontStruct);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 create_pixmap_mask (1, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 b_maskGC = create_gc (dpy, b_mask, bg, fg, b_fontStruct);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 b_winMapped = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 b_timer = None;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 b_delay = 500;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 b_screenWidth = DisplayWidth (b_dpy, DefaultScreen(b_dpy));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 b_screenHeight = DisplayHeight (b_dpy, DefaultScreen(b_dpy));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 b_lastShape = SHAPE_CONE_FREE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 balloon_help_set_delay (unsigned long milliseconds)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 b_delay = milliseconds;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
544 balloon_help_show (const char* text)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 assert (b_dpy != NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 /* We don't copy the text */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 b_text = text;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 b_lastShape = SHAPE_CONE_FREE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 if (b_winMapped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 /* If help is already being shown, don't delay just update */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 show_help (NULL, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 b_timer =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 XtAppAddTimeOut (XtDisplayToApplicationContext(b_dpy),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 b_delay, show_help, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 balloon_help_hide (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 assert (b_dpy != NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 b_text = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 XUnmapWindow (b_dpy, b_win);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 b_winMapped = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 if (b_timer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 XtRemoveTimeOut (b_timer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 b_timer = None;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 balloon_help_move_to_pointer (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 assert (b_dpy != NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 if (b_winMapped)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 int x, y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 int shape = b_lastShape;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 get_pointer_xy (b_dpy, &x, &y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 x += (shape & SHAPE_CONE_LEFT) ? POINTER_OFFSET : -POINTER_OFFSET;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 y += (shape & SHAPE_CONE_TOP) ? POINTER_OFFSET : -POINTER_OFFSET;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 shape = get_shape (shape, x, y, b_width, b_height, b_screenWidth, b_screenHeight);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 if (shape == b_lastShape)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 XMoveWindow (b_dpy, b_win,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 shape & SHAPE_CONE_LEFT ? x : x - b_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 shape & SHAPE_CONE_TOP ? y : y - b_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 /* text would be off screen, rebuild with new shape */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 b_lastShape = SHAPE_CONE_FREE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 show_help (NULL, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 }