Dialogs/*: add "override" and "final"
[xcsoar.git] / src / Dialogs / Device / LX / ManageV7Dialog.cpp
blob92f18bd40acccc589325a9596a9c8267653e0a3d
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 "ManageV7Dialog.hpp"
25 #include "V7ConfigWidget.hpp"
26 #include "ManageNanoDialog.hpp"
27 #include "Dialogs/WidgetDialog.hpp"
28 #include "Widget/RowFormWidget.hpp"
29 #include "UIGlobals.hpp"
30 #include "Language/Language.hpp"
31 #include "Operation/MessageOperationEnvironment.hpp"
32 #include "Device/Driver/LX/Internal.hpp"
33 #include "NMEA/DeviceInfo.hpp"
35 class ManageV7Widget final
36 : public RowFormWidget, private ActionListener {
37 enum Controls {
38 SETUP,
39 NANO,
42 LXDevice &device;
43 const DeviceInfo info;
44 const DeviceInfo secondary_info;
46 public:
47 ManageV7Widget(const DialogLook &look, LXDevice &_device,
48 const DeviceInfo &info,
49 const DeviceInfo &secondary_info)
50 :RowFormWidget(look), device(_device), info(info),
51 secondary_info(secondary_info) {}
53 /* virtual methods from Widget */
54 virtual void Prepare(ContainerWindow &parent, const PixelRect &rc) override;
56 private:
57 /* virtual methods from ActionListener */
58 virtual void OnAction(int id) override;
61 void
62 ManageV7Widget::Prepare(ContainerWindow &parent, const PixelRect &rc)
64 StaticString<64> buffer;
66 if (!info.product.empty()) {
67 buffer.clear();
68 buffer.UnsafeAppendASCII(info.product.c_str());
69 AddReadOnly(_("Product"), NULL, buffer.c_str());
72 if (!info.serial.empty()) {
73 buffer.clear();
74 buffer.UnsafeAppendASCII(info.serial.c_str());
75 AddReadOnly(_("Serial"), NULL, buffer.c_str());
78 if (!info.hardware_version.empty()) {
79 buffer.clear();
80 buffer.UnsafeAppendASCII(info.hardware_version.c_str());
81 AddReadOnly(_("Hardware version"), NULL, buffer.c_str());
84 if (!info.software_version.empty()) {
85 buffer.clear();
86 buffer.UnsafeAppendASCII(info.software_version.c_str());
87 AddReadOnly(_("Firmware version"), NULL, buffer.c_str());
90 AddButton(_("Setup"), *this, SETUP);
92 if (device.IsNano())
93 AddButton(_T("LXNAV Nano"), *this, NANO);
96 void
97 ManageV7Widget::OnAction(int id)
99 MessageOperationEnvironment env;
101 switch (id) {
102 case SETUP:
104 V7ConfigWidget widget(GetLook(), device);
105 DefaultWidgetDialog(UIGlobals::GetMainWindow(), GetLook(),
106 _T("LXNAV V7"), widget);
108 break;
110 case NANO:
111 if (device.EnablePassThrough(env)) {
112 ManageNanoDialog(device, secondary_info);
113 device.EnableNMEA(env);
116 break;
120 void
121 ManageV7Dialog(Device &device, const DeviceInfo &info,
122 const DeviceInfo &secondary_info)
124 WidgetDialog dialog(UIGlobals::GetDialogLook());
125 dialog.CreateAuto(UIGlobals::GetMainWindow(), _T("LXNAV V7"),
126 new ManageV7Widget(UIGlobals::GetDialogLook(),
127 (LXDevice &)device, info,
128 secondary_info));
129 dialog.AddButton(_("Close"), mrCancel);
130 dialog.ShowModal();