KwikPeg Manuals
Home
PegSpinButton
Examples
Examples
Index
Index


Members
Styles
Signals
Overview Derived from class PegThing

The PegSpinButton class provides a thumbwheel-like control that is normally used to adjust a numeric string value displayed within an adjacent object. The object housing the string value is called the spin button's buddy object.

A buddy object is a PegTextThing derived object that is updated as the directional arrows on the spin button are manipulated. The buddy object must be designed to display a numeric value as a text string. When the spin button is operated, the PegSpinButton object will convert the buddy object's string to an integer value, increment or decrement the integer value as required and then convert the integer value back to a string for assignment to the buddy object.

The buddy object must have the TT_COPY style flag applied to it so that a copy of its string value will be kept with the buddy object. A spin button object will apply the TT_COPY style flag to its buddy object to ensure that this requirement is met.

A PegSpinButton object can also be created with no buddy object. This type of spin button sends notification signals to its parent and leaves it up to the parent to determine the action to be taken as the directional arrows on the spin button are operated.

PegSpinButton objects can be oriented horizontally or vertically.



 See Also

PegSlider

PegTextThing



 Styles

The PegSpinButton class supports the following style flags:

FF_NONE No frame.
FF_THIN Thin frame.
FF_THICK Thick 3D frame.
FF_RAISED Raised 3D frame.
FF_RECESSED Recessed 3D frame.
AF_ENABLED  This style flag is used to indicate that the object can be selected.
SB_VERTICAL  A PegSpinButton object with this style flag set will be drawn with a vertical orientation. Normally, a spin button is drawn with a horizontal orientation.


 Signals

The PegSpinButton class generates the following signals:

PSF_SPIN_MORE Sent by PegSpinButton when the up or right arrow is selected.
PSF_SPIN_LESS Sent by PegSpinButton when the down or left arrow is selected.
 
The spin signals are sent to the spin button's parent if the PegSpinButton object has a non-zero ID value.
 
The signal message contains the following information:
 
Message.iData  ID of spin button control.
Message.pSource  Pointer to PegSpinButton object.
 

Top of page


 Members

Constructors:

PegSpinButton(SIGNED iLeft, SIGNED iTop,
  WORD wId = 0,
  WORD wStyle = AF_ENABLED|SB_VERTICAL)

This constructor creates a PegSpinButton object with its top left corner located at (iLeft,iTop). The spin button will assume the default width specified for your KwikPeg Library. The spin button will have no buddy object. It will send notification signals to its parent object as the spin button is operated. By default, the spin button will be enabled and oriented vertically.

PegSpinButton(const PegRect &Rect,
  WORD wId = 0,
  WORD wStyle = AF_ENABLED|SB_VERTICAL)

This constructor creates a PegSpinButton at a specific location within a rectangle specified by parameter Rect. The spin button will have no buddy object. It will send notification signals to its parent object as the spin button is operated. By default, the spin button will be enabled and oriented vertically.

PegSpinButton(SIGNED iLeft, SIGNED iTop,
  PegTextThing *buddy,
  LONG lMin, LONG lMax,
  SIGNED iStep, WORD wId = 0,
  WORD wStyle = AF_ENABLED|SB_VERTICAL)

This constructor creates a PegSpinButton object with its top left corner located at (iLeft,iTop). The spin button will assume the default width specified for your KwikPeg Library. The spin button will have a PegTextThing buddy object which will be updated as the spin control is operated. It will also send notification signals to its parent object as the spin button is operated. By default, the spin button will be enabled and oriented vertically.

PegSpinButton(const PegRect &Rect,
  PegTextThing *buddy,
  LONG lMin, LONG lMax,
  SIGNED iStep, WORD wId = 0,
  WORD wStyle = AF_ENABLED|SB_VERTICAL)

This constructor creates a PegSpinButton at a specific location within a rectangle specified by parameter Rect. The spin button will have a PegTextThing buddy object which will be updated as the spin control is operated. It will also send notification signals to its parent object as the spin button is operated. By default, the spin button will be enabled and oriented vertically.

 

Public Functions:

virtual SIGNED Message(const PegMessage &Mesg)

The PegSpinButton class catches messages from the spin button directional selection arrows to update the buddy object, if any, and to send signals to the spin button parent.

void SetBuddy(PegTextThing *buddy)

This inline function establishes the PegTextThing object specified by parameter buddy as the buddy object for the spin button.

void SetLimits(LONG lMin, LONG lMax,
  SIGNED iStep = -1)

This function resets the spin button minimum limit to lMin, the maximum limit to lMax and the step value to iStep. A positive step value causes the spin button to increase the value of its buddy object when the "Up" or "Right" spin button is pressed and to decrease the value when the "Down" or "Left" spin button is pressed. A negative step value reverses the effect of the spin buttons.

void SetOutputWidth(SIGNED iWidth)
  {miOutputWidth = iWidth;}

This function adjusts the numeric width of the output string generated by a spin button with a buddy object. The iWidth parameter indicates the number of digits to be generated in the output numeric string. The output string is padded with leading zeros if required to meet the indicated width.


Top of page


 Examples

The following example illustrates a vertical PegSpinButton object with a PegPrompt buddy object:

The following function creates a PegPrompt object for displaying a numeric value. The prompt will be updated by a vertical PegSpinButton object. The range of values will be limited to 20 through 80. The displayed value will increment or decrement by 5 each time the spin button is operated.

void MyWindow::AddSpinPrompt(void)
{
    PegRect ChildRect;
    ChildRect.Set(20, 20, 100, 40);

    PegPrompt *pPrompt =
	new PegPrompt(PromptRect, "20", 0,
        FF_RECESSED|TJ_RIGHT|TT_COPY);

    Add(pPrompt);

    // Set the spin button position to the right of the prompt

    ChildRect.wLeft = pPrompt->mReal.wRight + 1;
    ChildRect.wRight = ChildRect.wLeft + PEG_SCROLL_WIDTH;
    PegSpinButton *pSpin =
        new PegSpinButton(ChildRect, pPrompt,
            20, 80, 5, SB_VERTICAL);

    Add(pSpin);
}



Top of page
KwikPeg Manuals
Home
Index
Index

 
Copyright © 2000-2003