-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
116 lines (97 loc) · 2.91 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* This file is part of fra-airtraffic screensaver,
* https://github.com/flederwiesel/fra-airtraffic
* Copyright © 2017 Tobias Kühne
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "container.h"
#include "preview.h"
#include "screenshot.h"
#include "stdpaths.h"
#include <wx/app.h>
#include <wx/cmdline.h>
#include <wx/wx.h>
#include <stdlib.h>
#ifdef _MSC_VER
#define putenv _putenv
#define tzset _tzset
#endif
// Define the MainApp
class MainApp : public wxApp
{
public:
MainApp() { }
virtual ~MainApp() { }
virtual bool OnInit();
};
DECLARE_APP(MainApp)
IMPLEMENT_APP(MainApp)
bool MainApp::OnInit()
{
wxCmdLineParser parser(argc, argv);
wxWindow *saver = NULL;
// We're going to display FRA local time...
// http://man7.org/linux/man-pages/man3/tzset.3.html
if (::putenv("TZ=CET-01:00:00CEST-02:00:00,M3.5.0/2,M10.5.0/3") == 0)
tzset();
MyStandardPaths::Get().UseAppInfo(wxStandardPathsBase::AppInfo_None);
// https://support.microsoft.com/en-us/kb/182383
parser.AddSwitch(wxT("S"), wxEmptyString,
wxT("Run the Screen Saver"),
wxCMD_LINE_PARAM_OPTIONAL);
parser.AddSwitch(wxT("s"), wxEmptyString,
wxT("Run the Screen Saver"),
wxCMD_LINE_PARAM_OPTIONAL);
parser.AddOption(wxT("c"), wxEmptyString,
wxT("Show the Settings dialog box, modal to the foreground window <HWND>."),
wxCMD_LINE_VAL_NUMBER,
wxCMD_LINE_PARAM_OPTIONAL);
parser.AddOption(wxT("p"), wxT("preview"),
wxT("Preview Screen Saver as child of window <HWND>"),
wxCMD_LINE_VAL_NUMBER,
wxCMD_LINE_PARAM_OPTIONAL);
parser.AddLongSwitch(wxT("screenshots"), wxEmptyString,
wxCMD_LINE_PARAM_OPTIONAL);
try
{
if (parser.Parse(false) == 0)
{
wxNativeContainerWindowHandle parentHWND(NULL);
if (parser.Found(wxT("c"), (long*)&parentHWND))
{
wxMessageBox(wxT("No settings for this screensaver.\n")
wxT("For more information visit http://wxwidgets.info"),
wxString().Format(wxT("%p"), parentHWND));
}
else if (parser.Found(wxT("p"), (long*)&parentHWND))
{
if (parentHWND != 0)
saver = new SaverPreview(parentHWND);
}
else if (parser.Found(wxT("S")) || parser.Found(wxT("s")))
{
saver = new SaverContainer();
}
else if (parser.Found(wxT("screenshots")))
{
saver = new ScreenshotContainer(wxSize(480, 280));
}
}
}
catch (...)
{
}
return saver ? true : false;
}