1
by Claude Lecommandeur
CTWM version 1.1 |
1 |
/*
|
2 |
* Copyright 1989 Massachusetts Institute of Technology
|
|
3 |
*
|
|
4 |
* Permission to use, copy, modify, and distribute this software and its
|
|
5 |
* documentation for any purpose and without fee is hereby granted, provided
|
|
6 |
* that the above copyright notice appear in all copies and that both that
|
|
7 |
* copyright notice and this permission notice appear in supporting
|
|
8 |
* documentation, and that the name of M.I.T. not be used in advertising
|
|
9 |
* or publicity pertaining to distribution of the software without specific,
|
|
10 |
* written prior permission. M.I.T. makes no representations about the
|
|
11 |
* suitability of this software for any purpose. It is provided "as is"
|
|
12 |
* without express or implied warranty.
|
|
13 |
*
|
|
14 |
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
|
15 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
|
|
16 |
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
17 |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
18 |
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
1
by Claude Lecommandeur
CTWM version 1.1 |
19 |
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
20 |
*/
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
21 |
/*
|
11
by Claude Lecommandeur
CTWM version 3.2p1 |
22 |
* [ ctwm ]
|
23 |
*
|
|
24 |
* Copyright 1992 Claude Lecommandeur.
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
25 |
*
|
11
by Claude Lecommandeur
CTWM version 3.2p1 |
26 |
* Permission to use, copy, modify and distribute this software [ctwm] and
|
27 |
* its documentation for any purpose is hereby granted without fee, provided
|
|
28 |
* that the above copyright notice appear in all copies and that both that
|
|
29 |
* copyright notice and this permission notice appear in supporting documen-
|
|
30 |
* tation, and that the name of Claude Lecommandeur not be used in adverti-
|
|
31 |
* sing or publicity pertaining to distribution of the software without
|
|
32 |
* specific, written prior permission. Claude Lecommandeur make no represen-
|
|
33 |
* tations about the suitability of this software for any purpose. It is
|
|
34 |
* provided "as is" without express or implied warranty.
|
|
35 |
*
|
|
36 |
* Claude Lecommandeur DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
37 |
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
|
|
38 |
* EVENT SHALL Claude Lecommandeur BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
39 |
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
|
|
40 |
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
41 |
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
42 |
* PERFORMANCE OF THIS SOFTWARE.
|
|
43 |
*
|
|
44 |
* Author: Claude Lecommandeur [ lecom@sic.epfl.ch ][ April 1992 ]
|
|
45 |
*/
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
46 |
|
47 |
/***********************************************************************
|
|
48 |
*
|
|
49 |
* $XConsortium: cursor.c,v 1.10 89/12/14 14:52:23 jim Exp $
|
|
50 |
*
|
|
51 |
* cursor creation code
|
|
52 |
*
|
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
53 |
* 05-Apr-89 Thomas E. LaStrange File created
|
1
by Claude Lecommandeur
CTWM version 1.1 |
54 |
*
|
55 |
* Do the necessary modification to be integrated in ctwm.
|
|
56 |
* Can no longer be used for the standard twm.
|
|
57 |
*
|
|
58 |
* 22-April-92 Claude Lecommandeur.
|
|
59 |
*
|
|
60 |
*
|
|
61 |
***********************************************************************/
|
|
62 |
||
395.1.1
by Matthew Fuller
Move ctwm.h to always be included first. |
63 |
#include "ctwm.h" |
64 |
||
1
by Claude Lecommandeur
CTWM version 1.1 |
65 |
#include <stdio.h> |
340.1.1
by Matthew Fuller
Rearrange includes to be in what we'll call the Proper Order. |
66 |
|
492.2.11
by Matthew Fuller
Pull the X11/cursorfont.h out of ctwm.h, and include it in the two |
67 |
#include <X11/cursorfont.h> |
68 |
||
1
by Claude Lecommandeur
CTWM version 1.1 |
69 |
#include "screen.h" |
93
by Richard Levitte
- Convert all functions to use proper prototypes. |
70 |
#include "cursor.h" |
479.1.11
by Matthew Fuller
Rename image_xbm to image_bitmap to better match our internal naming, |
71 |
#include "image_bitmap.h" |
1
by Claude Lecommandeur
CTWM version 1.1 |
72 |
|
73 |
static struct _CursorName { |
|
323.1.1
by Matthew Fuller
Dribble a couple const's through these things that are... y'know. |
74 |
const char *name; |
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
75 |
unsigned int shape; |
76 |
Cursor cursor; |
|
1
by Claude Lecommandeur
CTWM version 1.1 |
77 |
} cursor_names[] = { |
78 |
||
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
79 |
{"X_cursor", XC_X_cursor, None}, |
80 |
{"arrow", XC_arrow, None}, |
|
81 |
{"based_arrow_down", XC_based_arrow_down, None}, |
|
82 |
{"based_arrow_up", XC_based_arrow_up, None}, |
|
83 |
{"boat", XC_boat, None}, |
|
84 |
{"bogosity", XC_bogosity, None}, |
|
85 |
{"bottom_left_corner", XC_bottom_left_corner, None}, |
|
86 |
{"bottom_right_corner", XC_bottom_right_corner, None}, |
|
87 |
{"bottom_side", XC_bottom_side, None}, |
|
88 |
{"bottom_tee", XC_bottom_tee, None}, |
|
89 |
{"box_spiral", XC_box_spiral, None}, |
|
90 |
{"center_ptr", XC_center_ptr, None}, |
|
91 |
{"circle", XC_circle, None}, |
|
92 |
{"clock", XC_clock, None}, |
|
93 |
{"coffee_mug", XC_coffee_mug, None}, |
|
94 |
{"cross", XC_cross, None}, |
|
95 |
{"cross_reverse", XC_cross_reverse, None}, |
|
96 |
{"crosshair", XC_crosshair, None}, |
|
97 |
{"diamond_cross", XC_diamond_cross, None}, |
|
98 |
{"dot", XC_dot, None}, |
|
99 |
{"dotbox", XC_dotbox, None}, |
|
100 |
{"double_arrow", XC_double_arrow, None}, |
|
101 |
{"draft_large", XC_draft_large, None}, |
|
102 |
{"draft_small", XC_draft_small, None}, |
|
103 |
{"draped_box", XC_draped_box, None}, |
|
104 |
{"exchange", XC_exchange, None}, |
|
105 |
{"fleur", XC_fleur, None}, |
|
106 |
{"gobbler", XC_gobbler, None}, |
|
107 |
{"gumby", XC_gumby, None}, |
|
108 |
{"hand1", XC_hand1, None}, |
|
109 |
{"hand2", XC_hand2, None}, |
|
110 |
{"heart", XC_heart, None}, |
|
111 |
{"icon", XC_icon, None}, |
|
112 |
{"iron_cross", XC_iron_cross, None}, |
|
113 |
{"left_ptr", XC_left_ptr, None}, |
|
114 |
{"left_side", XC_left_side, None}, |
|
115 |
{"left_tee", XC_left_tee, None}, |
|
116 |
{"leftbutton", XC_leftbutton, None}, |
|
117 |
{"ll_angle", XC_ll_angle, None}, |
|
118 |
{"lr_angle", XC_lr_angle, None}, |
|
119 |
{"man", XC_man, None}, |
|
120 |
{"middlebutton", XC_middlebutton, None}, |
|
121 |
{"mouse", XC_mouse, None}, |
|
122 |
{"pencil", XC_pencil, None}, |
|
123 |
{"pirate", XC_pirate, None}, |
|
124 |
{"plus", XC_plus, None}, |
|
125 |
{"question_arrow", XC_question_arrow, None}, |
|
126 |
{"right_ptr", XC_right_ptr, None}, |
|
127 |
{"right_side", XC_right_side, None}, |
|
128 |
{"right_tee", XC_right_tee, None}, |
|
129 |
{"rightbutton", XC_rightbutton, None}, |
|
130 |
{"rtl_logo", XC_rtl_logo, None}, |
|
131 |
{"sailboat", XC_sailboat, None}, |
|
132 |
{"sb_down_arrow", XC_sb_down_arrow, None}, |
|
133 |
{"sb_h_double_arrow", XC_sb_h_double_arrow, None}, |
|
134 |
{"sb_left_arrow", XC_sb_left_arrow, None}, |
|
135 |
{"sb_right_arrow", XC_sb_right_arrow, None}, |
|
136 |
{"sb_up_arrow", XC_sb_up_arrow, None}, |
|
137 |
{"sb_v_double_arrow", XC_sb_v_double_arrow, None}, |
|
138 |
{"shuttle", XC_shuttle, None}, |
|
139 |
{"sizing", XC_sizing, None}, |
|
140 |
{"spider", XC_spider, None}, |
|
141 |
{"spraycan", XC_spraycan, None}, |
|
142 |
{"star", XC_star, None}, |
|
143 |
{"target", XC_target, None}, |
|
144 |
{"tcross", XC_tcross, None}, |
|
145 |
{"top_left_arrow", XC_top_left_arrow, None}, |
|
146 |
{"top_left_corner", XC_top_left_corner, None}, |
|
147 |
{"top_right_corner", XC_top_right_corner, None}, |
|
148 |
{"top_side", XC_top_side, None}, |
|
149 |
{"top_tee", XC_top_tee, None}, |
|
150 |
{"trek", XC_trek, None}, |
|
151 |
{"ul_angle", XC_ul_angle, None}, |
|
152 |
{"umbrella", XC_umbrella, None}, |
|
153 |
{"ur_angle", XC_ur_angle, None}, |
|
154 |
{"watch", XC_watch, None}, |
|
155 |
{"xterm", XC_xterm, None}, |
|
1
by Claude Lecommandeur
CTWM version 1.1 |
156 |
};
|
157 |
||
323.1.1
by Matthew Fuller
Dribble a couple const's through these things that are... y'know. |
158 |
void NewFontCursor(Cursor *cp, const char *str) |
1
by Claude Lecommandeur
CTWM version 1.1 |
159 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
160 |
int i; |
1
by Claude Lecommandeur
CTWM version 1.1 |
161 |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
162 |
for(i = 0; i < sizeof(cursor_names) / sizeof(struct _CursorName); i++) { |
163 |
if(strcmp(str, cursor_names[i].name) == 0) { |
|
164 |
if(cursor_names[i].cursor == None) |
|
165 |
cursor_names[i].cursor = XCreateFontCursor(dpy, |
|
166 |
cursor_names[i].shape); |
|
167 |
*cp = cursor_names[i].cursor; |
|
168 |
return; |
|
169 |
}
|
|
1
by Claude Lecommandeur
CTWM version 1.1 |
170 |
}
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
171 |
fprintf(stderr, "%s: unable to find font cursor \"%s\"\n", |
172 |
ProgramName, str); |
|
1
by Claude Lecommandeur
CTWM version 1.1 |
173 |
}
|
174 |
||
93
by Richard Levitte
- Convert all functions to use proper prototypes. |
175 |
int NewBitmapCursor(Cursor *cp, char *source, char *mask) |
1
by Claude Lecommandeur
CTWM version 1.1 |
176 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
177 |
XColor fore, back; |
178 |
int hotx, hoty; |
|
179 |
int sx, sy, mx, my; |
|
180 |
unsigned int sw, sh, mw, mh; |
|
181 |
Pixmap spm, mpm; |
|
182 |
Colormap cmap = Scr->RootColormaps.cwins[0]->colormap->c; |
|
183 |
||
184 |
fore.pixel = Scr->Black; |
|
185 |
XQueryColor(dpy, cmap, &fore); |
|
186 |
back.pixel = Scr->White; |
|
187 |
XQueryColor(dpy, cmap, &back); |
|
188 |
||
189 |
spm = GetBitmap(source); |
|
190 |
if((hotx = HotX) < 0) { |
|
191 |
hotx = 0; |
|
192 |
}
|
|
193 |
if((hoty = HotY) < 0) { |
|
194 |
hoty = 0; |
|
195 |
}
|
|
196 |
mpm = GetBitmap(mask); |
|
197 |
||
198 |
/* make sure they are the same size */
|
|
199 |
||
200 |
XGetGeometry(dpy, spm, &JunkRoot, &sx, &sy, &sw, &sh, &JunkBW, &JunkDepth); |
|
201 |
XGetGeometry(dpy, mpm, &JunkRoot, &mx, &my, &mw, &mh, &JunkBW, &JunkDepth); |
|
202 |
if(sw != mw || sh != mh) { |
|
203 |
fprintf(stderr, |
|
204 |
"%s: cursor bitmaps \"%s\" and \"%s\" not the same size\n", |
|
205 |
ProgramName, source, mask); |
|
206 |
return (1); |
|
207 |
}
|
|
208 |
*cp = XCreatePixmapCursor(dpy, spm, mpm, &fore, &back, hotx, hoty); |
|
209 |
return (0); |
|
1
by Claude Lecommandeur
CTWM version 1.1 |
210 |
}
|
17
by Claude Lecommandeur
CTWM version 3.5 |
211 |
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
212 |
Cursor MakeStringCursor(char *string) |
17
by Claude Lecommandeur
CTWM version 3.5 |
213 |
{
|
304.1.2
by Matthew Fuller
Run 'make indent' to reindent the world. |
214 |
Cursor cursor; |
215 |
XColor black, white; |
|
216 |
Pixmap bitmap; |
|
217 |
unsigned int width, height, middle; |
|
218 |
GC gc; |
|
219 |
Colormap cmap = Scr->RootColormaps.cwins[0]->colormap->c; |
|
220 |
MyFont myfont = Scr->TitleBarFont; |
|
221 |
XRectangle inc_rect; |
|
222 |
XRectangle logical_rect; |
|
223 |
||
224 |
black.pixel = Scr->Black; |
|
225 |
XQueryColor(dpy, cmap, &black); |
|
226 |
white.pixel = Scr->White; |
|
227 |
XQueryColor(dpy, cmap, &white); |
|
228 |
||
229 |
XmbTextExtents(myfont.font_set, string, strlen(string), |
|
230 |
&inc_rect, &logical_rect); |
|
231 |
width = logical_rect.width + 4; |
|
232 |
height = logical_rect.height + 2; |
|
233 |
middle = myfont.ascent; |
|
234 |
/*XQueryBestCursor (dpy, Scr->Root, width, height, &rwidth, &rheight);*/
|
|
235 |
||
236 |
bitmap = XCreatePixmap(dpy, Scr->Root, width, height, 1); |
|
237 |
gc = XCreateGC(dpy, bitmap, 0L, NULL); |
|
238 |
||
239 |
XSetForeground(dpy, gc, 0L); |
|
240 |
XFillRectangle(dpy, bitmap, gc, 0, 0, width, height); |
|
241 |
XSetForeground(dpy, gc, 1L); |
|
242 |
XDrawRectangle(dpy, bitmap, gc, 0, 0, width - 1, height - 1); |
|
243 |
||
244 |
XmbDrawString(dpy, bitmap, myfont.font_set, |
|
245 |
gc, 2, middle, string, strlen(string)); |
|
246 |
||
247 |
cursor = XCreatePixmapCursor(dpy, bitmap, None, &black, &white, 0, 0); |
|
248 |
XFreePixmap(dpy, bitmap); |
|
249 |
XFreeGC(dpy, gc); |
|
250 |
return (cursor); |
|
17
by Claude Lecommandeur
CTWM version 3.5 |
251 |
}
|