RtMeter

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

# `RtMeter`

`RtMeter` -- An arc-shaped real-time meter with indicator needle.

## Synopsis

    class RtMeter PtBasic
    {
        meter_color;                  // color  (Rt_ARG_METER_COLOR)
        meter_flags;                  // flag  (Rt_ARG_METER_FLAGS)
        meter_font_color;             // color  (Rt_ARG_METER_FONT_COLOR)
        meter_increment;              // integer  (Rt_ARG_METER_INCREMENT)
        meter_key_left;               // integer  (Rt_ARG_METER_KEY_LEFT)
        meter_key_right;              // integer  (Rt_ARG_METER_KEY_RIGHT)
        meter_level1_color;           // color  (Rt_ARG_METER_LEVEL1_COLOR)
        meter_level1_pos;             // short  (Rt_ARG_METER_LEVEL1_POS)
        meter_level2_color;           // color  (Rt_ARG_METER_LEVEL2_COLOR)
        meter_level2_pos;             // short  (Rt_ARG_METER_LEVEL2_POS)
        meter_level3_color;           // color  (Rt_ARG_METER_LEVEL3_COLOR)
        meter_max_needle_position;    // short  (Rt_ARG_METER_MAX_NEEDLE_POSITION)
        meter_min_needle_position;    // short  (Rt_ARG_METER_MIN_NEEDLE_POSITION)
        meter_needle_color;           // color  (Rt_ARG_METER_NEEDLE_COLOR)
        meter_needle_position;        // short  (Rt_ARG_METER_NEEDLE_POSITION)
        meter_num_severity_levels;    // short  (Rt_ARG_METER_NUM_SEVERITY_LEVELS)
        meter_text_font;              // string  (Rt_ARG_METER_TEXT_FONT)
    }

## Base Classes

`PtWidget` <-- `PtBasic` <-- `RtMeter`

## Description

This widget is a half-circle meter with an indicator needle and up to three different-colored pie-shaped arcs that mark three chosen ranges on the meter.

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

## Instance Variables

meter_color

  A number specifying the color used for the meter's center, outline, and tick marks. Default is `0x0` (black).

meter_flags

  This instance variable controls characteristics of the widget, and may have one or two of the following values:

  Constant | Description
  --- | ---
  RtM_NON_SELECTABLE | The meter is non-interactive.
  RtM_SELECTABLE | The meter is interactive. Default is ON.
  RtM_NO_TEXT | The minimum and maximum values are not displayed.

meter_font_color

  A number specifying the color for the display of minimum and maximum values. Default is `0x0` (black).

meter_increment

  A number of units to move the needle when an assigned key is pressed.

meter_key_left, meter_key_right

  A number or key name from `PkKeyDef.lsp` for the key that moves the needle to the left or right. Defaults are Pk_Left and Pk_Right. You can load the key name constants with a call to `require_lisp("PkKeyDef.lsp")`.

meter_level1_color

  A number specifying a color for the left arc of the meter that corresponds to Level 1. Default is `0x00ff00` (green).

meter_level1_pos

  A number specifying the end of Level 1, expressed as a percentage of the whole meter. Default is 50. This setting is unaffected by changes to `meter_max_needle_position` or `meter_min_needle_position`.

meter_level2_color

  A number specifying a color for the center arc of the meter that corresponds to Level 2. Default is `0xffff00` (yellow).

meter_level2_pos

  A number specifying the end of Level 2, expressed as a percentage of the whole meter. Default is 75. This setting is unaffected by changes to `meter_max_needle_position` or `meter_min_needle_position`.

meter_level3_color

  A number specifying a color for the right arc of the meter that corresponds to Level 3. Default is `0xff0000` (red).

meter_max_needle_position

  A number specifying the maximum point on the meter, the maximum value for the needle to register.

meter_min_needle_position

  A number specifying the minimum point on the meter, the minimum value for the needle to register.

meter_needle_color

  A number specifying the color of the needle. Default is `0xffffff` (white).

meter_needle_position

  A number specifying the current position of the needle, within the range of `meter_min_needle_position` and `meter_max_needle_position`. The needle will remain at the maximum or minimum position for any value outside that range.

meter_num_severity_levels

  The number of arcs that the meter is divided into. The maximum number is 3, which is also the default.

meter_text_font

  A string specifying the font used for displaying the maximum and minimum values. Default is `"helv10"`.

## Associated Classes

`RtMeterCallback`, `PtCallbackInfo`

## Example

This example, `ex_RtMeter.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 an RtMeter.
     */

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

    function display_value(wnum, wmet)
    {
      wmet.meter_needle_position = wnum.numeric_value;
    }

    win = new(PtWindow);
    win.SetArea(100, 100, 250, 200);
    meter = new(RtMeter);

    meter.SetArea(20, 40, 200, 200);
    meter.meter_color = 0xccddff;
    meter.meter_max_needle_position = 150;
    meter.meter_min_needle_position = 0;
    meter.meter_level1_color = 0x00ff00;
    meter.meter_level1_pos = 50;
    meter.meter_level2_color = 0xffff00;
    meter.meter_level2_pos = 100;
    meter.meter_level3_color = 0xff0000;
    meter.meter_needle_position = 70;
    meter.meter_needle_color = 0x000000;

    num = new(PtNumericInteger);
    num.SetArea(100, 150, 50, 20);
    num.numeric_increment = 10;
    num.numeric_min = 0;
    num.numeric_max = 150;
    num.numeric_value = 70;
    num.numeric_flags = cons(Pt_NUMERIC_WRAP, nil);
    num.numeric_flags = cons(Pt_NUMERIC_AUTO_HIGHLIGHT, nil);

    PtAttachCallback(num, Pt_CB_NUMERIC_CHANGED, `display_value(@num, @meter));
    display_value(num, meter);

    PtRealizeWidget(win);
    PtMainLoop();

Prev | Home | Next
`PtWindow` | Up | `RtProgress`

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