1 /*------------------------------------------------------------\
2 | |
3 | This file is part of the Alliance CAD System Copyright |
4 | (C) Laboratoire LIP6 - D�partement ASIM Universite P&M Curie|
5 | |
6 | Home page : http://www-asim.lip6.fr/alliance/ |
7 | E-mail : mailto:alliance-users@asim.lip6.fr |
8 | |
9 | This progam is free software; you can redistribute it |
10 | and/or modify it under the terms of the GNU General Public |
11 | License as published by the Free Software Foundation; |
12 | either version 2 of the License, or (at your option) any |
13 | later version. |
14 | |
15 | Alliance VLSI CAD System is distributed in the hope that |
16 | it will be useful, but WITHOUT ANY WARRANTY; |
17 | without even the implied warranty of MERCHANTABILITY or |
18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
19 | Public License for more details. |
20 | |
21 | You should have received a copy of the GNU General Public |
22 | License along with the GNU C Library; see the file COPYING. |
23 | If not, write to the Free Software Foundation, Inc., |
24 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
25 | |
26 \------------------------------------------------------------*/
27
28 /*------------------------------------------------------------\
29 | |
30 | Tool : GRAAL |
31 | |
32 | File : cursor.c |
33 | |
34 | Author : Jacomme Ludovic |
35 | |
36 | Date : 28.03.95 |
37 | |
38 \------------------------------------------------------------*/
39
40 /*------------------------------------------------------------\
41 | |
42 | Include Files |
43 | |
44 \------------------------------------------------------------*/
45
46 # include <stdio.h>
47 # include <X11/cursorfont.h>
48 # include <X11/Intrinsic.h>
49 # include <Xm/Xm.h>
50 # include "mut.h"
51 # include "rds.h"
52 # include "GTB.h"
53 # include "GTB_cursor.h"
54
55 /*------------------------------------------------------------\
56 | |
57 | Constants |
58 | |
59 \------------------------------------------------------------*/
60 /*------------------------------------------------------------\
61 | |
62 | Types |
63 | |
64 \------------------------------------------------------------*/
65 /*------------------------------------------------------------\
66 | |
67 | Variables |
68 | |
69 \------------------------------------------------------------*/
70
71 static GraalMouseCursor GraalMouseCursorArray [ GRAAL_MAX_CURSOR ] =
72
73 {
74 { XC_left_ptr , True },
75 { XC_watch , True },
76 { XC_pirate , True },
77 { XC_cross_reverse , True },
78 { 0 , True }
79 };
80
81 static char GraalCursorMaskOr [ 8 ] =
82
83 {
84 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
85 };
86
87 static char GraalCursorMaskAnd [ 8 ] =
88
89 {
90 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
91 };
92
93 /*------------------------------------------------------------\
94 | |
95 | Functions |
96 | |
97 \------------------------------------------------------------*/
98 /*------------------------------------------------------------\
99 | |
100 | GraalSetMouseCursor |
101 | |
102 \------------------------------------------------------------*/
103
GraalSetMouseCursor(MainWidget,CursorType)104 void GraalSetMouseCursor( MainWidget, CursorType )
105
106 Widget MainWidget;
107 char CursorType;
108 {
109 Display *DisplayId;
110 Window MainWindow;
111 XColor White;
112 XColor Black;
113 XColor ForgetIt;
114 Colormap ColorMap;
115 Pixmap MaskOr;
116 Pixmap MaskAnd;
117 Cursor Type;
118 Cursor NewCursor;
119
120 rdsbegin();
121
122 DisplayId = XtDisplay( MainWidget );
123 MainWindow = XtWindow( MainWidget );
124
125 Type = GraalMouseCursorArray[ (int)CursorType ].CURSOR;
126
127 if ( GraalMouseCursorArray[ (int)CursorType ].MAKE == True )
128 {
129 if ( Type != 0 )
130 {
131 NewCursor = XCreateFontCursor( DisplayId, Type );
132 }
133 else
134 {
135 ColorMap = DefaultColormapOfScreen ( XtScreen( MainWidget ) );
136
137 XAllocNamedColor( DisplayId, ColorMap, "black", &Black, &ForgetIt );
138 XAllocNamedColor( DisplayId, ColorMap, "white", &White, &ForgetIt );
139
140 MaskOr =
141
142 XCreatePixmapFromBitmapData( DisplayId,
143 MainWindow,
144 GraalCursorMaskOr,
145 8, 8,
146 Black.pixel,
147 White.pixel, 1 );
148
149 MaskAnd =
150
151 XCreatePixmapFromBitmapData( DisplayId,
152 MainWindow,
153 GraalCursorMaskAnd,
154 8, 8,
155 Black.pixel,
156 White.pixel, 1 );
157
158 NewCursor = XCreatePixmapCursor( DisplayId,
159 MaskAnd, MaskOr,
160 &Black, &White, 0, 0 );
161 }
162
163 GraalMouseCursorArray[ (int)CursorType ].CURSOR = NewCursor;
164 GraalMouseCursorArray[ (int)CursorType ].MAKE = False;
165
166 Type = NewCursor;
167 }
168
169 XDefineCursor( DisplayId, MainWindow, Type );
170
171 XmUpdateDisplay( MainWidget );
172
173 rdsend();
174 }
175