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_HPP
25 #define XCSOAR_INFO_BOX_HPP
27 #include "Util/StaticString.hpp"
28 #include "InfoBoxes/Content/Base.hpp"
29 #include "Screen/PaintWindow.hpp"
30 #include "Screen/Timer.hpp"
33 struct InfoBoxSettings
;
37 class InfoBoxWindow
: public PaintWindow
39 /** timeout of infobox focus [ms] */
40 static constexpr unsigned FOCUS_TIMEOUT_MAX
= 20 * 1000;
43 InfoBoxContent
*content
;
45 const InfoBoxSettings
&settings
;
46 const InfoBoxLook
&look
;
47 const UnitsLook
&units_look
;
49 const unsigned border_kind
;
58 * Is the mouse currently pressed inside this InfoBox?
63 * draw the selector event if the InfoBox window is not the system focus
65 bool force_draw_selector
;
67 /** a timer which returns keyboard focus back to the map window after a while */
68 WindowTimer focus_timer
;
71 * This timer opens the dialog. It is used to check for "long
72 * click" and to delay the dialog a bit (for double click
75 WindowTimer dialog_timer
;
79 PixelRect comment_rect
;
80 PixelRect value_and_comment_rect
;
83 * Paints the InfoBox title to the given canvas
84 * @param canvas The canvas to paint on
86 void PaintTitle(Canvas
&canvas
);
88 * Paints the InfoBox value to the given canvas
89 * @param canvas The canvas to paint on
91 void PaintValue(Canvas
&canvas
);
93 * Paints the InfoBox comment on the given canvas
94 * @param canvas The canvas to paint on
96 void PaintComment(Canvas
&canvas
);
98 * Paints the InfoBox with borders, title, comment and value
100 void Paint(Canvas
&canvas
);
103 void PaintInto(Canvas
&dest
, PixelScalar xoff
, PixelScalar yoff
,
104 UPixelScalar width
, UPixelScalar height
);
107 * Sets the InfoBox title to the given Value
108 * @param Value New value of the InfoBox title
110 void SetTitle(const TCHAR
*title
);
112 const TCHAR
* GetTitle() {
117 * Constructor of the InfoBoxWindow class
118 * @param Parent The parent ContainerWindow (usually MainWindow)
120 InfoBoxWindow(ContainerWindow
&parent
, PixelRect rc
, unsigned border_flags
,
121 const InfoBoxSettings
&settings
, const InfoBoxLook
&_look
,
122 const UnitsLook
&units_look
,
124 WindowStyle style
=WindowStyle());
128 const InfoBoxLook
&GetLook() const {
132 void SetContentProvider(InfoBoxContent
*_content
);
133 void UpdateContent();
136 void SetPressed(bool _pressed
) {
137 if (_pressed
== pressed
)
147 bool HandleKey(InfoBoxContent::InfoBoxKeyCodes keycode
);
151 const InfoBoxPanel
*GetDialogContent() const;
153 const PixelRect
GetValueRect() const {
156 const PixelRect
GetValueAndCommentRect() const {
157 return value_and_comment_rect
;
161 virtual void OnDestroy() override
;
162 virtual void OnResize(PixelSize new_size
) override
;
163 virtual void OnSetFocus() override
;
164 virtual void OnKillFocus() override
;
165 virtual void OnCancelMode() override
;
166 virtual bool OnTimer(WindowTimer
&timer
) override
;
168 virtual bool OnKeyDown(unsigned key_code
) override
;
170 virtual bool OnMouseDown(PixelScalar x
, PixelScalar y
) override
;
171 virtual bool OnMouseUp(PixelScalar x
, PixelScalar y
) override
;
172 virtual bool OnMouseDouble(PixelScalar x
, PixelScalar y
) override
;
173 virtual bool OnMouseMove(PixelScalar x
, PixelScalar y
,
174 unsigned keys
) override
;
176 virtual void OnPaint(Canvas
&canvas
) override
;