As described in [MIA 91-13] every program using Bifrost must have ORIGIN in or INCLUDE the fragment called Bifrost, and execute an instance of the pattern called bifrost. The following program skeleton subway1.bet will be the starting point:
ORIGIN '~beta/bifrost/Bifrost'; -- PROGRAM: descriptor -- bifrost (# (* The program skelleton *) theWindow: @window (# myCanvas: @BifrostCanvas (# open:: (# do (300, 300)->Size->theWindow.size #); eventhandler:: (# onOpen:: (# (* ... *) #); onMouseDown:: (# (* ... *) #); onKeyDown:: (# do (if ch ='Q' then Terminate if) #); #); #); open:: (# do myCanvas.open #) #) (* theWindow *) do theWindow.open; 1->Arguments->theWindow.title; #)
The ORIGIN ~beta/bifrost/Bifrost
contains the bifrost fragment.
Bifrost includes the graphical user interface environment Lidskjalv,
see [MIA 94-27], so
we can start by declaring an ordinary Lidskjalv window to contain the
graphics.
In the window a static Canvas [1] is declared, in which further binding of various virtuals have been prepared.
In init, so far, the Canvas is given an arbitrary size.
The onOpen virtual is called when the open procedure pattern has completed, e.g., when the window containing the Canvas has become visible in the window system. From within this virtual pattern, the drawing operations on the Canvas should be performed.
The virtual pattern onMouseDown is called when a button on the pointing device, if any, has been pressed. So far the actions to perform in this case are unspecified.
The virtual pattern onKeyDown is called when a keyboard key has been pressed. In this case, it is checked whether the user types 'Q' within the Canvas, and if so the application is stopped.
After theWindow has been opened, it is given the name of the program as title.
The Bifrost Graphics System - Tutorial | © 1991-2004 Mjølner Informatics |
[Modified: Monday October 23rd 2000 at 22:18]
|