comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: How to know a window id is valid
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: How to know a window id is valid [message #7072] Fri, 20 September 1996 00:00
davidf is currently offline  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
Re: How to know a window id is valid [message #7073 is a reply to message #7072] Fri, 20 September 1996 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
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
Re: How to know a window id is valid [message #7080 is a reply to message #7072] Fri, 20 September 1996 00:00 Go to previous message
Peter Mason is currently offline  Peter Mason
Messages: 145
Registered: June 1996
Senior Member
On 19 Sep 1996, Gary Fu wrote:
> Is there a command to tell that a window id created by a
> draw window widget is valid for WSET to use ?

I don't know of a neat way to do this. I use the following hack:

function draw_valid,draw
;returns 1 if the draw-widget or plot-window ID in DRAW is valid, else 0
catch,e &if (e ne 0) then return,0
wshow,draw
return,1
end

It works with plot windows and draw widgets (regular and pixmap).
(Use WIDGET_CONTROL,draw_widget_id,GET_VAL=draw to get the draw ID of a draw
WIDGET.)

It has the side-effect of de-iconising the window and bringing it to the
foreground. (Something you might want to do anyway if you're about to plot
to the thing.)

Peter Mason
Re: How to know a window id is valid [message #7082 is a reply to message #7072] Thu, 19 September 1996 00:00 Go to previous message
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
gfu@shark.gsfc.nasa.gov (Gary Fu) writes:

> Hello,

> Is there a command to tell that a window id created by a
> draw window widget is valid for WSET to use ?

The call

DEVICE, WINDOW_STATE=WIN_STATE

returns an array into the variable WIN_STATE, with 0 for windows that don't
exist, and 1 for windows that do. One can then use a statement like

VALID = WIN_STATE(WINDOW_ID)

to return whether or not the window is valid.

Bill Thompson
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: BEYOND TECHNOLOGY
Next Topic: Re: Drawing axes for volumetric data

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:09:00 PDT 2025

Total time taken to generate the page: 0.01082 seconds