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 #include "BigThermalAssistantWidget.hpp"
25 #include "Gauge/BigThermalAssistantWindow.hpp"
26 #include "Blackboard/LiveBlackboard.hpp"
27 #include "Language/Language.hpp"
28 #include "Form/Button.hpp"
29 #include "Screen/Layout.hpp"
30 #include "UIGlobals.hpp"
31 #include "UIState.hpp"
32 #include "Interface.hpp"
33 #include "PageActions.hpp"
36 BigThermalAssistantWidget::UpdateLayout()
38 const PixelRect rc
= GetContainer().GetClientRect();
42 const unsigned margin
= Layout::Scale(1);
43 const unsigned button_height
= Layout::GetMinimumControlHeight();
46 button_rc
.bottom
= rc
.bottom
- margin
;
47 button_rc
.top
= button_rc
.bottom
- button_height
;
48 button_rc
.right
= rc
.right
- margin
;
49 button_rc
.left
= button_rc
.right
- Layout::Scale(50);
50 close_button
->Move(button_rc
);
55 BigThermalAssistantWidget::Update(const AttitudeState
&attitude
,
56 const DerivedInfo
&calculated
)
58 view
->Update(attitude
, calculated
);
62 BigThermalAssistantWidget::Prepare(ContainerWindow
&parent
,
65 ContainerWidget::Prepare(parent
, _rc
);
67 const PixelRect rc
= GetContainer().GetClientRect();
70 close_button
= new WndButton(GetContainer(), UIGlobals::GetDialogLook(),
71 _("Close"), rc
, ButtonWindowStyle(),
75 view
= new BigThermalAssistantWindow(look
, Layout::FastScale(10));
76 view
->Create(GetContainer(), rc
);
80 BigThermalAssistantWidget::Unprepare()
87 ContainerWidget::Unprepare();
91 BigThermalAssistantWidget::Show(const PixelRect
&rc
)
93 Update(blackboard
.Basic().attitude
, blackboard
.Calculated());
95 ContainerWidget::Show(rc
);
99 /* show the "Close" button only if this is a "special" page */
100 close_button
->SetVisible(CommonInterface::GetUIState().pages
.special_page
.IsDefined());
103 blackboard
.AddListener(*this);
107 BigThermalAssistantWidget::Hide()
109 blackboard
.RemoveListener(*this);
110 ContainerWidget::Hide();
114 BigThermalAssistantWidget::Move(const PixelRect
&rc
)
116 ContainerWidget::Move(rc
);
122 BigThermalAssistantWidget::SetFocus()
130 BigThermalAssistantWidget::OnAction(int id
)
132 switch ((Action
)id
) {
134 PageActions::Restore();
142 BigThermalAssistantWidget::OnCalculatedUpdate(const MoreData
&basic
,
143 const DerivedInfo
&calculated
)
145 Update(basic
.attitude
, calculated
);