Kelly Dean (dean@phobos.cira.colostate.edu) wrote:
> I am attempting to use WIDGET_CONTROL to pass a structure to a widget
> _EVENT PRO. However, I am getting an invalid event id. I am working with
> IDL for Windows 3.5.1.
> My goal here is to have two separate window displays with the cursor
> dumping from either window 1 or window 2.
[program deleted]
I have included below my fix to the program. You do not need to use
WIDGET_EVENT to get the x and y values. They are passed along with
the WIDGET_DRAW structure. I tried to mark the parts I changed. Let
me know if there are problems of if you have any questions.
--Keith A. Scollick
BEGIN file.pro --------------------------------------------
FUNCTION Read_Image_Data, file, xsize, ysize
IF N_Params() NE 3 THEN $
Message, 'Must call Read_Image_Data with three parameters.'
Openr, unit, file, /Get_LUN
image = BytArr(xsize,ysize)
ReadU, unit, image
Free_LUN, unit
Return, image
END
PRO KD_DISPLAY_EVENT, event
Widget_Control, event.id, GET_UVALUE = eventval
WIDGET_CONTROL, event.handler, GET_UVALUE = WDRAWstr
CASE eventval OF
"DRAW_WIN_EVENT" : BEGIN
WSET, WDRAWSTR.Win_id
WSHOW, WDRAWSTR.Win_id
x = event.x ; ***************
y = event.y ; ***************
;PRINT, ' X >', x,' Y >',y
xy = strtrim(x)+','+strtrim(y) ; ***********
widget_control,wdrawstr.place,set_value=xy ; ******
END
ENDCASE
END
PRO KD_DISPLAY, Parent, name, image, xsize, ysize, wedit ; *******
wBase = WIDGET_BASE(title = name, GROUP_LEADER = Parent)
wDraw = WIDGET_DRAW(wBase, $
UVALUE = 'DRAW_WIN_EVENT', $
XSIZE=xsize, YSIZE=ysize, $
/MOTION_EVENTS, $
/BUTTON_EVENTS, $
RETAIN = 2)
WIDGET_CONTROL, wBase, /REALIZE
WIDGET_CONTROL, wDraw, GET_VALUE = Win
WSET, Win
WSHOW, Win
TV, image
WDRAWstr = { WDRAWSTR, Par_id:Parent, Win_id:Win, place:wedit } ; *******
XManager, 'KD_DISPLAY' , wBase
WIDGET_CONTROL, wBase, SET_UVALUE = WDRAWstr
END
PRO mine_event, event
widget_control, event.top, get_uvalue=wedit ; ********
WIDGET_CONTROL, Event.Id, GET_UVALUE = Ev
CASE Ev OF
"IMAGE1": BEGIN
name = 'ctscan.dat'
xsize = 256
ysize = 256
image = Read_Image_Data(Filepath(Subdir='images', name), $
xsize, ysize)
KD_DISPLAY, Event.top, name, image, xsize, ysize, wedit ; **
END
"IMAGE2": BEGIN
name = 'galaxy.dat'
xsize = 256
ysize = 256
image = Read_Image_Data(Filepath(Subdir='images', name), $
xsize, ysize)
KD_DISPLAY, Event.top, name, image, xsize, ysize, wedit ; **
END
"QUIT": WIDGET_CONTROL, Event.Top, /DESTROY
ENDCASE
if widget_info(event.top, /valid) then $ ; *************
widget_control, event.top, set_uvalue=wedit ; *************
END
PRO MINE
wBase = WIDGET_BASE(/COLUMN)
wBase2 = WIDGET_BASE(wBase, /ROW)
wButton = WIDGET_BUTTON(wBase2, VALUE="Image1", UVALUE="IMAGE1")
wButton = WIDGET_BUTTON(wBase2, VALUE="Image2", UVALUE="IMAGE2")
wBase2 = WIDGET_BASE(wBase, /ROW)
wLabel = WIDGET_LABEL(wBase2, VALUE="Cursor position:", /FRAME)
wEdit = WIDGET_TEXT(wBase2, VALUE='0,0', EDITABLE=0)
wButton = WIDGET_BUTTON(wBase, VALUE="Quit", UVALUE="QUIT")
WIDGET_CONTROL, wBase, /REALIZE
widget_control,wbase, set_uvalue=wedit ; *************
XMANAGER, "MINE", wBase
END
END file.pro -------------------------------------------------------
|