File: MainApplication.h

package info (click to toggle)
jazz2-native 3.5.0-2
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 16,912 kB
  • sloc: cpp: 172,557; xml: 113; python: 36; makefile: 5; sh: 2
file content (79 lines) | stat: -rw-r--r-- 1,955 bytes parent folder | download
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
#pragma once

#include "Application.h"

namespace nCine
{
	/** @brief Native argument type, `wchar_t*` on Windows, otherwise `char*` */
#if defined(DEATH_TARGET_WINDOWS)
	typedef wchar_t* NativeArgument;
#else
	typedef char* NativeArgument;
#endif

#if defined(WITH_QT5)
	class Qt5Widget;
#endif

	/// Main entry point and handler for standard (desktop) applications
	class MainApplication : public Application
	{
	public:
		/** @brief Entry point method to be called in the `main()`/`wWinMain()` function */ 
		static int Run(CreateAppEventHandlerDelegate createAppEventHandler, int argc, NativeArgument* argv);

		void Quit() override;

		bool EnablePlayStationExtendedSupport(bool enable) override;
		String GetUserName() override;
		bool OpenUrl(StringView url) override;
		
		bool CanShowScreenKeyboard() override;
		bool ToggleScreenKeyboard() override;
		bool ShowScreenKeyboard() override;
		bool HideScreenKeyboard() override;

	private:
		bool wasSuspended_;

#if defined(WITH_QT5)
		Qt5Widget* qt5Widget_;
#endif

		/** @brief Must be called at the beginning to initialize the application */
		void Init(CreateAppEventHandlerDelegate createAppEventHandler, int argc, NativeArgument* argv);
		/** @brief Must be called continuously to keep the application running */
		void ProcessStep();
#if defined(WITH_GLFW) || defined(WITH_SDL)
		/** @brief Processes events inside the game loop */
		void ProcessEvents();
#endif
#if defined(DEATH_TARGET_EMSCRIPTEN)
		static void EmscriptenStep();
#endif

		MainApplication()
			:
			Application(),
#if defined(WITH_QT5)
			qt5Widget_(nullptr),
#endif
			wasSuspended_(false)
		{
		}

		~MainApplication() = default;

		MainApplication(const MainApplication&) = delete;
		MainApplication& operator=(const MainApplication&) = delete;

		friend Application& theApplication();
#if defined(WITH_QT5)
		friend class Qt5Widget;
#endif
	};

	/// Returns application instance
	Application& theApplication();

}