OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [insight/] [tk/] [win/] [tkWinCursor.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.