ダイアログボックス 【dialog box】(IT用語辞典)
「ダイアログ」とは「対話」と言う意味で、 GUI 操作画面でユーザに何らかの入力を促すために表示されるポップアップウインドウのことです。
- 「モーダルダイアログ」(modal dialog) : 表示中はウインドウの外の操作ができなくなる
- 「モードレスダイアログ」(modeless dialog): 他のウインドウの操作を行ってもよい
- 「メッセージボックス」:単純にメッセージを伝える
Graphics.UI.WX.Dialogs
ダイアログを表示するためのサンプル。
-- ghc --make dialogs.hs -o dialog module Main where import Graphics.UI.WX import Graphics.UI.WXCore main :: IO () main = start gui gui :: IO () gui = do form <- frame [text := "Test Dialogs"] p <- panel form [] ok <- button p [text := "Show Dialog", on command := dialogOpen form] quit <- button p [text := "Exit", on command := close form] set form [layout := container p $ column 0 [( margin 10 $ row 5 [widget ok, widget quit]) ] , clientSize := sz 300 200 ] return () where dialogOpen form = do -- sample はこの部分 errorDialog form "error" "fatal error, please re-install windows" ----------------------------------- return ()
- Modalダイアログ
dObj <- dialog form [text := "Demo", clientSize := sz 200 50] ok <- button dObj [text := "Ok"] result <- showModal dObj (\stop -> set ok [on command := stop (Just 42)])
- errorDialog
errorDialog form "error" "fatal error, please re-install windows"
- warningDialog
warningDialog form "warning" "you need a break"
- infoDialog
infoDialog form "info" "you've got mail"
- confirmDialog
最後のBool型引数はデフォルトボタンの選択:True->Yes False->No
ret <- confirmDialog form "confirm" "are you sure that you want to reformat the hardisk?" True
- proceedDialog
proceedDialog form "Error" "Do you want to debug this application?"
- fileOpenDialog (これはLinux)
fileOpenDialog :: Window a -> Bool -> Bool -> String -> [(String, [String])] -> FilePath -> FilePath -> IO (Maybe FilePath) fileOpenDialog form True True "Open image" [("Any file",["*.*"]),("Bitmaps",["*.bmp"])] "" ""
【2012/01/07】追記
- textDialog
textDialog で入力された文字をinfoDialogで表示します。
dialogOpen form = do inputString <- textDialog form "TextBox Title" "Dialog Title" "Default String" infoDialog form "TextDialog" inputString return ()
- passwordDialog
dialogOpen form = do -- sample はこの部分 inputString <- passwordDialog form "Password Title" "PasswordDialog Title" "DefaultPassword" infoDialog form "PasswordDialog" inputString ----------------------------------- return ()