Driver/Volkslogger: rename function to ReadAllFlights()
[xcsoar.git] / src / Gauge / BigThermalAssistantWidget.cpp
blob5fe5e5999b0a47faebac1967b86b5e8eb67af2d2
1 /*
2 Copyright_License {
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"
35 void
36 BigThermalAssistantWidget::UpdateLayout()
38 const PixelRect rc = GetContainer().GetClientRect();
39 view->Move(rc);
41 #ifndef GNAV
42 const unsigned margin = Layout::Scale(1);
43 const unsigned button_height = Layout::GetMinimumControlHeight();
45 PixelRect button_rc;
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);
51 #endif
54 void
55 BigThermalAssistantWidget::Update(const AttitudeState &attitude,
56 const DerivedInfo &calculated)
58 view->Update(attitude, calculated);
61 void
62 BigThermalAssistantWidget::Prepare(ContainerWindow &parent,
63 const PixelRect &_rc)
65 ContainerWidget::Prepare(parent, _rc);
67 const PixelRect rc = GetContainer().GetClientRect();
69 #ifndef GNAV
70 close_button = new WndButton(GetContainer(), UIGlobals::GetDialogLook(),
71 _("Close"), rc, ButtonWindowStyle(),
72 *this, CLOSE);
73 #endif
75 view = new BigThermalAssistantWindow(look, Layout::FastScale(10));
76 view->Create(GetContainer(), rc);
79 void
80 BigThermalAssistantWidget::Unprepare()
82 delete view;
83 #ifndef GNAV
84 delete close_button;
85 #endif
87 ContainerWidget::Unprepare();
90 void
91 BigThermalAssistantWidget::Show(const PixelRect &rc)
93 Update(blackboard.Basic().attitude, blackboard.Calculated());
95 ContainerWidget::Show(rc);
96 UpdateLayout();
98 #ifndef GNAV
99 /* show the "Close" button only if this is a "special" page */
100 close_button->SetVisible(CommonInterface::GetUIState().pages.special_page.IsDefined());
101 #endif
103 blackboard.AddListener(*this);
106 void
107 BigThermalAssistantWidget::Hide()
109 blackboard.RemoveListener(*this);
110 ContainerWidget::Hide();
113 void
114 BigThermalAssistantWidget::Move(const PixelRect &rc)
116 ContainerWidget::Move(rc);
118 UpdateLayout();
121 bool
122 BigThermalAssistantWidget::SetFocus()
124 return false;
127 #ifndef GNAV
129 void
130 BigThermalAssistantWidget::OnAction(int id)
132 switch ((Action)id) {
133 case CLOSE:
134 PageActions::Restore();
135 break;
139 #endif
141 void
142 BigThermalAssistantWidget::OnCalculatedUpdate(const MoreData &basic,
143 const DerivedInfo &calculated)
145 Update(basic.attitude, calculated);