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.
27 #include "Screen/SingleWindow.hpp"
28 #include "Screen/ButtonWindow.hpp"
29 #include "Screen/Timer.hpp"
30 #include "Screen/Canvas.hpp"
31 #include "Look/HorizonLook.hpp"
32 #include "Renderer/HorizonRenderer.hpp"
33 #include "NMEA/Attitude.hpp"
35 class HorizonWindow
: public PaintWindow
37 const HorizonLook
&look
;
38 AttitudeState attitude
;
41 HorizonWindow(const HorizonLook
&_look
)
44 void SetAttitude(const AttitudeState
&_attitude
) {
50 virtual void OnPaint(Canvas
&canvas
) override
{
52 HorizonRenderer::Draw(canvas
, canvas
.GetRect(), look
, attitude
);
56 class TestWindow
: public SingleWindow
58 ButtonWindow close_button
;
59 HorizonWindow horizon
;
69 TestWindow(const HorizonLook
&look
):horizon(look
), timer(*this)
78 void Create(PixelSize size
) {
82 SingleWindow::Create(_T("RunHorizonRenderer"), size
, style
);
84 const PixelRect rc
= GetClientRect();
86 WindowStyle with_border
;
89 horizon
.Create(*this, rc
, with_border
);
91 PixelRect button_rc
= rc
;
92 button_rc
.top
= button_rc
.bottom
- 30;
93 close_button
.Create(*this, _T("Close"), ID_CLOSE
, button_rc
);
97 virtual bool OnCommand(unsigned id
, unsigned code
) override
{
104 return SingleWindow::OnCommand(id
, code
);
107 virtual bool OnTimer(WindowTimer
&_timer
) override
{
108 if (_timer
== timer
) {
109 AttitudeState attitude
;
110 attitude
.bank_angle_available
= true;
111 attitude
.pitch_angle_available
= true;
112 attitude
.bank_angle
= Angle::Zero();
113 attitude
.pitch_angle
= Angle::Zero();
115 horizon
.SetAttitude(attitude
);
119 return SingleWindow::OnTimer(_timer
);
122 virtual void OnResize(PixelSize new_size
) override
{
123 SingleWindow::OnResize(new_size
);
124 if (horizon
.IsDefined())
125 horizon
.Resize(new_size
);
132 HorizonLook horizon_look
;
133 horizon_look
.Initialise();
135 TestWindow
window(horizon_look
);
136 window
.Create({160, 160});
139 window
.RunEventLoop();