[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Apr 18 11:03:15 1996 
Subject:Interactive graphics extensions to rc_graphic 
From:Aaron Sloman 
Volume-ID:960418.02 

I previously wrote
> Does anyone have any code for adding keyboard event handler to
> a graphic window?

Thanks to help from Adrian Howard and Chris Thornton I have
found out how to do that, and also to find out which modifier
keys (Contrl, Meta, Shift) are pressed when a mouse event happens.

So now I have a first draft version of my new package available for
anyone who wishes to try it out. If there is any interest, let me know
and I'll put it into a tar file in the Birmingham ftp Poplog directory.

It is an extension to rc_graphic, combined with objectclass, which has
two main components:

(a) LIB RC_LINEPIC enables you to create static or moving (including
    rotating) pictures in a Pop-11 graphical window, where picture parts
    may use different line thicknesses or line styles, and where each
    object corresponds to an objectclass instance, with associated
    methods for drawing and moving. The pictures are specified in a
    declarative notation using coordinates relative to the centre of
    the object. Drawing and un-drawing involves interpreting the
    picture specification, in an rc_graphic coordinate frame located
    at the centre of the object. Strings can be included but cannot
    be rotated. A set of mixins is provided, which can be combined with
    classes of various sorts:
         define :mixin rc_linepic;
         define :mixin rc_linepic_movable; is rc_linepic;
         define :mixin rc_rotatable; is rc_linepic_movable;

    E.g. part of a picture specification may be two rotatable squares
    using linewidth 3, slanted at an angle of 45 degrees relative to
    the object's internal frame
            [ANGLE 45 WIDTH 3 RSQUARE {5 -5 10} {0 50 20}]
    Each triple defines a square, with the first two numbers giving
    the location of the "top left" corner in the object's frame, and
    the third its side. The description language is user extendable.

(b) LIB RC_MOUSEPIC adds "mouse sensitivity" to a graphical window and
    to objects that it contains. This considerably extends the features
    provided in LIB RC_MOUSE described in TEACH RC_GRAPHIC and HELP
    RC_GRAPHIC. For example picture objects can be created which can
    then be selected for action, such as interrogating the object or
    dragging it to a new location. The following are provided
         define :mixin rc_selectable;
         define :mixin rc_keysensitive; is rc_selectable;
         define :class rc_live_window; is rc_selectable  rc_keysensitive;

    with associated methods, such as these

 define :method rc_button_1_down(pic:rc_selectable, x, y, modifiers);
 define :method rc_button_1_down(pic:rc_live_window, x, y, modifiers);
 define :method rc_button_2_down(pic:rc_selectable, x, y, modifiers);
 define :method rc_button_3_down(pic:rc_selectable, x, y, modifiers);
 define :method rc_button_1_up(pic:rc_selectable, x, y, modifiers);
 define :method rc_button_2_up(pic:rc_selectable, x, y, modifiers);
 define :method rc_button_3_up(pic:rc_selectable, x, y, modifiers);
 define :method rc_button_1_drag(pic:rc_selectable, x, y, modifiers);
 define :method rc_button_1_drag(pic:rc_live_window, x, y, modifiers);
 define :method rc_button_2_drag(pic:rc_selectable, x, y, modifiers);
 define :method rc_button_2_drag(pic:rc_live_window, x, y, modifiers);
 define :method rc_button_3_drag(pic:rc_selectable, x, y, modifiers);
 define :method rc_button_3_drag(pic:rc_live_window, x, y, modifiers);
 define :method rc_move_mouse(pic:rc_selectable, x, y, modifiers);
 define :method rc_handle_keypress(pic:rc_selectable, x, y, modifiers, key);

If a mouse or keyboard event happens with the mouse cursor in a blank
part of the picture the event is handled by a pic:rc_live_window
method. Otherwise by the first rc_selectable object containing the
mouse location in its square of sensitivity.

Handlers can create propsheet objects, produce graphical events, drag
things, select things for subsequent action, etc. The modifiers argument
is possibly empty string containing any subset of the characters
`c`,`s`,`m`, indicating which of Control, Shift and Meta keys happens to
be down.

All objects inherit the default handlers, but individual objects can be
given specialised handlers, as can subclasses.

The library needs Poplog > V15.0 as it uses objectclass a lot, though
it should work with linux poplog if you can fit it into the available
heap space. I have not tried.

Planned extensions include much easier facilities for using propsheet to
create control panels and popup menus (more in the style of pop-11
rather than the current propsheet language).

It will be easy to add a procedure to dump the current window into
an editable text file giving a description of the objects and locations,
in a formalism that can be compiled and run to recreate the window.
So this can be used for interface design.

I don't yet have linked objects, but the existing mixins and the event
handlers should make it easy to have special attachment points, and the
fact that objects have their own coordinate frames should make things
like stretching and rotating of a link straight forward.

I would like to share the continued development of this package with
others, and have a common library (which could perhaps be donated to
Poplog, or at least made freely available by ftp, etc.?).

I have not yet had time to look closely enough at the GO (Graphical
Objects) library in Poplog version 15, to see what scope there is for
combining the approaches. It offers things I don't, e.g. filled objects
that partially cover other objects, etc.

All my drawing and moving of objects uses the "xor" function which
occasionally produces strange effects (e.g. unexpected colours on
coloured or grey level windows). But that's the price of the wonderful
convenience "xor" offers for moving objects. I don't want to have to
handle bit maps and exposure events. (Static rc_linepic objects are not
drawn with "xor".)

Aaron
-- 
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs )
School of Computer Science, The University of Birmingham, B15 2TT, England
EMAIL   A.Sloman@cs.bham.ac.uk
Phone: +44-121-414-4775 (Sec 3711)       Fax:   +44-121-414-4281