TaskStats: remove unused attribute "Time"
[xcsoar.git] / test / src / Main.hpp
blob20a36491f94dd4c794f4cfe65582e0558fbabaf3
1 /*
2 * This header contains common boilerplate initialisation code for a
3 * lot of debug programs.
5 */
7 #ifdef ENABLE_CMDLINE
8 #include "OS/Args.hpp"
9 #endif
11 #ifdef ENABLE_XML_DIALOG
12 #include "Dialogs/XML.hpp"
13 #define ENABLE_DIALOG
14 #define ENABLE_RESOURCE_LOADER
15 #endif
17 #if defined(ENABLE_RESOURCE_LOADER) && defined(USE_GDI)
18 #include "ResourceLoader.hpp"
19 #endif
21 #ifdef ENABLE_DIALOG
22 #include "Dialogs/DialogSettings.hpp"
23 #include "UIGlobals.hpp"
24 #define ENABLE_DIALOG_LOOK
25 #endif
27 #ifdef ENABLE_MAIN_WINDOW
28 #include "Screen/SingleWindow.hpp"
29 #include "UIGlobals.hpp"
30 #endif
32 #ifdef ENABLE_LOOK
33 #include "Look/Look.hpp"
34 #include "UISettings.hpp"
35 #define ENABLE_SCREEN
36 #elif defined(ENABLE_DIALOG_LOOK)
37 #include "Look/DialogLook.hpp"
38 #define ENABLE_SCREEN
39 #endif
41 #ifdef ENABLE_SCREEN
42 #include "Screen/Init.hpp"
43 #include "Screen/Layout.hpp"
44 #include "Fonts.hpp"
45 #endif
47 #ifdef ENABLE_PROFILE
48 #include "Profile/Profile.hpp"
49 #define ENABLE_DATA_PATH
50 #endif
52 #ifdef ENABLE_DATA_PATH
53 #include "LocalPath.hpp"
54 #endif
56 #ifdef WIN32
57 #include <windows.h>
58 #endif
60 #ifdef ENABLE_CMDLINE
61 static void
62 ParseCommandLine(Args &args);
63 #endif
65 static void Main();
67 #ifdef ENABLE_LOOK
68 static Look *look;
69 #endif
71 #ifdef ENABLE_DIALOG_LOOK
72 static DialogLook *dialog_look;
73 #endif
75 #ifdef ENABLE_DIALOG
76 static DialogSettings dialog_settings;
78 const DialogSettings &
79 UIGlobals::GetDialogSettings()
81 return dialog_settings;
84 const DialogLook &
85 UIGlobals::GetDialogLook()
87 return *dialog_look;
89 #endif
91 #ifdef ENABLE_MAIN_WINDOW
92 static SingleWindow main_window;
94 SingleWindow &
95 UIGlobals::GetMainWindow()
97 return main_window;
99 #endif
101 #ifndef WIN32
102 int main(int argc, char **argv)
103 #else
104 int WINAPI
105 WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
106 #ifdef _WIN32_WCE
107 LPWSTR lpCmdLine,
108 #else
109 LPSTR lpCmdLine2,
110 #endif
111 int nCmdShow)
112 #endif
114 #ifdef ENABLE_CMDLINE
115 #ifdef WIN32
116 Args args(GetCommandLine(), USAGE);
117 #else
118 Args args(argc, argv, USAGE);
119 #endif
120 ParseCommandLine(args);
121 args.ExpectEnd();
122 #endif
124 #if defined(ENABLE_RESOURCE_LOADER) && defined(USE_GDI)
125 ResourceLoader::Init(hInstance);
126 #endif
128 #ifdef ENABLE_SCREEN
129 ScreenGlobalInit screen_init;
130 Layout::Initialize({640, 480});
131 InitialiseFonts();
132 #endif
134 #ifdef ENABLE_DIALOG
135 dialog_settings.SetDefaults();
136 #endif
138 #ifdef ENABLE_LOOK
139 look = new Look();
140 look->Initialise(normal_font, bold_font, small_font);
143 UISettings ui_settings;
144 ui_settings.SetDefaults();
145 look->InitialiseConfigured(ui_settings,
146 normal_font, bold_font, small_font,
147 small_font, monospace_font,
148 normal_font, small_font,
149 #ifndef GNAV
150 small_font,
151 #endif
152 small_font);
155 dialog_look = &look->dialog;
156 #elif defined(ENABLE_DIALOG_LOOK)
157 dialog_look = new DialogLook();
158 dialog_look->Initialise(bold_font, normal_font, small_font,
159 bold_font, bold_font, bold_font);
160 #endif
162 #ifdef ENABLE_XML_DIALOG
163 SetXMLDialogLook(*dialog_look);
164 #endif
166 #ifdef ENABLE_DATA_PATH
167 InitialiseDataPath();
168 #endif
170 #ifdef ENABLE_PROFILE
171 Profile::SetFiles(_T(""));
172 Profile::Load();
173 #endif
175 #ifdef ENABLE_MAIN_WINDOW
176 main_window.Create(_T("Test"), {640, 480});
177 main_window.Show();
178 #endif
180 Main();
182 #ifdef ENABLE_MAIN_WINDOW
183 main_window.Destroy();
184 #endif
186 #ifdef ENABLE_DATA_PATH
187 DeinitialiseDataPath();
188 #endif
190 #ifdef ENABLE_LOOK
191 delete look;
192 #elif defined(ENABLE_DIALOG_LOOK)
193 delete dialog_look;
194 #endif
196 #ifdef ENABLE_SCREEN
197 DeinitialiseFonts();
198 #endif
200 return 0;