Permalink
Browse files

Add XRC support

darcs-hash:20081021095548-75908-38573f98683fb23a0735171d538c7cf1b43c5bad.gz
  • Loading branch information...
1 parent 46a3769 commit 5165b437bfeb4083ce9b40ba4b33dfe122ab1d4c @jodonoghue committed Oct 21, 2008
View
@@ -1,9 +1,23 @@
----------------------------------------------------------------------
Copyright (c) 2003, 2004, 2005 Daan Leijen.
+ Copyright (c) 2006, 2007, 2008 Jeremy O'Donoghue,
+ Eric Kow,
+ Kido Takahiro (Shelarcy),
+ Mads Lindstroem
See license.txt for details.
----------------------------------------------------------------------
+Version 0.10.5
+--------------
+
+Backward compatible additions
+- Added support for using XRC resource files to load most controls
+ and menus attached to frames.
+- Added sample file showing how to use XRC support to attach command
+ handlers to menu items
+- Added sample file showing how to use properties with many controls.
+
Version 0.10.4
-------------
Non backward compatible changes:
@@ -15,7 +29,7 @@ Non backward compatible changes:
2.8 documentation for wxcore functions
- Added "TopLevelWindow", which mainly removes some functionality
from "Frame"
-- Changed "--with-stc" argument to "--with-cotrib"
+- Changed "--with-stc" argument to "--with-contrib"
- Removed "Wave" type synonym
Backward compatible additions:
@@ -0,0 +1,68 @@
+{--------------------------------------------------------------------------------
+ Copyright (c) Daan Leijen 2003
+ Copyright (c) Jeremy O'Donoghue 2008
+ wxWindows License.
+
+ Demonstrates:
+ - many different kind of controls
+ - message logging.
+--------------------------------------------------------------------------------}
+module Main where
+
+import Graphics.UI.WX
+import Graphics.UI.WXCore
+
+main :: IO ()
+main
+ = start gui
+
+gui :: IO ()
+gui =
+ do -- main gui elements: frame, panel, text control, and the notebook
+ f <- frameLoadRes "controls.xrc" "f" []
+
+ -- use text control as logger
+ textlog <- textCtrlRes f "textlog" []
+ textCtrlMakeLogActiveTarget textlog
+ logMessage "logging enabled"
+
+ -- button page
+ ok <- buttonRes f "ok" [on command := logMessage "ok button pressed"]
+ quit <- buttonRes f "ok" [on command := close f]
+
+ -- radio box page
+ r1 <- radioBoxRes f "r1" [on select ::= logSelect]
+ r2 <- radioBoxRes f "r2" [on select ::= logSelect]
+ rb1 <- buttonRes f "rb1" [on command ::= onEnable r1]
+
+ -- choice page
+ c1 <- choiceRes f "c1" [on select ::= logSelect]
+ c2 <- choiceRes f "c2" [on select ::= logSelect]
+ cb1 <- buttonRes f "cb1" [on command ::= onEnable c1]
+
+ -- list box page
+ sl1 <- singleListBoxRes f "sl1" [on select ::= logSelect]
+ sl2 <- singleListBoxRes f "sl2" [on select ::= logSelect]
+ sc1 <- checkBoxRes f "sc1" [on command ::= onEnable sl1]
+
+ -- slider/gauge page
+ s <- sliderRes f "s" []
+ g <- gaugeRes f "g" []
+ set s [on command := do { i <- get s selection; set g [selection := i] } ]
+
+ -- specify layout
+ set f [ clientSize := sz 400 300 ]
+ windowShow f
+ return ()
+
+ where
+ -- logSelect :: (Selection w, Items w String) => w -> IO ()
+ logSelect w
+ = do i <- get w selection
+ s <- get w (item i)
+ logMessage ("selected index: " ++ show i ++ ": " ++ s)
+
+ onEnable w b
+ = do set w [enabled :~ not]
+ enable <- get w enabled
+ set b [text := (if enable then "disable" else "enable")]
@@ -0,0 +1,34 @@
+-- Menu from XRC demo
+module Main where
+
+import Graphics.UI.WXCore
+import Graphics.UI.WX
+
+main = start gui
+
+gui :: IO ()
+gui =
+ do
+ f <- frameLoadRes "xrcmenu.xrc" "menuTest" []
+
+ -- Attach event handlers to the menu items loaded above.
+ menuItemOnCommandRes f "new" (onFileNew f)
+ menuItemOnCommandRes f "open" (onFileOpen f)
+
+ set f [clientSize := sz 400 300]
+ windowShow f
+ return ()
+
+onFileNew w =
+ do
+ dlg <- dialog w [text := "File New"]
+ ok <- button dlg [text := "Ok"]
+ _ <- showModal dlg (\onPress -> set ok [on command := onPress Nothing])
+ return ()
+
+onFileOpen w =
+ do
+ dlg <- dialog w [text := "File Open"]
+ ok <- button dlg [text := "Ok"]
+ _ <- showModal dlg (\onPress -> set ok [on command := onPress Nothing])
+ return ()
Oops, something went wrong.

0 comments on commit 5165b43

Please sign in to comment.