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 // ValControlDigitSegment.h
34 // Represents a fixed number of digits in a numeric value-
37 // e.moon 18sep99 moving to a fixed-point approach
38 // e.moon 20jan99 Begun
41 #ifndef __VALCONTROLDIGITSEGMENT_H__
42 #define __VALCONTROLDIGITSEGMENT_H__
44 #include "ValControlSegment.h"
48 #include "cortex_defs.h"
49 __BEGIN_CORTEX_NAMESPACE
53 class ValControlDigitSegment
: /*extends*/ public ValControlSegment
{
54 typedef ValControlSegment _inherited
;
56 public: // flags/types
62 public: // ctor/dtor/accessors
63 // scaleFactor is the power of ten corresponding to the
64 // rightmost digit: for a whole-number segment, this is 0;
65 // for a 2-digit fractional segment, this would be -2.
66 // +++++ is this still accurate? 18sep99
68 ValControlDigitSegment(
72 display_flags flags
=NONE
);
73 ~ValControlDigitSegment();
75 uint16
digitCount() const;
76 int16
scaleFactor() const;
79 float prefWidth() const;
80 float prefHeight() const;
83 // revised setValue() 18sep99: now sets the
84 // value of the displayed digits ONLY.
89 // // operates on a real value; based on scaling factor,
90 // // retrieves the proper digits +++++nyi
91 // void setValue(double dfValue); // made public 30jan99
93 public: // ValControlSegment impl.
95 // do any font-related layout work
96 virtual void fontChanged(
99 virtual ValCtrlLayoutEntry
makeLayoutEntry();
101 virtual float handleDragUpdate(
103 virtual void mouseReleased(); //nyi
105 public: // BView impl.
106 virtual void Draw(BRect updateRect
);
107 virtual void GetPreferredSize(float* pWidth
, float* pHeight
);
109 public: // BHandler impl.
110 virtual void MessageReceived(BMessage
* pMsg
); //nyi
112 public: // archiving/instantiation
113 ValControlDigitSegment(BMessage
* pArchive
);
114 virtual status_t
Archive(BMessage
* pArchive
, bool bDeep
) const;
115 _EXPORT
static BArchivable
* Instantiate(BMessage
* pArchive
);
117 //private: // impl. helpers
120 protected: // members
121 // * internal value representation
129 font_height m_fontHeight
;
131 float m_minusSignWidth
;
133 float m_digitPadding
;
135 // * display settings
136 display_flags m_flags
;
137 bool m_negativeVisible
;
140 static const float s_widthTrim
;
142 protected: // static stuff
143 static float MaxDigitWidth(const BFont
* pFont
);
145 static const BFont
* s_cachedFont
;
146 static float s_cachedDigitWidth
;
149 __END_CORTEX_NAMESPACE
150 #endif /* __VALCONTROLDIGITSEGMENT_H__ */