Update of /cvsroot/htoolkit/gio/src/examples/simple In directory sc8-pr-cvs1:/tmp/cvs-serv16778/src/examples/simple Modified Files: Able.hs BitmapViewer.hs BouncingBalls.hs ByeDemo.hs Calculator.hs ConfigKey.hs ConfirmQuit.hs Counter.hs Fonts.hs Hanoi.hs Progress.hs SimpleControls.hs SimpleDialog.hs SimpleDrawing.hs SimpleHello.hs SimpleMenu.hs SimpleQuitButton.hs Log Message: Make possible to hide/show a window at any time. The newly created window is always hidden. Index: Able.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/Able.hs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Able.hs 1 Jul 2003 20:44:00 -0000 1.5 --- Able.hs 7 Oct 2003 21:39:31 -0000 1.6 *************** *** 16,19 **** --- 16,21 ---- enable "Control" bctrl ent enable "Window" bwnd w1 + showWindow w1 + showWindow w2 return () where Index: BitmapViewer.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/BitmapViewer.hs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** BitmapViewer.hs 30 May 2003 11:58:16 -0000 1.7 --- BitmapViewer.hs 7 Oct 2003 21:39:31 -0000 1.8 *************** *** 45,46 **** --- 45,47 ---- , on deactivate =: set mclose [enabled =: False, off command] ] + showWindow w Index: BouncingBalls.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/BouncingBalls.hs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** BouncingBalls.hs 3 Jul 2003 16:49:55 -0000 1.5 --- BouncingBalls.hs 7 Oct 2003 21:39:31 -0000 1.6 *************** *** 21,24 **** --- 21,25 ---- ] + showWindow w where nextBalls w vballs Index: ByeDemo.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/ByeDemo.hs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ByeDemo.hs 1 Jul 2003 20:44:00 -0000 1.5 --- ByeDemo.hs 7 Oct 2003 21:39:31 -0000 1.6 *************** *** 24,28 **** b <- button [title =: "Bye"] w set w [layout =: pad 10 (center l ^^^^ center b)] ! set b [on command =: bye l b] where -- called on the first click, with the window, label, and button as arguments. --- 24,29 ---- b <- button [title =: "Bye"] w set w [layout =: pad 10 (center l ^^^^ center b)] ! set b [on command =: bye l b] ! showWindow w where -- called on the first click, with the window, label, and button as arguments. Index: Calculator.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/Calculator.hs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Calculator.hs 21 Jun 2003 10:14:47 -0000 1.6 --- Calculator.hs 7 Oct 2003 21:39:31 -0000 1.7 *************** *** 16,19 **** --- 16,20 ---- "123+456-789*C0=/" set w [layout =: (pad 10 (hglue <<< display)) ^^^ grid (matrix 4 (map (hfix 50) keys))] + showWindow w where matrix n [] = [] Index: ConfigKey.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/ConfigKey.hs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ConfigKey.hs 4 Jul 2003 17:41:04 -0000 1.1 --- ConfigKey.hs 7 Oct 2003 21:39:31 -0000 1.2 *************** *** 12,13 **** --- 12,14 ---- l <- label [title =: prompt ++ show value] w set w [layout =: l] + showWindow w Index: ConfirmQuit.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/ConfirmQuit.hs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ConfirmQuit.hs 1 Jul 2003 20:44:00 -0000 1.4 --- ConfirmQuit.hs 7 Oct 2003 21:39:31 -0000 1.5 *************** *** 8,11 **** --- 8,12 ---- do w <- window [view =: sz 200 200] set w [on dismiss =: confirmQuit w] + showWindow w where confirmQuit w Index: Counter.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/Counter.hs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Counter.hs 13 Jul 2003 11:50:31 -0000 1.1 --- Counter.hs 7 Oct 2003 21:39:31 -0000 1.2 *************** *** 9,12 **** --- 9,13 ---- bminus <- button [title =: "+", tooltip =: "Increment Value", on command =: upd (\x->x+1) ent] w set w [layout =: hfill ent ^^^ hcenter (pad 5 (fill bplus <<< fill bminus))] + showWindow w where upd f ent = set ent [title ~: show . f . read] Index: Fonts.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/Fonts.hs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Fonts.hs 13 Jul 2003 17:51:31 -0000 1.1 --- Fonts.hs 7 Oct 2003 21:39:31 -0000 1.2 *************** *** 1,63 **** ! module Main where ! ! import Data.FiniteMap ! import Graphics.UI.GIO ! ! main = start "Fonts" "1.0" SDI [] $ do ! w <- window [] ! set w [on paint =: onPaint w, on resize =: \_ -> repaint w] ! names <- getFontNames ! styles <- popup [] w ! sizes <- popup [] w ! fonts <- popup [items =: map (\name -> (name, onSetFontName w styles sizes name)) names] w ! set w [layout =: hfill fonts <<< hfill styles <<< hfill sizes, size =: Size 400 200] ! where ! onSetFontName w styles popSizes name = do ! variants <- getFontVariants name 1 40 ! set styles [items =: foldFM (\w_s sizes items -> styleToItem w_s sizes : items) [] variants] ! where ! styleToItem (weight,style) sizes = ! (variantToString weight style, onSetFontStyle popSizes w name weight style sizes) ! ! onSetFontStyle popSizes w name weight style sizes = ! set popSizes [items =: map sizeToItem sizes] ! where ! sizeToItem size = ! (show size, onSetFontSize w (FontDef { fontName=name ! , fontSize=size ! , fontWeight=weight ! , fontStyle=style ! , fontUnderline=False ! , fontStrikeOut=False ! })) ! ! onSetFontSize :: Window -> FontDef -> IO () ! onSetFontSize w fontdef = do ! myfont <- createFont fontdef ! set w [font =: myfont] ! repaint w ! ! onPaint w can _ _ = do ! size <- get w view ! metrics <- get can canvasFontMetrics ! width <- get can (canvasFontStringWidth text) ! let Rect l t r b = centralRect (rectOfSize size) (Size width (fontLineHeight metrics)) ! drawString (Point l (t+fontAscent metrics)) text can ! where ! text = "Hello, world!" ! ! variantToString weight style = weightToString weight ++ " " ++ styleToString style ! where ! weightToString 100 = "thin" ! weightToString 200 = "ultra light" ! weightToString 300 = "light" ! weightToString 400 = "regular" ! weightToString 500 = "medium" ! weightToString 600 = "demi bold" ! weightToString 700 = "bold" ! weightToString 800 = "ultra bold" ! weightToString 900 = "black" ! ! styleToString Roman = "" ! styleToString Italic = "italic" ! styleToString Oblique = "oblique" --- 1,64 ---- ! module Main where ! ! import Data.FiniteMap ! import Graphics.UI.GIO ! ! main = start "Fonts" "1.0" SDI [] $ do ! w <- window [] ! set w [on paint =: onPaint w, on resize =: \_ -> repaint w] ! names <- getFontNames ! styles <- popup [] w ! sizes <- popup [] w ! fonts <- popup [items =: map (\name -> (name, onSetFontName w styles sizes name)) names] w ! set w [layout =: hfill fonts <<< hfill styles <<< hfill sizes, size =: Size 400 200] ! showWindow w ! where ! onSetFontName w styles popSizes name = do ! variants <- getFontVariants name 1 40 ! set styles [items =: foldFM (\w_s sizes items -> styleToItem w_s sizes : items) [] variants] ! where ! styleToItem (weight,style) sizes = ! (variantToString weight style, onSetFontStyle popSizes w name weight style sizes) ! ! onSetFontStyle popSizes w name weight style sizes = ! set popSizes [items =: map sizeToItem sizes] ! where ! sizeToItem size = ! (show size, onSetFontSize w (FontDef { fontName=name ! , fontSize=size ! , fontWeight=weight ! , fontStyle=style ! , fontUnderline=False ! , fontStrikeOut=False ! })) ! ! onSetFontSize :: Window -> FontDef -> IO () ! onSetFontSize w fontdef = do ! myfont <- createFont fontdef ! set w [font =: myfont] ! repaint w ! ! onPaint w can _ _ = do ! size <- get w view ! metrics <- get can canvasFontMetrics ! width <- get can (canvasFontStringWidth text) ! let Rect l t r b = centralRect (rectOfSize size) (Size width (fontLineHeight metrics)) ! drawString (Point l (t+fontAscent metrics)) text can ! where ! text = "Hello, world!" ! ! variantToString weight style = weightToString weight ++ " " ++ styleToString style ! where ! weightToString 100 = "thin" ! weightToString 200 = "ultra light" ! weightToString 300 = "light" ! weightToString 400 = "regular" ! weightToString 500 = "medium" ! weightToString 600 = "demi bold" ! weightToString 700 = "bold" ! weightToString 800 = "ultra bold" ! weightToString 900 = "black" ! ! styleToString Roman = "" ! styleToString Italic = "italic" ! styleToString Oblique = "oblique" Index: Hanoi.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/Hanoi.hs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Hanoi.hs 24 Aug 2003 15:35:56 -0000 1.4 --- Hanoi.hs 7 Oct 2003 21:39:31 -0000 1.5 *************** *** 29,35 **** main = start "Hanoi" "1.0" SDI [] $ mdo w <- window [domain =: Size 430 180, on paint =: onPaint ref] ! ref <- newIORef (initTowers 0) ! mhanoi <- menu [title =: "&Hanoi"] mainMenu mrun <- menu [title =: "&Run (nr disks)"] mhanoi --- 29,36 ---- main = start "Hanoi" "1.0" SDI [] $ mdo w <- window [domain =: Size 430 180, on paint =: onPaint ref] ! showWindow w ! ref <- newIORef (initTowers 0) ! mhanoi <- menu [title =: "&Hanoi"] mainMenu mrun <- menu [title =: "&Run (nr disks)"] mhanoi *************** *** 38,42 **** mhalt <- menuitem [title =: "Halt", accel =: KeyChar '.', enabled =: False, on command =: onHalt mrun mcont mhalt t] mhanoi mcont <- menuitem [title =: "Continue", accel =: KeyChar ',', enabled =: False, on command =: onCont mrun mcont mhalt t] mhanoi ! mspeed <- menu [title =: "&Speed"] mhanoi mVerySlow <- menuRadioItem [title =: "V&ery Slow", accel =: KeyChar '\^A', on command =: onSetSpeed speed1 t] mspeed mSlow <- menuRadioItem [title =: "&Slow", accel =: KeyChar '\^S', on command =: onSetSpeed speed2 t] mspeed --- 39,43 ---- mhalt <- menuitem [title =: "Halt", accel =: KeyChar '.', enabled =: False, on command =: onHalt mrun mcont mhalt t] mhanoi mcont <- menuitem [title =: "Continue", accel =: KeyChar ',', enabled =: False, on command =: onCont mrun mcont mhalt t] mhanoi ! mspeed <- menu [title =: "&Speed"] mhanoi mVerySlow <- menuRadioItem [title =: "V&ery Slow", accel =: KeyChar '\^A', on command =: onSetSpeed speed1 t] mspeed mSlow <- menuRadioItem [title =: "&Slow", accel =: KeyChar '\^S', on command =: onSetSpeed speed2 t] mspeed Index: Progress.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/Progress.hs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Progress.hs 21 Jun 2003 10:14:47 -0000 1.4 --- Progress.hs 7 Oct 2003 21:39:31 -0000 1.5 *************** *** 18,21 **** --- 18,22 ---- set sld [on command =: changeSpeed tm sld] set w [on destroy =: destroyWidget tm] + showWindow w return () where Index: SimpleControls.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/SimpleControls.hs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SimpleControls.hs 1 Sep 2003 20:27:50 -0000 1.2 --- SimpleControls.hs 7 Oct 2003 21:39:31 -0000 1.3 *************** *** 4,12 **** main = start "Controls" "1.0" SDI [] demo ! demo :: IO () demo = do w <- window [] nb <- notebook [] w ! -- Buttons page pg1 <- notebookPage [title =: "Buttons"] nb --- 4,12 ---- main = start "Controls" "1.0" SDI [] demo ! demo :: IO () demo = do w <- window [] nb <- notebook [] w ! -- Buttons page pg1 <- notebookPage [title =: "Buttons"] nb *************** *** 16,27 **** set group [layout =: b1pg1 <<<< b2pg1] set pg1 [layout =: group] ! -- Edit page pg2 <- notebookPage [title =: "Edit"] nb ! lbl <- label [title =: "Comments"] pg2 edit <- entry [] pg2 chk <- checkBox [title =: "Read only", on command =: set edit [readOnly ~: not]] pg2 set pg2 [layout =: (lbl <<<< (hglue <<< chk)) ^^^ hfill (vfill (edit))] ! -- radio buttons group <- groupBox [title =: "Tabs"] w --- 16,27 ---- set group [layout =: b1pg1 <<<< b2pg1] set pg1 [layout =: group] ! -- Edit page pg2 <- notebookPage [title =: "Edit"] nb ! lbl <- label [title =: "Comments"] pg2 edit <- entry [] pg2 chk <- checkBox [title =: "Read only", on command =: set edit [readOnly ~: not]] pg2 set pg2 [layout =: (lbl <<<< (hglue <<< chk)) ^^^ hfill (vfill (edit))] ! -- radio buttons group <- groupBox [title =: "Tabs"] w *************** *** 35,37 **** e <- entry [readOnly =: True, title =: "Hello, world!"] w set w [layout =: (group <<< vfill (hfill nb)) ^^^ hfill e] ! --- 35,37 ---- e <- entry [readOnly =: True, title =: "Hello, world!"] w set w [layout =: (group <<< vfill (hfill nb)) ^^^ hfill e] ! showWindow w Index: SimpleDialog.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/SimpleDialog.hs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SimpleDialog.hs 1 Jul 2003 20:44:00 -0000 1.2 --- SimpleDialog.hs 7 Oct 2003 21:39:31 -0000 1.3 *************** *** 2,6 **** import Graphics.UI.GIO - import Control.Monad(when) main --- 2,5 ---- *************** *** 15,18 **** b2 <- button [title =: "Open Modeless Dialog", on command =: showDialog False (Just d)] d set d [layout =: pad 10 (center (b1 <<< b2))] ! when b (runDialog d) --- 14,17 ---- b2 <- button [title =: "Open Modeless Dialog", on command =: showDialog False (Just d)] d set d [layout =: pad 10 (center (b1 <<< b2))] ! (if b then runDialog else showWindow) d Index: SimpleDrawing.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/SimpleDrawing.hs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SimpleDrawing.hs 30 May 2003 11:58:16 -0000 1.5 --- SimpleDrawing.hs 7 Oct 2003 21:39:31 -0000 1.6 *************** *** 10,13 **** --- 10,14 ---- ] set w [on motion =: \p -> set w [title =: ("mouse is at " ++ show p)]] + showWindow w where mypaint sserif14b c updFrame updArea Index: SimpleHello.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/SimpleHello.hs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SimpleHello.hs 1 Jul 2003 20:44:00 -0000 1.4 --- SimpleHello.hs 7 Oct 2003 21:39:31 -0000 1.5 *************** *** 3,7 **** import Graphics.UI.GIO ! main ! = start "hello world" "1.0" SDI [] $ ! do window [view =: sz 200 200] --- 3,5 ---- import Graphics.UI.GIO ! main = start "hello world" "1.0" SDI [] (window [view =: sz 200 200] >>= showWindow) Index: SimpleMenu.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/SimpleMenu.hs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SimpleMenu.hs 15 Aug 2003 21:24:54 -0000 1.9 --- SimpleMenu.hs 7 Oct 2003 21:39:31 -0000 1.10 *************** *** 6,9 **** --- 6,10 ---- = start "SimpleMenu" "1.0" SDI [] $ do w <- window [view =: sz 200 200] + showWindow w bmpNew <- readBitmap "res/new.bmp" [] Index: SimpleQuitButton.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/examples/simple/SimpleQuitButton.hs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SimpleQuitButton.hs 1 Jul 2003 20:44:00 -0000 1.4 --- SimpleQuitButton.hs 7 Oct 2003 21:39:31 -0000 1.5 *************** *** 9,10 **** --- 9,11 ---- q <- button [title =: "Quit", on command =: halt] w set w [layout =: pad 10 (center q)] + showWindow w |