PtNumericInteger

PtNumericInteger — An entry box for integer values.

Synopsis

class PtNumericInteger PtNumeric
{
    numeric_increment;    // integer  (Pt_ARG_NUMERIC_INCREMENT)    
    numeric_max;          // integer  (Pt_ARG_NUMERIC_MAX)    
    numeric_min;          // integer  (Pt_ARG_NUMERIC_MIN)    
    numeric_value;        // integer  (Pt_ARG_NUMERIC_VALUE)    
}
		

Base Classes

PtWidget <-- PtBasic <-- PtContainer <-- PtNumeric <-- PtNumericInteger

Description

This widget is a text-entry box for integers that can be incremented or decremented with small arrow-shaped buttons. You can set a minimum, a maximum, and the size of the increment/decrement for the arrow buttons. Inherited variables let you use comma separators or add a prefix/suffix strings.

[Note]

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

Instance Variables

numeric_increment

A number specifying the amount to increase or decrease the displayed value when the arrow buttons are pressed. Default is 1.

numeric_max

A number specifying the maximum allowable value to be entered. Default is 1,000,000.

numeric_min

A number specifying the minimum allowable value to be entered. Default is -1,000,000.

numeric_value

The currently displayed value. Default is 0.

Callbacks

The following callback is associated with this widget:

CallbackDescription
Pt_CB_NUMERIC_CHANGEDThis callback is generated when the entered value changes.

Associated Classes

PtNumericIntegerCallback, PtCallbackInfo

Example

This example, ex_PtNumeric-RtProgress.g, is included in the product distribution.

#!/usr/cogent/bin/phgamma

/*
 * This example demonstrates PtNumeric and
 * PtProgress widgets.
 */

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

function display_value(wnum, wprog)
{
  wprog.gauge_value = wnum.numeric_value;
}

win = new(PtWindow);
win.SetDim(160, 190);

ilab = new(PtLabel);
ilab.text_string = "Integer values";
ilab.SetArea(20, 6, 120, 20);
ilab.horizontal_alignment = Pt_CENTER;

inum = new(PtNumericInteger);
inum.SetArea(20, 30, 120, 20);
inum.numeric_increment = 5;
inum.numeric_max = 50;
inum.numeric_min = -50;
inum.numeric_value = 5;
inum.numeric_flags = cons(Pt_NUMERIC_WRAP, nil);
inum.numeric_flags = cons(Pt_NUMERIC_AUTO_HIGHLIGHT, nil);

if (_os_ == "QNX4")
     iprog = new(RtProgress);
else
     iprog = new(PtProgress);
iprog.SetArea(20, 60, 115, 20);
iprog.gauge_minimum = -50;
iprog.gauge_maximum = 50;

PtAttachCallback(inum, Pt_CB_NUMERIC_CHANGED, `display_value(@inum, @iprog));
display_value(inum, iprog);

if (_os_ == "QNX4")
{
  flab = new(PtLabel);
  flab.text_string = "Float values";
  flab.SetArea(20, 96, 120, 20);
  flab.horizontal_alignment = Pt_CENTER;
  
  fnum = new(PtNumericFloat);
  fnum.SetArea(20, 120, 120, 20);
  fnum.numeric_increment = 4.8941;
  fnum.numeric_max = 50;
  fnum.numeric_min = -50;
  fnum.numeric_value = 5.34153;
  fnum.numeric_precision = 4;
  fnum.numeric_flags = cons(Pt_NUMERIC_WRAP, nil);
  fnum.numeric_flags = cons(Pt_NUMERIC_AUTO_HIGHLIGHT, nil);
  
  fprog = new(RtProgress);
  fprog.SetArea(20, 150, 115, 20);
  fprog.gauge_minimum = -50;
  fprog.gauge_maximum = 50;
  fprog.progress_bar_color = 0x0000ff;
  PtAttachCallback(fnum, Pt_CB_NUMERIC_CHANGED, `display_value(@fnum, @fprog));
  display_value(fnum, fprog);
}

else
{
  lab = new(PtLabel);
  lab.SetPos(15, 90);
  lab.text_font  = "helv8";
  lab.text_string = string("Note: This example in QNX 4\n",
			   "also contains a PtNumeric Float \n",
			   "widget, which is not currently\n",
			   "available in Gamma/Photon for\n",
			   "QNX 6.");
}

PtRealizeWidget(win);
PtMainLoop();