21.23 Prompts Interface

ORIGIN '../guienv';
LIB_DEF 'guienvutilspromp' '../../lib';
BODY 'private/promptsbody';

--GuienvLib: attributes--

(* Standard text dialogs for guienv.
 * Known problems:
 *     1. Buttons should be highlighted when invoked via <return>, 
 *        <esc> etc.
 *     2. Patterns should be specializations of special dialog pattern,
 *        which would make the window manager treat the prompts as dialogs.
 *)

Prompt: window
  (* Dialog with a message text and an OK and Cancel button.
   * When typing <Return> in the text fiels, the OK button
   * is invoked, and when typing <Escape> the cancel button 
   * is invoked.
   *)
  (# <<SLOT prompt: attributes>>;
     menubarVisible:: (# do false -> value #);
     type:: (# do windowTypes.dialog->value #);
     ok:< Object
       (* Called when the OK button is clicked *);
     notok:< Object
       (* Called when the 'No' button is pressed (only promptForBoolean )*);
     cancel:< object 
       (* Called when the Cancel button is clicked *);
     extra_hspace:< integerValue
       (* Extra horizontal space to put to the right of the fields *);
     extra_vspace:< integerValue
       (* Extra vertical space to put between the fields and the buttons *);
     popup:<
       (* Used to pop up the dialog and wait for the text to be typed *)
       (# titleText, msgText: ^text;
          father: ^window;
       enter (father[], titleText[], msgText[])
       ...
       #);
     okLabel:< (# value: ^text do 'OK'->value[]; INNER exit value[] #);
     notokLabel:<
       (# value: ^text do 'NOT OK'->value[]; INNER exit value[] #);
     cancelLabel:<
       (# value: ^text do 'Cancel'->value[]; INNER exit value[] #);
     open::< (# ... #);
     private: @...;
  enter popup
  #);

PromptForText: Prompt
  (* Prompt with a field to enter a text added. *)
  (# <<SLOT promptForTextLib: attributes>>;
     usertext: ^text; (* The text entered by user *)
     linesInUsertext:< (* number of lines in the text field for user input *)
       integerValue(# do 1->value #);
     ok::<
       (# ... #);
     validate:< BooleanValue
       (* Called when the OK button is pressed. THIS(Prompt) is only
        * dismissed (and INNER in the ok virtual called) if validate returns 
        * true.
        *)
       (# hiliteOnError: @boolean
            (* Hilite text on error. Default true *);
       ...
       #);
     popup::<
       (# defaultText: ^text;
       enter defaultText[]
       ...
       #);
     open::< (# ... #);
     textprivate: @...;
  #);

PromptForInteger: PromptForText
  (* Special PromptForText that will only accept integer input *)
  (# <<SLOT promptForIntegerLib: attributes>>;
     userinteger: @integer (* The integer typed by the user *);
     validate::<
       (# ... #)
  #);

promptForBoolean: Prompt
  (* Special Prompt where the OK buttons has label 'Yes' and
   * there is an extra button with label 'No'.
   *)
  (# ok::<
       (# ... #);
     notok::< (* Called when the 'No' button is pressed *)
       (# ... #);
     okLabel::<
       (# do 'Yes'->value[]; INNER #);
     notokLabel::<
       (# do 'No'->value[]; INNER #);
     cancelLabel::<
       (# do 'Cancel'->value[]; INNER #);
     open::<
       (# ... #)
  #)


21.23 Prompts Interface
© 1994-2002 Mjølner Informatics
[Modified: Friday January 21st 2000 at 8:41]