Projection: make invalid by default, add IsValid()
[xcsoar.git] / src / ProgressGlue.cpp
blob713e97f9abd880f657b840b6075e86628f464d3a
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 "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;
33 /**
34 * This clock throttles screen updates.
36 static PeriodClock throttle_clock;
38 void
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();
53 void
54 ProgressGlue::Move(const PixelRect &rc)
56 if (global_progress_window == NULL)
57 return;
59 global_progress_window->Move(rc);
60 throttle_clock.Reset();
63 void
64 ProgressGlue::Close()
66 delete global_progress_window;
67 global_progress_window = NULL;
70 void
71 ProgressGlue::Step()
73 if (global_progress_window == NULL)
74 return;
76 if (!throttle_clock.CheckUpdate(200))
77 return;
79 global_progress_window->Step();
80 UIGlobals::GetMainWindow().RefreshSize();
81 UIGlobals::GetMainWindow().Refresh();
84 void
85 ProgressGlue::SetValue(unsigned value)
87 if (global_progress_window == NULL)
88 return;
90 if (!throttle_clock.CheckUpdate(200))
91 return;
93 global_progress_window->SetValue(value);
94 UIGlobals::GetMainWindow().RefreshSize();
95 UIGlobals::GetMainWindow().Refresh();
98 void
99 ProgressGlue::SetRange(unsigned value)
101 if (global_progress_window == NULL)
102 return;
104 global_progress_window->SetRange(0, value);
105 throttle_clock.Reset();
108 void
109 ProgressGlue::SetStep(int step)
111 if (global_progress_window == NULL)
112 return;
114 global_progress_window->SetStep(step);
115 throttle_clock.Reset();