Renderer, ...: use PixelRect::GetCenter()
[xcsoar.git] / test / src / RunTaskEditorDialog.cpp
blob4884dc8cdf81fc6e5eb8d7b9a9268b1be6433dcf
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 "Screen/SingleWindow.hpp"
25 #include "Screen/Init.hpp"
26 #include "Dialogs/Dialogs.h"
27 #include "UtilsSystem.hpp"
28 #include "LocalPath.hpp"
29 #include "WayPointParser.h"
30 #include "Airspace/AirspaceClientUI.hpp"
31 #include "TaskClientUI.hpp"
32 #include "Task/TaskManager.hpp"
33 #include "InfoBoxes/InfoBoxLayout.hpp"
34 #include "Interface.hpp"
35 #include "Blackboard/DeviceBlackboard.hpp"
36 #include "Logger/Logger.hpp"
37 #include "Engine/Airspace/Airspaces.hpp"
38 #include "Engine/Airspace/AirspaceWarningManager.hpp"
39 #include "LocalPath.hpp"
40 #include "Look/Fonts.hpp"
42 #include <tchar.h>
43 #include <stdio.h>
45 void
46 DeviceBlackboard::SetStartupLocation(const GeoPoint &loc,
47 const double alt)
51 Projection::Projection() {}
53 static RasterTerrain terrain;
54 Logger logger;
56 InterfaceBlackboard CommonInterface::blackboard;
58 Logger::Logger() {}
59 Logger::~Logger() {}
60 void Logger::LoggerDeviceDeclare() {}
62 void RasterTerrain::Lock() {}
63 void RasterTerrain::Unlock() {}
65 void dlgAnalysisShowModal() {}
66 void dlgTaskCalculatorShowModal(SingleWindow &parent) {}
68 Waypoints way_points;
69 static TaskBehaviour task_behaviour;
70 static TaskEvents task_events;
71 static TaskManager task_manager(task_events, task_behaviour, way_points);
73 static Airspaces airspace_database;
75 static AirspaceWarningManager airspace_warning(airspace_database,
76 task_manager);
78 AirspaceClientUI airspace_ui(airspace_database, airspace_warning);
80 static void
81 LoadFiles()
83 WayPointParser::ReadWaypoints(way_points, &terrain);
86 static void
87 CreateDefaultTask(TaskManager &task_manager, const Waypoints &way_points)
89 const TCHAR start_name[] = _T("Bergneustadt");
91 task_manager.set_factory(OrderedTask::FactoryType::MIXED);
92 AbstractTaskFactory &factory = task_manager.GetFactory();
94 const Waypoint *wp;
95 OrderedTaskPoint *tp;
97 wp = way_points.lookup_name(start_name);
98 if (wp != NULL) {
99 tp = factory.createStart(AbstractTaskFactory::START_LINE, *wp);
100 if (!factory.append(tp, false)) {
101 fprintf(stderr, "Failed to create start point\n");
103 } else {
104 fprintf(stderr, "No start waypoint\n");
107 wp = way_points.lookup_name(_T("Uslar"));
108 if (wp != NULL) {
109 tp = factory.createIntermediate(AbstractTaskFactory::AST_CYLINDER, *wp);
110 if (!factory.append(tp, false)) {
111 fprintf(stderr, "Failed to create turn point\n");
113 } else {
114 fprintf(stderr, "No turn point\n");
117 wp = way_points.lookup_name(_T("Suhl Goldlaut"));
118 if (wp != NULL) {
119 tp = factory.createIntermediate(AbstractTaskFactory::AST_CYLINDER, *wp);
120 if (!factory.append(tp, false)) {
121 fprintf(stderr, "Failed to create turn point\n");
123 } else {
124 fprintf(stderr, "No turn point\n");
127 wp = way_points.lookup_name(start_name);
128 if (wp != NULL) {
129 tp = factory.createFinish(AbstractTaskFactory::FINISH_LINE, *wp);
130 if (!factory.append(tp, false)) {
131 fprintf(stderr, "Failed to create finish point\n");
133 } else {
134 fprintf(stderr, "No finish waypoint\n");
138 #ifndef WIN32
139 int main(int argc, char **argv)
140 #else
141 int WINAPI
142 WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
143 #ifdef _WIN32_WCE
144 LPWSTR lpCmdLine,
145 #else
146 LPSTR lpCmdLine2,
147 #endif
148 int nCmdShow)
149 #endif
151 InitialiseDataPath();
152 ScreenGlobalInit screen_init;
154 LoadFiles();
156 CreateDefaultTask(task_manager, way_points);
158 SingleWindow main_window;
159 main_window.set(_T("STATIC"), _T("RunTaskEditorDialog"),
160 0, 0, 640, 480);
161 ((Window &)main_window).InstallWndProc();
162 main_window.Show();
164 Fonts::Initialize();
166 dlgTaskOverviewShowModal(main_window);
168 Fonts::Deinitialize();
169 DeinitialiseDataPath();
171 return 0;