summaryrefslogtreecommitdiff
path: root/plugins/MirandaG15/src/CScreensaverScreen.cpp
blob: 492274a2cc0ffc55ba963bda0f9819440b6681a9 (plain)
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#include "stdafx.h"
#include "CScreensaverScreen.h"
#include "CAppletManager.h"

//************************************************************************
// Constructor
//************************************************************************
CScreensaverScreen::CScreensaverScreen()
{
}

//************************************************************************
// Destructor
//************************************************************************
CScreensaverScreen::~CScreensaverScreen()
{
}

//************************************************************************
// Initializes the screen 
//************************************************************************
bool CScreensaverScreen::Initialize()
{
	if (!CScreen::Initialize())
		return false;

	m_Label.Initialize();
	m_Label2.Initialize();

	m_Label.SetAlignment(DT_CENTER);
	m_Label.SetWordWrap(TRUE);
	m_Label.SetText(L"Screensaver is active");
	m_Label.SetFontFaceName(L"Microsoft Sans Serif");
	m_Label.SetFontPointSize(10);
	m_Label.SetFontWeight(FW_BOLD);

	m_Label2.SetAlignment(DT_CENTER);
	m_Label2.SetWordWrap(TRUE);
	m_Label2.SetText(L"");
	m_Label2.SetFontFaceName(L"Microsoft Sans Serif");
	m_Label2.SetFontPointSize(8);

	m_Label.SetOrigin(0, 0);
	m_Label.SetSize(GetWidth(), 20);

	m_Label2.SetOrigin(0, 23);
	m_Label2.SetSize(GetWidth(), 20);

	AddObject(&m_Label);
	AddObject(&m_Label2);
	return true;
}

//************************************************************************
// Shutdown the scren
//************************************************************************
bool CScreensaverScreen::Shutdown()
{
	if (!CScreen::Shutdown())
		return false;

	return true;
}

//************************************************************************
// Updates the screen
//************************************************************************
bool CScreensaverScreen::Update()
{
	if (!CScreen::Update())
		return false;

	DWORD dwTimeElapsed = GetTickCount() - m_dwActivation;
	int iOldPosition = m_iPosition;

	if (dwTimeElapsed > m_dwDuration) {
		m_dwDuration = 4000;
		m_Label.SetText(L"");
		m_Label2.SetText(L"");
		switch (m_iPosition) {
		case 0:
			m_Label.SetFontPointSize(8);
			m_Label.SetText(L"MirandaG15");
			m_Label2.SetText(L"Screensaver is active");
			m_dwDuration = 1800;
			break;
		case 1:
			m_Label.SetFontPointSize(11);
			m_Label.SetText(L"MirandaG15");
			m_Label2.SetText(L"Applet locked");
			m_dwDuration = 1800;
			m_iPosition = -1;
			break;

		default:
			CAppletManager::GetInstance()->ActivateEventScreen();
			return true;
		}
		m_iPosition++;
		CAppletManager::GetInstance()->StartTransition(TRANSITION_MORPH);
	}

	if (m_iPosition != iOldPosition)
		m_dwActivation = GetTickCount();

	return true;
}

//************************************************************************
// Resets the credits screens state
//************************************************************************
void CScreensaverScreen::Reset()
{
	m_dwDuration = 0;
	m_iPosition = 0;

	m_Label.SetFontPointSize(10);

	m_Label.SetText(L"");
	m_Label2.SetText(L"");

	CAppletManager::GetInstance()->GetLCDConnection()->SetAsForeground(true);
}


//************************************************************************
// Draws the screen
//************************************************************************
bool CScreensaverScreen::Draw(CLCDGfx *pGfx)
{
	if (!CScreen::Draw(pGfx))
		return false;

	return true;
}

//************************************************************************
// Called when the configuration has changed
//************************************************************************
void CScreensaverScreen::OnConfigChanged()
{
	CScreen::OnConfigChanged();
}

//************************************************************************
// Called when the screen size has changed
//************************************************************************
void CScreensaverScreen::OnSizeChanged()
{
	CScreen::OnSizeChanged();
}

//************************************************************************
// Called when an LCD-button is pressed
//************************************************************************
void CScreensaverScreen::OnLCDButtonDown(int)
{
}

//************************************************************************
// Called when an LCD-button event is repeated
//************************************************************************
void CScreensaverScreen::OnLCDButtonRepeated(int)
{
}

//************************************************************************
// Called when an LCD-button is released
//************************************************************************
void CScreensaverScreen::OnLCDButtonUp(int)
{
}

//************************************************************************
// Called when the screen is activated
//************************************************************************
void CScreensaverScreen::OnActivation()
{
}

//************************************************************************
// Called when the screen is deactivated
//************************************************************************
void CScreensaverScreen::OnDeactivation()
{
	CAppletManager::GetInstance()->GetLCDConnection()->SetAsForeground(false);
	CAppletManager::GetInstance()->StartTransition(TRANSITION_MORPH);
}

//************************************************************************
// Called when the screen has expired
//************************************************************************
void CScreensaverScreen::OnExpiration()
{
}