(Don't suggest using add-source as it doesn't detect changes to source)
(Added category wxHaskell)
Revision as of 20:49, 15 January 2012
This page is intended to provide information for those wishing to work on the wxHaskell library, specifically creating and maintaining an environment in which to do so.
2 Obtaining wxWidgets
Note that wxHaskell is currently between wxWidgets 2.8 and the development 2.9 release, so it pays well to ensure new code will work with both versions. It is possible to safely co-habit two version of wxWidgets. When you do wxHaskell will build against whichever version is returned by
wxconfig --version, on Linux you can change which version you build wxHaskell against by follow steps similar to this (this should be easier):
$ wx-config --version 2.8.12 $ whereis wx-config wx-config: /usr/local/bin/wx-config $ ls -l /usr/local/bin/wx-config lrwxrwxrwx 1 root root 41 2011-09-14 21:20 /usr/local/bin/wx-config -> /usr/local/lib/wx/config/gtk2-unicode-debug-2.8 $ sudo rm /usr/local/bin/wx-config $ sudo ln -s /usr/local/lib/wx/config/gtk2-unicode-2.9 /usr/local/bin/wx-config $ wx-config --version 2.9.2
3 Building and testing wxHaskell
Firstly, see Source Release, however it is recommended that you do the following, instead of following the instructions there to build each component:
Use Cabal-dev to isolate your development code from stable wxHaskell packages you may have obtained from Hackage.
You can then install your development version of wxHaskell into a separate Cabal-dev package database (which will be under
To do this enter the root wxHaskell directory (the one you obtained with
darcs from http://code.haskell.org/wxhaskell/) and enter the following:
cabal-dev install ./wx ./wxcore ./wxdirect
Note: Previously this page suggested using
add-source, but packages added in such a way will not be recompiled when the source given is changed, this is discussed in the "Using a sandbox-local Hackage" section.
You may then build against your development install thus:
ghc -package-conf /path/to/wxhaskell/cabal-dev/packages-7.0.3.conf/ --make MyTestCode.hs
4 Wrapping new wxWidgets functionality
Note: Inspiration for this comes from this email.
4.1 Purpose of files which will need to be updated
Although the specific modifications required depends on the complexity of the wxWidgets functionality you are wrapping, this list serves to document the relationship between the files and what purpose they serve.
- 'High' level Haskell wrapper. You place constructors which are property-aware here. In most respects this is straightforward except that you need to work out what instances are appropriate to a your new functionality. You may want to look here for some more information about implementing
- An ugly piece of legacy from the days when wxcore was derived from an Eiffel wrapping of wxWidgets. Event identifiers need to be defined here. (Jeremy: I *really* want to get rid of this file one day - it serves no purpose to have an Eiffel file these days.)
- This creates the correct type witnesses to map the class Hierarchy.
- This is basically where you need to put the declarations for C++ method wrappers.
- Your Haskell event handler code goes here. You need one function which reacts to events, which accepts an event handler as a parameter and a function which will fetch your event handler (you need this mostly in case you want to hook a further event handler which doesn't kill the one already present).
- Implementations of the wrappers. The old
eljXXXnaming convention for these files really isn't necessary any more. I'd suggest calling the implementation
mynewfunctionality.cppor something like that.
- Constructs functions for geting control pointers out of window hierarchies created from XRC files.
- Wrap up event values as functions. I tend to do this instead.
- Another way of wrapping up event values as functions. (Jeremy: I don't tend to do this, and I don't think anyone has for years.).
- Ensure you add