-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.cpccScreenSaverInterface.h
More file actions
108 lines (82 loc) · 3.67 KB
/
app.cpccScreenSaverInterface.h
File metadata and controls
108 lines (82 loc) · 3.67 KB
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
/* *****************************************
* File: cpccScreenSaverInterface.h
* Version: see function getClassVersion()
* Purpose: Portable (cross-platform), light-weight, library
* screensaver interface with windows and OSX
* *****************************************
* Library: Cross Platform C++ Classes (cpcc)
* Copyright: 2014 StarMessage software.
* License: Free for opensource projects.
* Commercial license for closed source projects.
* Web: http://www.StarMessageSoftware.com/cpcclibrary
* Download: https://code.google.com/p/cpcc/
* https://github.com/starmessage/cpcc
* email: sales -at- starmessage.info
* *****************************************
*/
#pragma once
#if defined(__APPLE__)
#include <Cocoa/Cocoa.h>
#elif defined(_WIN32)
#include <Windows.h>
#else
#error Unknown platform for cpccScreenSaverInterface
#endif
#include "cpccUnicodeSupport.h"
/**
cpccScreenSaverInterface
This class is a separator bewteen the underlying operating system API for screensavers
and your screensaver class
It receives the screensaver related events from the OS.
Configuration: if entering the configuration dialog of the screensaver, there is no need to
create the graphics (the sprites and the world) of the screensaver.
In other words, do not create the whole screensaver when this class is created.
You can create the graphics after the initWithWindowHandle() event
Multiple monitors: this class is created once for each monitor. The parameter monitorId
indicates the number of the monitor: 0=primary, 1=second monitor,
-1=preview under the screensaver configuration dialog of the OS.
*/
class cpccScreenSaverInterface
{
public: // data
public: // screensaver interface functions: calls that the operating system dispatches to the screensaver
virtual ~cpccScreenSaverInterface() { }
// initWithWindowHandle should not do any drawing. Allocate the screensaver here
// monitodID: -1=preview, 0=first monitor, 1=second monitor, etc
#ifdef _WIN32
virtual void initWithWindowHandle(HWND wHandle, const int monitorId, const int dpiScaleFactor ) = 0;
virtual void showConfigureSheet(HWND wHandleOwner) = 0;
#elif __APPLE__
virtual void initWithWindowHandle(NSView* wHandle, const int monitorId, const int dpiScaleFactor) = 0;
virtual NSWindow* showConfigureSheet(NSView* wOwnerHandle) =0;
#endif
virtual void setContainerFolder(const cpcc_char *aFolder)=0;
virtual void animateOneFrame(const float dt_inSec)=0;
virtual void drawOneFrame(void)=0;
virtual void flushOneFrame(void)=0;
virtual void backgroundWasInvalidatedByOS(void) = 0;
/// free the allocated resources
virtual void shutDown()=0;
virtual bool hasConfigureSheet(void) = 0;
};
// Assuming the your custom class for the screensaver is 'mySsClass',
// the following function 'createScreenSaver()' must be implemeted in your source code
/*
class cpccScreenSaverFactory
{
public:
static cpccScreenSaverInterface* createScreenSaver(void);
}
*/
namespace cpccScreenSaverFactory
{
cpccScreenSaverInterface* createScreenSaver(void);
}
// Example: in your myScreenSaverClass.cpp file, put:
// cpccScreenSaverInterface* createScreenSaver(void) { return new mySsClass; };
// OR
// You can use the following macro to do the same job
// #define DECLARE_SCREENSAVER_CLASS(T) cpccScreenSaverInterface* cpccScreenSaverFactory::createScreenSaver(void) { return new T; }
#define DECLARE_SCREENSAVER_CLASS(T) namespace cpccScreenSaverFactory { cpccScreenSaverInterface* createScreenSaver(void) { return new T; }; }
// Example:
// DECLARE_SCREENSAVER_CLASS(mySsClass)