next up previous contents
Next: The control widget Up: Graphical widgets Previous: Graphical widgets

The screen widget

The screen widget is based on the canvas widget from the hush library. It also offers methods to add, move and remove items from the screen and to group items into a figure. The main difference is in the use of world coordinates, which makes it possible to scale the screen and therefore all the graphical widgets (which are derived from the screen widget). Adjusting the graphical widgets (and embedding it inside a screen or hypertext for example) is now done by simply adjusting the width and height of the widget (taking the world coordinates into account).

The screen widget has the following interface :

   interface screen : public widget
     screen(char* p,char* options = "");
     screen(widget* w,char* p,char* options = "");
     virtual ~screen();
     // add item
     int line(int x1,int y1,int x2,int y2,char* options = "");
     int line(char* linespec,char* options = "");
     int oval(int x1,int y1,int x2,int y2,char* options = "");
     int circle(int x,int y,int r,char* options = "");
     int polygon(char* linespec,char* options = "");
     int rectangle(int x1,int y1,int x2,int y2,char* options = "");
     int square(int x,int y,int r,char* options = "");
     int bitmap(int x,int y,char* bitmap,char* options = "");
     int window(int x,int y,widget* w,char* options = "");
     int text(int x,int y,char* txt,char* options = "");
     void tag(int id,char* tg);           // group items
     char* tags(int id);
     void move(int id,int x,int y);       // move item / figure
     void move(char* tg,int x,int y);
     void del(int id);                    // remove item / figure
     void del(char* tg);
     int overlapping(int x,int y);        // which items ?
     char* items(int x,int y);
     void postscript(char* fn);           // generate postscript
The constructor takes the path and the options of the screen. The following options are provided : Items are added and moved according to the world coordinates. Their sizes (for example the radius for a circle or the font for the text) are adjusted by a factor width/worldx. If you change the coordinates of the screen the factor width/worldx should be equal to height/worldy. Items can be grouped into a figure by specifying the same string for the items with the tag method. An item is identified by the integer that is returned after adding the figure. Items as well as figures can be deleted and moved. Remember that you should use the kit::update method if you want the change on the screen to be seen on the display.

A Eliens
Tue Oct 31 09:27:21 MET 1995