Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / tas / xal / Cursor.c
1 /****************************************************************************/
2 /* */
3 /* ALLIANCE CAD FRAMEWORK */
4 /* */
5 /* Tool : libXal Version 1.01 */
6 /* File : Cursor.c */
7 /* */
8 /* (c) copyright 1993 MASI Laboratory. CAO & VLSI CAD Team */
9 /* All rights reserved. */
10 /* Support : e-mail cao-vlsi@masi.ibp.fr */
11 /* */
12 /* Author(s) : Nizar ABDALLAH Date : 02/02/1993 */
13 /* */
14 /* Modified by : Nizar Date : 02/03/1993 */
15 /* Add the function XalPirateCursor. */
16 /* */
17 /* Modified by : Lionel PROTZENKO Date : 04/04/1997 */
18 /* Modified by : Date : ../../.... */
19 /* */
20 /****************************************************************************/
21 /* */
22 /* This file describes a set of functions which provide manipulations on */
23 /* cursor look. One is to create a cursor with a particular look. This is */
24 /* an internal function not accessible to users. */
25 /* */
26 /* When called, the second function makes the cursor looks like a watch. */
27 /* This function can be used to tell the user that some non visible */
28 /* treatments are in progress. */
29 /* */
30 /* When called, the third function makes the cursor looks like a pirate flag*/
31 /* */
32 /* The last one makes the cursor appears normally. This function can be */
33 /* called after a treatment to tell the user that it's up to him again. All */
34 /* the bufferized events are cleared before returning. */
35 /* */
36 /****************************************************************************/
37
38
39 /*--------------------------------------------------------------------------*/
40 /* INCLUDE FILES */
41 /*--------------------------------------------------------------------------*/
42 /*----------------*/
43 /* Motif includes */
44 /*----------------*/
45 #include <X11/cursorfont.h>
46 #include <X11/Intrinsic.h>
47
48 /*-----------------------------*/
49 /* Motif for Alliance includes */
50 /*-----------------------------*/
51 #include MUT_H
52
53 #include XAL_H
54
55 /*--------------------------------------------------------------------------*/
56 /* WORK VARIABLES */
57 /*--------------------------------------------------------------------------*/
58 static Widget xal_topshell, xal_diashell;
59
60 static Cursor xal_busycursor = (Cursor)NULL;
61 static Cursor xal_normalcursor = (Cursor)NULL;
62 static Cursor xal_piratecursor = (Cursor)NULL;
63
64
65 /*--------------------------------------------------------------------------*/
66 /* FUNCTIONS */
67 /*--------------------------------------------------------------------------*/
68
69 /*---------------------------------------------------------------------------*/
70 /* */
71 /* FUNCTION : XalSetPointer */
72 /* */
73 /* IN ARGS : .widget : The widget that will serve to get the display pointer*/
74 /* .cursorid : A previous created cursor. */
75 /* */
76 /* OUT ARGS : ( void ) */
77 /* */
78 /* OBJECT : Makes cursorid the current cursor of the display. */
79 /* */
80 /*---------------------------------------------------------------------------*/
81 void XalSetPointer( widget, cursorid )
82 Widget widget;
83 Cursor cursorid;
84 {
85 XDefineCursor(XtDisplay(widget), XtWindow(widget), cursorid);
86 }
87
88
89 /*---------------------------------------------------------------------------*/
90 /* */
91 /* FUNCTION : XalSetCursor */
92 /* */
93 /* IN ARGS : .w : The widget that will serve to get the display pointer. */
94 /* .t : The type of the cursor wanted */
95 /* */
96 /* OUT ARGS : ( void ) */
97 /* */
98 /* OBJECT : Makes the cursor pointer appears as defined type */
99 /* */
100 /*---------------------------------------------------------------------------*/
101 void XalSetCursor( w, t )
102 Widget w;
103 int t;
104 {
105 Display *dpy = NULL;
106 XEvent event;
107
108 if ( w != (Widget)0 )
109 {
110 /*---------------------------------------*/
111 /* Locate the shell we are interested in */
112 /*---------------------------------------*/
113 for (xal_diashell = w; !XtIsShell(xal_diashell);xal_diashell = XtParent(xal_diashell)) ;
114
115 /*------------------------------------*/
116 /* Locate it's primary window's shell */
117 /*------------------------------------*/
118 for (xal_topshell = xal_diashell; !XtIsTopLevelShell(xal_topshell);xal_topshell = XtParent(xal_topshell)) ;
119
120 /*--------------------------------------------------------*/
121 /* If this is the first time, then create the cursor type */
122 /*--------------------------------------------------------*/
123
124 if ( t == NORMAL )
125 dpy = XtDisplay( xal_diashell ) ;
126
127 switch ( t ) {
128 case NORMAL : if ( !xal_normalcursor )
129 xal_normalcursor = XCreateFontCursor( dpy,XC_top_left_arrow );
130
131 /*------------------------------*/
132 /* Cancel all bufferized events */
133 /*------------------------------*/
134 while (XCheckMaskEvent( dpy,
135 ButtonPressMask | ButtonReleaseMask |
136 ButtonMotionMask | PointerMotionMask |
137 KeyPressMask, &event) );
138 /*------------*/
139 /* do nothing */
140 /*------------*/
141
142 XalSetPointer(xal_topshell,xal_normalcursor);
143 XalForceUpdate( xal_topshell );
144 break;
145
146 case WAIT : if ( !xal_busycursor )
147 {
148 dpy = XtDisplay( xal_diashell ) ;
149 xal_busycursor = XCreateFontCursor( dpy,XC_watch ) ;
150 }
151
152 XalSetPointer(xal_topshell, xal_busycursor);
153 XalForceUpdate( xal_topshell );
154 break;
155
156 case PIRATE : if ( !xal_piratecursor )
157 {
158 dpy = XtDisplay( xal_diashell ) ;
159 xal_piratecursor = XCreateFontCursor( dpy,XC_pirate ) ;
160 }
161
162 XalSetPointer(xal_topshell, xal_piratecursor);
163 XalForceUpdate( xal_topshell );
164 break;
165
166 default : break;
167 }
168 }
169 }