Programmer Guide/Macro Library/BUTIL: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 3: Line 3:
|[[#MsgBox|<code>MsgBox</code> and <code>MsgBoxEx</code>]] || --
|[[#MsgBox|<code>MsgBox</code> and <code>MsgBoxEx</code>]] || --
|[[#FileDialog|<code>FileDialog</code>]] || --
|[[#FileDialog|<code>FileDialog</code>]] || --
|[[#DirectoryDialog|<code>DirectoryDialog</code>
|}
|}


Line 75: Line 76:


==FileDialog==
==FileDialog==
;<code>BUTIL FILEDIALOG <var>type</var> [ ; <var>title</var> ; <var>path</var> ]</code>: General file dialog.
;<code>BUTIL FILEDIALOG <var>type</var> [ ; <var>title</var> ; <var>path</var> ; <var>ftype1</var> ; ... ]</code>: General file dialog.
;<code>FILEOPENDIALOG [ '<var>title</var>' '<var>path</var>' ]</code>: Dialog to open an existing file
;<code>FILEOPENDIALOG [ '<var>title</var>' '<var>path</var>' 'ftype1' ... ]</code>: Dialog to open an existing file
;<code>FILENEWDIALOG [ '<var>title</var>' '<var>path</var>' ]</code>: Dialog to create a new file.
;<code>FILENEWDIALOG [ '<var>title</var>' '<var>path</var>' 'ftype1' ... ]</code>: Dialog to create a new file.
{|class="einrahmen"
{|class="einrahmen"
!argument !!description !!default
!argument !!description !!default
Line 94: Line 95:
|The default file or directory.
|The default file or directory.
|current directory
|current directory
|-
|<var>ftype1</var> ...
|Each <var>ftype</var> argument defines one entry of the filetype-combobox of the dialog.<BR>
Each filetype is defined by the string <code><var>extension</var>=<code>description</var></code>.<BR>
<var>extension</var> ... the extension used for the filetype<BR>
<var>description</var> ... a short description of the filetype<BR>
Example: <code>WAV=wave files</var><BR>
Note: If a <var>ftype</var> argument is the name of a (simple) table item, each entry of the table defines a filetype.
|-
|-
!RESULT !!description
!RESULT !!description
Line 101: Line 110:
|''empty string'' ||If the dialog was canceled.
|''empty string'' ||If the dialog was canceled.
|}
|}
==DirectoryDialog==
;<code>BUTIL DIRECTORYDIALOG [ <var>title</var> ; <var>path</var> ; <var>restore</var> ; <var>sdmode</var> ; <var>sdvalue</var> ]</code>:
;<code>DIRECTORYDIALOG [ '<var>title</var>' [ '<var>path</var>' '<var>restore</var>' '<var>sdmode</var>' '<var>sdvalue</var>' ]</code>: Dialog to select a directory.
{|class="einrahmen"
!argument !!description !!default
|-
|<var>type</var>
|Selects the action to perform:<BR>
<code>LOAD</code> or <code>OPEN</code> &rarr; open existing file<BR>
<code>SAVE</code> or <code>NEW</code> &rarr; create new file
|<code>OPEN</code>
|-
|<var>title</var>
|The caption of the dialog window.
|<code>Select File</code>
|-
|<var>file</var>
|The default file or directory.
|current directory
|-
!RESULT !!description
|-
|<code>path</code> ||The full pathname of the file to be opened or created.
|-
|''empty string'' ||If the dialog was canceled.
|}
<!--
/*++
.sub DirectoryDialog
.head DirectoryDialog
.call BUTIL DIRECTORYDIALOG title [; path ; restore ; subdirs ; subflag ; ...]
.arg title dialog window caption
.arg path default directory or * for current
.arg restore restore current working directory (No|Yes)
.arg subdirs show sub-directory checkbox (No|Yes)
.arg subflag state of sub-directory checkbox (Off|On)
.return empty string (cancel), 'directory' (if subdirs=No),
'directory;subflag' (if subdirs=Yes, value of subflag equals 0 or 1)
.text Display a directory select dialog. If subdirs is set to Yes (1) a
check-box for sub-directory processing is displayed.
.end
--*/
CmdDirectoryDialog:
readstr '* no no Select Directory' #path #restore #subdirs #title
readvar #argv #title';'#path';'#restore';'#subdirs';'#subflag';'#
#pwd := pwd
#restore := $(butil getswitch $#restore;no)
#subdirs := $(butil getswitch $#subdirs;no)
#subflag := $(butil getswitch $#subflag;no)
-->

Revision as of 12:25, 11 May 2011

MsgBox and MsgBoxEx -- FileDialog -- [[#DirectoryDialog|DirectoryDialog

MsgBox

BUTIL MSGBOX type [buttonlist] [ ; text ; title ; maxtime [timestep ; xpos ; ypos ; monitor ; defaultbutton ]
BUTIL MSGBOXEX 'type [buttonlist]' 'text' [ 'title' 'maxtime [timestep]' 'xpos' 'ypos' 'monitor' 'defaultbutton' ]
Display a message box dialog.


argument description default
type [buttonlist] Defines the type of the message box and the displayed buttons (see table below).
The buttonlist is the blank seperated list of buttons, if type is set to USERDEFINED.
text The text to be displayed in the message box.
title Caption of the message box. name of the STx application
maxtime [timestep] If this argument is a number, it is used as timeout value in seconds.
If a timeout is set, a progress bar is displayed and the message box is closed automatically after timeout seconds. The timestep is the time for the progress bar update in seconds (if <1) or milli-seconds (if ≥1). The default timestep is set to 50ms.
no timeout
xpos Horizontal position in pixels or keyword LEFT, RIGHT, CENTER.
If xpos is a number it specifies, the offset to the left (≥0) or the right (<0) side of the desktop.
depends on parent window
ypos Vertical position in pixels or keyword TOP, BOTTOM, CENTER.
If ypos is a number it specifies, the offset to the top (≥0) or the bottom (<0) of the desktop.
depends on parent window
monitor The index (1, 2, ..) of the monitor to display the message box on. monitor the mouse is on
defaultbutton The index (1, 2, ..) of the default button, which will initially be receiving the focus. Buttons are numbered from left to right, starting with index 1. 1
RESULT description
CANCEL If the message box was closed using the close button or the [Escape]-key.
TIMEOUT If a timeout was set and the maximum timout value was reached before a user input.
button The name of the pressed button.
Note that USERDEFINED buttons using the ampersand & to underline a letter (e.g. &Segment) return the keyword including the ampersand.


type buttons (return values are specified in brackets)
NONE no buttons, message box must be closed with the [Escape]-key or by using a timeout
Msg or Message OK (okay)
OkayCancel OK (okay), Cancel (cancel)
OkayRetryCancel OK (okay), Retry (retry) Cancel (cancel)
YesNo Yes (yes), No (no)
YesNoCancel Yes (yes), No (no) Cancel (cancel)
UserDefined buttons are defined by the argument buttonlist


FileDialog

BUTIL FILEDIALOG type [ ; title ; path ; ftype1 ; ... ]
General file dialog.
FILEOPENDIALOG [ 'title' 'path' 'ftype1' ... ]
Dialog to open an existing file
FILENEWDIALOG [ 'title' 'path' 'ftype1' ... ]
Dialog to create a new file.
argument description default
type Selects the action to perform:

LOAD or OPEN → open existing file
SAVE or NEW → create new file

OPEN
title The caption of the dialog window. Select File
file The default file or directory. current directory
ftype1 ... Each ftype argument defines one entry of the filetype-combobox of the dialog.

Each filetype is defined by the string extension=description.
extension ... the extension used for the filetype
description ... a short description of the filetype
Example: WAV=wave files
Note: If a ftype argument is the name of a (simple) table item, each entry of the table defines a filetype.

RESULT description
path The full pathname of the file to be opened or created.
empty string If the dialog was canceled.

DirectoryDialog

BUTIL DIRECTORYDIALOG [ title ; path ; restore ; sdmode ; sdvalue ]
DIRECTORYDIALOG [ 'title' [ 'path' 'restore' 'sdmode' 'sdvalue' ]
Dialog to select a directory.
argument description default
type Selects the action to perform:

LOAD or OPEN → open existing file
SAVE or NEW → create new file

OPEN
title The caption of the dialog window. Select File
file The default file or directory. current directory
RESULT description
path The full pathname of the file to be opened or created.
empty string If the dialog was canceled.


Navigation menu

Personal tools