Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
darcs-hash:20081021095548-75908-38573f98683fb23a0735171d538c7cf1b43c5bad.gz
- Loading branch information
1 parent
46a3769
commit 5165b43
Showing
14 changed files
with
886 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.