[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to pick a window?

All I have to say is, a "smart" widget direct graphics window is very
simple to achieve.
The following "two-line" code easily sets the "pseudo"-DG window to have
focus. Since Andrew's windows will be created from some other code, it
is very easy to store instructions for plotting windows at the time of
their creation.
The basic idea of the example below is to make a window *act* when
clicked on, and keep it looking and behaving *exactly* as a standard DG
IDL window, to keep William happy and unaware :-) In my example, they
set focus to themselves and allow resizing. Just use "smart_w" instead
of "window, /free". That's it. Then use Plot, Oplot, Xyouts, Contour - whatever.

pro smart_w_event, event
widget_control, event.top, get_uvalue=win_id
wset, win_id
if tag_names(event, /STRUCTURE_NAME) EQ 'WIDGET_BASE' then $
widget_control, widget_info(event.id, /child), $
draw_xsize=event.x, draw_ysize=event.y
pro smart_w
top_base = widget_base(/kbrd_focus_event, /tlb_size_event)
draw = widget_draw(top_base, xsize=600, ysize=400, retain=2)
widget_control, top_base, /realize
widget_control, draw, get_value=win_id
widget_control, top_base, set_uvalue=win_id, $
tlb_set_title='IDL '+strcompress(win_id, /rem)
xmanager, 'smart_w', top_base, /no_block

Anyway, don't let the word "widget" scare you out of using IDL. Wait
till you get to objects :-)

William Thompson wrote:
> Let me just say that if IDL were written as an environment where everything
> *had* to be done as a widget program, we probably would *not* be using IDL
> today.  We'd be using something else more forgiving.  And I say this as someone
> who's written a fair number of widget programs in his time.
> William Thompsonn