PtGraphic

PtGraphic — A parent class for graphic widget resources.

Synopsis

class PtGraphic PtBasic
{
    dash_list;        // char array  (Pt_ARG_DASH_LIST)    
    dash_scale;       // long  (Pt_ARG_DASH_SCALE)    
    graphic_flags;    // flag  (Pt_ARG_GRAPHIC_FLAGS)    
    line_cap;         // unsigned short  (Pt_ARG_LINE_CAP)    
    line_join;        // unsigned short  (Pt_ARG_LINE_JOIN)    
    line_width;       // long  (Pt_ARG_LINE_WIDTH)    
    origin;           // PhPoint  (Pt_ARG_ORIGIN)    
    points;           // PhPoint array  (Pt_ARG_POINTS)    
}
		

Base Classes

PtWidget <-- PtBasic <-- PtGraphic

Derived Classes

PtArc, PtBezier, PtEllipse, PtLine, PtPixel, PtPolygon, PtRect

Description

This widget serves as a parent class of resources for graphic widgets, and is not normally instantiated. The variables here have to do mainly with line origins, thicknesses, joints and caps, as well as fill colors for closed shapes.

[Note]

For detailed information, please refer to PtGraphic in the Photon documentation.

Instance Variables

dash_list

An array of integers specifying in pixels the length of each dash and/or space for dashed lines. If there is more than one element in the array, each element applies to the next dash or space, and then the pattern repeats. An array with an odd number of elements will produce an alternating pattern of dashes and spaces (see the example below). The default is an empty array [ ], which gives a solid line.

[Note]

Setting this variable to an array of length 0 with a Gamma statement like this: GraphicInstance.dash_list = array(0); will cause undefined behavior. To reset the default, use array().

dash_scale

A 32 bit number that specifies the scale of the dash_list. The top 16 bits correspond to numbers greater than one, the bottom 16 to fractions less than one. The number 0x00010000 is equal to one.

For example, to scale dashes 2 times larger, you would use the number 0x00020000; to make them half size, you would use 0x00008000 (because that is half of 0x00010000). See also the example below.

graphic_flags

This instance variable controls the position and origin of the widget and the graphic with respect to the parent widget. It may be a combination of zero (the default) or more of the following flags:

ConstantDescription
Pt_FLOAT_POSAllow the position and origin of the widget to change, leaving the graphic fixed to the parent.
Pt_FLOAT_ORIGINAllow the origin of the graphic to change, leaving the position of the widget fixed to the parent.

line_cap

A constant that determines the shape of line ends, which become visible when a line is fairly wide. The default is butted, which means the line ends squarely at the end point. You can put a round or square cap at the end, which overlaps the end point by a factor of half the line width.

This instance variable may have one of the following values:

ConstantDescription
Pg_BUTT_CAPThe default, leaves line capless, with square-cut ends.
Pg_ROUND_CAPPuts a round cap on thick lines.
Pg_SQUARE_CAPPuts a square cap on thick lines.

line_join

This instance variable determines the shape of line joints (mainly visible for wide lines), and may have one of the following values:

ConstantDescription
Pg_MITER_JOINMakes a squared-off joint.
Pg_ROUND_JOINMakes a small-radius rounded joint.
Pg_BEVEL_JOINMakes a beveled joint.
Pg_QROUND_JOINMakes a large-radius rounded joint.
Pg_BUTT_JOINMakes a butt joint (outside line edges don't join).

line_width

A number specifying the width of a line, in pixels.

origin

A PhPoint specifying the origin of the widget, which is the upper-left corner of its widget canvas.

points

An array of PhPoints defining the graphic. The number and purpose of the points depends on the type of graphic.

Example

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

#!/usr/cogent/bin/phgamma

/*
 * This example illustrates dash variables for graphic lines.
 */
require_lisp("PhotonWidgets.lsp");
require_lisp("PhabTemplate.lsp");
PtInit(nil);

wfile = PhabReadWidgetFile (string(_os_, "-WidgetFiles/wgt/graphics.wgtw"));
window = PhabCreateWidgets(wfile, nil, nil);

win = PhabLookupWidget(window,#graphics,nil);
ln0 = PhabLookupWidget(window,#Line0,nil);
ln1 = PhabLookupWidget(window,#Line1,nil);
ln2 = PhabLookupWidget(window,#Line2,nil);
ln3 = PhabLookupWidget(window,#Line3,nil);
ln4 = PhabLookupWidget(window,#Line4,nil);
ln5 = PhabLookupWidget(window,#Line5,nil);

ebut = PhabLookupWidget(window,#ExitButton,nil);
PtAttachCallback(ebut, Pt_CB_ACTIVATE, #exit_program(1));

ln0.dash_list = array();
ln1.dash_list = array(20);
ln2.dash_list = array(20,5);
ln3.dash_list = array(20,5,20);

ln4.dash_list = array(20);
ln4.dash_scale = 0x00020000;

ln5.dash_list = array(20);
ln5.dash_scale = 0x00004000;

PtRealizeWidget(win);
PtMainLoop();

Callbacks

The following callback is associated with this widget:

CallbackDescription
Pt_CB_RESCALEThis callback is generated when the widget's dim or area resources are modified.

Associated Classes

PtCallbackInfo