next up previous contents index
Next: Dj-field declarations Up: Defining Classes Previous: Defining Classes

Layout area

Every user-defined class has the following default attributes:
       dj int x;
       dj int y;
       dj int width;
       dj int height;
These four attributes specify the layout area for the components in the class. The x and y are the xy-coordinate of the left-upper corner, and width and height are the width and height of the area, respectively. No component can be laid outside this area.

Recall our HelloWorld example:

       class HelloWorld {
             dj Button bt{text=="Hello World!"}; 
       }
If we write the default attributes and constraints explicitly, then the class would look like:
       class HelloWorld {
             dj int x;
             dj int y;
             dj int width;
             dj int height;
             dj Button bt{text=="Hello World!"}; 
             bt.x >= x; bt.y >= y;
             bt.x+bt.width <= x+width;
             bt.y+bt.height <= y+height;
       }
In DJ, the four default attributes cannot be overridden. Also, a global coordinate system is used and all x and y attributes refer to some xy-coordinates int the global coordinate system.



Neng-Fa Zhou
1999-02-16