From: David R. <dr...@jd...> - 2003-10-07 11:51:50
|
On Tue, Oct 07, 2003 at 11:22:47AM +0200, Daan Leijen wrote: > Hi David, > > > Hello. I'm unclear as to how to get a scrolledWindow to work properly > > with sizers. In the following example, I don't get a scrollbar, > > Well, I am not a wxWindows expert either. However, I think that you > always have to set the "virtualSize" of a scrolled window to get the > sizer working. In your example, you set the "scrollRate", but forget to > set the "virtualSize". Maybe that is the cause of the problems? According to the wxwin docs, it seems that if you use a sizer with the wxScrolledWindow, it can determine the virtualSize from the sizer data. My problem is in making the actual size of the window smaller than the virtual size. I've figured out a rather ugly solution. The following code works: \begin{code} module Main where import Graphics.UI.WX import Graphics.UI.WXCore.WxcClasses ( windowSetSizeHints ) main = start $ hello hello = do f <- frame [text := "Hello Scrollbars!"] scrolled <- scrolledWindow f [layout := rigid $ column 0 $ take 47 labels, scrollRate := size 10 10] windowSetSizeHints scrolled (-1) (-1) (-1) (-1) (-1) (-1) set f [clientSize := size 100 100] quit <- button f [text := "Quit", on command := close f] set f [layout := column 0 [fill $ widget scrolled, centre $ hstretch $ margin 5 $ widget quit]] where labels = map (floatLeft . label . ("Label Number "++) . show) [1..] \end{code} Interestingly, if you move the set f clientSize either after the "quit <-" line or before the windowSetSizeHints line, the code no longer works. In either case, "scrolled" is set to be the size of its contents, and cannot be resized to be smaller. The windowSetSizeHints call is interesting, as it just sets the size hints to their default values (that's what all the -1s are about), so it suggests that someone is setting them to non-default values... (since without that call, the code won't work). -- David Roundy http://www.abridgegame.org |