4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef XCSOAR_INFO_BOX_DATA_HPP
25 #define XCSOAR_INFO_BOX_DATA_HPP
27 #include "Util/StaticString.hpp"
28 #include "Units/Unit.hpp"
29 #include "Math/fixed.hpp"
36 static constexpr unsigned COLOR_COUNT
= 6;
38 StaticString
<32> title
;
39 StaticString
<32> value
;
40 StaticString
<32> comment
;
44 uint8_t title_color
, value_color
, comment_color
;
49 * Enable custom painting via InfoBoxContent::OnCustomPaint().
52 /* 0xff is a "magic" value that indicates custom painting*/
57 bool GetCustom() const {
58 return value_color
== 0xff;
62 * Resets value to --- and unassigns the unit
64 void SetValueInvalid();
69 void SetCommentInvalid() {
74 * calls SetValueInvalid() then SetCommentInvalid()
79 * Sets the InfoBox title to the given Value
81 * @param title New value of the InfoBox title
83 void SetTitle(const TCHAR
*title
);
85 const TCHAR
*GetTitle() const {
90 * Sets the InfoBox value to the given Value
91 * @param Value New value of the InfoBox value
93 void SetValue(const TCHAR
*value
);
95 void SetValue(const TCHAR
*format
, fixed value
);
98 * Sets the InfoBox value to the given angle.
100 void SetValue(Angle value
, const TCHAR
*suffix
=_T(""));
102 void SetValueFromBearingDifference(Angle delta
);
105 * Set the InfoBox value to the specified glide ratio.
107 void SetValueFromGlideRatio(fixed gr
);
110 * Set the InfoBox value to the specified distance.
112 void SetValueFromDistance(fixed value
);
115 * Set the InfoBox value to the specified altitude.
117 void SetValueFromAltitude(fixed value
);
120 * Set the InfoBox value to the specified arrival altitude.
122 void SetValueFromArrival(fixed value
);
125 * Set the InfoBox value to the specified horizontal speed.
127 void SetValueFromSpeed(fixed value
, bool precision
=true);
130 * Sets the InfoBox comment to the given Value
131 * @param Value New value of the InfoBox comment
133 void SetComment(const TCHAR
*comment
);
136 * Sets the InfoBox comment to the given angle.
138 void SetComment(Angle comment
, const TCHAR
*suffix
=_T(""));
140 void SetCommentFromDistance(fixed value
);
142 void SetCommentFromBearingDifference(Angle delta
);
145 * Set the InfoBox comment to the specified horizontal speed.
147 void SetCommentFromSpeed(fixed value
, bool precision
=true);
150 * Set the InfoBox value to the specified altitude in the alternate
153 void SetCommentFromAlternateAltitude(fixed value
);
156 * Set the InfoBox comment value to the specified vertical speed.
158 void SetCommentFromVerticalSpeed(fixed value
, bool include_sign
=true);
160 template<typename
... Args
>
161 void FormatTitle(const TCHAR
*fmt
, Args
&&... args
) {
162 title
.Format(fmt
, args
...);
163 title
.CropIncompleteUTF8();
166 template<typename
... Args
>
167 void FormatValue(const TCHAR
*fmt
, Args
&&... args
) {
168 value
.Format(fmt
, args
...);
171 template<typename
... Args
>
172 void FormatComment(const TCHAR
*fmt
, Args
&&... args
) {
173 comment
.Format(fmt
, args
...);
174 comment
.CropIncompleteUTF8();
177 template<typename
... Args
>
178 void UnsafeFormatValue(const TCHAR
*fmt
, Args
&&... args
) {
179 value
.UnsafeFormat(fmt
, args
...);
182 template<typename
... Args
>
183 void UnsafeFormatComment(const TCHAR
*fmt
, Args
&&... args
) {
184 comment
.UnsafeFormat(fmt
, args
...);
188 * Sets the unit of the InfoBox value
190 * @param Value New unit of the InfoBox value
192 void SetValueUnit(Unit _value_unit
) {
193 value_unit
= _value_unit
;
197 * Sets the color of the InfoBox value to the given value
198 * @param value New color of the InfoBox value
200 void SetValueColor(unsigned _color
) {
201 assert(_color
< COLOR_COUNT
);
203 value_color
= _color
;
207 * Sets the color of the InfoBox comment to the given value
208 * @param value New color of the InfoBox comment
210 void SetCommentColor(unsigned _color
) {
211 assert(_color
< COLOR_COUNT
);
213 comment_color
= _color
;
217 * Sets the color of the InfoBox title to the given value
218 * @param value New color of the InfoBox title
220 void SetTitleColor(unsigned _color
) {
221 assert(_color
< COLOR_COUNT
);
223 title_color
= _color
;
226 void SetAllColors(unsigned color
);
228 bool CompareTitle(const InfoBoxData
&other
) const;
229 bool CompareValue(const InfoBoxData
&other
) const;
230 bool CompareComment(const InfoBoxData
&other
) const;