Copyright | (c) Daan Leijen 2003 |
---|---|
License | wxWindows |
Maintainer | wxhaskell-devel@lists.sourceforge.net |
Stability | provisional |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
- type Dialog a = TopLevelWindow (CDialog a)
- dialog :: Window a -> [Prop (Dialog ())] -> IO (Dialog ())
- showModal :: Dialog b -> ((Maybe a -> IO ()) -> IO ()) -> IO (Maybe a)
- errorDialog :: Window a -> String -> String -> IO ()
- warningDialog :: Window a -> String -> String -> IO ()
- infoDialog :: Window a -> String -> String -> IO ()
- confirmDialog :: Window a -> String -> String -> Bool -> IO Bool
- proceedDialog :: Window a -> String -> String -> IO Bool
- fileOpenDialog :: Window a -> Bool -> Bool -> String -> [(String, [String])] -> FilePath -> FilePath -> IO (Maybe FilePath)
- filesOpenDialog :: Window a -> Bool -> Bool -> String -> [(String, [String])] -> FilePath -> FilePath -> IO [FilePath]
- fileSaveDialog :: Window a -> Bool -> Bool -> String -> [(String, [String])] -> FilePath -> FilePath -> IO (Maybe FilePath)
- dirOpenDialog :: Window a -> Bool -> FilePath -> FilePath -> IO (Maybe FilePath)
- fontDialog :: Window a -> FontStyle -> IO (Maybe FontStyle)
- colorDialog :: Window a -> Color -> IO (Maybe Color)
- passwordDialog :: Window a -> String -> String -> String -> IO String
- textDialog :: Window a -> String -> String -> String -> IO String
- numberDialog :: Window a -> String -> String -> String -> Int -> Int -> Int -> IO (Maybe Int)
- dialogEx :: Window a -> Style -> [Prop (Dialog ())] -> IO (Dialog ())
Generic dialogs
type Dialog a = TopLevelWindow (CDialog a) #
Pointer to an object of type Dialog
, derived from TopLevelWindow
.
showModal :: Dialog b -> ((Maybe a -> IO ()) -> IO ()) -> IO (Maybe a) Source #
Show a modal dialog. Take a function as argument that takes a function itself
as argument that can be used to end the modal dialog. The argument of this function
is returned as the result of the dialog. The result is Nothing
when the dialog
is dismissed via the system menu.
d <- dialog w [text := "Demo"] ok <- button d [text := "Ok"] ... result <- showModal d (\stop -> set ok [on command := stop (Just 42)])
Messages
errorDialog :: Window a -> String -> String -> IO () #
An error dialog with a single Ok button.
errorDialog parent "error" "fatal error, please re-install windows"
warningDialog :: Window a -> String -> String -> IO () #
An warning dialog with a single Ok button.
warningDialog parent "warning" "you need a break"
infoDialog :: Window a -> String -> String -> IO () #
An information dialog with a single Ok button.
infoDialog parent "info" "you've got mail"
confirmDialog :: Window a -> String -> String -> Bool -> IO Bool #
The expression (confirmDialog caption msg yesDefault parent
) shows a confirm dialog
with a Yes and No button. If yesDefault
is True
, the Yes button is default,
otherwise the No button. Returns True
when the Yes button was pressed.
yes <- confirmDialog parent "confirm" "are you sure that you want to reformat the hardisk?"
proceedDialog :: Window a -> String -> String -> IO Bool #
An dialog with an Ok and Cancel button. Returns True
when Ok is pressed.
proceedDialog parent "Error" "Do you want to debug this application?"
Files
fileOpenDialog :: Window a -> Bool -> Bool -> String -> [(String, [String])] -> FilePath -> FilePath -> IO (Maybe FilePath) #
Show a modal file selection dialog. Usage:
fileOpenDialog parent rememberCurrentDir allowReadOnly message wildcards directory filename
If rememberCurrentDir
is True
, the library changes the current directory to the one where the
files were chosen. allowReadOnly
determines whether the read-only files can be selected. The message
is displayed on top of the dialog. The directory
is the default directory (use the empty string for
the current directory). The filename
is the default file name. The wildcards
determine the entries
in the file selection box. It consists of a list of pairs: the first element is a description ("Image files"
)
and the second element a list of wildcard patterns (["*.bmp","*.gif"]
).
fileOpenDialog frame True True "Open image" [("Any file",["*.*"]),("Bitmaps",["*.bmp"])] "" ""
Returns Nothing
when the user presses the cancel button.
filesOpenDialog :: Window a -> Bool -> Bool -> String -> [(String, [String])] -> FilePath -> FilePath -> IO [FilePath] #
Opens a dialog that lets the user select multiple files. See fileOpenDialog
for a description
of the arguments. Returns the empty list when the user selected no files or pressed the cancel button.
fileSaveDialog :: Window a -> Bool -> Bool -> String -> [(String, [String])] -> FilePath -> FilePath -> IO (Maybe FilePath) #
Show a modal file save dialog. Usage:
fileSaveDialog parent rememberCurrentDir overwritePrompt message directory filename
The overwritePrompt
argument determines whether the user gets a prompt for confirmation when
overwriting a file. The other arguments are as in fileOpenDialog
.
dirOpenDialog :: Window a -> Bool -> FilePath -> FilePath -> IO (Maybe FilePath) #
Show a modal directory dialog. Usage:
dirOpenDialog parent allowNewDir message directory
The allowNewDir
argument determines whether the user can create new directories and edit
directory names. The message
is displayed on top of the dialog and directory
is the
default directory (or empty for the current directory). Return Nothing
when the users
presses the cancel button.
Misc.
fontDialog :: Window a -> FontStyle -> IO (Maybe FontStyle) #
Show a font selection dialog with a given initial font. Returns Nothing
when cancel was pressed.
colorDialog :: Window a -> Color -> IO (Maybe Color) #
Show a color selection dialog given an initial color. Returns Nothing
when cancel was pressed.
passwordDialog :: Window a -> String -> String -> String -> IO String #
Retrieve a password from a user. Returns the empty string on cancel. Usage:
passwordDialog window message caption defaultText
textDialog :: Window a -> String -> String -> String -> IO String #
Retrieve a text string from a user. Returns the empty string on cancel. Usage:
textDialog window message caption defaultText
numberDialog :: Window a -> String -> String -> String -> Int -> Int -> Int -> IO (Maybe Int) #
Retrieve a positive number from a user. Returns Nothing
on cancel. Usage:
numberDialog window message prompt caption initialValue minimum maximum
Primitive
dialogEx :: Window a -> Style -> [Prop (Dialog ())] -> IO (Dialog ()) Source #
Create a dialog window with a certain style.