3D PLM Enterprise Architecture

User Interface - Dialogs

CATDlgSlider

Selects numeric values
Quick Reference

CATDialog
  |
  +---CATDlgControl
        |
        +---CATDlgSlider

The Slider
CATDlgSlider.gif (4634 bytes) The slider enables the end user to select a value among a discrete list of values ranging from a start value to an end value. The value can be incremented or decremented by dragging along with the mouse, or clicking in the sliding area. You set the start and end values as floats, while you set the step number as an int. The step value is the difference between start and end values, divided by the number of steps. A slider can be horizontal or vertical.

Use sliders whenever you propose to the end user to select a numerical value from a discrete list in a given range.


Styles
Name Description
CATDlgCtrHorizontal The slider is horizontal. This is the default.
CATDlgCtrVertical The slider is vertical.
CATDlgSldNoValue. The slider doesn't display the current value.

[Top]


Events
Notification Method Sent when
CATDlgSliderModifyNotification GetSliderModifyNotification Whenever the end user clicks in the scrollable field. If the click is right or above the slider, the value increments of one step, and decrements of one step otherwise. The end user can press the left mouse key continuously and then the current value increments or decrements accordingly as long as the left mouse key is pressed, or the start or end value is reached.
CATDlgSliderDragNotification GetSliderDragNotification As long as the slider is dragged.

[Top]


Programmer's Guide

The slider has default values: They range from 1 to 10 with 10 steps. The start and end values, and the step count, can be set as you need. For example, the slider in the figure below has a start value of 100, and end value of 200 and 10 steps. Possible values are then 100, 110, 120, 130, and so forth up to 200.

The Slider Range
CATDlgSlider1.jpg (1123 bytes) CATDlgSlider2.jpg (1103 bytes) CATDlgSlider3.jpg (1110 bytes)
Start value A possible value End value

The start value is placed left or bottom, and the end value is placed right or top.

The Slider Decimal Point Position
CATDlgSlider4.jpg (1117 bytes) The current value display is affected by the position of the decimal point. This position is set as the number of decimals after the point. The slider beside features two decimal after the point. The default is zero.

warning.gif (206 bytes) Pay attention to the fact that the range and the number of steps must be consistent with the decimal point position. For example, a slider ranging from 0 to 10 with 10 steps and a decimal point position of 0 leaves 11 values available. Setting the number of steps to 100 with the same decimal point position does not increase the number of values available, but additionally setting the decimal point to 1 gives 100 available values.

[Top]

Constructing a Slider

Construct sliders as follows:

Horizontal
_pHSlider = new CATDlgSlider (IParent, "HSliderId");
Vertical
_pVSlider = new CATDlgSlider (IParent, "VSliderId",
                              CATDlgCtrVertical);
Vertical and no value displayed
_pVNoValueSlider = new CATDlgSlider (IParent, "VNVSliderId",
                       CATDlgCtrVertical|CATDlgSldNoValue);

[Top]

Managing the Value Range

You can retrieve and set the value range with the methods GetRange and SetRange:

float Start, End;
int Step;
_pSlider->GetRange(Start, End, Step);
...
iStart = 0:
iEnd = 100;
iStep = 20;
_pSlider->SetRange(Start, End, Step);

[Top]

Managing the Value Display

You can retrieve the decimal point position in the current value displayed with the method GetDecimalPoint, and set it with the method SetDecimalPoint:

int DecimalPoint;
DecimalPoint = _pSlider->GetDecimalPosition();
...
DecimalPoint = 2;
_pSlider->SetDecimalPosition(DecimalPoint);

[Top]

Managing the Selection or Current Value

You can retrieve the current value using the method GetCurrentValue, and set it with the method SetCurrentValue:

float CurrentValue = _pSlider->GetCurrentValue();
...
CurrentValue = 40.0;
int Notify=1;
pSlider->SetCurrentValue(CurrentValue, Notify);

Set the first parameter to the current value you require, and the parameter Notify to a non null value if you want the corresponding notification to be sent. Otherwise set to 0, no notification is sent.

[Top]

Setting a Callback on a Slider

When constructing and using a slider, you need to take into account that you don’t know how the user will set the value, either by dragging the slider or clicking. You thus need always to set two callbacks for the two possible notifications sent.

Retrieve the user selection notification
AddAnalyseNotificationCB(
  _pSlider,                                   // slider 
  _pSlider->GetSliderModifyNotification(),    // modify notification
  (CATCommand)&Container::MethodToExecute,        // method to execute 
  CATCommandClientData iUsefulData);              // useful data for this method 
Retrieve the user drag notification
AddAnalyseNotificationCB(
  _pSlider,                                   // slider 
  _pSlider->GetSliderDragNotification(),      // drag notification
  (CATCommand)&Container::MethodToExecute,        // method to execute 
  CATCommandClientData iUsefulData);              // useful data for this method 

The same method MethodToExecute can of course be called by these two callbacks.

[Top]

Setting a Title to a Slider

The slider title should be set by the resource file using a key built with the identifier you declare as the second parameter of the push button constructor. This title is never displayed. If you want to comment the choice available from the slider in your dialog, use a label.

[Top]


History

Version: 1 [Jan 2000] Document created
[Top]

Copyright © 2000, Dassault Systèmes. All rights reserved.