2 * Copyright (c) 1999-2000, Eric Moon.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions, and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 // NumericValControl.h
34 // Extends ValControl to provide the basis for a variety
35 // of numeric UI controls.
37 // e.moon 18sep99 General cleanup; values are now stored
38 // in fixed-point form only.
39 // e.moon 17jan99 Begun
40 // +++++ 31jan99: negatives are still handled wrong...
42 // CLASS: NumericValControl
43 #ifndef NUMERIC_VAL_CONTROL_H
44 #define NUMERIC_VAL_CONTROL_H
46 #include "cortex_defs.h"
47 #include "ValControl.h"
49 #include <MediaDefs.h>
52 class BContinuousParameter
;
55 __BEGIN_CORTEX_NAMESPACE
57 class ValControlDigitSegment
;
60 class NumericValControl
: public ValControl
{
62 typedef ValControl _inherited
;
66 // +++++ need control over number of segments +++++
68 // parameter-linked ctor
69 NumericValControl(BRect frame
, const char* name
, BContinuousParameter
* param
,
70 uint16 wholeDigits
, uint16 fractionalDigits
= 0, align_mode alignMode
= ALIGN_FLUSH_RIGHT
,
71 align_flags alignFlags
= ALIGN_NONE
);
74 NumericValControl(BRect frame
, const char* name
, BMessage
* message
, uint16 wholeDigits
,
75 uint16 fractionalDigits
= 0, bool negativeVisible
= true,
76 align_mode alignMode
= ALIGN_FLUSH_RIGHT
, align_flags alignFlags
= ALIGN_NONE
);
80 BContinuousParameter
* param() const;
81 // bound parameter, or 0 if none
83 void getConstraints(double* outMinValue
, double* outMaxValue
);
84 // value constraints (by default, the min/max allowed by the ctor
85 // settings: wholeDigits, fractionalDigits, and negativeVisible)
87 status_t
setConstraints(double minValue
, double maxValue
);
88 // the current value is not yet re-constrained by this call
91 // fetches the current value (calculated on the spot from each
94 void setValue(double value
, bool setParam
= false);
95 // set the displayed value (and, if setParam is true, the
96 // linked parameter.) The value will be constrained if necessary.
98 public: // segment interface
99 // 18sep99: old segment interface
100 // virtual void offsetValue(double dfDelta);
102 // 18sep99: new segment interface. 'offset' is given
103 // in the segment's units.
105 virtual void offsetSegmentValue(ValControlDigitSegment
* segment
, int64 offset
);
108 virtual void mediaParameterChanged();
110 virtual void updateParameter(double value
);
111 // writes the stored value to the bound parameter
113 virtual void initSegments();
114 virtual void initConstraintsFromParam();
116 public: // ValControl impl.
117 void setValue(const void* data
, size_t size
); //nyi
119 void getValue(void* data
, size_t* ioSize
); //nyi
121 // string value access
122 virtual status_t
setValueFrom(const char* text
);
123 virtual status_t
getString(BString
& buffer
);
126 virtual void MessageReceived(BMessage
* message
);
128 protected: // internal operations
129 virtual void _SetDefaultConstraints(bool negativeVisible
);
132 int64
_ValueFixed() const; //nyi
133 // calculates the current value as an int64
135 void _SetValueFixed(int64 fixed
); //nyi
136 // sets the value of each segment based on an int64 value;
137 // does not constrain the value
140 // double m_dfValue; removed 18sep99
142 BContinuousParameter
* fParam
;
146 uint16 fFractionalDigits
;
155 __END_CORTEX_NAMESPACE
156 #endif /* NUMERIC_VAL_CONTROL_H */