PtBkgd

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

# `PtBkgd`

`PtBkgd` -- A background image, bitmap, or color-gradient.

## Synopsis

    class PtBkgd PtPane
    {
        bkgd_brt_from;       // unsigned short  (Pt_ARG_BKGD_BRT_FROM)
        bkgd_brt_to;         // unsigned short  (Pt_ARG_BKGD_BRT_TO)
        bkgd_hue_from;       // unsigned short  (Pt_ARG_BKGD_HUE_FROM)
        bkgd_hue_to;         // unsigned short  (Pt_ARG_BKGD_HUE_TO)
        bkgd_image;          // PhImage  (Pt_ARG_BKGD_IMAGE)
        bkgd_mix;            // unsigned short  (Pt_ARG_BKGD_MIX)
        bkgd_orientation;    // unsigned short  (Pt_ARG_BKGD_ORIENTATION)
        bkgd_pix_height;     // unsigned short  (Pt_ARG_BKGD_PIX_HEIGHT)
        bkgd_pix_width;      // unsigned short  (Pt_ARG_BKGD_PIX_WIDTH)
        bkgd_pixcolors;      // color array  (Pt_ARG_BKGD_PIXCOLORS)
        bkgd_pixmap;         // char array array  (Pt_ARG_BKGD_PIXMAP)
        bkgd_sat_from;       // unsigned short  (Pt_ARG_BKGD_SAT_FROM)
        bkgd_sat_to;         // unsigned short  (Pt_ARG_BKGD_SAT_TO)
        bkgd_spacing;        // PhPoint  (Pt_ARG_BKGD_SPACING)
        bkgd_steps;          // unsigned short  (Pt_ARG_BKGD_STEPS)
        bkgd_tile;           // unsigned short  (Pt_ARG_BKGD_TILE)
        bkgd_type;           // unsigned short  (Pt_ARG_BKGD_TYPE)
    }

## Base Classes

`PtWidget` <-- `PtBasic` <-- `PtContainer` <-- `PtPane` <-- `PtBkgd`

## Description

This widget lets you make backgrounds for application windows. The `bkgd_type` variable lets you choose from three types of backgrounds: images, pixmaps, and color-gradients, which are controlled with their associated variables.

- Images can be created in graphics programs, loaded with a call to `PxLoadImage`, and subsequently used for background images as instances of `PhImage`. They can be tiled in several ways using the `bkgd_tile` and `bkgd_spacing` variables.

- Pixmaps are bitmapped images created in PhAB, or by using the Photon function PtDrawBitmap. This type of image can easily be made transparent.

- Color gradients are specified by their hue, saturation, and brightness variables: `bkgd_hue`, `bkgd_sat` and `bkgd_brt`, each with a `_from` and `_to` variable for specifying the range. But the range can only be applied to one of the three. Choose one of them, and set the flag for it in the `bkgd_type` variable. Then for that one alone you can specify the range, assigning both its `_from` and `_to` variables. The other two take only the `_to` variable.

  Other options for color gradients include horizontal or vertical orientation, color dithering, and number of gradient steps.

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

## Instance Variables

bkgd_brt_from, bkgd_brt_to

  An integer between 0 and 255 specifying the brightness range (black to full brightness) of color gradients, using the hue/saturation/brightness color model.

bkgd_hue_from, bkgd_hue_to

  An integer between 0 and 65535 specifying the hue range (on the color spectrum) of color gradients, using the hue/saturation/brightness color model.

bkgd_image

  A `PhImage` that you wish to display.

bkgd_mix

  An integer that specifies whether or not dithering is used in color-gradient backgrounds. 1 (the default) is on, 0 is off.

bkgd_orientation

  A constant specifying the orientation of color-gradient backgrounds. The default is vertical.

  This instance variable may have one of the following values:

  Constant | Description
  --- | ---
  `Pt_BKGD_HORIZONTAL` | Sets the gradient orientation to horizontal.
  `Pt_BKGD_VERTICAL` | Sets the gradient orientation to vertical.

bkgd_pix_height, bkgd_pix_width

  A number of pixels specifying the height and width of a pixmap image.

bkgd_pixcolors

  An array of colors used by a pixmap image.

bkgd_pixmap

  A bitmapped background image created in PhAB. This type of image can be easily made transparent.

bkgd_sat_from, bkgd_sat_to

  An integer between 0 and 255 specifying the saturation range (white to full color) of color gradients, using the hue/saturation/brightness color model.

bkgd_spacing

  A `PhPoint` whose x and y values specify the horizontal and vertical separation between tiles. Default is:

          {PhPoint (x	. 0) (y . 0)}

bkgd_steps

  An integer specifying the number of steps to get from the minimum gradient value to the maximum. Default is `10`.

bkgd_tile

  A constant specifying the tiling option for images and pixmaps.

  This instance variable may have one of the following values:

  Constant | Description
  --- | ---
  `Pt_BKGD_NONE` | None.
  `Pt_BKGD_GRID` | The image repeats in rows and columns.
  `Pt_BKGD_ALT` | The image repeats alternately, like brickwork.
  `Pt_BKGD_CENTER` | The image is drawn in the center of the container.
  `Pt_BKGD_CENTER_GRID` | The image is drawn in the center, and repeated for a single row and column around the border.

bkgd_type

  A constant specifying the type of background image you want to use. The relevance of other variables depends on this choice.

  This instance variable may have one of the following values:

  Constant | Description
  --- | ---
  `Pt_BKGD_HUE` | The background color gradient is based on hue value.
  `Pt_BKGD_SATURATION` | The background color gradient is based on saturation value.
  `Pt_BKGD_BRIGHTNESS` | The default, the background color gradient is based on brightness value.
  `Pt_BKGD_PIXMAP` | Used to create a background of a small/hand-drawn image; background fill color stays visible.
  `Pt_BKGD_IMAGE` | Used to create a background with an imported image.

## Example

This example, `ex_PtBkgd.g`, is included in the `gamma_ph_`#`_examples_1_QNX4.tgz` file available on the Cogent Web Site.

    #!/usr/cogent/bin/phgamma

    /*
     * This example demonstrates a saturation color_gradient
     * PtBkgd anchored to a window.
     */

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

    win = new(PtWindow);
    win.SetDim (300,300);

    back = new(PtBkgd);
    back.bkgd_type = Pt_BKGD_SATURATION;
    back.bkgd_brt_to = 255;
    back.bkgd_hue_to = 30000;
    back.bkgd_sat_from = 255;
    back.bkgd_sat_to = 0;
    back.bkgd_steps = 200;
    back.SetDim(300,300);
    back.bkgd_orientation = Pt_BKGD_HORIZONTAL;
    back.anchor_flags = Pt_LEFT_ANCHORED_RELATIVE |
                        Pt_RIGHT_ANCHORED_RELATIVE |
    		    Pt_TOP_ANCHORED_RELATIVE |
    		    Pt_BOTTOM_ANCHORED_RELATIVE;

    PtRealizeWidget(win);
    PtMainLoop();

Prev | Home | Next
`PtBitmap` | Up | `PtButton`

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