Widget_Control [message #2359] |
Tue, 28 June 1994 15:27  |
dean
Messages: 55 Registered: March 1993
|
Member |
|
|
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.
Kelly Dean
CSU/CIRA
================================= Error ===================================
IDL> mine
% WIDGET_EVENT: Invalid widget identifier: 33.
% Execution halted at KD_DISPLAY_EVEN <F:\IDL\TRAINING\MINE.PRO(25)>
(WIDGET_EVENT).
% Called from XMANAGER <E:\IDL35\LIB\WIDGETS\XMANAGER.PRO(458)>.
% Called from MINE <F:\IDL\TRAINING\MINE.PRO( 110)>.
% Called from $MAIN$ .
===================================== Mine.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.top, GET_UVALUE = WDRAWstr
;HELP, /STRUCTURE, WDRAWstr
CASE eventval OF
"DRAW_WIN_EVENT" : BEGIN
WSET, WDRAWSTR.Win_id
WSHOW, WDRAWSTR.Win_id
pxvnt = WIDGET_EVENT(WDRAWSTR.Win_id)
HELP, /STRUCTURE, pxvnt
WHILE (pxvnt.press NE 4 ) DO BEGIN
pxvnt = WIDGET_EVENT(WDRAWSTR.Win_id)
x = pxvnt.x
y = pxvnt.y
PRINT, ' Win >',wid,' X >', x,' Y >',y
ENDWHILE
END
ENDCASE
END
PRO KD_DISPLAY, Parent, name, image, xsize, ysize
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 }
XManager, 'KD_DISPLAY' , wBase
WIDGET_CONTROL, wBase, SET_UVALUE = WDRAWstr
END
PRO mine_event, event
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
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
END
"QUIT": WIDGET_CONTROL, Event.Top, /DESTROY
ENDCASE
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
XMANAGER, "MINE", wBase
END
|
|
|
Re: Widget_Control [message #2408 is a reply to message #2359] |
Wed, 29 June 1994 09:40   |
8015
Messages: 52 Registered: November 1993
|
Member |
|
|
In article <Cs4p1L.1st6@yuma.acns.colostate.edu>,
<dean%phobos.dnet@sirius.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.
>
> ================================= Error ===================================
> IDL> mine
> % WIDGET_EVENT: Invalid widget identifier: 33.
>
> ===================================== Mine.pro ===============================
I didn't make a thorough effort at debugging this because of some
problems you need to take care of first. Each of the widget_id's on the
left hand side of the "=" need to be unique names. These will store a
"long" value as the widget is created. In several places you are
reusing the same name which will cause the previous widget's id of the
same name to be lost.
>
> wBase = WIDGET_BASE(title = name, GROUP_LEADER = Parent)
> 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)
> wButton = WIDGET_BUTTON(wBase, VALUE="Quit", UVALUE="QUIT")
>
Each of these names need to be unique. You can use wBase1, thru wBase4
(or something more descriptive), and maybe im1_button, im2_button and
quit_button instead of the wButton's. I'll take another look if you are
still having problems after resolving the naming issue.
I've done what you are trying to do (two drawing widgets with info from
each) and don't mind providing info along the way. Maybe I can keep you
out of some of the same pits I fell into.
Mike Schienle Hughes Santa Barbara Research Center
8015@sbsun0010.sbrc.hac.com 75 Coromar Drive, M/S B28/87
Voice: (805)562-7466 Fax: (805)562-7881 Goleta, CA 93117
|
|
|
Re: Widget_Control [message #2449 is a reply to message #2359] |
Wed, 29 June 1994 13:17   |
robijn
Messages: 18 Registered: June 1994
|
Junior Member |
|
|
In article <Cs4p1L.1st6@yuma.acns.colostate.edu>,
<dean%phobos.dnet@sirius.cira.colostate.edu> wrote:
>
> PRO KD_DISPLAY_EVENT, event
>
> Widget_Control, event.id, GET_UVALUE = eventval
> WIDGET_CONTROL, event.top, GET_UVALUE = WDRAWstr
>
> ;HELP, /STRUCTURE, WDRAWstr
>
> CASE eventval OF
> "DRAW_WIN_EVENT" : BEGIN
> WSET, WDRAWSTR.Win_id
> WSHOW, WDRAWSTR.Win_id
> pxvnt = WIDGET_EVENT(WDRAWSTR.Win_id)
Here it is: WDRAWSTR.Win_id is the ID of the graphical window, not
the widget ID of the graphical widget. By the way, if you have
a problem like this try to locate the position where the error occurs
first before posting the whole program. That makes it easier to
see what's happening.
Frank
--
_____ ____
/ / / Frank Robijn Internet: Robijn@Strw.LeidenUniv.NL
/___ /___/ Sterrewacht Leiden Bitnet: Robijn@HLERUL51
/ / \ Phone (31) 71 275841 Local: Robijn@HL628
/ / \ Fax : (31) 71 275819 Snail: P.O.Box 9513, 2300 RA Leiden,
The Netherlands
|
|
|
Re: Widget_Control [message #2451 is a reply to message #2359] |
Wed, 29 June 1994 16:25   |
scollick
Messages: 8 Registered: November 1993
|
Junior Member |
|
|
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 -------------------------------------------------------
|
|
|
|