8 The scrolllists Library

The scrolllists library contains two subpatterns of windowItem which implements scrolling lists:

[1kb 95x74 GIF]

ScrollList is a general superpattern realizing the basic functionality of displaying and scrolling in a list of equally sized elements (including facilities for managing single and multiple selections of the elements in the scrollList).

ScrollList contains attributes for inserting and deleting elements as well as for managing the selections (inserting, deleting, scanning and testing).

ScrollList is an abstract pattern that cannot be instantiated.

TextScrollList is a minor augmentation of scrollList to make support for scrolling lists of text elements. Adds three additional attributes: setText, getText and style, which allows for accessing and changing the text and the text style of the individual text elements in the scrollList.

8.1 Using the scrolllists Library

Remember that in order to utilize this extension to Lidskjalv, the fragment scrolllists must be included as follows:

ORIGIN '~beta/guienv/guienv';
INCLUDE '~beta/guienv/scrolllists'
--- program: descriptor ---
guienv(# tsl: @textScrollList;
         ...
      do ...
         tsl.selection.first -> ...;
         ...
      #)

8.2 Examples of Use of the scrolllists Fragment

This example illustrates how to use the textscrolllist windowItem.

Program 7: textscrolllist.bet

ORIGIN '~beta/guienv/guienv';
INCLUDE '~beta/guienv/scrolllists';
(* This demo gives a simple example of how to use the textScrollList
 * windowitem.
 *)
--- program: descriptor ---
guienv
(# theWindow: @window
     (# menubarType::
          (# fileMenu: @menu
               (# quitItem: @menuItem
                    (# eventHandler::
                         (# onSelect::
                              (# do terminate #);
                         #);
                       open::
                         (# do 'Quit' -> name #)
                    #);
                  open::
                    (# 
                    do 'File' -> name;
                       quitItem.open; quitItem[] -> append
                    #)
               #);
             open::
               (# 
               do fileMenu.open; fileMenu[] -> append
               #)
          #);
        eventhandler::
          (# onAboutToClose:: (# do terminate #) #);
        theTextScrollList: @textScrollList
          (# eventHandler::
               (# onMouseDown::
                    (# 
                    do (if doubleClick then
                           selection.first -> gettext -> putline
                       if)
                    #)
               #);
             open::
               (# v: @point;
                  noOfItems: @integer
               do (5,5) -> position;
                  theWindow.size -> v;
                  (10,10) -> v.subtract;
                  v -> size;
                  true -> bindBottom;
                  true -> bindRight;
                  5 -> append;
                  theTextScrollList.numberOfItems -> noOfItems;
                  (noOfItems-4,'Abraham Lincoln 1') -> settext;
                  (noOfItems-3,'Abraham Lincoln 2') -> settext;
                  (noOfItems-2,'Abraham Lincoln 3') -> settext;
                  (noOfItems-1,'Abraham Lincoln 4') -> settext;
                  (noOfItems,'Abraham Lincoln 5') -> settext
               #)
          #);
        open::
          (# 
          do (400,400) -> size;
             theTextScrollList.open;
             theTextScrollList[] -> target
          #)
     #)
do theWindow.open
#)

[62kb 397x446 GIF]


Lidskjalv: User Interface Framework - Reference Manual
© 1994-2002 Mjølner Informatics
[Modified: Friday October 27th 2000 at 14:56]