KwikPeg Manuals
Home
PegSlider
Examples
Examples
Index
Index


Members
Styles
Signals
Overview Derived from class PegThing

The PegSlider class provides an analog adjustment control. The slider has an associated value which can be adjusted by dragging the slider's handle.

The PegSlider object can be oriented horizontally or vertically. The orientation is determined by the height and width specified in the position rectangle used to contruct the slider.

The PegSlider class can draw tickmarks at specified intervals along the slider range, provided the specified tick interval is >= 1. The slider handle and tickmarks are automatically drawn proportional to the overall slider size.

The slider scale ticks of a PegSlider object are optional. If present, the scale ticks will be drawn beneath or to the left of the slider control.

Normally, the slider handle moves smoothly along its track. However, the slider can be configured to snap to exact tick positions.

A PegSlider object sends PSF_SLIDER_CHANGE notification signals to its parent when the slider value is adjusted.



 See Also

PegHScroll

PegVScroll



 Styles

The PegSlider 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.
SF_SNAP  The slider handle of a PegSlider object will snap to exact tick positions.


 Signals

The PegSlider class generates the following signals:

PSF_SLIDER_CHANGE Sent by PegSlider derived objects when the slider is moved.
 
The signal message contains the following information:
 
Message.lData  Current slider value.
Message.iData  ID of slider control.
Message.pSource  Pointer to PegSlider object.
 

Top of page


 Members

Constructors:

PegSlider(const PegRect &Rect,
  SIGNED iMin, SIGNED iMax,
  WORD wId = 0,
  WORD wStyle = FF_RAISED,
  SIGNED iScale = -1)

This constructor creates a PegSlider object at a specific location within a rectangle specified by parameter Rect.

The iMin and iMax values specify the initial limits of the slider. The slider ID, if non-zero, enables the PSF_SLIDER_CHANGE notification signal. The slider scale value iScale determines the interval between slider tickmarks.

 

Public Functions:

virtual void Draw(void)

The PegSlider class overrides the Draw() function to draw the slider control.

SIGNED GetCurrentValue(void)

This inline function returns the current slider value.

SIGNED GetMaxValue(void) {return miMax;}

This inline function returns the slider maximum limit value.

SIGNED GetMinValue(void) {return miMin;}

This inline function returns the slider minimum limit value.

SIGNED GetScale(void) {return miScale;}

This inline function returns the slider scale interval.

virtual SIGNED Message(const PegMessage &Mesg)

The PegSlider class catches the PM_LBUTTONDOWN to capture the pointer and move the slider button as it receives PM_POINTER_MOVE messages.

void Reset(SIGNED iMin, SIGNED iMax,
  SIGNED iNew)

This function resets the slider minimum limit to iMin, the maximum limit to iMax and the current slider value to iNew.

virtual void Resize(PegRect NewSize)

The PegSlider class overrides the Resize() function to adjust the position of the slider to reflect the result of the resizing operation.

void SetCurrentValue(SIGNED iNewVal,
  BOOL bDraw = FALSE)

This function resets the current slider value to iNewVal. The slider will be redrawn to reflect the new value if parameter bDraw is TRUE.

void SetMaxValue(SIGNED iMax)

This function resets the slider maximum limit value to iMax.

void SetMinValue(SIGNED iMin)

This function resets the slider minimum limit value to iMin.

void SetScale(SIGNED iScale)
  {miScale = iScale;}

This function resets the slider tickmark interval to iScale.


Top of page


 Examples

The following example illustrates different styles of PegSlider objects:



The following code fragment creates a PegSlider object. The slider will be vertical with a minimum value of 0 and a maximum value of 200. Tick marks will be drawn at intervals of 20. Hence a total of ten tick marks will be drawn for the defined range of 200. The initial slider value will be 50.

void MyWindow::AddSlider(void)
{
    PegRect SliderRect;
    SliderRect.Set(20, 20, 60, 120);

    PegSlider *pSlider 
      = new PegSlider(SliderRect,
        0, 200, ID_SLIDER, FF_RAISED, 20);

    pSlider->SetCurrentValue(50);

    Add(pSlider);
}



Top of page
KwikPeg Manuals
Home
Index
Index

 
Copyright © 2000-2003