; Written by: P.A.Romashkin, 07-2001 ; Purpose: Utility replacing WINDOW caommand ; Description: Creates an IDL direct graphics window to receive graphics output. ; If multiple windows are created, the window that is clicked in receives focus ; for the next graphics operation. ; Usage: SMART_W[, DIMENSIONS=[x_size, y_size]] ; Can be used to create self-focusing windows in widget applications by using ; SMART_W, PARENT=Parent_base[, DIMENSIONS=[x_size, y_size]] ; The child smart window causes selected widget applicaiton's draw widget to ; receive focus for plotting. ; **************************************************** ; This event handler is for child smart windows. Note that it may overwrite ; an event handling FUNCTION if one exisetd for the parent base. function smart_w_ev, event widget_control, widget_info(event.top, find_by_uname='THE_DRAW'), get_value=win_id wset, win_id end ; **************************************************** ; This event handler is for standalone smart windows. pro smart_w_ev, 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 end ; **************************************************** pro smart_w, parent=top_base, dimensions=dimensions if n_elements(top_base) ne 0 then $ widget_control, top_base, /kbrd_focus_event, event_func='smart_w_ev' $ else top_base = widget_base(/kbrd_focus_event, /tlb_size_event) if n_elements(dimensions) ne 2 then dimensions = [600, 400] draw = widget_draw(top_base, xsize=dimensions[0], ysize=dimensions[1], retain=2, uname='THE_DRAW') if arg_present(top_base) eq 0 then begin 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, event_handler='smart_w_ev' endif end ; ****************************************************