Re: How to know a window id is valid [message #7072] |
Fri, 20 September 1996 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Reposting article removed by rogue canceller.
In article <51sbok$r8j@post.gsfc.nasa.gov>, Gary Fu writes:
> Is there a command to tell that a window id created by a
> draw window widget is valid for WSET to use ?
Quite often in widget programs you have your graphics
windows separated from your control panels. This makes
it easy to resize your graphics windows, for example.
It also makes it easy for the user to close graphics
windows.
For this reason, you have to be sure the window is still
around before you draw into it. What I typically do is
keep the draw widget ID around in the info or state
structure that contains all the information I need to
run my widget program. Before I draw into the draw
widget, I check to make sure it's still a valid widget
ID.
If the widget ID is NOT valid, the user must have closed
the graphics window. I simply make another. I often
know the last size and position of the window that
the user closed, so I can put up a virtually identical
window.
A typical draw widget event handler might look like
this:
PRO EXAMPLE_DRAW, event
WIDGET_CONTROL, event.top, GET_UVALUE=info, /NO_COPY
IF NOT WIDGET_INFO(info.drawID, /VALID_ID) THEN BEGIN
graphicsbase = WIDGET_BASE(XOFFSET=info.xoffset, YOFFSET=info.yoffset)
info.drawID = WIDGET_DRAW(graphicsbase, XSIZE=info.xsize,
YSIZE=info.ysize)
WIDGET_CONTROL, graphicsbase, /REALIZE
ENDIF
WIDGET_CONTROL, info.drawID, GET_VALUE=wid
WSET, wid
PLOT, data
WIDGET_CONTROL, event.top, SET_UVALUE=info, /NO_COPY
END ; ***************************** of EXAMPLE_DRAW event handler
Hope this helps.
Yours,
David
--
David Fanning, Ph.D.
Phone: 970-221-0438
Fax: 970-221-4728
E-Mail: davidf@fortnet.org
|
|
|