wxcore-0.90.0.3: wxHaskell core

Portability | portable
Stability | provisional
Maintainer | wxhaskell-devel@lists.sourceforge.net
Safe Haskell | None

Graphics.UI.WXCore.Dialogs

Contents

- Messages
  - Non-modal
- Files
- Misc
- Internal

Description

Standard dialogs and (non modal) tip windows.

Synopsis

- 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
- tipWindowMessage :: Window a -> String -> IO ()
- tipWindowMessageBounded :: Window a -> String -> Rect -> IO ()
- 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)
- messageDialog :: Window a -> String -> String -> BitFlag -> IO BitFlag
- fileDialog :: Window a -> (FileDialog () -> Int -> IO b) -> Int -> String -> [(String, [String])] -> FilePath -> FilePath -> IO b

# 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?"

## Non-modal

tipWindowMessage :: Window a -> String -> IO ()

Opens a non-modal tip window with a text. The window is closed automatically when the user clicks the window or when it loses the focus.

tipWindowMessageBounded :: Window a -> String -> Rect -> IO ()

Opens a non-modal tip window with a text. The window is closed automatically when the mouse leaves the specified area, or when the user clicks the window, or when the window loses the focus.

# 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

# Internal

messageDialog :: Window a -> String -> String -> BitFlag -> IO BitFlag

A primitive message dialog, specify icons and buttons.

     r <- messageDialog w "Confirm" "Do you really want that?"
                           (wxYES_NO .+. wxNO_DEFAULT .+. wxICON_QUESTION)

fileDialog :: Window a -> (FileDialog () -> Int -> IO b) -> Int -> String -> [(String, [String])] -> FilePath -> FilePath -> IO b

Generic file dialog function. Takes a function that is called when the dialog is terminated, style flags, a message, a list of wildcards, a directory, and a file name. For example:

     fileOpenDialog
       = fileDialog parent result flags message wildcards directory filename
       where
         flags
          = wxOPEN .+. (if rememberCurrentDir then wxCHANGE_DIR else 0)
            .+. (if allowReadOnly then 0 else wxHIDE_READONLY)

        result fd r
          = if (r /= wxID_OK)
             then return Nothing
             else do fname <- fileDialogGetPath fd
                     return (Just fname)