Subversion Repositories spk

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
79 cycrow 1
//************************************************************************
2
//
3
// LCDManager.cpp
4
//
5
// The CLCDManager class is the representation of a "Screen". LCD UI class
6
// objects are added here.
7
// 
8
// Logitech LCD SDK
9
//
10
// Copyright 2005 Logitech Inc.
11
//************************************************************************
12
 
13
#include "LCDManager.h"
14
 
15
 
16
//************************************************************************
17
//
18
// CLCDManager::CLCDManager
19
//
20
//************************************************************************
21
 
22
CLCDManager::CLCDManager(void)
23
{
24
    m_dwElapsedTime = 0;
25
    m_dwExpirationTime = 0;
26
    m_dwStartTime = 0;
27
}
28
 
29
 
30
//************************************************************************
31
//
32
// CLCDManager::~CLCDManager
33
//
34
//************************************************************************
35
 
36
CLCDManager::~CLCDManager(void)
37
{
38
    Shutdown();
39
}
40
 
41
 
42
//************************************************************************
43
//
44
// CLCDManager::Initialize
45
//
46
//************************************************************************
47
 
48
HRESULT CLCDManager::Initialize(void)
49
{
50
    HRESULT hRes = CLCDCollection::Initialize();
51
    if(FAILED(hRes))
52
    {
53
        LCDUITRACE(_T("CLCDManager::Initialize(): failed to initialize base class.\n"));
54
        Shutdown();
55
        return hRes;
56
    }
57
 
58
    SetOrigin(0, 0);
59
    SetSize(LGLCD_BMP_WIDTH, LGLCD_BMP_HEIGHT);
60
 
61
    hRes = m_Gfx.Initialize(GetWidth(), GetHeight());
62
    if(FAILED(hRes))
63
    {
64
        LCDUITRACE(_T("CLCDManager::Initialize(): failed to initialize graphics component.\n"));
65
        Shutdown();
66
        return hRes;
67
    }
68
 
69
    return S_OK;
70
}
71
 
72
 
73
//************************************************************************
74
//
75
// CLCDManager::Shutdown
76
//
77
//************************************************************************
78
 
79
void CLCDManager::Shutdown(void)
80
{
81
    m_Gfx.Shutdown();
82
}
83
 
84
 
85
//************************************************************************
86
//
87
// CLCDManager::GetLCDScreen
88
//
89
//************************************************************************
90
 
91
lgLcdBitmap160x43x1 *CLCDManager::GetLCDScreen(void)
92
{
93
    return m_Gfx.GetLCDScreen();
94
}
95
 
96
 
97
//************************************************************************
98
//
99
// CLCDManager::GetBitmapInfo
100
//
101
//************************************************************************
102
 
103
BITMAPINFO *CLCDManager::GetBitmapInfo(void)
104
{
105
    return m_Gfx.GetBitmapInfo();
106
}
107
 
108
 
109
//************************************************************************
110
//
111
// CLCDManager::Draw
112
//
113
//************************************************************************
114
 
115
HRESULT CLCDManager::Draw(void)
116
{
117
    LCDUIASSERT(NULL != m_Gfx.GetHDC());
118
    LCDUIASSERT(NULL != m_Gfx.GetHBITMAP());
119
    if((NULL == m_Gfx.GetHDC()) || (NULL == m_Gfx.GetHBITMAP()))
120
    {
121
        LCDUITRACE(_T("CLCDManager::Draw(): trying to draw without successful Initialize() first.!\n"));
122
        return E_FAIL;
123
    }
124
 
125
    // select our bitmap into the Gfx DC
126
    m_Gfx.BeginDraw();
127
 
128
    m_Gfx.ClearScreen();
129
 
130
    // invoke LCD UI Elements
131
    OnDraw(m_Gfx);
132
 
133
    // select it back out of it
134
    m_Gfx.EndDraw();
135
 
136
    return S_OK;
137
}
138
 
139
 
140
//************************************************************************
141
//
142
// CLCDManager::Update
143
//
144
//************************************************************************
145
 
146
void CLCDManager::Update(DWORD dwTimestamp)
147
{
148
    LCDUIASSERT(m_dwStartTime != 0);
149
    m_dwElapsedTime = (dwTimestamp - m_dwStartTime);
150
    CLCDCollection::OnUpdate(dwTimestamp);
151
}
152
 
153
 
154
//************************************************************************
155
//
156
// CLCDManager::SetExpiration
157
//
158
//************************************************************************
159
 
160
void CLCDManager::SetExpiration(DWORD dwMilliseconds)
161
{
162
    m_dwStartTime = GetTickCount();
163
    m_dwElapsedTime = 0;
164
    m_dwExpirationTime = dwMilliseconds;
165
}
166
 
167
 
168
//************************************************************************
169
//
170
// CLCDManager::HasExpired
171
//
172
//************************************************************************
173
 
174
BOOL CLCDManager::HasExpired(void)
175
{
176
    return (!m_dwStartTime || (m_dwElapsedTime > m_dwExpirationTime));
177
}
178
 
179
 
180
//************************************************************************
181
//
182
// CLCDManager::OnLCDButtonDown
183
//
184
//************************************************************************
185
 
186
void CLCDManager::OnLCDButtonDown(int nButton)
187
{
188
    UNREFERENCED_PARAMETER(nButton);
189
}
190
 
191
 
192
//************************************************************************
193
//
194
// CLCDManager::OnLCDButtonUp
195
//
196
//************************************************************************
197
 
198
void CLCDManager::OnLCDButtonUp(int nButton)
199
{
200
    UNREFERENCED_PARAMETER(nButton);
201
}
202
 
203
 
204
//** end of LCDManager.cpp ***********************************************