IDL程序中修改鼠标显示 - ENVI/IDL空间 - ALL FOR GIS —GIS,...
来源:百度文库 编辑:神马文学网 时间:2024/04/30 16:14:15
IDL程序中修改鼠标显示
上一篇 / 下一篇 2009-12-08 09:12:33 / 个人分类:IDL技术相关
查看( 24 ) / 评论( 0 ) / 评分( 0 / 0 )在控制如缩放、平移时,希望点击了放大按钮后,鼠标变成放大按钮的状态,然后再进行放大操作。IDL下可以IDLgrWindow->setcurrentcursor方法进行修改,除了默认的鼠标状态外,可以用图片或符号来显示。
;escription:
; 更换鼠标显示状态demo
; Base .MagicBar-ImageInfo;
;
; Author: DYQ 2009-12-07;
;
;创建鼠标形状函数
FUNCTION Cursorcreate, normhand=normhand, $
diamond = diamond, $
handgrasp=handgrasp, $
magic=magic
IF KEYWORD_SET(normhand) THEN BEGIN
strArray = [ $
' ## ', $
' ## # ### ', $
' # ## # # ', $
' # ## # # # ', $
' # # # ## #', $
' # # # # #', $
' ## # # #', $
'# ## #', $
'# # $ # ', $
' # # ', $
' # # ', $
' # # ', $
' ########## ', $
' ######### ', $
' ######## ', $
' ']
ENDIF
IF KEYWORD_SET(handgrasp) THEN BEGIN
strArray = [ $
' ', $
' ', $
' ', $
' ', $
' ', $
' ## ## ## ', $
' # # # ## ', $
' # # # ', $
' # # ', $
' ## # ', $
' # $ # ', $
' # # ', $
' # # ', $
' ######### ', $
' ######## ', $
' ######## ']
ENDIF
IF KEYWORD_SET(diamond) THEN BEGIN
strArray = [ $
' . ', $
' .#. ', $
' .###. ', $
' .#####. ', $
' ....#.... ', $
' .#. .#. .#. ', $
' .##...#...##. ', $
'.######$######. ', $
' .##...#...##. ', $
' .#. .#. .#. ', $
' ....#.... ', $
' .#####. ', $
' .###. ', $
' .#. ', $
' . ', $
' ']
ENDIF
IF KEYWORD_SET(magic) THEN BEGIN
strArray = [ $
' # ', $
' # # # ', $
' ####### ', $
' # # ', $
' # # ', $
' ### ### ', $
' # # ', $
' # # ', $
' ######## ', $
' # # ### ', $
' ### ', $
' ### ', $
' ### ', $
' ###', $
' ', $
' ']
ENDIF
cursor_image = Create_cursor(strArray, HOTSPOT=hotspot, MASK=mask)
REGISTER_CURSOR, 'translate', cursor_image, HOTSPOT=hotspot, MASK=mask
RETURN, cursor_image
END
PRO Test_mousecursor
;
oWindow = OBJ_NEW('IDLgrWindow',dimension =[400,400],retain = 2)
oView = OBJ_NEW('IDLgrView')
oWindow->Draw,oView
;
cursornames = ['ARROW','CROSSHAIR',$
'ICON','IBEAM','MOVE','ORIGINAL',$
'SIZE_NE','SIZE_NW','SIZE_SE',$
'SIZE_SW','SIZE_NS','SIZE_EW',$
'UP_ARROW']
;
FOR i=0,12 DO BEGIN
;
WAIT,0.8
oWindow->Setcurrentcursor,cursornames
oWindow->Draw,oView
ENDFOR
;自定义
WAIT,0.8
cursorImg = Cursorcreate(/normhand)
oWindow->Setcurrentcursor,image=cursorImg
oWindow->Draw,oView
WAIT,0.8
cursorImg = Cursorcreate(/handgrasp)
oWindow->Setcurrentcursor,image=cursorImg
oWindow->Draw,oView
WAIT,0.8
cursorImg = Cursorcreate(/diamond)
oWindow->Setcurrentcursor,image=cursorImg
oWindow->Draw,oView
WAIT,0.8
cursorImg = Cursorcreate(/magic)
oWindow->Setcurrentcursor,image=cursorImg
oWindow->Draw,oView
;
OBJ_DESTROY,[oWindow,oView]
END