1 /****************************************************************************/
3 /* ALLIANCE CAD FRAMEWORK */
5 /* Tool : libXal Version 1.01 */
8 /* (c) copyright 1993 MASI Laboratory. CAO & VLSI CAD Team */
9 /* All rights reserved. */
10 /* Support : e-mail cao-vlsi@masi.ibp.fr */
12 /* Author(s) : Nizar ABDALLAH Date : 02/02/1993 */
14 /* Modified by : Nizar Date : 02/03/1993 */
15 /* Add the function XalPirateCursor. */
17 /* Modified by : Lionel PROTZENKO Date : 04/04/1997 */
18 /* Modified by : Date : ../../.... */
20 /****************************************************************************/
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. */
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. */
30 /* When called, the third function makes the cursor looks like a pirate flag*/
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. */
36 /****************************************************************************/
39 /*--------------------------------------------------------------------------*/
41 /*--------------------------------------------------------------------------*/
45 #include <X11/cursorfont.h>
46 #include <X11/Intrinsic.h>
48 /*-----------------------------*/
49 /* Motif for Alliance includes */
50 /*-----------------------------*/
55 /*--------------------------------------------------------------------------*/
57 /*--------------------------------------------------------------------------*/
58 static Widget xal_topshell
, xal_diashell
;
60 static Cursor xal_busycursor
= (Cursor
)NULL
;
61 static Cursor xal_normalcursor
= (Cursor
)NULL
;
62 static Cursor xal_piratecursor
= (Cursor
)NULL
;
65 /*--------------------------------------------------------------------------*/
67 /*--------------------------------------------------------------------------*/
69 /*---------------------------------------------------------------------------*/
71 /* FUNCTION : XalSetPointer */
73 /* IN ARGS : .widget : The widget that will serve to get the display pointer*/
74 /* .cursorid : A previous created cursor. */
76 /* OUT ARGS : ( void ) */
78 /* OBJECT : Makes cursorid the current cursor of the display. */
80 /*---------------------------------------------------------------------------*/
81 void XalSetPointer( widget
, cursorid
)
85 XDefineCursor(XtDisplay(widget
), XtWindow(widget
), cursorid
);
89 /*---------------------------------------------------------------------------*/
91 /* FUNCTION : XalSetCursor */
93 /* IN ARGS : .w : The widget that will serve to get the display pointer. */
94 /* .t : The type of the cursor wanted */
96 /* OUT ARGS : ( void ) */
98 /* OBJECT : Makes the cursor pointer appears as defined type */
100 /*---------------------------------------------------------------------------*/
101 void XalSetCursor( w
, t
)
108 if ( w
!= (Widget
)0 )
110 /*---------------------------------------*/
111 /* Locate the shell we are interested in */
112 /*---------------------------------------*/
113 for (xal_diashell
= w
; !XtIsShell(xal_diashell
);xal_diashell
= XtParent(xal_diashell
)) ;
115 /*------------------------------------*/
116 /* Locate it's primary window's shell */
117 /*------------------------------------*/
118 for (xal_topshell
= xal_diashell
; !XtIsTopLevelShell(xal_topshell
);xal_topshell
= XtParent(xal_topshell
)) ;
120 /*--------------------------------------------------------*/
121 /* If this is the first time, then create the cursor type */
122 /*--------------------------------------------------------*/
125 dpy
= XtDisplay( xal_diashell
) ;
128 case NORMAL
: if ( !xal_normalcursor
)
129 xal_normalcursor
= XCreateFontCursor( dpy
,XC_top_left_arrow
);
131 /*------------------------------*/
132 /* Cancel all bufferized events */
133 /*------------------------------*/
134 while (XCheckMaskEvent( dpy
,
135 ButtonPressMask
| ButtonReleaseMask
|
136 ButtonMotionMask
| PointerMotionMask
|
137 KeyPressMask
, &event
) );
142 XalSetPointer(xal_topshell
,xal_normalcursor
);
143 XalForceUpdate( xal_topshell
);
146 case WAIT
: if ( !xal_busycursor
)
148 dpy
= XtDisplay( xal_diashell
) ;
149 xal_busycursor
= XCreateFontCursor( dpy
,XC_watch
) ;
152 XalSetPointer(xal_topshell
, xal_busycursor
);
153 XalForceUpdate( xal_topshell
);
156 case PIRATE
: if ( !xal_piratecursor
)
158 dpy
= XtDisplay( xal_diashell
) ;
159 xal_piratecursor
= XCreateFontCursor( dpy
,XC_pirate
) ;
162 XalSetPointer(xal_topshell
, xal_piratecursor
);
163 XalForceUpdate( xal_topshell
);