PhArea

PhArea — The position and size of a rectangular area.

Synopsis

class PhArea
{
    pos;     // PhPoint
    size;    // PhDim
}
		

Description

This class defines an area by its position (pos) and size. The position is relative to the upper left-hand corner of the containing widget. The units of all measurements are pixels.

[Important]

The only reliable way to set or change the dim, pos, and area variables of widgets (not other classes) is with SetDim, SetPos and SetArea variables of PtWidget. Attempting to change these variables or their sub-components without using these methods will lead to unpredictable results in your program.

[Note]

Do not confuse the size variable of a PhArea with the dim variable of a PtWidget. They are both instances of PhDim, but the former belongs to a common class, while the latter belongs to a widget class.

Also see PhArea in the Photon documentation.

Instance Variables

pos

A PhPoint specifying the upper-left hand corner position of the area.

size

A PhDim specifying the height and width of the area.

Example

This example, ex_PhArea.g, is included in the product distribution.

#!/usr/cogent/bin/phgamma

/*
This example puts up a window with a rectangle in it, and
prints the rectangle's area, position, and dimensions.
*/

PtInit(nil);
require_lisp("PhotonWidgets.lsp");

win = new(PtWindow);
win.SetDim(200,100);
win.SetPos(350,30);

rect = new(PtRect);
rect.SetArea(18,22,150,50);
rect.fill_color = PgRGB(100,220,240);

pretty_princ("The area is: \n",rect.area,"\n\n");
princ("The position is: \n",rect.pos,"\n\n");
princ("The dimensions are: \n",rect.dim,"\n");

PtRealizeWidget(win);
PtMainLoop();