summaryrefslogtreecommitdiff
path: root/plugins/MirandaG15/src/CScreen.cpp
blob: 1759fa9686762689599abf07722d4641771b9d8d (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
#include "stdafx.h"
#include "CScreen.h"
#include "CConfig.h"

//************************************************************************
// Constructor
//************************************************************************
CScreen::CScreen()
{
	m_bHideButtons = false;
}

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

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

	// initialize the four button labels
	for (int i = 0; i < 4; i++)
    {
        m_aButtons[i].Initialize();
        m_aButtons[i].SetSize(17, 3);
        m_aButtons[i].Show(0);
		m_abShowButtons[i] = false;
		m_ahBitmaps[i] = NULL;
		if(GetWidth() == 160) {
			m_aButtons[i].SetOrigin(10+i*29+(i/2)*36, GetHeight()-3);
		} else {
			m_aButtons[i].SetOrigin((280/4)*(i+0.5f) + (i/2)*40, GetHeight()-3);
		}
		AddObject(&m_aButtons[i]);
    }

	/*
	m_Clock.Initialize();

	m_Clock.SetOrigin(68,0);
	m_Clock.SetSize(40,2);
	m_Clock.SetText(_T("23:00 - "));

	m_Clock.SetFontFaceName(_T("Small Fonts"));//Digital Limit 3õ3 C"));
	m_Clock.SetFontPointSize(10);
	//m_Clock.SetFont(CConfig::GetFont(FONT_CLIST));

	AddObject(&m_Clock);
	*/
	return true;
}

//************************************************************************
// Shutdown the scren
//************************************************************************
bool CScreen::Shutdown()
{
	if(!CLCDScreen::Shutdown())
		return false;
	
	for(int i=0; i < 4; i++)
		if(m_ahBitmaps[i] != NULL)
			DeleteObject(m_ahBitmaps[i]);

	return true;
}

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

	return true;
}

//************************************************************************
// Draws the screen
//************************************************************************
bool CScreen::Draw(CLCDGfx *pGfx)
{
	if(!CLCDScreen::Draw(pGfx))
		return false;
	
	for(int i=0;i<4;i++)
		if(m_aButtons[i].IsVisible())
		{
			pGfx->DrawLine(0,GetHeight()-5,GetWidth(),GetHeight()-5);
			break;
		}

	return true;
}

//************************************************************************
// Set the specified button label
//************************************************************************
void CScreen::SetButtonBitmap(int iButton, int iBitmap)
{
	if(iButton <0 || iButton > 3)
		return;
	if(iBitmap == 0)
	{
		m_aButtons[iButton].Show(0);
		m_abShowButtons[iButton] = false;
	}
	else
	{
		if(m_ahBitmaps[iButton] != NULL)
			DeleteObject(m_ahBitmaps[iButton]);

		m_ahBitmaps[iButton] = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(iBitmap),
												IMAGE_BITMAP,17, 3, LR_MONOCHROME);
		m_aButtons[iButton].SetBitmap(m_ahBitmaps[iButton]);

		if(CConfig::GetBoolSetting(SHOW_LABELS))
			m_aButtons[iButton].Show(1);
		m_abShowButtons[iButton] = true;
	}
}

//************************************************************************
// shows/hides the buttons
//************************************************************************
void CScreen::ShowButtons(bool bShow)
{
	m_bHideButtons = !bShow;
	UpdateButtons();
}

//************************************************************************
// Update the buttons
//************************************************************************
void CScreen::UpdateButtons()
{
	for (int i = 0; i < 4; i++)
	{
		if(GetWidth() == 160) {
			m_aButtons[i].SetOrigin(10+i*29+(i/2)*36, GetHeight()-3);
		} else {
			m_aButtons[i].SetOrigin((280/4)*(i+0.5f) + (i/2)*40, GetHeight()-3);
		}
		
		if(m_abShowButtons[i])
			m_aButtons[i].Show(CConfig::GetBoolSetting(SHOW_LABELS) && !m_bHideButtons);
	}
}

//************************************************************************
// Called when an event is received
//************************************************************************
void CScreen::OnEventReceived(CEvent *pEvent)
{
}

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

//************************************************************************
// Called when the screens size has changed
//************************************************************************
void CScreen::OnSizeChanged() {
	CLCDScreen::OnSizeChanged();

	UpdateButtons();
}