MapItemListDialog: add airspace ack button (#2139)
[xcsoar.git] / src / Dialogs / Weather / NOAADetails.cpp
blobb16b66303ebde6583779c584efbdab9f5f92905b
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 "WeatherDialogs.hpp"
25 #include "Dialogs/JobDialog.hpp"
26 #include "Dialogs/CallBackTable.hpp"
27 #include "Dialogs/XML.hpp"
28 #include "Dialogs/Message.hpp"
29 #include "Form/Form.hpp"
30 #include "Form/Button.hpp"
31 #include "Language/Language.hpp"
32 #include "Weather/Features.hpp"
34 #ifdef HAVE_NOAA
36 #include "Weather/NOAAGlue.hpp"
37 #include "Weather/NOAAStore.hpp"
38 #include "Weather/NOAAUpdater.hpp"
39 #include "Weather/METAR.hpp"
40 #include "Weather/ParsedMETAR.hpp"
41 #include "Weather/TAF.hpp"
42 #include "Weather/NOAAFormatter.hpp"
43 #include "Formatter/Units.hpp"
44 #include "Screen/LargeTextWindow.hpp"
45 #include "Screen/Layout.hpp"
46 #include "UIGlobals.hpp"
48 #include <stdio.h>
50 static WndForm *wf = NULL;
51 static NOAAStore::iterator station_iterator;
53 static void
54 Update()
56 tstring metar_taf = _T("");
58 NOAAFormatter::Format(*station_iterator, metar_taf);
60 ((LargeTextWindow *)wf->FindByName(_T("DetailsText")))->SetText(metar_taf.c_str());
62 StaticString<100> caption;
63 caption.Format(_T("%s: "), _("METAR and TAF"));
65 if (!station_iterator->parsed_metar_available ||
66 !station_iterator->parsed_metar.name_available)
67 caption += station_iterator->GetCodeT();
68 else
69 caption.AppendFormat(_T("%s (%s)"),
70 station_iterator->parsed_metar.name.c_str(),
71 station_iterator->GetCodeT());
73 wf->SetCaption(caption);
76 static void
77 UpdateClicked()
79 DialogJobRunner runner(wf->GetMainWindow(), wf->GetLook(),
80 _("Download"), true);
81 NOAAUpdater::Update(*station_iterator, runner);
82 Update();
85 static void
86 RemoveClicked()
88 StaticString<256> tmp;
89 tmp.Format(_("Do you want to remove station %s?"),
90 station_iterator->GetCodeT());
92 if (ShowMessageBox(tmp, _("Remove"), MB_YESNO) == IDNO)
93 return;
95 noaa_store->erase(station_iterator);
96 noaa_store->SaveToProfile();
98 wf->SetModalResult(mrOK);
101 static constexpr CallBackTableEntry CallBackTable[] = {
102 DeclareCallBackEntry(UpdateClicked),
103 DeclareCallBackEntry(RemoveClicked),
104 DeclareCallBackEntry(NULL)
107 void
108 dlgNOAADetailsShowModal(NOAAStore::iterator iterator)
110 station_iterator = iterator;
112 wf = LoadDialog(CallBackTable, UIGlobals::GetMainWindow(),
113 Layout::landscape ?
114 _T("IDR_XML_NOAA_DETAILS_L") : _T("IDR_XML_NOAA_DETAILS"));
115 assert(wf != NULL);
117 Update();
119 wf->ShowModal();
121 delete wf;
124 #else
126 #include "Dialogs/Message.hpp"
128 void
129 dlgNOAADetailsShowModal(unsigned station_index)
131 ShowMessageBox(_("This function is not available on your platform yet."),
132 _("Error"), MB_OK);
134 #endif