Some user-interface extensions to Poplog 
Author Message
 Some user-interface extensions to Poplog

This message describes some extensions to Poplog X facilities available
via ftp from Sussex.

The Poplog+X interface is very powerful and general, and there is
a great deal of it. However it is mostly fairly low level (hence the
generality) and if you wish to produce an interface to a program it
can be difficult at times to find out how, especially if you are not
an expert on X.

There are some fairly high level and easy to use graphical facilities in
LIB RC_GRAPHIC, LIB RC_GRAPHPLOT, LIB RC_GRAPHPLOT2, and more will be
provided in the GO (Graphical Objects) library to be soon to be
distributed with Poplog Version 14.5.

This still leaves a gap regarding simple facilities for textual
interaction, menu facilities, etc. all of which are supported, at a low
level, by LIB PROPSHEET. Some higher level facilities are available in
the POPLOG_UI library, and described in REF POP_UI in the online
documentation in Poplog (at least since version 14.2).

I have extended and generalised some of these, and Ian Rogers has now
made them available in the PLUG archive on the Sussex University ftp
server: ftp.cogs.susx.ac.uk

Look for them in the compressed tar file:
        pub/plug/ui.tar.Z

I can probably send a uuencoded version of the file if anyone wants
it and can't use ftp. It's not a very large package.

I'll append the draft HELP file to this message. Note that this is a
first draft library, and is liable to be revised. Suggestions welcome.

Unfortunately the facilities concerned with vertical columns of menu
buttons (implemented with help from Adrian Howard) won't work with
Motif, since I don't have Motif and don't know the Propsheet widget
structure, so if anyone is willing to do the port to Motif Poplog and
test it I'd be happy to install the extension.

I don't know whether the font and colour changing tools will work with
Motif, though as far as I am aware I have not used OpenLook-specific
features.

I have so far tested the package on Poplog on SunOS 4.1.3 and on Solaris
2.2 and 2.3 (Poplog V14.5 pre-release).

Aaron
Help file follows:
=======================================================================
HELP POP_UI_POPUPTOOL                              Aaron Sloman Dec 1993

LIB * POP_UI_POPUPTOOL
LIB * POP_UI_ANCHOR
LIB * POP_UI_COLOURS
LIB * POP_UI_FILESELECT
LIB * POP_UI_FONT
LIB * POP_UI_GETINPUT
LIB * POP_UI_LOCATION
LIB * POP_UI_QUERY
LIB * POP_UI_SELECT
LIB * POP_UI_SET_VERTICAL
LIB * POP_UI_WARP_TO

-- Introduction -------------------------------------------------------

These libraries provide extensions to the facilities described in in the
file REF * POP_UI. In particular, the new facilities are designed to
simplify the creation of popup menus or selection panels.

The main procedure provided here is pop_ui_popuptool, described below.
It makes use of mechanisms described in TEACH * PROPSHEET, which are
very powerful and general. Those mechanisms have also been used in the
Poplog UI facilities described in REF * POP_UI. Those facilities
do not provide all of the frequently encountered requirements, so
some additions are provided here.

E.g. there was a need for a collection of utilities to perform tasks
like presenting a menu of options in a specific location on the screen,
with the menu of options arrayed in a vertical column. (The default for
LIB * PROPSHEET is horizontal, which works well only for very short
lists of options.).

There was also a need for facilities for changing colours or fonts
of indivdual widgets.

Unfortunately I have not been able to try the new facilities out on a
Motif Poplog system, and it is very likely that some of the libraries
would need to be modified to work under Motif.

These have been tried with Poplog + OpenLook libraries on SunOS 4.1.3
and Solaris 2.2. You can tell whether your Poplog is of this type
by giving the following command to Pop-11

    XLINK_TYPE =>
which should print out
    ** openlook

(See HELP NEWPOP on linking options).

         CONTENTS - (Use <ENTER> g to access required sections)

 -- Introduction
 -- Tutorial on pop_ui_popuptool
 -- - The inputs to pop_ui_popuptool
 -- Making the library available
 -- - Example
 -- - Allowing subset selection (true 4th argument)
 -- - Using strings as selection options
 -- - Using integers as options
 -- pop_ui_current_window
 -- pop_ui_location
 -- - Types of location specifiers
 -- Text input from the user: pop_ui_getinput
 -- - Examples using pop_ui_getinput
 -- - pop_ui_readstrings
 -- - pop_ui_readline
 -- Tracing input obtained via pop_ui_getinput
 -- Getting an editor command: pop_ui_vedcommand
 -- Changing button orientation: false -> pop_ui_horizontal
 -- pop_ui_set_vertical
 -- pop_ui_fileselect
 -- pop_ui_getfile (Getting files from disk)
 -- Other POP_UI facilities
 -- Changing colour of a display using pop_ui_colours
 -- Changing font in a propbox
 -- Warping the mouse pointer (pop_ui_warp_to)
 -- pop_ui_query
 -- Centring a query panel on another widget
 -- pop_ui_select (Select a subset)
 -- pop_ui_anchor (Location specifier widget)
 -- NOTE about pop_ui_popuptool
 -- SEE ALSO:

-- Tutorial on pop_ui_popuptool ---------------------------------------

-- - The inputs to pop_ui_popuptool

pop_ui_popuptool takes four arguments
    1. A question to be put to the user

    2. A list of possible answers (words or strings)

    3. A location specifier, described below, or false.

    4. A boolean to determine whether an arbitray subset of the
       options can be selected. If false, exactly one selection
       must be made, otherwise any subset is accepted.

It returns one result, which is either a word or string selected
if the fourth argument is false, otherwise a list containing the
options selected. The list may be empty.

-- Making the library available ---------------------------------------

Mark and load the following

uses pop_ui_popuptool;

-- - Example

The following command, which you should mark and load, will produce a
menu with a question and three options, and will locate it in the middle
of the screen, or if you are using XVed, in the middle of the current
window. You can dismiss the window by clicking on one of the options,
after which the item you selected will be printed out:

pop_ui_popuptool(
    'Are you confident?', [Very Somewhat No], wvedwindow, false) =>

The "false" argument at the end restricts this to a single choice menu.

We can ask it to do the same, but placing the menu against the right
hand edge of the screen, by giving a location specifier as third
argument which is a vector of two integers, the first being a small
negative number (i.e. a negative "x" coordinate):

pop_ui_popuptool(
    'Are you confident?', [Very Somewhat No], {-1 400}, false) =>

or near the middle of the bottom edge by making "y" small and negative:

pop_ui_popuptool(
    'Are you confident?', [Very Somewhat No], {500 -1}, false) =>

-- - Allowing subset selection (true 4th argument)

Making the fourth argument true produces a different format:

pop_ui_popuptool(
    'Are you confident?', [Very Somewhat No], {500 -1}, true) =>

You can independently select and deselect the three options before
finally clicking on the "Accept" button in the bottom row. The procedure
will then return a list of words indicating which items you selected. If
you wish to accept All of them or None of them you can do so by
selecting all of them, or ensuring that all are deselected. But there
are short-cuts provided in the form of select buttons marked "All" and
"None" at the bottom.

If you invoke the same combination of question and options more than
once, the selected subset is remembered so that you can choose the
same subset again simply by clicking on Accept.

-- - Using strings as selection options

Here is a different example, where the options are all strings and the
third (location) argument is false, so that the display panel will
appear in the middle of the screen.

pop_ui_popuptool(
    'how are you?', ['Very well' 'Happy' 'Rich' 'So calm'],
        false, true) =>

Note that if you include the first or fourth items in the selected
subset, the printout will make it look as if there are two words,
rather than one string, unless you make pop_pr_quotes true. (See
HELP * pop_pr_quotes). Try the above example again, and select All,
after marking and loading each of these two lines.

true -> pop_pr_quotes;

false -> pop_pr_quotes;

-- - Using integers as options

You cannot put integers into the options list, unless you first
convert them to strings: The following produces a mishap message:

pop_ui_popuptool( 'Think of a number', [1 2 3], false, true) =>

Whereas this doesn't

pop_ui_popuptool( 'Think of a number', ['1' '2' '3'], false, false) =>

However, if you wish the result to be converted back to a number,
us strnumber to do it. (See REF * strnumber)

-- pop_ui_current_window ----------------------------------------------

This is a variable whose value is set after pop_ui_popuptool has been
used. It always refers to the last popup panel displayed. Its value will
be a propbox, of the type produced by propsheet_new (as illustrated in
TEACH * PROPSHEET)

pop_ui_current_window =>

You can use propsheet_show and propsheet_hide to make the panel appear
and disappear. Clicking on one of the select buttons will make it
disappear but will otheriwse have no effect unless the panel is invoked
by pop_ui_popuptool or something that calls it. However, you can change
the setting in a selection panel, and the changes will be remembered for
next time. Try the following and see what happens if you click on one of
the bottom buttons.

propsheet_show(pop_ui_current_window);
propsheet_hide(pop_ui_current_window);

-- pop_ui_location ----------------------------------------------------

This procedure can be used to interrogate the location of the most
recently produced panel, or any other panel produced by propsheet_new,
and its updater can be made to change it.

propsheet_show(pop_ui_current_window);

The base procedure returns two numbers, the "x" and "y" coordinates of
the panel relative to the screen:

pop_ui_location(pop_ui_current_window) =>

If you move the panel and redo the command, the numbers will change.

This will work also for a propbox not produced by pop_ui_popuptool, e.g.

vars mybox=propsheet_new_box('Demo Box', false, false, [A B C Dismiss]);
vars mysheet = propsheet_new('Dummy panel', mybox, false);
propsheet_show(mysheet);
propsheet_show(mybox);

pop_ui_location(mybox) =>

-- - Types of location specifiers

You can also alter the location of a propbox by assigning a location
specifier to its pop_ui_location, where a location specifier can
either be

false
    Meaning, use the centre of the screen

Another widget
    Meaning locate it at the centre of that widget

A pair of integers, positive or negative
    Where negative X refers to distance (in pixels) from the right edge
    and negative Y refers to distance from bottom of screen

A vector containing a pair of integers, positive or negative.

The following examples illustrates how the above comments can be
applied to the two widgets created above, pop_ui_current_window and
propbox;

pop_ui_location(mybox) =>
pop_ui_location(pop_ui_current_window) =>

propsheet_show(mybox);
propsheet_show(pop_ui_current_window);

-1, 300 -> pop_ui_location(mybox);

{25 -10} -> pop_ui_location(pop_ui_current_window);

;;; The following will put the window at the middle of the screen

false  -> pop_ui_location(pop_ui_current_window);

In XVed try the following, though be warned : it goes to the centre of
the current XVed window, and may then be covered as input focus returns
to the window. So you may have to bring it to the surface using
propsheet_show.

wvedwindow  -> pop_ui_location(pop_ui_current_window);
propsheet_show(pop_ui_current_window);

By giving another widget as location specifier you can put
pop_ui_current_window on top of it.

mybox -> pop_ui_location(pop_ui_current_window);

The next example will centre mybox on the current VED window if you are
using XVed:

wvedwindow -> pop_ui_location(mybox);
propsheet_show(mybox);

Notice that the other panel does not follow this one automatically even
though previously it was centred on it.

-- Text input from the user: pop_ui_getinput --------------------------

This procedure can be used to obtain a string of text input from the
user. By using sysparse_string or other facilities the output can be
turned into a list of strings, or words.

pop_ui_getinput(<string1>,<string2>,<string3>,<loc>) -> <string>

A panel will be presented, inviting the user to type something in a text
field. <string1> is used as the title in the title bar. <string2> is
presented as a prompt, displayed centred above the field where the user
is to type. <string3> is the default string that will be put into the
text field. It could show a pattern for the user to type. <loc>
specifies location, and can take the same forms as for pop_ui_popuptool,
i.e. false, or a vector of two integers (positive or negative) or
another widget on which this one is to be centred.

For full details SHOWLIB * POP_UI_GETINPUT

-- - Examples using pop_ui_getinput

pop_ui_getinput('Prompt','Your name please','<name>',{-1 300})=>

-- - pop_ui_readstrings

If the output is to be made into a list of strings and numbers use
something like this (see * SYSPARSE_STRING):

define pop_ui_readstrings(title,prompt,default,loc) -> list;
    lvars title, prompt, default, loc, list;

    sysparse_string(
        pop_ui_getinput(title,prompt,default,loc), true) -> list
enddefine;

;;; Test it
pop_ui_readstrings('Prompt','How are you','',wvedwindow)=>

LIB * POP_UI_READSTRINGS exists in the library and is defined as above.

-- - pop_ui_readline

If you wish the input to be of the same type as readline produces, use
the following:

define pop_ui_readline(title,prompt,default,loc) -> list;
    lvars title, prompt, default, loc, list;
    ;;; create a dynamic list from the input string
    pdtolist(
        incharitem(
            stringin(pop_ui_getinput(title,prompt,default,loc)))
        ) -> list;
    ;;; expand the dynamic list
    expandlist(list) -> list;
enddefine;

;;; Test it
compile(pop_ui_readline('Prompt','Type some pop11 text','',wvedwindow))=>

You can then type in something like

    99 * 9 + 5
or
    hd([the cat sat on the mat])

and have it evaluated.

LIB * POP_UI_READLINE exists in the library and is defined as above.

-- Tracing input obtained via pop_ui_getinput

Once pop_ui_getinput has been loaded, either explicitly or via one of
its derivatives (e.g. pop_ui_readstrings, pop_ui_readline) a tracing
facility is provided in the form of a user definable procedure:

    pop_ui_traceinput(prompt, reply)

This has a default definition as follows:

global vars pop_ui_inputs = [];

define pop_ui_traceinput(prompt, reply);
    ;;; User definable tracing procedure
    conspair(prompt,reply) :: pop_ui_inputs -> pop_ui_inputs;
enddefine;

I.e. it creates in reverse chronological order a list of prompt+reply
pairs, held in the list pop_ui_inputs. To see the trace for the current
session do:

    pop_ui_inputs ==>

Note that a pair containing two strings prints in square brackets, with
a vertical bar between them, e.g.

    conspair('Type some text', 'Ok here it is') =>
    ** [Type some text|Ok here it is]

For more sophisticated tracing the above procedure can be redefined,
e.g. to send output to a file.

-- Getting an editor command: pop_ui_vedcommand -----------------------

You can use the getinput facility to create a procedure that prompts the
user for a command to be obeyed in VED.

define pop_ui_vedcommand();
    lvars
        string =
    pop_ui_getinput(
        'VED COMMAND', 'Type VED ENTER Command','',wvedwindow);

    unless string = nullstring then
        vedinput(veddo(%string, true%))
    endunless
enddefine;

For full details see HELP * VEDINPUT, * VEDDO

Try the above, by giving a command to search for vecommand in response
to the prompt:

pop_ui_vedcommand();

It would be possible to map that procedure onto the ENTER key. Instead
try the following, which maps it onto Control-]

    vedsetkey('\^]', "pop_ui_vedcommand");

For some purposes this may be more convenient than ENTER. However the
use of the status line via the ENTER key or the STATUSSWITCH key has the
advantage that one can access and edit or redo previous commands that
were given on the status line. See HELP * VEDCOMMANDS

-- Changing button orientation: false -> pop_ui_horizontal ------------

This variable is used for determining orientation of the bottom set of
option buttons in panels produced by pop_ui_popuptool. It has the
following default:

global vars pop_ui_horizontal = true;

It controls whether the buttons at the bottom of the popuptool display
are arranged horizontally or vertically. The default is horizontal, but
that can be disastrous if there are several options and they are fairly
long strings or words. Try the following:

vars people =
    [ 'Tom Jones' 'Mary Jones' 'Suzie Smith' 'Tom John Watson'
      'Hannah May Bloggs' 'Fred Bloggs' 'Barbara Towers'
      'Jackie Major' 'Maggie Tiler' 'Willy Weeper'
    ];

Offer a choice of favourite:

pop_ui_popuptool(
    'Who is your favourite person??', people, false, false) =>

If the list were twice as long it would not fit on the screen.

The global variable pop_ui_horizontal can be set false if several
options consisting of long words or strings are to be offered in a menu.
Try:

global vars pop_ui_horizontal = false;

And then redo the above command:
pop_ui_popuptool(
    'Who is your favourite person??', people<>people, false, false) =>

Reset the default value, and try again:

global vars pop_ui_horizontal = true;

-- pop_ui_set_vertical ------------------------------------------------

The procedure pop_ui_set_vertical, which takes a widget and a boolean
can be used to alter the orientation of the action buttons on a propbox
after it has been created. Try the following:

propsheet_show(pop_ui_current_window);
propsheet_hide(pop_ui_current_window);
pop_ui_set_vertical(pop_ui_current_window, true);
propsheet_show(pop_ui_current_window);
propsheet_hide(pop_ui_current_window);
pop_ui_set_vertical(pop_ui_current_window, false);
propsheet_show(pop_ui_current_window);

WARNING: If you change the setting from vertical to horizontal, without
creating a completely new panel, the program may get confused, and you
could end up having to dismiss the panel and then recreate it using
propsheet_new_box or pop_ui_popuptool. In particular, if button widths
have been expanded to line up in vertical format, then then if the same
panel is set horizonal they will take up more space than before.

There are some applications for which it is very likely that the
horizontal format will be unsuitable, so for such applications it may be
useful to set the format vertical by default, by making
pop_ui_horizontal false locally in the relevant procedures.

For example,

define column_query(string, list) -> answer;
    lvars string, list, answer;
    dlocal pop_ui_horizontal = false;
    ;;; set location middle of screen, no subset
    pop_ui_popuptool(string, list, false, false) -> answer;
enddefine;

Compile that (ESC c) then try the following, using the list "people"
defined above:

column_query('Who is your worst enemy?', people) =>

The library provides a number of utilities that make use of the vertical
format for action buttons.

-- pop_ui_fileselect --------------------------------------------------

This utility provides an alternative to vedfileselect for selecting
one of the currently active ved files.

It could be defined roughly as follows:

define pop_ui_fileselect();
    lvars file, files;

    [%vedappfiles(procedure; vedpathname endprocedure)%] -> files;

    ;;; Make menus vertical in format, and prevent mouse warping
    dlocal pop_ui_horizontal = false, vedwarpcontext = false;

    pop_ui_popuptool(
        'Choose file please', files, wvedwindow, false) -> file;

    edit(file);
    vedcurrentfile -> vedinputfocus;
    true -> wvedwindowchanged;
enddefine;

In order to make this replace vedfileselect as the procedure invoked
by the "ESC e" sequence (see HELP VEDKEYS, and HELP VEDNEWKEYS) you
could do the following

lib pop_ui_fileselect;     ;;; to get the library version

vedsetkey('\^[e', "pop_ui_fileselect");

After that the VED sequence "ESC e" will invoke this procedure.

Users of LIB VEDEMACS may prefer to do the following to map the new
procedure onto the sequence "^X b"

vedsetkey('\^Xb', "pop_ui_fileselect");

See HELP * VEDEMACS, LIB * VEDEMACS

-- pop_ui_getfile (Getting files from disk) ---------------------------

uses pop_ui_getfile;

pop_ui_getfile(<filter>, <lim>) -> <file(s)>                 [procedure]

This procedure is given a string containing a pattern suitable for
directory searching (See * SYS_FILE_MATCH), and a limit which can be
false, meaning no limit, or an integer, specifying the maximum number of
files to be displayed.

It uses sys_file_match to search for files matching the pattern, and
then uses pop_ui_popuptool to display the set of file names possibly
truncated according to <lim>. The file chosen by the user could then,
for example, be inserted into VED, e.g. using the procedure edit.

Example

    pop_ui_getfile('$popsys/*11*', false) =>
    pop_ui_getfile('$popsavelib/*', false) =>

You can give it a filter that can be used to choose a file for editing,
and then apply edit to the result, e.g.

    edit(pop_ui_getfile('a*.p', false));

Or do the following to insert the selected file name into the current
ved buffer (don't compile the next line with the cursor in the middle of
the line):

    vedinsertstring((pop_ui_getfile('~/*', 25)));

    edit(pop_ui_getfile('$usepop/pop/lib/*/*unix*.p', false));

Related facilities are described in REF * POP_UI, notably
    * pop_ui_filetool
    * pop_ui_edittool
    * pop_ui_compiletool

E.g. try this procedure

pop_ui_edittool(false, '$usepop/pop/x/pop/teach','*', wvedwindow);

and compre with the following:

define pop_ui_editfile(defaultproc, filter);
    ;;; String is a file name pattern, procedure something like
    ;;; vedhelpdefaults or vedveddefaults, to set file defaults.
    lvars filter, loc, defaultproc, file;

    ;;; Get file name from user
    pop_ui_getfile(filter, wvedwindow) -> file;
    vededitor(defaultproc,file);
    vedcurrentfile  -> vedinputfocus;
enddefine;

Test it:

pop_ui_editfile(vedhelpdefaults, '$usepop/pop/x/pop/teach/*');

pop_ui_editfile(vedhelpdefaults, '$usepop/pop/x/pop/ref/xpt*');

Note - if you wish to abort such a selection you can interrupt by typing
in the Poplog window. (CTRL-C).

-- Other POP_UI facilities --------------------------------------------

-- Changing colour of a display using pop_ui_colours ------------------

CHANGING COLOURS WILL NOT YET WORK WITH MOTIF

uses pop_ui_colours;

Makes available the following facility

pop_ui_colours(<propbox>) -> <list>                          [procedure]
<string1> <string2> <string3> -> pop_ui_colours(<propbox>)

In access mode the procedure crawls over the whole widget tree and
returns a list of vectors, where each vector is of the form

    {<widget> <foreground> <background> <fontcolour> }

This list will not be of much use except possibly for experts. The
updater is far more useful, as the three strings can be used to change
the foreground, background and font colours. (The procedure does not
seem to work on Solaris Poplog.)

Here are some examples:

vars mybox=propsheet_new_box('TEST', false, false, [Big Small Dismiss]);
vars mysheet = propsheet_new('Dummy Panel', mybox, false);
propsheet_show(mysheet);
propsheet_show(mybox);

;;; Put the box somewhere useful:
-100, 350 -> pop_ui_location(mybox);

;;; The updater can be used to set background and fontcolour, as follows
;;; the "foreground" (namely the first argument) seems to have no effect
;;; fg     bg      font
'pink', 'yellow', 'blue' -> pop_ui_colours(mybox);
'black', 'white', 'black' -> pop_ui_colours(mybox);

Try changing the file selector colours. Run this command and select the
current file (the first option):

pop_ui_fileselect();

Show the panel again:
propsheet_show(pop_ui_current_window);
'pink', 'yellow', 'blue' -> pop_ui_colours(pop_ui_current_window);
propsheet_hide(pop_ui_current_window);

-- Changing font in a propbox -----------------------------------------

CHANGING FONT WILL NOT YET WORK WITH MOTIF

It is possible to use the updater of procedure pop_ui_font to vary the
font displayed:

uses pop_ui_font;

;;; See TEACH * PROPSHEET for examples like this:

vars mybox=propsheet_new_box('TEST', false, false, [Big Small Dismiss]);
vars sheet1 = propsheet_new('SAMPLE PANEL', mybox, false);
propsheet_field(sheet1, [
        [Filename 'default.p']
        [Number 10 kilobytes]              ;;; a narrow text field
        [Switch true ]           ;;; a toggle switch
        [List  oneof [cat dog rat mouse flea] (default=2)]
        [Options menuof [yes no unset] ]
        [Flags someof {bold italic}]
    ]);
propsheet_show(sheet1);
propsheet_show(mybox);

;;; Changing font is best done with the panel invisible
;;; (Some of these font changes may not work on your system)
propsheet_hide(mybox);
'-adobe-helvetica-bold-r-normal-*-*-100-*-*-p-*-*-*' -> pop_ui_font(mybox);
propsheet_show(mybox);
or using a fixed width font
propsheet_hide(mybox);
'6x13' -> pop_ui_font(mybox);
propsheet_show(mybox);
propsheet_hide(mybox);
'-adobe-helvetica-bold-r-normal-*-*-120-*-*-p-*-*-*' -> pop_ui_font(mybox);
propsheet_show(mybox);

;;; Try a bigger font: may spoil some of the fields, on account of wrong
;;; geometry:
propsheet_hide(mybox);
'-adobe-helvetica-bold-r-normal-*-*-140-*-*-p-*-*-*' -> pop_ui_font(mybox);
propsheet_show(mybox);

WARNING: some of the fields may be spoiled by font changes, especially
changing from a smaller to a larger font.

;;; Now try a fixed width font
propsheet_hide(mybox);
'10x20' -> pop_ui_font(mybox);
propsheet_show(mybox);

If you are enlarging the font, it is best to update font BEFORE creating any
text fields.

It is hoped that there will be better support for all this in later
versions.

-- Warping the mouse pointer (pop_ui_warp_to) -------------------------

It is sometimes useful to be able to move the mouse to a new panel, to
help users when they are required to make a selection.

uses pop_ui_warp_to;

vars mybox=propsheet_new_box('TEST', false, false, [Big Small Dismiss]);
vars sheet1 = propsheet_new('SAMPLE PANEL', mybox, false);
propsheet_show(sheet1);
propsheet_show(mybox);

Compare:

pop_ui_warp_to(sheet1);

You can warp the mouse pointer to an invisible box:

propsheet_hide(mybox);
pop_ui_warp_to(mybox);

-- pop_ui_query -------------------------------------------------------

A very simple menu facility, for use with X. Give it a question, a
list of possible answers, and a location specifier, as described above.

It will interrogate the user and return the selected answer.

To make it available do:

uses pop_ui_query

Mark and load this example to see the functionality of pop_ui_query

    pop_ui_query(
        'Which language\ndo you use?',
            [C Pop11 Lisp Prolog ML], false) =>

That appears in centre of screen, unlike this one:

    pop_ui_query('Do you like VED?', ['Yes' 'A lot'], {700 20})=>

The general format is as follows:

pop_ui_query(<question string>, <option list>, <loc>) -> <answer>;

<question string> is a string, possibly containing newlines, to be
    presented to the user. It will usually be a question, appearing in a
    panel above the menu. The panel will automatically adjust to the
    appropriate size.

<loc> is false or a widget or a vector containing two integers
    specifying a location in screen co-ordinates {0 0} being top left.
    If it is false, the query box will be presented at the centre of the
    screen. If it is a widget it will be located in the centre of the
    widget. If it is a vector, the specified location will be used,
    as with pop_ui_location, described above.

<option list> is a list of words or strings to be used as labels for the
    buttons on the menu. When the user selects one of the buttons the
    actual label chosen will be returned.

<answer> is a word or string, i.e. the one selected by the user.

This example shows a question that extends over three lines:

pop_ui_query('How are\nall my lovely friends\nthis sunny day?',
        [well poorly fine sick],{400 200}) =>

-- Centring a query panel on another widget ---------------------------

Create a little propsheet box, and locate it somewhere on the screen.

    vars mybox = propsheet_new_box('HERE',false, false, [Dismiss]);
    propsheet_show(mybox);

Move the box to some interesting place then click on Dismiss to make
it go away, but remember where you put it.

The previous visible location of the box can be used to specify where a
query widget should appear.

pop_ui_query('What is today?', [M T W Th F S Su 'EXPLAIN?'], mybox) =>

There is also an invisible "anchor" widget described below. Put it near
the centre left of screen

uses pop_ui_anchor;     ;;; described below
100,400 -> pop_ui_anchor;

Now use it to locate the query widget
pop_ui_query(
    'How many people here?', [one two three four], pop_ui_anchor) =>

-- pop_ui_select (Select a subset)

LIB * POP_UI_SELECT

This is analogous to pop_ui_query, except that it presents the user with
a set of options from which to select a subset, using a true value for
the fourth argument of pop_ui_popuptool.

POP_UI_SELECT(<string>, <list> <loc>) -> <word or string>    [procedure]

Here are some examples:

pop_ui_select('How are you?', [hungry happy rich well], false) ==>
pop_ui_select('How are you?', [hungry happy rich well], {600 300}) ==>
pop_ui_select('Which days?', [Mon Tue Wed], wvedwindow) ==>

-- pop_ui_anchor (Location specifier widget) --------------------------

LIB * POP_UI_ANCHOR

This utility provides a convenient widget that can be used, whether
visible or invisible, as a location specifier for other widgets. It can
be made available via the command:

uses pop_ui_anchor

pop_ui_anchor is an active variable, which returns a widget tthat can
used used as argument to procedures that require a widget argument in
order to specify their location. Its location can be directly updated
via any of the previously listed types of location specifiers, and
without using pop_ui_location. More precisely:

pop_ui_anchor -> WIDGET                                [active variable]
X,Y        -> pop_ui_anchor
FALSE      -> pop_ui_anchor
VECTOR     -> pop_ui_anchor
REF_WIDGET -> pop_ui_anchor

The anchor widget is not normally visible itself, though it can be made
visible by using the command:

    propsheet_show(pop_ui_anchor);

Once visible it can be moved using the mouse. It can then be hidden
again either by clicking on the Dismiss button on the widget, or by
using propsheet_hide. (See REF * PROPSHEET).

The anchor widget can be used as the location argument for
pop_ui_popuptool, and procedures defined in terms of it, such as
pop_ui_query and pop_ui_select. It can also be used with those
procedures which REF * POP_UI describes as requiring a REF_WIDGET, e.g.

    pop_ui_edittool
    pop_ui_confirm
    pop_ui_message
    pop_ui_filetool

For full details see LIB * POP_UI_ANCHOR

Examples of use:

;;; set a location
800, 500 -> pop_ui_anchor;
;;; Pop up a message, then remove it.
pop_ui_message('Hi there',false,pop_ui_anchor);

Note that pop_ui_message locates its widgets to one side of the anchor
widget, for some reason (with OpenLook).

;;; Change the location
700, 200 -> pop_ui_anchor;
propsheet_show(pop_ui_anchor);
;;; Hide it
propsheet_hide(pop_ui_anchor);
;;; Try a popuptool widget
pop_ui_popuptool('Hello hello?',[A B C], pop_ui_anchor, false) =>

You can put the anchor widget in the centre of screen using false
as location specifier

false -> pop_ui_anchor;

And then put another widget on top of it
pop_ui_anchor -> pop_ui_location(mybox);
propsheet_show(mybox);

You can also do the reverse, i.e. use another widget to locate
pop_ui_anchor thus:

{-1 400} -> pop_ui_location(mybox);
mybox -> pop_ui_location(pop_ui_anchor);
propsheet_show(pop_ui_anchor);

-- NOTE about pop_ui_popuptool ----------------------------------------

The procedure is implemented in such a way that it is not possible for
two display panels produced by pop_ui_popupatool to appear at the same
time, e.g. produced by different Pop-11 processes in the same poplog
process. (See REF * PROCESS)

This is because where possible a single widget is reused after the first
creation, partly in order to save garbage, but more importantly in order
to achieve speed of response. Subsequent uses after the first are
significantly faster. For the same reason it saves and re-uses the text
sheets used to display the question. If this leads to garbage problems,
simply reload the library to clear the cache.

If two questions need to be put up simultaneously, it is possible to
save the value of pop_ui_popuptool in an identifier with a different
name and then reload the library to get a new version with its own
associated widget and cache. This will enable different sub-processes to
put up coexisting queries.

    vars procedure old_popuptool = pop_ui_popuptool;
    lib pop_ui_popuptool

-- SEE ALSO: ----------------------------------------------------------

TEACH * PROPSHEET
The mechanism described here is based on LIB * PROPSHEET. For full
information see TEACH * PROPSHEET

This provides a richer and more general set of facilities, though they
are not all as easy to use as those described here.

REF * POP_UI

This describes a related set of facilties also based on PROPSHEET.

In particular, pop_ui_confirm is fairly close to pop_ui_query, as the
following example shows:

pop_ui_confirm(
    'How are things?', [good bad indifferent], 1, true, false) =>

SEE REF * pop_ui_confirm

The main differences between them are as follows:

 o  pop_ui_confirm allows you to specify a default answer other than
    the first, using an integer for its third argument,

 o  pop_ui_query allows you to specify location in screen coordinates,
    via a two element vector.

 o  pop_ui_query returns the selected label whereas pop_ui_confirm
    returns a number corresponding to the selection.

 o  pop_ui_confirm cannot so easily be interrupted: you have to make a
    selection, and then interrupt the program, whereas pop_ui_query can
    be interrupted in the Poplog window.

Which is more appropriate will clearly depend on the application.

Other utilities described in REF * POP_UI include:
    * pop_ui_information
    * pop_ui_message
    * pop_ui_filetool
    * pop_ui_helptool
    * pop_ui_librarytool

--- $poplocal/local/help/pop_ui_popuptool
--- The University of Birmingham 1993.  --------------------------------



Sun, 09 Jun 1996 04:05:55 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. New Emacs interface for (free) Poplog users

2. New Emacs interface for Poplog users

3. New Emacs interface for (free) Poplog users

4. New Emacs interface for Poplog users

5. New Emacs interface for (free) Poplog users

6. New Emacs interface for Poplog users

7. How transfer buffer from extension to user interface

8. Multi user interface - picking user and work directory !

9. RCLIB graphical extensions to pop11 etc in Poplog

10. graphical extensions to pop11 etc in Poplog

11. AdaSAGE users and those with PC User Interfaces

12. RCLIB graphical extensions to pop11 etc in Poplog

 

 
Powered by phpBB® Forum Software