-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHelloWorld.hs
47 lines (38 loc) · 1.34 KB
/
HelloWorld.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{--------------------------------------------------------------------------------
The 'hello world' demo from the wxWindows site.
--------------------------------------------------------------------------------}
module Main where
import Graphics.UI.WXCore
main :: IO ()
main = run helloWorld
helloWorld = do -- create file menu
fm <- menuCreate "" 0
menuAppend fm wxID_ABOUT "&About.." "About wxHaskell" False {- not checkable -}
menuAppendSeparator fm
menuAppend fm wxID_EXIT "&Quit\tCtrl-Q" "Quit the demo" False
-- create menu bar
m <- menuBarCreate 0
menuBarAppend m fm "&File"
-- create top frame
f <- frameCreate objectNull idAny "Hello world" rectZero frameDefaultStyle
windowSetBackgroundColour f white
windowSetClientSize f (sz 600 250)
-- set status bar with 1 field
frameCreateStatusBar f 1 0
frameSetStatusText f "Welcome to wxHaskell" 0
-- connect menu
frameSetMenuBar f m
evtHandlerOnMenuCommand f wxID_ABOUT (onAbout f)
evtHandlerOnMenuCommand f wxID_EXIT (onQuit f)
-- show it
windowShow f
windowRaise f
return ()
where
onAbout f = do
version <- versionNumber
messageDialog f "About 'Hello World'" ("This is a wxHaskell " ++ show version ++ " sample") (wxOK + wxICON_INFORMATION)
return ()
onQuit f = do
windowClose f True {- force close -}
return ()