/[dtapublic]/projs/trunk/shared_source/c_tk_base_7_5_w_mods/tkwincursor.c
ViewVC logotype

Contents of /projs/trunk/shared_source/c_tk_base_7_5_w_mods/tkwincursor.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 69 - (show annotations) (download)
Sat Nov 5 10:54:17 2016 UTC (8 years, 1 month ago) by dashley
File MIME type: text/plain
File size: 6275 byte(s)
License and property (keyword) changes.
1 /* $Header$ */
2
3 /*
4 * tkWinCursor.c --
5 *
6 * This file contains Win32 specific cursor related routines.
7 *
8 * Copyright (c) 1995 Sun Microsystems, Inc.
9 *
10 * See the file "license.terms" for information on usage and redistribution
11 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12 *
13 * RCS: @(#) $Id: tkwincursor.c,v 1.1.1.1 2001/06/13 05:12:07 dtashley Exp $
14 */
15
16 #include "tkWinInt.h"
17
18 /*
19 * The following data structure contains the system specific data
20 * necessary to control Windows cursors.
21 */
22
23 typedef struct {
24 TkCursor info; /* Generic cursor info used by tkCursor.c */
25 HCURSOR winCursor; /* Win32 cursor handle. */
26 int system; /* 1 if cursor is a system cursor, else 0. */
27 } TkWinCursor;
28
29 /*
30 * The table below is used to map from the name of a predefined cursor
31 * to its resource identifier.
32 */
33
34 static struct CursorName {
35 char *name;
36 LPCTSTR id;
37 } cursorNames[] = {
38 {"starting", IDC_APPSTARTING},
39 {"arrow", IDC_ARROW},
40 {"ibeam", IDC_IBEAM},
41 {"icon", IDC_ICON},
42 {"no", IDC_NO},
43 {"size", IDC_SIZE},
44 {"size_ne_sw", IDC_SIZENESW},
45 {"size_ns", IDC_SIZENS},
46 {"size_nw_se", IDC_SIZENWSE},
47 {"size_we", IDC_SIZEWE},
48 {"uparrow", IDC_UPARROW},
49 {"wait", IDC_WAIT},
50 {"crosshair", IDC_CROSS},
51 {"fleur", IDC_SIZE},
52 {"sb_v_double_arrow", IDC_SIZENS},
53 {"sb_h_double_arrow", IDC_SIZEWE},
54 {"center_ptr", IDC_UPARROW},
55 {"watch", IDC_WAIT},
56 {"xterm", IDC_IBEAM},
57 {NULL, 0}
58 };
59
60 /*
61 * The default cursor is used whenever no other cursor has been specified.
62 */
63
64 #define TK_DEFAULT_CURSOR IDC_ARROW
65
66
67 /*
68 *----------------------------------------------------------------------
69 *
70 * TkGetCursorByName --
71 *
72 * Retrieve a system cursor by name.
73 *
74 * Results:
75 * Returns a new cursor, or NULL on errors.
76 *
77 * Side effects:
78 * Allocates a new cursor.
79 *
80 *----------------------------------------------------------------------
81 */
82
83 TkCursor *
84 TkGetCursorByName(interp, tkwin, string)
85 Tcl_Interp *interp; /* Interpreter to use for error reporting. */
86 Tk_Window tkwin; /* Window in which cursor will be used. */
87 Tk_Uid string; /* Description of cursor. See manual entry
88 * for details on legal syntax. */
89 {
90 struct CursorName *namePtr;
91 TkWinCursor *cursorPtr;
92
93 /*
94 * Check for the cursor in the system cursor set.
95 */
96
97 for (namePtr = cursorNames; namePtr->name != NULL; namePtr++) {
98 if (strcmp(namePtr->name, string) == 0) {
99 break;
100 }
101 }
102
103 cursorPtr = (TkWinCursor *) ckalloc(sizeof(TkWinCursor));
104 cursorPtr->info.cursor = (Tk_Cursor) cursorPtr;
105 cursorPtr->winCursor = NULL;
106 if (namePtr->name != NULL) {
107 cursorPtr->winCursor = LoadCursor(NULL, namePtr->id);
108 cursorPtr->system = 1;
109 }
110 if (cursorPtr->winCursor == NULL) {
111 cursorPtr->winCursor = LoadCursor(Tk_GetHINSTANCE(), string);
112 cursorPtr->system = 0;
113 }
114 if (string[0] == '@') {
115 int argc;
116 char **argv = NULL;
117 if (Tcl_SplitList(interp, string, &argc, &argv) != TCL_OK) {
118 return NULL;
119 }
120 /*
121 * Check for system cursor of type @<filename>, where only
122 * the name is allowed. This accepts either:
123 * -cursor @/winnt/cursors/globe.ani
124 * -cursor @C:/Winnt/cursors/E_arrow.cur
125 * -cursor {@C:/Program\ Files/Cursors/bart.ani}
126 */
127 if ((argc != 1) || (argv[0][0] != '@')) {
128 ckfree((char *) argv);
129 goto badCursorSpec;
130 }
131 if (Tcl_IsSafe(interp)) {
132 Tcl_AppendResult(interp, "can't get cursor from a file in",
133 " a safe interpreter", (char *) NULL);
134 ckfree((char *) argv);
135 ckfree((char *)cursorPtr);
136 return NULL;
137 }
138 cursorPtr->winCursor = LoadCursorFromFile(&(argv[0][1]));
139 cursorPtr->system = 0;
140 ckfree((char *) argv);
141 }
142 if (cursorPtr->winCursor == NULL) {
143 badCursorSpec:
144 ckfree((char *)cursorPtr);
145 Tcl_AppendResult(interp, "bad cursor spec \"", string, "\"",
146 (char *) NULL);
147 return NULL;
148 } else {
149 return (TkCursor *) cursorPtr;
150 }
151 }
152
153 /*
154 *----------------------------------------------------------------------
155 *
156 * TkCreateCursorFromData --
157 *
158 * Creates a cursor from the source and mask bits.
159 *
160 * Results:
161 * Returns a new cursor, or NULL on errors.
162 *
163 * Side effects:
164 * Allocates a new cursor.
165 *
166 *----------------------------------------------------------------------
167 */
168
169 TkCursor *
170 TkCreateCursorFromData(tkwin, source, mask, width, height, xHot, yHot,
171 fgColor, bgColor)
172 Tk_Window tkwin; /* Window in which cursor will be used. */
173 char *source; /* Bitmap data for cursor shape. */
174 char *mask; /* Bitmap data for cursor mask. */
175 int width, height; /* Dimensions of cursor. */
176 int xHot, yHot; /* Location of hot-spot in cursor. */
177 XColor fgColor; /* Foreground color for cursor. */
178 XColor bgColor; /* Background color for cursor. */
179 {
180 return NULL;
181 }
182
183 /*
184 *----------------------------------------------------------------------
185 *
186 * TkpFreeCursor --
187 *
188 * This procedure is called to release a cursor allocated by
189 * TkGetCursorByName.
190 *
191 * Results:
192 * None.
193 *
194 * Side effects:
195 * The cursor data structure is deallocated.
196 *
197 *----------------------------------------------------------------------
198 */
199
200 void
201 TkpFreeCursor(cursorPtr)
202 TkCursor *cursorPtr;
203 {
204 TkWinCursor *winCursorPtr = (TkWinCursor *) cursorPtr;
205 }
206
207 /*
208 *----------------------------------------------------------------------
209 *
210 * TkpSetCursor --
211 *
212 * Set the global cursor. If the cursor is None, then use the
213 * default Tk cursor.
214 *
215 * Results:
216 * None.
217 *
218 * Side effects:
219 * Changes the mouse cursor.
220 *
221 *----------------------------------------------------------------------
222 */
223
224 void
225 TkpSetCursor(cursor)
226 TkpCursor cursor;
227 {
228 HCURSOR hcursor;
229 TkWinCursor *winCursor = (TkWinCursor *) cursor;
230
231 if (winCursor == NULL || winCursor->winCursor == NULL) {
232 hcursor = LoadCursor(NULL, TK_DEFAULT_CURSOR);
233 } else {
234 hcursor = winCursor->winCursor;
235 }
236
237 if (hcursor != NULL) {
238 SetCursor(hcursor);
239 }
240 }
241
242 /* End of tkwincursor.c */

Properties

Name Value
svn:keywords Header

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25