[Haskell-cafe] Re: wxHaskell - using XRC files

Jeremy O'Donoghue jeremy.odonoghue at gmail.com
Wed Jan 27 10:17:21 EST 2010


Hi Guenther, Gour

On Wed, 27 Jan 2010 13:38 +0100, "Gour" <gour at gour-nitai.com> wrote:
> On Wed, 27 Jan 2010 11:09:06 +0100
> >>>>>> "Günther" == Günther Schmidt <gue.schmidt at web.de> wrote:
> 
> Günther> I'm looking for documentation on using XRC files with
> Günther> wxHaskell.
> 
> I'd like to find it too...so, far I've found only two samples:
> xrcmenu.xrc & controls.xrc.

You have found just about all there is, I'm afraid. It's on my list for
a Blog article, but as you may have realised, my list is quite long, and
the rate of service rather slow.

The basics are pretty straightforward if you have read and understood
the wxWidgets documentation on XRC.

- An XRC file needs to be loaded into a top level window.
- The objects created when the XRC file is loaded can be made available
to wxHaskell by name using the <widget>Res functions (you will find most
of them in Graphics.UI.WX.Controls)

There are quite a few things to watch out for:
- XRC is incompatible with Layout (the XRC contains its own sizers, and
Layout creates sizers suitable for a given window layout)
- You must load your control as a child of the window in which you
loaded the XRC file
- If you try to fetch a control whose name doesn't exist, or if you load
a control by name as the wrong type of control, you will almost
certainly crash irrecoverably (the crash is usually in the wxWidgets
.DLL/.so/.dylib)
- It is not really possible to control an XRC-based menu very well. As
an example, I have never succeeded in disabling a menu option
- I also have not succeeded in getting XRC to work with wxHaskell custom
controls (and I've tried fairly hard). This is currently a show-stopper
for me. I very much doubt that this will ever work without putting
wxHaskell support into a GUI builder, since wxHaskell custom widgets do
not look (to C++) quite the same as C++ custom widgets.

The whole of the XRC support really needs a typesafe veneer over it (if
you search the wxhaskell-devel archives, there was a proof of concept
for doing this proposed about 8 months ago), and probably some
wxHaskell-specific work in a GUI builder.

I'll do my best to answer any specific questions you have.

Best regards
Jeremy

> Günther> BTW: I'm using wxFormBuilder, any other good tools out there?
> 
> Besides wxFormBuilder I played with DialogBlocks (eval version 'cause
> it's not free).
> 
> 
> Sincerely,
> Gour
> 
> -- 
> 
> Gour  | Hlapicina, Croatia  | GPG key: F96FF5F6
> ----------------------------------------------------------------
-- 
  Jeremy O'Donoghue
  jeremy.odonoghue at gmail.com



More information about the Haskell-Cafe mailing list