beautypg.com

Implementing a simple slider 7 – Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 273

background image

C H A P T E R 7

Controls and Other Protos

Gauge and Slider Protos

7-13

The

clGaugeView

class is used to display objects that look like analog bar

gauges. Although the

clGaugeView

class is available, you should use the

protoGauge

to display bar gauges. purpose as is the

protoGauge

proto. For

more information about the slots and methods for the

protoGauge

proto, see

“protoGauge” (page 6-35) in Newton Programmer’s Reference.

Figure 7-20

A

clGaugeView

view

Implementing a Simple Slider

7

The

clGaugeView

class and the slider protos all have several slots to define the

appearance and range of the slider:

The

viewBounds

slot specifies the size and location of the slider.

The

viewValue

slot specifies the current value of the slider.

The

minValue

slot specifies the minimum value of the slider, with a default

value of

0

.

The

maxValue

slot specifies the maximum value of the slider, with a default

value of

100

.

You can specify the initial value of a slider in the

viewValue

slot. However, you

often need to look up the initial value; when this is the case, set the initial value of
the slider in the ViewSetupFormScript method.

To implement a slider, define your template with the proto that you want to use,
specify the appearance and range slots, and (optionally) assign an initial value in
the

ViewSetupFormScript

method of the proto. For some protos, you need to

define additional methods that respond to the user modifying the slider.

The following example is a template that uses

protoSlider

to allow adjustment

of the current system volume:

SoundSetter := {...

_proto: protoSlider,

viewBounds: RelBounds( 12, -21, 65, 9),

viewJustify: vjParentBottomV,

maxValue: 4,

ViewSetupFormScript: func()

self.viewValue := GetUserConfig('soundVolume);

Knob