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 "ManageFlarmDialog.hpp"
25 #include "FLARM/ConfigWidget.hpp"
26 #include "Dialogs/WidgetDialog.hpp"
27 #include "Widget/RowFormWidget.hpp"
28 #include "UIGlobals.hpp"
29 #include "Language/Language.hpp"
30 #include "Operation/MessageOperationEnvironment.hpp"
31 #include "Device/Driver/FLARM/Device.hpp"
32 #include "FLARM/Version.hpp"
34 class ManageFLARMWidget final
35 : public RowFormWidget
, private ActionListener
{
42 const FlarmVersion version
;
45 ManageFLARMWidget(const DialogLook
&look
, FlarmDevice
&_device
,
46 const FlarmVersion
&version
)
47 :RowFormWidget(look
), device(_device
), version(version
) {}
49 /* virtual methods from Widget */
50 virtual void Prepare(ContainerWindow
&parent
, const PixelRect
&rc
) override
;
53 /* virtual methods from ActionListener */
54 virtual void OnAction(int id
) override
;
58 ManageFLARMWidget::Prepare(ContainerWindow
&parent
, const PixelRect
&rc
)
60 if (version
.available
) {
61 StaticString
<64> buffer
;
63 if (!version
.hardware_version
.empty()) {
65 buffer
.UnsafeAppendASCII(version
.hardware_version
.c_str());
66 AddReadOnly(_("Hardware version"), NULL
, buffer
.c_str());
69 if (!version
.software_version
.empty()) {
71 buffer
.UnsafeAppendASCII(version
.software_version
.c_str());
72 AddReadOnly(_("Firmware version"), NULL
, buffer
.c_str());
75 if (!version
.obstacle_version
.empty()) {
77 buffer
.UnsafeAppendASCII(version
.obstacle_version
.c_str());
78 AddReadOnly(_("Obstacle database"), NULL
, buffer
.c_str());
82 AddButton(_("Setup"), *this, Setup
);
83 AddButton(_("Reboot"), *this, Reboot
);
87 ManageFLARMWidget::OnAction(int id
)
92 FLARMConfigWidget
widget(GetLook(), device
);
93 DefaultWidgetDialog(UIGlobals::GetMainWindow(), GetLook(),
100 MessageOperationEnvironment env
;
108 ManageFlarmDialog(Device
&device
, const FlarmVersion
&version
)
110 WidgetDialog
dialog(UIGlobals::GetDialogLook());
111 dialog
.CreateAuto(UIGlobals::GetMainWindow(), _T("FLARM"),
112 new ManageFLARMWidget(UIGlobals::GetDialogLook(),
113 (FlarmDevice
&)device
, version
));
114 dialog
.AddButton(_("Close"), mrCancel
);