-- Each click in the window should increase the view domain. But this never happens,
-- as the debug output and the peculiar scrollbar-behaviour reveal.
-- When replacing the TextControl with NilLS the resulting window suddenly
-- shows the wanted behaviour. Compare also with the Clean program viewsizenobug.icl
import Graphics.UI.ObjectIO

main = do wid <- openId
          startIO SDI () (openWindow undefined (theWindow wid)) [ProcessClose closeProcess]

theWindow wid = Window "Each click should increase viewdomain by 1000"  
                  (TextControl "Hello" [ControlPos (Center,zero)])
                  -- try NilLS instead of the above TextControl!
                  [WindowId wid,
	               WindowViewSize size,
	               WindowViewDomain (Rectangle zero (Point2 width height)),
	               WindowHScroll slide,
	               WindowVScroll slide,
	               WindowMouse (const True) Able (noLS1 mouseEvent)
                  ]
    where                  
      size = Size width height
      width = 300
      height = 360
      mouseEvent (MouseUp p _) ps = do
                   (Just dom) <- getWindowViewDomain wid
                   let Point2 width height = corner2 dom
                       newdom = dom {corner2 = Point2 (width + 1000) (height+1000)}
                   setWindowViewDomain wid newdom
                   liftIO $ print newdom --debug output
                   return ps
      mouseEvent _ ps = return ps

slide viewFrame (SliderState{sliderThumb=st}) state
      =  case state of 
         SliderThumb i  -> i
         SliderIncSmall -> st+20 
         SliderDecSmall -> st-20
         SliderIncLarge -> st+100
         SliderDecLarge -> st-100
