wxcore-0.92.3.0: wxHaskell core

Copyright(c) Daan Leijen 2003
LicensewxWindows
Maintainerwxhaskell-devel@lists.sourceforge.net
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Graphics.UI.WXCore.Dialogs

Contents

Description

Standard dialogs and (non modal) tip windows.

Synopsis

Messages

errorDialog :: Window a -> String -> String -> IO () Source #

An error dialog with a single Ok button.

errorDialog parent "error" "fatal error, please re-install windows"

warningDialog :: Window a -> String -> String -> IO () Source #

An warning dialog with a single Ok button.

warningDialog parent "warning" "you need a break"

infoDialog :: Window a -> String -> String -> IO () Source #

An information dialog with a single Ok button.

infoDialog parent "info" "you've got mail"

confirmDialog :: Window a -> String -> String -> Bool -> IO Bool Source #

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 Source #

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 () Source #

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 () Source #

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) Source #

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] Source #

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) Source #

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) Source #

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) Source #

Show a font selection dialog with a given initial font. Returns Nothing when cancel was pressed.

colorDialog :: Window a -> Color -> IO (Maybe Color) Source #

Show a color selection dialog given an initial color. Returns Nothing when cancel was pressed.

passwordDialog :: Window a -> String -> String -> String -> IO String Source #

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 Source #

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) Source #

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 Source #

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 () -> Style -> IO b) -> Style -> String -> [(String, [String])] -> FilePath -> FilePath -> IO b Source #

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)