PtGraphic

Gamma/Photon: Using Gamma™ with the Photon microGUIŽ, Version 4.0
Prev |  | Next

# `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.

| 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.

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:

  Constant | Description
  --- | ---
  `Pt_FLOAT_POS` | Allow the position and origin of the widget to change, leaving the graphic fixed to the parent.
  `Pt_FLOAT_ORIGIN` | Allow 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:

  Constant | Description
  --- | ---
  Pg_BUTT_CAP | The default, leaves line capless, with square-cut ends.
  Pg_ROUND_CAP | Puts a round cap on thick lines.
  Pg_SQUARE_CAP | Puts 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:

  Constant | Description
  --- | ---
  Pg_MITER_JOIN | Makes a squared-off joint.
  Pg_ROUND_JOIN | Makes a small-radius rounded joint.
  Pg_BEVEL_JOIN | Makes a beveled joint.
  Pg_QROUND_JOIN | Makes a large-radius rounded joint.
  Pg_BUTT_JOIN | Makes 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 `gamma_ph_`#`_examples_1_QNX4.tgz` file available on the Cogent Web Site.

    #!/usr/cogent/bin/phgamma

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

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

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

    ln1.dash_list = array(20.5);

    ln2.dash_list = array(20,5,20);

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

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

    PtRealizeWidget(win);
    PtMainLoop();

## Callbacks

The following callback is associated with this widget:

Callback | Description
--- | ---
`Pt_CB_RESCALE` | This callback is generated when the widget's dim or area resources are modified.

## Associated Classes

`PtCallbackInfo`

Prev | Home | Next
`PtGenTree` | Up | `PtGrid`

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.