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 "ReplayDialog.hpp"
25 #include "Dialogs/Message.hpp"
26 #include "Dialogs/WidgetDialog.hpp"
27 #include "Widget/RowFormWidget.hpp"
28 #include "Form/ActionListener.hpp"
29 #include "Form/DataField/Listener.hpp"
30 #include "UIGlobals.hpp"
31 #include "Components.hpp"
32 #include "Replay/Replay.hpp"
33 #include "Form/DataField/FileReader.hpp"
34 #include "Form/DataField/Float.hpp"
35 #include "Language/Language.hpp"
42 class ReplayControlWidget final
43 : public RowFormWidget
, public ActionListener
, DataFieldListener
{
50 ReplayControlWidget(const DialogLook
&look
)
51 :RowFormWidget(look
) {}
55 void OnStartClicked();
58 /* virtual methods from class Widget */
59 virtual void Prepare(ContainerWindow
&parent
,
60 const PixelRect
&rc
) override
;
62 /* virtual methods from ActionListener */
63 virtual void OnAction(int id
) override
;
66 /* methods from DataFieldListener */
67 virtual void OnModified(DataField
&df
) override
;
71 ReplayControlWidget::Prepare(ContainerWindow
&parent
, const PixelRect
&rc
)
74 AddFileReader(_("File"),
75 _("Name of file to replay. Can be an IGC file (.igc), a raw NMEA log file (.nmea), or if blank, runs the demo."),
77 _T("*.nmea\0*.igc\0"),
79 ((DataFieldFileReader
*)file
->GetDataField())->Lookup(replay
->GetFilename());
80 file
->RefreshDisplay();
83 _("Time acceleration of replay. Set to 0 for pause, 1 for normal real-time replay."),
84 _("%.0f x"), _T("%.0f"),
85 fixed(0), fixed(10), fixed(1), false,
86 replay
->GetTimeScale(),
91 ReplayControlWidget::OnStopClicked()
97 ReplayControlWidget::OnStartClicked()
99 const DataFieldFileReader
&df
= (const DataFieldFileReader
&)
101 const TCHAR
*path
= df
.GetPathFile();
102 if (!replay
->Start(path
))
103 ShowMessageBox(_("Could not open IGC file!"),
104 _("Replay"), MB_OK
| MB_ICONINFORMATION
);
108 ReplayControlWidget::OnAction(int id
)
122 ReplayControlWidget::OnModified(DataField
&_df
)
124 const DataFieldFloat
&df
= (const DataFieldFloat
&)_df
;
126 replay
->SetTimeScale(df
.GetAsFixed());
132 const DialogLook
&look
= UIGlobals::GetDialogLook();
133 ReplayControlWidget
*widget
= new ReplayControlWidget(look
);
134 WidgetDialog
dialog(look
);
135 dialog
.CreateAuto(UIGlobals::GetMainWindow(), _("Replay"), widget
);
136 dialog
.AddButton(_("Start"), *widget
, START
);
137 dialog
.AddButton(_("Stop"), *widget
, STOP
);
138 dialog
.AddButton(_("Close"), mrOK
);