btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / cortex / ValControl / ValControlDigitSegment.h
blob27696473894ad5ed115c567271ee4930917a641f
1 /*
2 * Copyright (c) 1999-2000, Eric Moon.
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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
33 // * PURPOSE
34 // Represents a fixed number of digits in a numeric value-
35 // selection control.
36 // * HISTORY
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"
46 #include <Font.h>
48 #include "cortex_defs.h"
49 __BEGIN_CORTEX_NAMESPACE
51 class ValControl;
53 class ValControlDigitSegment : /*extends*/ public ValControlSegment {
54 typedef ValControlSegment _inherited;
56 public: // flags/types
57 enum display_flags {
58 NONE =0,
59 ZERO_FILL =1
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(
69 uint16 digitCount,
70 int16 scaleFactor,
71 bool negativeVisible,
72 display_flags flags=NONE);
73 ~ValControlDigitSegment();
75 uint16 digitCount() const;
76 int16 scaleFactor() const;
77 int64 value() const;
79 float prefWidth() const;
80 float prefHeight() const;
82 public: // operations
83 // revised setValue() 18sep99: now sets the
84 // value of the displayed digits ONLY.
85 void setValue(
86 int64 value,
87 bool negative);
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(
97 const BFont* font);
99 virtual ValCtrlLayoutEntry makeLayoutEntry();
101 virtual float handleDragUpdate(
102 float distance);
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
118 // void initFont();
120 protected: // members
121 // * internal value representation
122 uint16 m_digitCount;
123 int64 m_value;
124 bool m_negative;
125 int16 m_scaleFactor;
127 // * font
128 const BFont* m_font;
129 font_height m_fontHeight;
130 float m_yOffset;
131 float m_minusSignWidth;
133 float m_digitPadding;
135 // * display settings
136 display_flags m_flags;
137 bool m_negativeVisible;
139 public: // constants
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__ */