| I've encountered two problems with WIDGET_WINDOW that I've been unable to find a solution for, and they seem to be the result of a bug. One is that when using the SYMBOL function, the graphics do not appear until after there is a mouse click within the window; all other graphic functions that I've tried so far appear right away.
The other problem is that when using the SAVE method with the window to write a PDF file, the output is blank , but appears normal if this is done within a widget_event handler.Neither of these problems occur when the WINDOW function is used instead.
The following program demonstrates both problems, using an example adapted from the documentation for SYMBOL:
;------------------------------------------------ 
 pro demo_widget_window_event,event
help,/str,event
WIDGET_CONTROL,event.top,GET_UVALUE=owin
oWin.Save, 'demo_widget_window_2.pdf', BITMAP=0 ;this PDF is fine
if (TAG_NAMES(Event, /STRUCTURE_NAME) EQ 'WIDGET_KILL_REQUEST') then begin
  WIDGET_CONTROL,event.top,/DESTROY
  if obj_valid(owin) then begin
    obj_destroy,owin
    ;alternative:
    ;wclass=obj_class(owin)
    ;if wclass EQ 'GRAPHICSWIN' || wclass EQ 'GRAPHICSBUFFER' then owin.close
  endif
endif
RETURN
END
;pro demo_widget_window
;or run as a MAIN program:
pagename='demo_widget_window'
keyboard_event=0
opengl=1 ;both options give same result
widget_top=WIDGET_BASE(TITLE=pagename,SPACE=0,YPAD=0,XPAD=0,/COL,$
  /TLB_KILL_REQUEST_EVENTS ,TLB_SIZE_EVENTS=1 ,$
  KBRD_FOCUS_EVENTS=keyboard_event) 
  ;MBAR=menubase) ;in most cases, creating a menu bar is the reason for using widget_window,$
    ;as well as customized handling of widget events
  top_base=widget_top
  winbase=WIDGET_BASE(widget_top)
  xsize=900
  ysize=800
  ;create main draw base/widget
  dbase=WIDGET_BASE(winbase,XOFFSET=0,YOFFSET=0)
  wWindow=WIDGET_WINDOW(dbase,$
    XSIZE=xsize,YSIZE=ysize,FRAME=0,$
    RENDERER=(OpenGL EQ 0))
  WIDGET_CONTROL,widget_top,/REALIZE ;do before getting owin property
  WIDGET_CONTROL,wWindow,GET_VALUE=oWin
  oWin.Select
   WIDGET_CONTROL,widget_top,SET_UVALUE=owin
   
 ;does not matter if XMANAGER call is here, or farther down
 ; XMANAGER,'demo_widget_window',widget_top,NO_BLOCK=1
    m = MAP('Orthographic', COLOR='light blue', $
      CURRENT=oWin, $
      ;POSITION=[x0, y0, x1, y1], $ NORMAL coord. assumed
      LIMIT=[30, -120, 50, -90], $
      CENTER_LONGITUDE=-105, CENTER_LATITUDE=40)
    c = MAPCONTINENTS(/USA)
    m.mapgrid.ORDER, /SEND_TO_BACK
    lon = [-104.98,-104.80,-111.88,-116.22,-112.03, $
      -119.75,-100.78,-100.34,-96.68,-95.69, $
      -97.54,-97.53,-105.97,-112.07]
    lat = [39.74,41.87,40.75,43.61,46.60, $
      39.16,46.82,44.37,40.81,39.06, $
      35.48,30.27,35.67,33.45]
    labels = ['CO','WY','UT','ID','MT','NV','ND', $
      'SD','NE','KS','OK','TX','NM','AZ']
    capitals = SYMBOL( lon, lat, 'Star', /DATA, $
      /SYM_FILLED, SYM_COLOR='red', SYM_SIZE = 2, $
      LABEL_STRING=labels )
      
oWin.refresh
XMANAGER,'demo_widget_window',widget_top,NO_BLOCK=1
oWin.Save, 'demo_widget_window_1.pdf', BITMAP=0
;for whatevern reason, this PDF is blank
end
 |