79 |
cycrow |
1 |
/****h* EZ.LCD.SDK.Wrapper/EZ_LCD_Page.cpp
|
|
|
2 |
* NAME
|
|
|
3 |
* EZ_LCD_Page.cpp
|
|
|
4 |
* COPYRIGHT
|
|
|
5 |
* The Logitech EZ LCD SDK Wrapper, including all accompanying
|
|
|
6 |
* documentation, is protected by intellectual property laws. All rights
|
|
|
7 |
* not expressly granted by Logitech are reserved.
|
|
|
8 |
* PURPOSE
|
|
|
9 |
* Part of the SDK package.
|
|
|
10 |
* AUTHOR
|
|
|
11 |
* Christophe Juncker (christophe_juncker@logitech.com)
|
|
|
12 |
* Vahid Afshar (Vahid_Afshar@logitech.com)
|
|
|
13 |
* CREATION DATE
|
|
|
14 |
* 06/13/2005
|
|
|
15 |
* MODIFICATION HISTORY
|
|
|
16 |
* 03/01/2006 - Added the concept of pages.
|
|
|
17 |
*
|
|
|
18 |
*******
|
|
|
19 |
*/
|
|
|
20 |
|
|
|
21 |
#include "StdAfx.h"
|
|
|
22 |
|
|
|
23 |
#include "LCDUI/LCDText.h"
|
|
|
24 |
#include "LCDUI/LCDStreamingText.h"
|
|
|
25 |
#include "LCDUI/LCDIcon.h"
|
|
|
26 |
#include "LCDUI/LCDProgressBar.h"
|
|
|
27 |
#include "LCDUI/LCDBitmap.h"
|
|
|
28 |
#include "EZ_LCD.h"
|
|
|
29 |
#include "EZ_LCD_Page.h"
|
|
|
30 |
|
|
|
31 |
// text box height for various font sizes
|
|
|
32 |
CONST INT LG_SMALL_FONT_TEXT_BOX_HEIGHT = 12;
|
|
|
33 |
CONST INT LG_MEDIUM_FONT_TEXT_BOX_HEIGHT = 13;
|
|
|
34 |
CONST INT LG_BIG_FONT_TEXT_BOX_HEIGHT = 20;
|
|
|
35 |
|
|
|
36 |
// corresponding font size
|
|
|
37 |
CONST INT LG_SMALL_FONT_SIZE = 7;
|
|
|
38 |
CONST INT LG_MEDIUM_FONT_SIZE = 8;
|
|
|
39 |
CONST INT LG_BIG_FONT_SIZE = 12;
|
|
|
40 |
|
|
|
41 |
// logical origin Y value for various font sizes
|
|
|
42 |
CONST INT LG_SMALL_FONT_LOGICAL_ORIGIN_Y = -3;
|
|
|
43 |
CONST INT LG_MEDIUM_FONT_LOGICAL_ORIGIN_Y = -2;
|
|
|
44 |
CONST INT LG_BIG_FONT_LOGICAL_ORIGIN_Y = -4;
|
|
|
45 |
|
|
|
46 |
// Scrolling text parameters
|
|
|
47 |
CONST INT LG_SCROLLING_SPEED = 25;
|
|
|
48 |
CONST INT LG_SCROLLING_STEP = 7;
|
|
|
49 |
CONST INT LG_SCROLLING_DELAY_MS = 2000;
|
|
|
50 |
CONST TCHAR LG_SCROLLING_GAP_TEXT[] = _T(" ");
|
|
|
51 |
|
|
|
52 |
// Progress bar parameters
|
|
|
53 |
CONST INT LG_PROGRESS_BAR_RANGE_MIN = 0;
|
|
|
54 |
CONST INT LG_PROGRESS_BAR_RANGE_MAX = 100;
|
|
|
55 |
CONST INT LG_PROGRESS_BAR_INITIAL_HEIGHT = 5;
|
|
|
56 |
|
|
|
57 |
// Font
|
|
|
58 |
CONST LPCTSTR LG_FONT = _T("Microsoft Sans Serif");
|
|
|
59 |
|
|
|
60 |
/****f* EZ.LCD.SDK.Wrapper/CEzLcdPage::CEzLcdPage
|
|
|
61 |
* NAME
|
|
|
62 |
* CEzLcdPage::CEzLcdPage(LPCTSTR friendlyName, INT width, INT height) -- Basic constructor
|
|
|
63 |
* FUNCTION
|
|
|
64 |
* Does necessary initialization.
|
|
|
65 |
* INPUTS
|
|
|
66 |
* friendlyName - friendly name of the applet/game. This name will be
|
|
|
67 |
* displayed in the Logitech G-series LCD Manager.
|
|
|
68 |
* width - width in pixels of the LCD.
|
|
|
69 |
* height - height in pixels of the LCD.
|
|
|
70 |
******
|
|
|
71 |
*/
|
|
|
72 |
CEzLcdPage::CEzLcdPage()
|
|
|
73 |
{
|
|
|
74 |
m_pContainer = NULL;
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
CEzLcdPage::CEzLcdPage(CEzLcd * pContainer, INT iWidth, INT iHeight)
|
|
|
78 |
{
|
|
|
79 |
m_pContainer = pContainer;
|
|
|
80 |
Init(iWidth, iHeight);
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
/****f* EZ.LCD.SDK.Wrapper/CEzLcdPage::CEzLcdPage
|
|
|
84 |
* NAME
|
|
|
85 |
* CEzLcdPage::CEzLcdPage(LPCTSTR friendlyName, INT width, INT height, lgLcdOnConfigureCB callbackFunction, PVOID configContext) -- Constructor including configure button callback function
|
|
|
86 |
* FUNCTION
|
|
|
87 |
* Does necessary initialization.
|
|
|
88 |
* INPUTS
|
|
|
89 |
* friendlyName - friendly name of the applet/game. This name will be
|
|
|
90 |
* displayed in the Logitech G-series LCD Manager.
|
|
|
91 |
* width - width in pixels of the LCD.
|
|
|
92 |
* height - height in pixels of the LCD.
|
|
|
93 |
******
|
|
|
94 |
*/
|
|
|
95 |
|
|
|
96 |
CEzLcdPage::~CEzLcdPage()
|
|
|
97 |
{
|
|
|
98 |
LCD_OBJECT_LIST::iterator it_ = m_Objects.begin();
|
|
|
99 |
while(it_ != m_Objects.end())
|
|
|
100 |
{
|
|
|
101 |
CLCDBase *pObject_ = *it_;
|
|
|
102 |
LCDUIASSERT(NULL != pObject_);
|
|
|
103 |
delete pObject_;
|
|
|
104 |
|
|
|
105 |
++it_;
|
|
|
106 |
}
|
|
|
107 |
}
|
|
|
108 |
|
|
|
109 |
/****f* EZ.LCD.SDK.Wrapper/CEzLcdPage::AddText
|
|
|
110 |
* NAME
|
|
|
111 |
* HANDLE CEzLcdPage::AddText(LGObjectType type, LGTextSize size, INT alignment, INT maxLengthPixels) -- Add a text object to the LCD
|
|
|
112 |
* INPUTS
|
|
|
113 |
* type - specifies whether the text is static or
|
|
|
114 |
* scrolling. Possible types are: LG_SCROLLING_TEXT,
|
|
|
115 |
* LG_STATIC_TEXT
|
|
|
116 |
* size - size of the text. Choose between these three:
|
|
|
117 |
* LG_SMALL, LG_MEDIUM or LG_BIG.
|
|
|
118 |
* alignment - alignment of the text. Values are: DT_LEFT,
|
|
|
119 |
* DT_CENTER, DT_RIGHT.
|
|
|
120 |
* maxLengthPixels - max length in pixels of the text. If the text is
|
|
|
121 |
* longer and of type LG_STATIC_TEXT, it will be cut
|
|
|
122 |
* off. If the text is longer and of type
|
|
|
123 |
* LG_SCROLLING_TEXT, it will scroll.
|
|
|
124 |
* RETURN VALUE
|
|
|
125 |
* Handle for this object.
|
|
|
126 |
* SEE ALSO
|
|
|
127 |
* CEzLcdPage::AddIcon
|
|
|
128 |
* CEzLcdPage::AddProgressBar
|
|
|
129 |
******
|
|
|
130 |
*/
|
|
|
131 |
HANDLE CEzLcdPage::AddText(LGObjectType type, LGTextSize size, INT iAlignment, INT iMaxLengthPixels)
|
|
|
132 |
{
|
|
|
133 |
return AddText(type, size, iAlignment, iMaxLengthPixels, 1);
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
/****f* EZ.LCD.SDK.Wrapper/CEzLcdPage::AddText
|
|
|
137 |
* NAME
|
|
|
138 |
* HANDLE CEzLcdPage::AddText(LGObjectType type, LGTextSize size, INT alignment, INT maxLengthPixels, INT numberOfLines) -- Add a text object to the LCD
|
|
|
139 |
* INPUTS
|
|
|
140 |
* type - specifies whether the text is static or
|
|
|
141 |
* scrolling. Possible types are: LG_SCROLLING_TEXT,
|
|
|
142 |
* LG_STATIC_TEXT
|
|
|
143 |
* size - size of the text. Choose between these three:
|
|
|
144 |
* LG_SMALL, LG_MEDIUM or LG_BIG.
|
|
|
145 |
* alignment - alignment of the text. Values are: DT_LEFT,
|
|
|
146 |
* DT_CENTER, DT_RIGHT.
|
|
|
147 |
* maxLengthPixels - max length in pixels of the text. If the text is
|
|
|
148 |
* longer and of type LG_STATIC_TEXT, it will be cut
|
|
|
149 |
* off. If the text is longer and of type
|
|
|
150 |
* LG_SCROLLING_TEXT, it will scroll.
|
|
|
151 |
* numberOfLines - number of lines the text can use. For static text
|
|
|
152 |
* only. If number bigger than 1 and statoc text is too
|
|
|
153 |
* long to fit on LCD, the text will be displayed on
|
|
|
154 |
* multiple lines as necessary.
|
|
|
155 |
* RETURN VALUE
|
|
|
156 |
* Handle for this object.
|
|
|
157 |
* SEE ALSO
|
|
|
158 |
* CEzLcdPage::AddIcon
|
|
|
159 |
* CEzLcdPage::AddProgressBar
|
|
|
160 |
******
|
|
|
161 |
*/
|
|
|
162 |
HANDLE CEzLcdPage::AddText(LGObjectType type, LGTextSize size, INT iAlignment, INT iMaxLengthPixels, INT iNumberOfLines)
|
|
|
163 |
{
|
|
|
164 |
LCDUIASSERT(LG_SCROLLING_TEXT == type || LG_STATIC_TEXT == type || type == LG_SCROLLING_TEXT_FAST);
|
|
|
165 |
CLCDText* pStaticText_;
|
|
|
166 |
CLCDStreamingText* pStreamingText_;
|
|
|
167 |
|
|
|
168 |
INT iBoxHeight_ = LG_MEDIUM_FONT_TEXT_BOX_HEIGHT;
|
|
|
169 |
INT iFontSize_ = LG_MEDIUM_FONT_SIZE;
|
|
|
170 |
INT iLocalOriginY_ = LG_MEDIUM_FONT_LOGICAL_ORIGIN_Y;
|
|
|
171 |
|
|
|
172 |
switch (type)
|
|
|
173 |
{
|
|
|
174 |
case LG_SCROLLING_TEXT:
|
|
|
175 |
case LG_SCROLLING_TEXT_FAST:
|
|
|
176 |
pStreamingText_ = new CLCDStreamingText();
|
|
|
177 |
LCDUIASSERT(NULL != pStreamingText_);
|
|
|
178 |
pStreamingText_->Initialize();
|
|
|
179 |
pStreamingText_->SetOrigin(0, 0);
|
|
|
180 |
pStreamingText_->SetFontFaceName(LG_FONT);
|
|
|
181 |
pStreamingText_->SetAlignment(iAlignment);
|
|
|
182 |
pStreamingText_->SetText(_T(" "));
|
|
|
183 |
pStreamingText_->SetGapText(LG_SCROLLING_GAP_TEXT);
|
|
|
184 |
if ( type == LG_SCROLLING_TEXT_FAST )
|
|
|
185 |
pStreamingText_->SetSpeed(LG_SCROLLING_SPEED * 2);
|
|
|
186 |
else
|
|
|
187 |
pStreamingText_->SetSpeed(LG_SCROLLING_SPEED);
|
|
|
188 |
pStreamingText_->SetScrollingStep(LG_SCROLLING_STEP);
|
|
|
189 |
pStreamingText_->SetStartDelay(LG_SCROLLING_DELAY_MS);
|
|
|
190 |
|
|
|
191 |
if (LG_SMALL == size)
|
|
|
192 |
{
|
|
|
193 |
iBoxHeight_ = LG_SMALL_FONT_TEXT_BOX_HEIGHT;
|
|
|
194 |
iFontSize_ = LG_SMALL_FONT_SIZE;
|
|
|
195 |
iLocalOriginY_ = LG_SMALL_FONT_LOGICAL_ORIGIN_Y;
|
|
|
196 |
}
|
|
|
197 |
else if (LG_MEDIUM == size)
|
|
|
198 |
{
|
|
|
199 |
iBoxHeight_ = LG_MEDIUM_FONT_TEXT_BOX_HEIGHT;
|
|
|
200 |
iFontSize_ = LG_MEDIUM_FONT_SIZE;
|
|
|
201 |
iLocalOriginY_ = LG_MEDIUM_FONT_LOGICAL_ORIGIN_Y;
|
|
|
202 |
}
|
|
|
203 |
else if (LG_BIG == size)
|
|
|
204 |
{
|
|
|
205 |
pStreamingText_->SetFontWeight(FW_BOLD);
|
|
|
206 |
iBoxHeight_ = LG_BIG_FONT_TEXT_BOX_HEIGHT;
|
|
|
207 |
iFontSize_ = LG_BIG_FONT_SIZE;
|
|
|
208 |
iLocalOriginY_ = LG_BIG_FONT_LOGICAL_ORIGIN_Y;
|
|
|
209 |
}
|
|
|
210 |
|
|
|
211 |
pStreamingText_->SetSize(iMaxLengthPixels, iBoxHeight_);
|
|
|
212 |
pStreamingText_->SetFontPointSize(iFontSize_);
|
|
|
213 |
pStreamingText_->SetLogicalOrigin(0, iLocalOriginY_);
|
|
|
214 |
pStreamingText_->SetObjectType(LG_SCROLLING_TEXT);
|
|
|
215 |
|
|
|
216 |
AddObject(pStreamingText_);
|
|
|
217 |
|
|
|
218 |
return pStreamingText_;
|
|
|
219 |
break;
|
|
|
220 |
case LG_STATIC_TEXT:
|
|
|
221 |
pStaticText_ = new CLCDText();
|
|
|
222 |
LCDUIASSERT(NULL != pStaticText_);
|
|
|
223 |
pStaticText_->Initialize();
|
|
|
224 |
pStaticText_->SetOrigin(0, 0);
|
|
|
225 |
pStaticText_->SetFontFaceName(LG_FONT);
|
|
|
226 |
pStaticText_->SetAlignment(iAlignment);
|
|
|
227 |
pStaticText_->SetBackgroundMode(OPAQUE);
|
|
|
228 |
pStaticText_->SetText(_T(" "));
|
|
|
229 |
|
|
|
230 |
if (LG_SMALL == size)
|
|
|
231 |
{
|
|
|
232 |
iBoxHeight_ = iNumberOfLines * LG_SMALL_FONT_TEXT_BOX_HEIGHT;
|
|
|
233 |
iFontSize_ = LG_SMALL_FONT_SIZE;
|
|
|
234 |
iLocalOriginY_ = LG_SMALL_FONT_LOGICAL_ORIGIN_Y;
|
|
|
235 |
}
|
|
|
236 |
else if (LG_MEDIUM == size)
|
|
|
237 |
{
|
|
|
238 |
iBoxHeight_ = iNumberOfLines * LG_MEDIUM_FONT_TEXT_BOX_HEIGHT;
|
|
|
239 |
iFontSize_ = LG_MEDIUM_FONT_SIZE;
|
|
|
240 |
iLocalOriginY_ = LG_MEDIUM_FONT_LOGICAL_ORIGIN_Y;
|
|
|
241 |
}
|
|
|
242 |
else if (LG_BIG == size)
|
|
|
243 |
{
|
|
|
244 |
pStaticText_->SetFontWeight(FW_BOLD);
|
|
|
245 |
iBoxHeight_ = iNumberOfLines * LG_BIG_FONT_TEXT_BOX_HEIGHT;
|
|
|
246 |
iFontSize_ = LG_BIG_FONT_SIZE;
|
|
|
247 |
iLocalOriginY_ = LG_BIG_FONT_LOGICAL_ORIGIN_Y;
|
|
|
248 |
}
|
|
|
249 |
|
|
|
250 |
pStaticText_->SetSize(iMaxLengthPixels, iBoxHeight_);
|
|
|
251 |
pStaticText_->SetFontPointSize(iFontSize_);
|
|
|
252 |
pStaticText_->SetLogicalOrigin(0, iLocalOriginY_);
|
|
|
253 |
pStaticText_->SetObjectType(LG_STATIC_TEXT);
|
|
|
254 |
|
|
|
255 |
if (1 < iNumberOfLines)
|
|
|
256 |
pStaticText_->SetWordWrap(TRUE);
|
|
|
257 |
|
|
|
258 |
AddObject(pStaticText_);
|
|
|
259 |
|
|
|
260 |
return pStaticText_;
|
|
|
261 |
break;
|
|
|
262 |
default:
|
|
|
263 |
LCDUITRACE(_T("ERROR: trying to add text object with undefined type\n"));
|
|
|
264 |
}
|
|
|
265 |
|
|
|
266 |
return NULL;
|
|
|
267 |
}
|
|
|
268 |
|
|
|
269 |
/****f* EZ.LCD.SDK.Wrapper/CEzLcdPage::SetText
|
|
|
270 |
* NAME
|
|
|
271 |
* HRESULT CEzLcdPage::SetText -- Set text
|
|
|
272 |
* INPUTS
|
|
|
273 |
* hHandle - handle to the object.
|
|
|
274 |
* pText - text string.
|
|
|
275 |
* RETURN VALUE
|
|
|
276 |
* E_FAIL if there was an error.
|
|
|
277 |
* S_OK if no error.
|
|
|
278 |
******
|
|
|
279 |
*/
|
|
|
280 |
HRESULT CEzLcdPage::SetText(HANDLE hHandle, LPCTSTR pText)
|
|
|
281 |
{
|
|
|
282 |
CLCDBase* pMyObject_ = GetObject(hHandle);
|
|
|
283 |
|
|
|
284 |
if (NULL != pMyObject_)
|
|
|
285 |
{
|
|
|
286 |
LCDUIASSERT(LG_STATIC_TEXT == pMyObject_->GetObjectType() || LG_SCROLLING_TEXT == pMyObject_->GetObjectType() || LG_SCROLLING_TEXT_FAST == pMyObject_->GetObjectType());
|
|
|
287 |
if (LG_STATIC_TEXT == pMyObject_->GetObjectType())
|
|
|
288 |
{
|
|
|
289 |
CLCDText* pStaticText_ = static_cast<CLCDText*>(pMyObject_);
|
|
|
290 |
LCDUIASSERT(NULL != pStaticText_);
|
|
|
291 |
pStaticText_->SetText(pText);
|
|
|
292 |
return S_OK;
|
|
|
293 |
}
|
|
|
294 |
else if (LG_SCROLLING_TEXT == pMyObject_->GetObjectType() || LG_SCROLLING_TEXT_FAST == pMyObject_->GetObjectType())
|
|
|
295 |
{
|
|
|
296 |
CLCDStreamingText* pStreamingText_ = static_cast<CLCDStreamingText*>(pMyObject_);
|
|
|
297 |
LCDUIASSERT(NULL != pStreamingText_);
|
|
|
298 |
pStreamingText_->SetText(pText);
|
|
|
299 |
return S_OK;
|
|
|
300 |
}
|
|
|
301 |
}
|
|
|
302 |
|
|
|
303 |
return E_FAIL;
|
|
|
304 |
}
|
|
|
305 |
|
|
|
306 |
HRESULT CEzLcdPage::SetSpeed(HANDLE hHandle, DWORD speed)
|
|
|
307 |
{
|
|
|
308 |
CLCDBase* pMyObject_ = GetObject(hHandle);
|
|
|
309 |
|
|
|
310 |
if (NULL != pMyObject_)
|
|
|
311 |
{
|
|
|
312 |
LCDUIASSERT(LG_SCROLLING_TEXT == pMyObject_->GetObjectType() || LG_SCROLLING_TEXT_FAST == pMyObject_->GetObjectType());
|
|
|
313 |
if (LG_SCROLLING_TEXT == pMyObject_->GetObjectType() || LG_SCROLLING_TEXT_FAST == pMyObject_->GetObjectType())
|
|
|
314 |
{
|
|
|
315 |
CLCDStreamingText* pStreamingText_ = static_cast<CLCDStreamingText*>(pMyObject_);
|
|
|
316 |
LCDUIASSERT(NULL != pStreamingText_);
|
|
|
317 |
pStreamingText_->SetSpeed ( speed );
|
|
|
318 |
return S_OK;
|
|
|
319 |
}
|
|
|
320 |
}
|
|
|
321 |
|
|
|
322 |
return E_FAIL;
|
|
|
323 |
}
|
|
|
324 |
|
|
|
325 |
HRESULT CEzLcdPage::SetText(HANDLE hHandle, const std::string &pText)
|
|
|
326 |
{
|
|
|
327 |
CLCDBase* pMyObject_ = GetObject(hHandle);
|
|
|
328 |
|
|
|
329 |
if (NULL != pMyObject_)
|
|
|
330 |
{
|
|
|
331 |
LCDUIASSERT(LG_STATIC_TEXT == pMyObject_->GetObjectType() || LG_SCROLLING_TEXT == pMyObject_->GetObjectType() || LG_SCROLLING_TEXT == pMyObject_->GetObjectType());
|
|
|
332 |
if (LG_STATIC_TEXT == pMyObject_->GetObjectType())
|
|
|
333 |
{
|
|
|
334 |
CLCDText* pStaticText_ = static_cast<CLCDText*>(pMyObject_);
|
|
|
335 |
LCDUIASSERT(NULL != pStaticText_);
|
|
|
336 |
pStaticText_->SetText(pText);
|
|
|
337 |
return S_OK;
|
|
|
338 |
}
|
|
|
339 |
else if (LG_SCROLLING_TEXT == pMyObject_->GetObjectType() || LG_SCROLLING_TEXT_FAST == pMyObject_->GetObjectType())
|
|
|
340 |
{
|
|
|
341 |
CLCDStreamingText* pStreamingText_ = static_cast<CLCDStreamingText*>(pMyObject_);
|
|
|
342 |
LCDUIASSERT(NULL != pStreamingText_);
|
|
|
343 |
pStreamingText_->SetText(pText);
|
|
|
344 |
return S_OK;
|
|
|
345 |
}
|
|
|
346 |
}
|
|
|
347 |
|
|
|
348 |
return E_FAIL;
|
|
|
349 |
}
|
|
|
350 |
|
|
|
351 |
/****f* EZ.LCD.SDK.Wrapper/CEzLcdPage::AddIcon
|
|
|
352 |
* NAME
|
|
|
353 |
* HANDLE CEzLcdPage::AddIcon -- Add an icon object to the LCD
|
|
|
354 |
* INPUTS
|
|
|
355 |
* hIcon - icon to be displayed on the LCD. Should be 1 bpp
|
|
|
356 |
* bitmap.
|
|
|
357 |
* iWidth - x-axis size of the bitmap.
|
|
|
358 |
* iHeight - y-axis size of the bitmap.
|
|
|
359 |
* RETURN VALUE
|
|
|
360 |
* Handle for this object.
|
|
|
361 |
* SEE ALSO
|
|
|
362 |
* CEzLcdPage::AddText
|
|
|
363 |
* CEzLcdPage::AddProgressBar
|
|
|
364 |
******
|
|
|
365 |
*/
|
|
|
366 |
HANDLE CEzLcdPage::AddIcon(HICON hIcon, INT iWidth, INT iHeight)
|
|
|
367 |
{
|
|
|
368 |
CLCDIcon* hIcon_ = new CLCDIcon();
|
|
|
369 |
LCDUIASSERT(NULL != hIcon_);
|
|
|
370 |
hIcon_->Initialize();
|
|
|
371 |
hIcon_->SetOrigin(0, 0);
|
|
|
372 |
hIcon_->SetSize(iWidth, iHeight);
|
|
|
373 |
hIcon_->SetIcon(hIcon, iWidth, iHeight);
|
|
|
374 |
hIcon_->SetObjectType(LG_ICON);
|
|
|
375 |
|
|
|
376 |
AddObject(hIcon_);
|
|
|
377 |
|
|
|
378 |
return hIcon_;
|
|
|
379 |
}
|
|
|
380 |
|
|
|
381 |
/****f* EZ.LCD.SDK.Wrapper/CEzLcdPage::AddProgressBar
|
|
|
382 |
* NAME
|
|
|
383 |
* HANDLE CEzLcdPage::AddProgressBar -- Add a progress bar object to the LCD.
|
|
|
384 |
* INPUTS
|
|
|
385 |
* type - type of the progress bar. Types are: LG_CURSOR,
|
|
|
386 |
* LG_FILLED.
|
|
|
387 |
* RETURN VALUE
|
|
|
388 |
* Handle for this object.
|
|
|
389 |
* SEE ALSO
|
|
|
390 |
* CEzLcdPage::AddText
|
|
|
391 |
* CEzLcdPage::AddIcon
|
|
|
392 |
******
|
|
|
393 |
*/
|
|
|
394 |
HANDLE CEzLcdPage::AddProgressBar(LGProgressBarType type)
|
|
|
395 |
{
|
|
|
396 |
LCDUIASSERT(LG_FILLED == type || LG_CURSOR == type || LG_DOT_CURSOR == type);
|
|
|
397 |
CLCDProgressBar *pProgressBar_ = new CLCDProgressBar();
|
|
|
398 |
LCDUIASSERT(NULL != pProgressBar_);
|
|
|
399 |
pProgressBar_->Initialize();
|
|
|
400 |
pProgressBar_->SetOrigin(0, 0);
|
|
|
401 |
pProgressBar_->SetSize(m_iLcdWidth, LG_PROGRESS_BAR_INITIAL_HEIGHT);
|
|
|
402 |
pProgressBar_->SetRange(LG_PROGRESS_BAR_RANGE_MIN, LG_PROGRESS_BAR_RANGE_MAX );
|
|
|
403 |
pProgressBar_->SetPos(static_cast<FLOAT>(LG_PROGRESS_BAR_RANGE_MIN));
|
|
|
404 |
pProgressBar_->SetObjectType(LG_PROGRESS_BAR);
|
|
|
405 |
|
|
|
406 |
// Map the progress style into what the UI classes understand
|
|
|
407 |
CLCDProgressBar::ePROGRESS_STYLE eStyle = CLCDProgressBar::ePROGRESS_STYLE::STYLE_FILLED;
|
|
|
408 |
switch (type)
|
|
|
409 |
{
|
|
|
410 |
case LG_FILLED:
|
|
|
411 |
eStyle = CLCDProgressBar::ePROGRESS_STYLE::STYLE_FILLED;
|
|
|
412 |
break;
|
|
|
413 |
case LG_CURSOR:
|
|
|
414 |
eStyle = CLCDProgressBar::ePROGRESS_STYLE::STYLE_CURSOR;
|
|
|
415 |
break;
|
|
|
416 |
case LG_DOT_CURSOR:
|
|
|
417 |
eStyle = CLCDProgressBar::ePROGRESS_STYLE::STYLE_DASHED_CURSOR;
|
|
|
418 |
break;
|
|
|
419 |
}
|
|
|
420 |
|
|
|
421 |
pProgressBar_->SetProgressStyle(eStyle);
|
|
|
422 |
|
|
|
423 |
AddObject(pProgressBar_);
|
|
|
424 |
|
|
|
425 |
return pProgressBar_;
|
|
|
426 |
}
|
|
|
427 |
|
|
|
428 |
/****f* EZ.LCD.SDK.Wrapper/CEzLcdPage::SetProgressBarPosition
|
|
|
429 |
* NAME
|
|
|
430 |
* HRESULT CEzLcdPage::SetProgressBarPosition -- Set position of the
|
|
|
431 |
* progress bar's cursor
|
|
|
432 |
* INPUTS
|
|
|
433 |
* hHandle - handle to the object.
|
|
|
434 |
* fPercentage - percentage of progress (0 to 100).
|
|
|
435 |
* RETURN VALUE
|
|
|
436 |
* E_FAIL if there was an error or if handle does not correspond to a
|
|
|
437 |
* progress bar.
|
|
|
438 |
* S_OK if no error.
|
|
|
439 |
******
|
|
|
440 |
*/
|
|
|
441 |
HRESULT CEzLcdPage::SetProgressBarPosition(HANDLE hHandle, FLOAT fPercentage)
|
|
|
442 |
{
|
|
|
443 |
CLCDBase* pMyObject_ = GetObject(hHandle);
|
|
|
444 |
|
|
|
445 |
if (NULL != pMyObject_)
|
|
|
446 |
{
|
|
|
447 |
LCDUIASSERT(LG_PROGRESS_BAR == pMyObject_->GetObjectType());
|
|
|
448 |
// only allow this function for progress bars
|
|
|
449 |
if (LG_PROGRESS_BAR == pMyObject_->GetObjectType())
|
|
|
450 |
{
|
|
|
451 |
CLCDProgressBar *progressBar_ = static_cast<CLCDProgressBar*>(pMyObject_);
|
|
|
452 |
LCDUIASSERT(NULL != progressBar_);
|
|
|
453 |
progressBar_->SetPos(fPercentage);
|
|
|
454 |
return S_OK;
|
|
|
455 |
}
|
|
|
456 |
}
|
|
|
457 |
|
|
|
458 |
return E_FAIL;
|
|
|
459 |
}
|
|
|
460 |
|
|
|
461 |
/****f* EZ.LCD.SDK.Wrapper/CEzLcdPage::SetProgressBarSize
|
|
|
462 |
* NAME
|
|
|
463 |
* HRESULT CEzLcdPage::SetProgressBarSize -- Set size of progress bar
|
|
|
464 |
* INPUTS
|
|
|
465 |
* hHandle - handle to the object.
|
|
|
466 |
* iWidth - x-axis part of the size
|
|
|
467 |
* iHeight - y-axis part of the size (a good default value is 5).
|
|
|
468 |
* RETURN VALUE
|
|
|
469 |
* E_FAIL if there was an error or if handle does not correspond to a
|
|
|
470 |
* progress bar.
|
|
|
471 |
* S_OK if no error.
|
|
|
472 |
******
|
|
|
473 |
*/
|
|
|
474 |
HRESULT CEzLcdPage::SetProgressBarSize(HANDLE hHandle, INT iWidth, INT iHeight)
|
|
|
475 |
{
|
|
|
476 |
CLCDBase* ppMyObject_ = GetObject(hHandle);
|
|
|
477 |
LCDUIASSERT(NULL != ppMyObject_);
|
|
|
478 |
|
|
|
479 |
if (NULL != ppMyObject_)
|
|
|
480 |
{
|
|
|
481 |
LCDUIASSERT(LG_PROGRESS_BAR == ppMyObject_->GetObjectType());
|
|
|
482 |
// only allow this function for progress bars
|
|
|
483 |
if (LG_PROGRESS_BAR == ppMyObject_->GetObjectType())
|
|
|
484 |
{
|
|
|
485 |
ppMyObject_->SetSize(iWidth, iHeight);
|
|
|
486 |
return S_OK;
|
|
|
487 |
}
|
|
|
488 |
}
|
|
|
489 |
|
|
|
490 |
return E_FAIL;
|
|
|
491 |
}
|
|
|
492 |
|
|
|
493 |
/****f* EZ.LCD.SDK.Wrapper/CEzLcdPage::AddBitmap
|
|
|
494 |
* NAME
|
|
|
495 |
* HANDLE CEzLcdPage::AddBitmap() -- Add a bitmap object to the LCD.
|
|
|
496 |
* COMMENTS
|
|
|
497 |
* A bitmap's size currently must always be 160x43 pixels.
|
|
|
498 |
* RETURN VALUE
|
|
|
499 |
* Handle for this object.
|
|
|
500 |
* SEE ALSO
|
|
|
501 |
* CEzLcdPage::AddText
|
|
|
502 |
* CEzLcdPage::AddIcon
|
|
|
503 |
******
|
|
|
504 |
*/
|
|
|
505 |
HANDLE CEzLcdPage::AddBitmap(void)
|
|
|
506 |
{
|
|
|
507 |
CLCDBitmap *hBitmap_ = new CLCDBitmap();
|
|
|
508 |
LCDUIASSERT(NULL != hBitmap_);
|
|
|
509 |
hBitmap_->Initialize();
|
|
|
510 |
hBitmap_->SetOrigin(0, 0);
|
|
|
511 |
|
|
|
512 |
AddObject(hBitmap_);
|
|
|
513 |
|
|
|
514 |
return hBitmap_;
|
|
|
515 |
}
|
|
|
516 |
|
|
|
517 |
/****f* EZ.LCD.SDK.Wrapper/CEzLcdPage::SetBitmap
|
|
|
518 |
* NAME
|
|
|
519 |
* HRESULT CEzLcdPage::SetBitmap(HANDLE handle, HBITMAP bitmap) -- Set the bitmap.
|
|
|
520 |
* INPUTS
|
|
|
521 |
* handle - handle to the object.
|
|
|
522 |
* bitmap - 160x43 1bpp bitmap.
|
|
|
523 |
* RETURN VALUE
|
|
|
524 |
* E_FAIL if there was an error or if handle does not correspond to a
|
|
|
525 |
* bitmap.
|
|
|
526 |
* S_OK if no error.
|
|
|
527 |
******
|
|
|
528 |
*/
|
|
|
529 |
HRESULT CEzLcdPage::SetBitmap(HANDLE hHandle, HBITMAP hBitmap)
|
|
|
530 |
{
|
|
|
531 |
if (NULL == hBitmap)
|
|
|
532 |
return E_FAIL;
|
|
|
533 |
|
|
|
534 |
CLCDBase* pMyObject_ = GetObject(hHandle);
|
|
|
535 |
|
|
|
536 |
if (NULL != pMyObject_)
|
|
|
537 |
{
|
|
|
538 |
CLCDBitmap* hBitmap_ = static_cast<CLCDBitmap*>(pMyObject_);
|
|
|
539 |
LCDUIASSERT(hBitmap_);
|
|
|
540 |
hBitmap_->SetBitmap(hBitmap);
|
|
|
541 |
return S_OK;
|
|
|
542 |
}
|
|
|
543 |
|
|
|
544 |
return S_OK;
|
|
|
545 |
}
|
|
|
546 |
|
|
|
547 |
/****f* EZ.LCD.SDK.Wrapper/CEzLcdPage::SetOrigin
|
|
|
548 |
* NAME
|
|
|
549 |
* HRESULT CEzLcdPage::SetOrigin -- Set the origin of an object. The
|
|
|
550 |
* origin corresponds to the furthest pixel on the
|
|
|
551 |
* upper left corner of an object.
|
|
|
552 |
* INPUTS
|
|
|
553 |
* hHandle - handle to the object.
|
|
|
554 |
* iOriginX - x-axis part of the origin.
|
|
|
555 |
* iOriginY - y-axis part of the origin.
|
|
|
556 |
* RETURN VALUE
|
|
|
557 |
* E_FAIL if there was an error.
|
|
|
558 |
* S_OK if no error.
|
|
|
559 |
******
|
|
|
560 |
*/
|
|
|
561 |
HRESULT CEzLcdPage::SetOrigin(HANDLE hHandle, INT iOriginX, INT iOriginY)
|
|
|
562 |
{
|
|
|
563 |
CLCDBase* pMyObject_ = GetObject(hHandle);
|
|
|
564 |
LCDUIASSERT(NULL != pMyObject_);
|
|
|
565 |
LCDUIASSERT(NULL != pMyObject_);
|
|
|
566 |
|
|
|
567 |
if (NULL != pMyObject_ && NULL != pMyObject_)
|
|
|
568 |
{
|
|
|
569 |
pMyObject_->SetOrigin(iOriginX, iOriginY);
|
|
|
570 |
return S_OK;
|
|
|
571 |
}
|
|
|
572 |
|
|
|
573 |
return E_FAIL;
|
|
|
574 |
}
|
|
|
575 |
|
|
|
576 |
/****f* EZ.LCD.SDK.Wrapper/CEzLcdPage::SetVisible
|
|
|
577 |
* NAME
|
|
|
578 |
* HRESULT CEzLcdPage::SetVisible -- set corresponding object to be
|
|
|
579 |
* visible or invisible.
|
|
|
580 |
* INPUTS
|
|
|
581 |
* hHandle - handle to the object.
|
|
|
582 |
* bVisible - set to FALSE to make object invisible, TRUE to
|
|
|
583 |
* make it visible (default).
|
|
|
584 |
* RETURN VALUE
|
|
|
585 |
* E_FAIL if there was an error.
|
|
|
586 |
* S_OK if no error.
|
|
|
587 |
******
|
|
|
588 |
*/
|
|
|
589 |
HRESULT CEzLcdPage::SetVisible(HANDLE hHandle, BOOL bVisible)
|
|
|
590 |
{
|
|
|
591 |
CLCDBase* pMyObject_ = GetObject(hHandle);
|
|
|
592 |
LCDUIASSERT(NULL != pMyObject_);
|
|
|
593 |
LCDUIASSERT(NULL != pMyObject_);
|
|
|
594 |
|
|
|
595 |
if (NULL != pMyObject_ && NULL != pMyObject_)
|
|
|
596 |
{
|
|
|
597 |
pMyObject_->Show(bVisible);
|
|
|
598 |
return S_OK;
|
|
|
599 |
}
|
|
|
600 |
|
|
|
601 |
return E_FAIL;
|
|
|
602 |
}
|
|
|
603 |
|
|
|
604 |
/****f* EZ.LCD.SDK.Wrapper/CEzLcdPage::Update
|
|
|
605 |
* NAME
|
|
|
606 |
* VOID CEzLcdPage::Update -- Update LCD display
|
|
|
607 |
* FUNCTION
|
|
|
608 |
* Updates the display. Must be called every loop.
|
|
|
609 |
******
|
|
|
610 |
*/
|
|
|
611 |
VOID CEzLcdPage::Update()
|
|
|
612 |
{
|
|
|
613 |
// Save copy of button state
|
|
|
614 |
for (INT ii = 0; ii < NUMBER_SOFT_BUTTONS; ii++)
|
|
|
615 |
{
|
|
|
616 |
m_bButtonWasPressed[ii] = m_bButtonIsPressed[ii];
|
|
|
617 |
}
|
|
|
618 |
}
|
|
|
619 |
|
|
|
620 |
CLCDBase* CEzLcdPage::GetObject(HANDLE hHandle)
|
|
|
621 |
{
|
|
|
622 |
LCD_OBJECT_LIST::iterator it_ = m_Objects.begin();
|
|
|
623 |
while(it_ != m_Objects.end())
|
|
|
624 |
{
|
|
|
625 |
CLCDBase *pObject_ = *it_;
|
|
|
626 |
LCDUIASSERT(NULL != pObject_);
|
|
|
627 |
|
|
|
628 |
if (pObject_ == hHandle)
|
|
|
629 |
{
|
|
|
630 |
return pObject_;
|
|
|
631 |
}
|
|
|
632 |
++it_;
|
|
|
633 |
}
|
|
|
634 |
|
|
|
635 |
return NULL;
|
|
|
636 |
}
|
|
|
637 |
|
|
|
638 |
VOID CEzLcdPage::Init(INT iWidth, INT iHeight)
|
|
|
639 |
{
|
|
|
640 |
m_iLcdWidth = iWidth;
|
|
|
641 |
m_iLcdHeight = iHeight;
|
|
|
642 |
|
|
|
643 |
for (INT ii = 0; ii < NUMBER_SOFT_BUTTONS; ii++)
|
|
|
644 |
{
|
|
|
645 |
m_bButtonIsPressed[ii] = FALSE;
|
|
|
646 |
m_bButtonWasPressed[ii] = FALSE;
|
|
|
647 |
}
|
|
|
648 |
}
|
|
|
649 |
|
|
|
650 |
void CEzLcdPage::OnLCDButtonDown(int iButton)
|
|
|
651 |
{
|
|
|
652 |
switch(iButton)
|
|
|
653 |
{
|
|
|
654 |
case LGLCDBUTTON_BUTTON0:
|
|
|
655 |
m_bButtonIsPressed[LG_BUTTON_1] = TRUE;
|
|
|
656 |
break;
|
|
|
657 |
case LGLCDBUTTON_BUTTON1:
|
|
|
658 |
m_bButtonIsPressed[LG_BUTTON_2] = TRUE;
|
|
|
659 |
break;
|
|
|
660 |
case LGLCDBUTTON_BUTTON2:
|
|
|
661 |
m_bButtonIsPressed[LG_BUTTON_3] = TRUE;
|
|
|
662 |
break;
|
|
|
663 |
case LGLCDBUTTON_BUTTON3:
|
|
|
664 |
m_bButtonIsPressed[LG_BUTTON_4] = TRUE;
|
|
|
665 |
break;
|
|
|
666 |
default:
|
|
|
667 |
LCDUITRACE(_T("ERROR: unknown button was pressed\n"));
|
|
|
668 |
break;
|
|
|
669 |
}
|
|
|
670 |
|
|
|
671 |
m_pContainer->OnLCDButtonDown(iButton);
|
|
|
672 |
}
|
|
|
673 |
|
|
|
674 |
void CEzLcdPage::OnLCDButtonUp(int iButton)
|
|
|
675 |
{
|
|
|
676 |
switch(iButton)
|
|
|
677 |
{
|
|
|
678 |
case LGLCDBUTTON_BUTTON0:
|
|
|
679 |
m_bButtonIsPressed[LG_BUTTON_1] = FALSE;
|
|
|
680 |
break;
|
|
|
681 |
case LGLCDBUTTON_BUTTON1:
|
|
|
682 |
m_bButtonIsPressed[LG_BUTTON_2] = FALSE;
|
|
|
683 |
break;
|
|
|
684 |
case LGLCDBUTTON_BUTTON2:
|
|
|
685 |
m_bButtonIsPressed[LG_BUTTON_3] = FALSE;
|
|
|
686 |
break;
|
|
|
687 |
case LGLCDBUTTON_BUTTON3:
|
|
|
688 |
m_bButtonIsPressed[LG_BUTTON_4] = FALSE;
|
|
|
689 |
break;
|
|
|
690 |
default:
|
|
|
691 |
LCDUITRACE(_T("ERROR: unknown button was pressed\n"));
|
|
|
692 |
break;
|
|
|
693 |
}
|
|
|
694 |
|
|
|
695 |
m_pContainer->OnLCDButtonUp(iButton);
|
|
|
696 |
}
|