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 "ProgressGlue.hpp"
25 #include "ProgressWindow.hpp"
26 #include "Screen/SingleWindow.hpp"
27 #include "Interface.hpp"
28 #include "UIGlobals.hpp"
29 #include "Time/PeriodClock.hpp"
31 static ProgressWindow
*global_progress_window
;
34 * This clock throttles screen updates.
36 static PeriodClock throttle_clock
;
39 ProgressGlue::Create(const TCHAR
*text
)
41 UIGlobals::GetMainWindow().RefreshSize();
43 if (global_progress_window
== NULL
)
44 global_progress_window
= new ProgressWindow(UIGlobals::GetMainWindow());
46 global_progress_window
->SetMessage(text
);
47 global_progress_window
->SetValue(0);
49 UIGlobals::GetMainWindow().Refresh();
50 throttle_clock
.Reset();
54 ProgressGlue::Move(const PixelRect
&rc
)
56 if (global_progress_window
== NULL
)
59 global_progress_window
->Move(rc
);
60 throttle_clock
.Reset();
66 delete global_progress_window
;
67 global_progress_window
= NULL
;
73 if (global_progress_window
== NULL
)
76 if (!throttle_clock
.CheckUpdate(200))
79 global_progress_window
->Step();
80 UIGlobals::GetMainWindow().RefreshSize();
81 UIGlobals::GetMainWindow().Refresh();
85 ProgressGlue::SetValue(unsigned value
)
87 if (global_progress_window
== NULL
)
90 if (!throttle_clock
.CheckUpdate(200))
93 global_progress_window
->SetValue(value
);
94 UIGlobals::GetMainWindow().RefreshSize();
95 UIGlobals::GetMainWindow().Refresh();
99 ProgressGlue::SetRange(unsigned value
)
101 if (global_progress_window
== NULL
)
104 global_progress_window
->SetRange(0, value
);
105 throttle_clock
.Reset();
109 ProgressGlue::SetStep(int step
)
111 if (global_progress_window
== NULL
)
114 global_progress_window
->SetStep(step
);
115 throttle_clock
.Reset();