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

Re: /MODAL makes widgets disappear



to david fanning and anyone else interested....

here is the code that builds the widget hierarchy, and the widget event
handler.  it's not that much code, so i included all of it.  maybe it has
something to do with the implicit x-sizing of the cw_field.  but why would
that depend only on whether it was spawned as a modal widget???

thanks for enjoying red herring!

david m.

----------------------begin code ----------------------------

pro sp_define_common
	common sp_widget_vars,spMinSettings,done,cancel
end

pro sp_BASE_1_event, Event

	common sp_widget_vars

  wWidget =  Event.top

  case Event.id of

    Widget_Info(wWidget, FIND_BY_UNAME='WID_BUTTON_1'): begin
    	done=1
    	WIDGET_CONTROL,$
    		Widget_Info(wWidget, FIND_BY_UNAME='WID_NXI'),$
    		GET_VALUE=temp
    		spMinSettings.nxi=temp
    	WIDGET_CONTROL,$
    		Widget_Info(wWidget, FIND_BY_UNAME='WID_NYI'),$
    		GET_VALUE=temp
    		spMinSettings.nyi=temp
    	WIDGET_CONTROL,$
    		Widget_Info(wWidget, FIND_BY_UNAME='WID_NZI'),$
    		GET_VALUE=temp
    		spMinSettings.nzi=temp
    	WIDGET_CONTROL,$
    		Widget_Info(wWidget, FIND_BY_UNAME='WID_CX_MIN'),$
    		GET_VALUE=temp
    		spMinSettings.ci[0,0]=temp
    	WIDGET_CONTROL,$
    		Widget_Info(wWidget, FIND_BY_UNAME='WID_CX_MAX'),$
    		GET_VALUE=temp
    		spMinSettings.ci[1,0]=temp
    	WIDGET_CONTROL,$
    		Widget_Info(wWidget, FIND_BY_UNAME='WID_CY_MIN'),$
    		GET_VALUE=temp
    		spMinSettings.ci[0,1]=temp
    	WIDGET_CONTROL,$
    		Widget_Info(wWidget, FIND_BY_UNAME='WID_CY_MAX'),$
    		GET_VALUE=temp
    		spMinSettings.ci[1,1]=temp
    	WIDGET_CONTROL,$
    		Widget_Info(wWidget, FIND_BY_UNAME='WID_CZ_MIN'),$
    		GET_VALUE=temp
    		spMinSettings.ci[0,2]=temp
    	WIDGET_CONTROL,$
    		Widget_Info(wWidget, FIND_BY_UNAME='WID_CZ_MAX'),$
    		GET_VALUE=temp
    		spMinSettings.ci[1,2]=temp

        WIDGET_CONTROL, event.top, /DESTROY
    end
    Widget_Info(wWidget, FIND_BY_UNAME='WID_BUTTON_0'): begin
    	cancel=1
        WIDGET_CONTROL, event.top, /DESTROY
    end
    else:
  endcase

end

pro sp_BASE_1, spMinSettingsExt, doneExt, cancelExt, GROUP_LEADER=wGroup,
_EXTRA=_VWBExtra_

	common sp_widget_vars

	done=0
	cancel=0

  if n_elements(wGroup) GT 0l then $
	  sp_BASE_1 = Widget_Base( GROUP_LEADER=wGroup, $
	      UNAME='sp_BASE_1'$
	      ,XOFFSET=5 ,YOFFSET=5 ,SCR_XSIZE=318 $
              ,SCR_YSIZE=409  $
	      ,TITLE='Deformation Minimization Parameters' $
              ,SPACE=3,XPAD=3  $
	      ,YPAD=3,/MODAL) $
  else $
	  sp_BASE_1 = Widget_Base( GROUP_LEADER=wGroup, $
	      UNAME='sp_BASE_1'$
	      ,XOFFSET=5 ,YOFFSET=5 ,SCR_XSIZE=318 ,SCR_YSIZE=409  $
	      ,TITLE='Deformation Minimization Parameters' $
	      ,SPACE=3,XPAD=3  $
	      ,YPAD=3)


  WID_LABEL_0 = Widget_Label(sp_BASE_1, UNAME='WID_LABEL_0'  $
      ,XOFFSET=49 ,YOFFSET=29 ,SCR_XSIZE=221 ,SCR_YSIZE=18  $
      ,/ALIGN_LEFT ,VALUE='Enter the deformation minimization'+ $
      ' constraints')


  WID_LABEL_1 = Widget_Label(sp_BASE_1, UNAME='WID_LABEL_1'  $
      ,XOFFSET=83 ,YOFFSET=70 ,SCR_XSIZE=170 ,SCR_YSIZE=19  $
      ,/ALIGN_LEFT ,VALUE='Number of deformation parameters')

  WID_LABEL_4 = Widget_Label(sp_BASE_1, UNAME='WID_LABEL_4'  $
      ,XOFFSET=13 ,YOFFSET=100 ,SCR_XSIZE=44 ,SCR_YSIZE=19  $
      ,/ALIGN_RIGHT ,VALUE='nxi')


  WID_LABEL_5 = Widget_Label(sp_BASE_1, UNAME='WID_LABEL_5'  $
      ,XOFFSET=13 ,YOFFSET=130 ,SCR_XSIZE=44 ,SCR_YSIZE=19  $
      ,/ALIGN_RIGHT ,VALUE='nyi')


  WID_LABEL_6 = Widget_Label(sp_BASE_1, UNAME='WID_LABEL_6'  $
      ,XOFFSET=13 ,YOFFSET=160 ,SCR_XSIZE=44 ,SCR_YSIZE=19  $
      ,/ALIGN_RIGHT ,VALUE='nzi')


  WID_LABEL_7 = Widget_Label(sp_BASE_1, UNAME='WID_LABEL_7'  $
      ,XOFFSET=13 ,YOFFSET=293 ,SCR_XSIZE=44 ,SCR_YSIZE=19  $
      ,/ALIGN_RIGHT ,VALUE='cz')


  WID_LABEL_8 = Widget_Label(sp_BASE_1, UNAME='WID_LABEL_8'  $
      ,XOFFSET=13 ,YOFFSET=263 ,SCR_XSIZE=44 ,SCR_YSIZE=19  $
      ,/ALIGN_RIGHT ,VALUE='cy')


  WID_LABEL_9 = Widget_Label(sp_BASE_1, UNAME='WID_LABEL_9'  $
      ,XOFFSET=13 ,YOFFSET=233 ,SCR_XSIZE=44 ,SCR_YSIZE=19  $
      ,/ALIGN_RIGHT ,VALUE='cx')


  WID_LABEL_10 = Widget_Label(sp_BASE_1, UNAME='WID_LABEL_10'  $
      ,XOFFSET=195 ,YOFFSET=208 ,SCR_XSIZE=30 ,SCR_YSIZE=18  $
      ,/ALIGN_LEFT ,VALUE='Max')


  WID_LABEL_11 = Widget_Label(sp_BASE_1, UNAME='WID_LABEL_11'  $
      ,XOFFSET=98 ,YOFFSET=208 ,SCR_XSIZE=30 ,SCR_YSIZE=18  $
      ,/ALIGN_LEFT ,VALUE='Min')


  WID_LABEL_12 = Widget_Label(sp_BASE_1, UNAME='WID_LABEL_12'  $
      ,XOFFSET=100 ,YOFFSET=190 ,SCR_XSIZE=151 ,SCR_YSIZE=19  $
      ,/ALIGN_LEFT ,VALUE='Deformation Constraints')


  WID_BUTTON_0 = Widget_Button(sp_BASE_1, UNAME='WID_BUTTON_0'  $
      ,XOFFSET=65 ,YOFFSET=330 ,SCR_XSIZE=90 ,SCR_YSIZE=25  $
      ,/ALIGN_CENTER ,VALUE='Cancel')


  WID_BUTTON_1 = Widget_Button(sp_BASE_1, UNAME='WID_BUTTON_1'  $
      ,XOFFSET=170 ,YOFFSET=330 ,SCR_XSIZE=90 ,SCR_YSIZE=25  $
      ,/ALIGN_CENTER ,VALUE='Done')


  WID_BASE_NXI = Widget_Base(sp_BASE_1,  $
      UNAME='WID_BASE_NXI' ,XOFFSET=78 ,YOFFSET=96  $
      ,SCR_XSIZE=170 ,SCR_YSIZE=25  $
      ,TITLE='IDL' ,SPACE=3 ,XPAD=3 ,YPAD=3)

	WID_NXI=CW_FIELD(WID_BASE_NXI,$
		UNAME='WID_NXI',$
		/LONG,$
		TITLE=' ',$
		/RETURN_EVENTS,$
		XSIZE=8,$
		VALUE=spMinSettingsExt.nxi)


  WID_BASE_NYI = Widget_Base(sp_BASE_1,  $
      UNAME='WID_BASE_NYI' ,XOFFSET=78 ,YOFFSET=126  $
      ,SCR_XSIZE=170 ,SCR_YSIZE=25   $
      ,TITLE='IDL' ,SPACE=3 ,XPAD=3 ,YPAD=3)

	WID_NYI=CW_FIELD(WID_BASE_NYI,$
		UNAME='WID_NYI',$
		/LONG,$
		TITLE=' ',$
		/RETURN_EVENTS,$
		XSIZE=8,$
		VALUE=spMinSettingsExt.nyi)


  WID_BASE_NZI = Widget_Base(sp_BASE_1, UNAME='WID_BASE_NZI'  $
      ,XOFFSET=78 ,YOFFSET=156 ,SCR_XSIZE=170 ,SCR_YSIZE=25  $
      ,TITLE='IDL' ,SPACE=3 ,XPAD=3  $
      ,YPAD=3)

	WID_NZI=CW_FIELD(WID_BASE_NZI,$
		UNAME='WID_NZI',$
		/LONG,$
		TITLE=' ',$
		/RETURN_EVENTS,$
		XSIZE=8,$
		VALUE=spMinSettingsExt.nzi)


  WID_BASE_CX_MIN = Widget_Base(sp_BASE_1, UNAME='WID_BASE_CX_MIN'  $
      ,XOFFSET=78 ,YOFFSET=230 ,SCR_XSIZE=90 ,SCR_YSIZE=25  $
      ,TITLE='IDL' ,SPACE=3 ,XPAD=3 ,YPAD=3)

	WID_CX_MIN=CW_FIELD(WID_BASE_CX_MIN,$
		UNAME='WID_CX_MIN',$
		/FLOATING,$
		TITLE=' ',$
		/RETURN_EVENTS,$
		XSIZE=8,$
		VALUE=spMinSettingsExt.ci[0,0])


  WID_BASE_CX_MAX = Widget_Base(sp_BASE_1, UNAME='WID_BASE_CX_MAX'  $
      ,XOFFSET=178 ,YOFFSET=230 ,SCR_XSIZE=170 ,SCR_YSIZE=25  $
      ,EVENT_FUNC='set_CX_max' ,TITLE='IDL' ,SPACE=3 ,XPAD=3 ,YPAD=3)

	WID_CX_MAX=CW_FIELD(WID_BASE_CX_MAX,$
		UNAME='WID_CX_MAX',$
		/FLOATING,$
		TITLE=' ',$
		/RETURN_EVENTS,$
		XSIZE=8,$
		VALUE=spMinSettingsExt.ci[1,0])


  WID_BASE_CY_MIN = Widget_Base(sp_BASE_1, UNAME='WID_BASE_CY_MIN'  $
      ,XOFFSET=78 ,YOFFSET=260 ,SCR_XSIZE=90 ,SCR_YSIZE=25  $
      ,TITLE='IDL' ,SPACE=3 ,XPAD=3 ,YPAD=3)

	WID_CY_MIN=CW_FIELD(WID_BASE_CY_MIN,$
		UNAME='WID_CY_MIN',$
		/FLOATING,$
		TITLE=' ',$
		/RETURN_EVENTS,$
		XSIZE=8,$
		VALUE=spMinSettingsExt.ci[0,1])


  WID_BASE_CY_MAX = Widget_Base(sp_BASE_1, UNAME='WID_BASE_CY_MAX'  $
      ,XOFFSET=178 ,YOFFSET=260 ,SCR_XSIZE=170 ,SCR_YSIZE=25  $
      ,TITLE='IDL' ,SPACE=3 ,XPAD=3 ,YPAD=3)

	WID_CY_MAX=CW_FIELD(WID_BASE_CY_MAX,$
		UNAME='WID_CY_MAX',$
		/FLOATING,$
		TITLE=' ',$
		/RETURN_EVENTS,$
		XSIZE=8,$
		VALUE=spMinSettingsExt.ci[1,1])


  WID_BASE_CZ_MIN = Widget_Base(sp_BASE_1, UNAME='WID_BASE_CZ_MIN'  $
      ,XOFFSET=78 ,YOFFSET=290 ,SCR_XSIZE=90 ,SCR_YSIZE=25  $
      ,TITLE='IDL' ,SPACE=3 ,XPAD=3 ,YPAD=3)

  	WID_CZ_MIN=CW_FIELD(WID_BASE_CZ_MIN,$
		UNAME='WID_CZ_MIN',$
		/FLOATING,$
		TITLE=' ',$
		/RETURN_EVENTS,$
		XSIZE=8,$
		VALUE=spMinSettingsExt.ci[0,2])


  WID_BASE_CZ_MAX = Widget_Base(sp_BASE_1, UNAME='WID_BASE_CZ_MAX'  $
      ,XOFFSET=178 ,YOFFSET=290 ,SCR_XSIZE=170 ,SCR_YSIZE=25  $
      ,TITLE='IDL' ,SPACE=3 ,XPAD=3 ,YPAD=3)

  	WID_CZ_MAX=CW_FIELD(WID_BASE_CZ_MAX,$
		UNAME='WID_CZ_MAX',$
		/FLOATING,$
		TITLE=' ',$
		/RETURN_EVENTS,$
		XSIZE=8,$
		VALUE=spMinSettingsExt.ci[1,2])

  Widget_Control, /REALIZE, sp_BASE_1

	spMinSettings=spMinSettingsExt
	cancel=0
	done=0

  ;  Manage the widget tree until dismissed
  XManager, 'sp_BASE_1', sp_BASE_1


	doneExt=done
	cancelExt=cancel

	if done EQ 1 then begin
		spMinSettingsExt.nxi=spMinSettings.nxi
		spMinSettingsExt.nyi=spMinSettings.nyi
		spMinSettingsExt.nzi=spMinSettings.nzi
		spMinSettingsExt.ci=spMinSettings.ci
	endif

end
;
; Empty stub procedure used for autoloading.
;
pro sp_settings, spMinSettings, done, cancel, GROUP_LEADER=wGroup,
_EXTRA=_VWBExtra_
  sp_BASE_1, spMinSettings, done, cancel, GROUP_LEADER=wGroup,
_EXTRA=_VWBExtra_
end

-----------------------end code---------------------------

On Thu, 11 May 2000, David Fanning wrote:

> D. Mattes (dmattes@u.washington.edu) writes:
> 
> > IDL gurus!  i have a strange one for you, and i hope you can help.  i
> > created a widget that can runs as a modal widget if a group is
> > specified.  this widget has some CW_FIELD widgets contained in it, no big
> > deal, right?  well, i get some strange behaviors...
> > 
> > on WINDOWS platform:
> > no strange effects, nice.
> > 
> > on UNIX platform: 
> > if the widget is managed in modal mode (by setting the /MODAL keyword for
> > the top level base), none of the CW_FIELD widgets appear!!!  yet, if the
> > widget is not run as a modal widget, the CW_FIELD widgets *ARE* there!
> > 
> > any insights into this problem?  specifically, a way around it would be to
> > not use the /MODAL keyword for the top level base, but i need the modal
> > effect.  is there another way to achieve this, say with xmanager?
> 
> Henk, pay attention. *This* is what is known as a 
> "red herring". :-)
> 
> Cheers,
> 
> David
> 
> P.S. Just to amuse me, could you try substituting my
> COYOTE_FIELD compound widget for your CW_FIELD compound
> widget. It should be a drop-in replacement, pretty much.
> But we are *really* going to have to see some code, because
> my modal widgets are filled with CW_FIELDs (or their
> equivalents) and I've never heard of this. :-)
> 
>     http://www.dfanning.com/programs/coyote_field.pro
> 
> -- 
> David Fanning, Ph.D.
> Fanning Software Consulting
> Phone: 970-221-0438 E-Mail: davidf@dfanning.com
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155
>