|
From: Daan L. <daa...@xs...> - 2003-10-13 17:02:22
|
Hi David,
> I have yet another difficulty I've run into. When a widget's
> size changes, I can't figure out how to inform its parent
> that it needs to recalculate its layout.
Yeah, this is the problem I pointed at a few mails ago. We/I should
really revise the sizing model in wxHaskell. The problem is that
this model is not really well specified in wxWindows (as they
tend to not use resizeable dialogs etc) and it takes some
experimentation to get it working well.
In this case, I have found the problem :-) I had forgotten to
set the "wxADJUST_MINSIZE" flag in the code for sizers... talking
about obscure behaviour :-)
For your particular example, this also solves our previous problem
of setting the client size again when label changed. Just one
tiny inconvenience left: you just have to call "windowFit" again
on the parent frame or otherwise the frame itself is not resized.
Maybe we can automate this too, but I'll have to think about it ..
For example, the "windowFit" is not completely satisfying, as it
will also shrink a window when it is resized by the user. You can
use the following code to just ensure that the window is at least large
enough, but it won't shrink to the minimal possible size (where
"f" is the frame):
sz <- get f clientSize
best <- get f bestSize
set f [clientSize := sizeMax best sz]
The fix is in the latest cvs HEAD. (note that anonymous checkouts
might be 24 hours late? you can check by searching for the
wxADJUST_MINSIZE word). If you can't compile wxHaskell by yourself
and really need this fix, drop me a mail and I'll try to provide an
interim release later this week.
All the best,
Daan.
In the following
> example, when the text changes to have two lines, I'd like
> the window to rearrange itself (resizing if necesary) to fit
> the new size of the text.
>
> In wxwin itself I think one would call wxWindow::Layout on
> the parent to do this, but I can't see how to do this in wxhaskell.
>
> module Main where
> import Graphics.UI.WX
>
> main = start $ do f <- frame [text := "layout demo"]
> h <- staticText f [text := "Hello world!"]
> set h [on click := \_ -> goodbye h]
> q <- button f [text := "quit", on command
> := close f]
> set f [layout := column 5 [widget h,
> widget q]]
>
> goodbye st = do set st [text := "Goodbye world!\nAlas, I knew
> it well..."]
> bs <- get st bestSize
> set st [clientSize := bs]
>
> --
> David Roundy
> http://www.abridgegame.org
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program.
> SourceForge.net hosts over 70,000 Open Source Projects. See
> the people who have HELPED US provide better services: Click
> here: http://sourceforge.net/supporters.php
> _______________________________________________
> wxhaskell-users mailing list wxh...@li...
> https://lists.sourceforge.net/lists/listinfo/wxhaskell-users
>
>
|