;*** display a draw widget. As the cursor is moved close to the center
;*** of the widget, its appearance should change from "sad" to "happy"
Hello,
I have a problem with cursor shape control.
According to the documentation, calls to DEVICE are sticky and should
remain until explicitly changed to another value. However, it seems that
calls to DEVICE,cursor_image=pattern, cursor_XY=[8,8], cursor_mask=mask
do not follow this rule. The test program below should show the problem.
The shape of the cursor is supposed to change from a sad to a happy face
as the cursor it moved toward the center of the window. Somehow, on my
system (5.4, Win98) its blinking arrow/face as it is moved. Any help
would be most welcome.
Thanks
Thomas
PS: the integer array for cursor shape is not OS independent but even if
you don't see the face the problem should be obvious
PRO testcursor_event, event
Widget_control, Event.top, Get_Uvalue=Info, /no_copy
distance=SQRT((info.sizedraw[0]/2-event.x)^2+$
(info.sizedraw[1]/2-event.y)^2)$
/SQRT((info.sizedraw[0]/2.0)^2+(info.sizedraw[1]/2.0)^2)
set=(Fix(distance/0.3))<2
;*** change cursor face depending on the distance to the target
pattern=[0,-8185,6168,1056,1056,576,576,576,$
576,576,576,1056,1056,6168,-8185,0]
Case set of ;*** 1:smile, 2:neutral, 3:sad
0: mask=[-8185,-2017,7224,1632,13932,13260,13260,$
-31807,-31807,3024,13260,-14749,1632,7224,-2017,-8185]
1: mask=[-8185,-2017,7224,1632,13932,13260,13260,$
-31807,-31807,960,960,-2449,1632,7224,-2017,-8185]
2: mask=[-8185,-2017,7224,1632,13932,13260,13260,$
-31807,-31807,960,-15421,9828,5736,7224,-2017,-8185]
;*** smilling by default :-)
Else: mask=[-8185,-2017,7224,1632,13932,13260,13260,$
-31807,-31807,3024,13260,-14749,1632,7224,-2017,-8185]
EndCase
device,cursor_image=pattern, cursor_XY=[8,8], cursor_mask=mask
Widget_control, Event.top, Set_Uvalue=Info, /no_copy
end;*********************** end of testcursor_event
******************************
Pro testcursor
Device, Get_Screen_Size=screenSize
Sizedraw=[screenSize[0]/2,screenSize[1]/2]
testcursor_tlb = Widget_Base(/Column,
Title='testcursor',TLB_Frame_Attr=1)
drawWidgetID=widget_draw(testcursor_tlb, /Motion_events,
Xsize=sizedraw[0], Ysize=sizedraw[1])
Widget_Control, testcursor_tlb, /Realize
Widget_control, drawWidgetID, get_value=windraw & windraw=windraw[0]
wset, windraw
info={$
drawWidgetID: drawWidgetID,$ ; the draw widget ID
windraw: windraw,$ ; the direct graphic window
sizedraw: sizedraw} ; [xdim,ydim] size
WIDGET_CONTROL, testcursor_tlb, SET_UVALUE=info, /NO_COPY
XManager, 'testcursor',testcursor_tlb ,$
EVENT_HANDLER='testcursor_event', /no_block
return
End
|