26
|
1 |
/*
|
|
2 |
* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Implementation of screensaver moving text display class.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifdef USE_DATE_AND_TEXT
|
|
19 |
|
|
20 |
#include <e32def.h>
|
|
21 |
#include <eikdef.h>
|
|
22 |
#include <AknUtils.h>
|
|
23 |
#include <e32math.h>
|
|
24 |
#include <aknlayoutscalable_avkon.cdl.h>
|
|
25 |
#include <screensaver.rsg>
|
|
26 |
|
|
27 |
#include "screensaverappui.h"
|
|
28 |
#include "screensavershareddatai.h"
|
|
29 |
#include "ScreensaverUtils.h"
|
|
30 |
#include "screensaverutility.h"
|
|
31 |
#include "screensaverctrlmovingtext.h"
|
|
32 |
|
|
33 |
const TInt KInvertedColors = 1;
|
|
34 |
|
|
35 |
//The color for text and background
|
|
36 |
const TInt KInvertedBgColor = 215;
|
|
37 |
const TInt KInvertedTextColor = 0;
|
|
38 |
const TInt KInvertedTextBgColor = 215;
|
|
39 |
|
|
40 |
const TInt KBgColor = 0;
|
|
41 |
const TInt KTextColor = 215;
|
|
42 |
const TInt KTextBgColor = 210;
|
|
43 |
|
|
44 |
// the minimum top value
|
|
45 |
const TInt KMinTop = 4;
|
|
46 |
|
|
47 |
const TInt KRefreshRate = 60000000; // 60 sec
|
|
48 |
//
|
|
49 |
// Class CScreensaverCtrlMovingText
|
|
50 |
//
|
|
51 |
// -----------------------------------------------------------------------------
|
|
52 |
// CScreensaverCtrlMovingText::NewL
|
|
53 |
// -----------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
CScreensaverCtrlMovingText* CScreensaverCtrlMovingText::NewL( TDisplayObjectType aType )
|
|
56 |
{
|
|
57 |
CScreensaverCtrlMovingText* obj = new( ELeave ) CScreensaverCtrlMovingText( aType );
|
|
58 |
CleanupStack::PushL( obj );
|
|
59 |
obj->ConstructL();
|
|
60 |
CleanupStack::Pop();
|
|
61 |
return obj;
|
|
62 |
}
|
|
63 |
|
|
64 |
// -----------------------------------------------------------------------------
|
|
65 |
// CScreensaverCtrlMovingText::~CScreensaverCtrlMovingText
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
//
|
|
68 |
CScreensaverCtrlMovingText::~CScreensaverCtrlMovingText()
|
|
69 |
{
|
|
70 |
iEikonEnv->RemoveFromStack( this );
|
|
71 |
|
|
72 |
DeleteTimer( iBarRefreshTimer );
|
|
73 |
DeleteTimer( iCaptureScreenTimer );
|
|
74 |
}
|
|
75 |
|
|
76 |
// -----------------------------------------------------------------------------
|
|
77 |
// CScreensaverCtrlMovingText::HandleResourceChange
|
|
78 |
// -----------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
void CScreensaverCtrlMovingText::HandleResourceChange( TInt aType )
|
|
81 |
{
|
|
82 |
if ( aType == KEikDynamicLayoutVariantSwitch )//&& iType != EDisplayNone)
|
|
83 |
{
|
|
84 |
// Screen layout has changed - resize
|
|
85 |
SetRect( iCoeEnv->ScreenDevice()->SizeInPixels() );
|
|
86 |
}
|
|
87 |
}
|
|
88 |
|
|
89 |
// -----------------------------------------------------------------------------
|
|
90 |
// CScreensaverCtrlMovingText::SizeChanged
|
|
91 |
// -----------------------------------------------------------------------------
|
|
92 |
//
|
|
93 |
void CScreensaverCtrlMovingText::SizeChanged()
|
|
94 |
{
|
|
95 |
GenerateDisplayAttributesForScreensaverBar();
|
|
96 |
}
|
|
97 |
|
|
98 |
// -----------------------------------------------------------------------------
|
|
99 |
// CScreensaverCtrlMovingText::Draw
|
|
100 |
// -----------------------------------------------------------------------------
|
|
101 |
//
|
|
102 |
void CScreensaverCtrlMovingText::Draw( const TRect& aRect ) const
|
|
103 |
{
|
|
104 |
if ( !Model().ScreenSaverIsOn() && !Model().ScreenSaverIsPreviewing() )
|
|
105 |
{
|
|
106 |
return;
|
|
107 |
}
|
|
108 |
|
|
109 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::Draw, screensaver is on or previewing") );
|
|
110 |
// Graphics context to draw on.
|
|
111 |
CWindowGc& gc = SystemGc();
|
|
112 |
|
|
113 |
// Fix for error ESMG-74Y4PE - S60 3.2 wk26, Power Saver:
|
|
114 |
// Flickering when power saver is deactivated.
|
|
115 |
// We now clear the screen with a black brush so the screensaver
|
|
116 |
// background is changed to black. There will no longer be a white
|
|
117 |
// intermediate screen and this will reduce the "flicker" effect.
|
|
118 |
gc.SetBrushColor( KRgbBlack );
|
|
119 |
|
|
120 |
// Start with a clear screen
|
|
121 |
gc.Clear( aRect );
|
|
122 |
// If there is no plugin module, indicator view overrides plugin module or
|
|
123 |
// plugin drawing is suspended then the standard screensaver bar is shown,
|
|
124 |
// let's draw it.
|
|
125 |
|
|
126 |
DrawNew( gc, aRect );
|
|
127 |
|
|
128 |
// Activate power save display mode after draw, so that
|
|
129 |
// the image is already in screen buffer
|
|
130 |
ScreensaverUtility::FlushDrawBuffer();
|
|
131 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::Draw, draw finished") );
|
|
132 |
}
|
|
133 |
|
|
134 |
// -----------------------------------------------------------------------------
|
|
135 |
// CScreensaverCtrlMovingText::SetMoving
|
|
136 |
// -----------------------------------------------------------------------------
|
|
137 |
//
|
|
138 |
void CScreensaverCtrlMovingText::SetMoving( TBool aMove )
|
|
139 |
{
|
|
140 |
iMoveBar = aMove;
|
|
141 |
}
|
|
142 |
|
|
143 |
// -----------------------------------------------------------------------------
|
|
144 |
// CScreensaverCtrlMovingText::StartTimer
|
|
145 |
// -----------------------------------------------------------------------------
|
|
146 |
//
|
|
147 |
void CScreensaverCtrlMovingText::StartTimer()
|
|
148 |
{
|
|
149 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::StartTimer start") );
|
|
150 |
Model().SharedDataInterface()->SetSSForcedLightsOn( ESSForceLightsOn );
|
|
151 |
|
|
152 |
StartCaptureScreenTimer();
|
|
153 |
|
|
154 |
StartBarRefreshTimer();
|
|
155 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::StartTimer finish") );
|
|
156 |
}
|
|
157 |
|
|
158 |
// -----------------------------------------------------------------------------
|
|
159 |
// CScreensaverCtrlMovingText::CancelTimer
|
|
160 |
// -----------------------------------------------------------------------------
|
|
161 |
//
|
|
162 |
void CScreensaverCtrlMovingText::CancelTimer()
|
|
163 |
{
|
|
164 |
DeleteTimer( iBarRefreshTimer );
|
|
165 |
DeleteTimer( iCaptureScreenTimer );
|
|
166 |
}
|
|
167 |
|
|
168 |
// -----------------------------------------------------------------------------
|
|
169 |
// CScreensaverCtrlMovingText::ClearScreen
|
|
170 |
// Date & time saver
|
|
171 |
// -----------------------------------------------------------------------------
|
|
172 |
//
|
|
173 |
void CScreensaverCtrlMovingText::ClearScreen()
|
|
174 |
{
|
|
175 |
|
|
176 |
}
|
|
177 |
|
|
178 |
// -----------------------------------------------------------------------------
|
|
179 |
// CScreensaverCtrlMovingText::Refresh
|
|
180 |
// -----------------------------------------------------------------------------
|
|
181 |
//
|
|
182 |
void CScreensaverCtrlMovingText::Refresh()
|
|
183 |
{
|
|
184 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::Refresh start") );
|
|
185 |
// Currently only keylock indicator is updated, because
|
|
186 |
// thats the only indicator whose state may change while screensaver
|
|
187 |
// is displaying. Other indicators' state changing also dismisses
|
|
188 |
// screensaver. Once redisplaying, the indicators are updated anyway.
|
|
189 |
// Key lock indicator depends on status of key guard.
|
|
190 |
TIndicatorPayload payload;
|
|
191 |
payload.iType = EPayloadTypeInteger;
|
|
192 |
|
|
193 |
Array().SetDependencyStatus( ESsKeyLockInd, !Model().SharedDataInterface()->IsKeyguardOn() );
|
|
194 |
payload.iInteger = Model().SharedDataInterface()->UnreadMessagesNumber();
|
|
195 |
Array().SetIndicatorPayload( ESsNewMessagesInd, payload );
|
|
196 |
Array().SetDependencyStatus( ESsNewMessagesInd, ( payload.iInteger <= 0 ) );
|
|
197 |
Array().SetDependencyStatus( ESsVoicemailInd, !Model().SharedDataInterface()->IsHaveNewVoicemail() );
|
|
198 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::Refresh move") );
|
|
199 |
// Don't move bar during this refresh
|
|
200 |
SetMoving( EFalse );
|
|
201 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::Refresh DrawObject") );
|
|
202 |
// Cause a redraw
|
|
203 |
DrawObject();
|
|
204 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::Refresh move") );
|
|
205 |
// Allow moving
|
|
206 |
SetMoving();
|
|
207 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::Refresh finish") );
|
|
208 |
}
|
|
209 |
|
|
210 |
// -----------------------------------------------------------------------------
|
|
211 |
// CScreensaverCtrlMovingText::CScreensaverCtrlMovingText
|
|
212 |
// Date & time saver
|
|
213 |
// -----------------------------------------------------------------------------
|
|
214 |
//
|
|
215 |
CScreensaverCtrlMovingText::CScreensaverCtrlMovingText( TDisplayObjectType aType )
|
|
216 |
:iType( aType )
|
|
217 |
{
|
|
218 |
// No implementation required
|
|
219 |
}
|
|
220 |
|
|
221 |
// -----------------------------------------------------------------------------
|
|
222 |
// CScreensaverCtrlMovingText::ConstructL
|
|
223 |
// -----------------------------------------------------------------------------
|
|
224 |
//
|
|
225 |
void CScreensaverCtrlMovingText::ConstructL()
|
|
226 |
{
|
|
227 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::ConstructL start") );
|
|
228 |
|
|
229 |
if ( iType == EDisplayText )
|
|
230 |
{
|
|
231 |
iPictoI = CAknPictographInterface::NewL( *this, *this );
|
|
232 |
}
|
|
233 |
|
|
234 |
iTop = KMinTop;
|
|
235 |
iRandSeed = RandomSeed();
|
|
236 |
iMoveBar = ETrue;
|
|
237 |
|
|
238 |
GetTextAndBgColor();
|
|
239 |
|
|
240 |
CreateWindowL();
|
|
241 |
|
|
242 |
// Cannot do this earlier - it'll cause a SizeChanged()
|
|
243 |
SetRect( iCoeEnv->ScreenDevice()->SizeInPixels() );
|
|
244 |
|
|
245 |
iEikonEnv->EikAppUi()->AddToStackL(
|
|
246 |
this, ECoeStackPriorityEnvironmentFilter, ECoeStackFlagRefusesFocus );
|
|
247 |
ConstructAndConnectLCDL();
|
|
248 |
ActivateL();
|
|
249 |
}
|
|
250 |
|
|
251 |
// -----------------------------------------------------------------------------
|
|
252 |
// CScreensaverCtrlMovingText::DrawNew
|
|
253 |
// -----------------------------------------------------------------------------
|
|
254 |
//
|
|
255 |
void CScreensaverCtrlMovingText::DrawNew( CWindowGc& aGc, const TRect& /* aRect */) const
|
|
256 |
{
|
|
257 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::DrawNew start") );
|
|
258 |
// Draw bar background
|
|
259 |
iLayoutBar.DrawRect( aGc );
|
|
260 |
|
|
261 |
// Draw clock
|
|
262 |
iLayoutClock.DrawRect( aGc );
|
|
263 |
iLayoutClockText.DrawText( aGc, iTextTime );
|
|
264 |
|
|
265 |
// Draw date / user text
|
|
266 |
iLayoutDate.DrawRect( aGc );
|
|
267 |
|
|
268 |
DrawText( aGc );
|
|
269 |
|
|
270 |
// Draw indicators
|
|
271 |
Array().Draw( aGc );
|
|
272 |
}
|
|
273 |
|
|
274 |
// -----------------------------------------------------------------------------
|
|
275 |
// CScreensaverCtrlMovingText::DrawPictoText
|
|
276 |
// Draws text with pictographs
|
|
277 |
// -----------------------------------------------------------------------------
|
|
278 |
//
|
|
279 |
void CScreensaverCtrlMovingText::DrawPictoText( CWindowGc &aGc ) const
|
|
280 |
{
|
|
281 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::DrawPictoText start") );
|
|
282 |
// Draw text and possible pictographs
|
|
283 |
MAknPictographDrawer* pictoDrawer = iPictoI->Interface();
|
|
284 |
ASSERT( pictoDrawer );
|
|
285 |
|
|
286 |
if ( ( !pictoDrawer ) || ( !pictoDrawer->ContainsPictographs( iText ) ) )
|
|
287 |
{
|
|
288 |
// Just draw normally
|
|
289 |
iLayoutDateText.DrawText( aGc, iText );
|
|
290 |
return;
|
|
291 |
}
|
|
292 |
|
|
293 |
// Else draw normal text with pictographs
|
|
294 |
aGc.UseFont( iLayoutDateText.Font() );
|
|
295 |
aGc.SetPenColor( iLayoutDateText.Color() );
|
|
296 |
|
|
297 |
// Calculating the offset (unfortunately not public in TAknLayoutText)
|
|
298 |
// copied from AknUtils TAknLayoutText::LayoutText()
|
|
299 |
pictoDrawer->DrawText( aGc, *iLayoutDateText.Font(), iText,
|
|
300 |
iLayoutDateText.TextRect(), iLayoutDateText.Font()->AscentInPixels(),
|
|
301 |
iLayoutDateText.Align() );
|
|
302 |
}
|
|
303 |
|
|
304 |
// -----------------------------------------------------------------------------
|
|
305 |
// CScreensaverCtrlMovingText::DrawText
|
|
306 |
// -----------------------------------------------------------------------------
|
|
307 |
//
|
|
308 |
void CScreensaverCtrlMovingText::DrawText( CWindowGc& aGc ) const
|
|
309 |
{
|
|
310 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::DrawText start") );
|
|
311 |
if ( iPictoI )
|
|
312 |
{
|
|
313 |
// Draw text and pictographs in the layout
|
|
314 |
DrawPictoText( aGc );
|
|
315 |
}
|
|
316 |
else
|
|
317 |
{
|
|
318 |
// Draw just text
|
|
319 |
iLayoutDateText.DrawText( aGc, iText );
|
|
320 |
}
|
|
321 |
}
|
|
322 |
|
|
323 |
// -----------------------------------------------------------------------------
|
|
324 |
// CScreensaverCtrlMovingText::UpdateCurrentTimeL
|
|
325 |
// -----------------------------------------------------------------------------
|
|
326 |
//
|
|
327 |
void CScreensaverCtrlMovingText::UpdateCurrentTimeL()
|
|
328 |
{
|
|
329 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::UpdateCurrentTimeL start") );
|
|
330 |
// AVKON does not have proper format string for just time,
|
|
331 |
// load from own resources
|
|
332 |
FormatTextFromResourceL( iTextTime, R_SCREENSAVER_TIME_USUAL_WITHOUT_AMPM );
|
|
333 |
|
|
334 |
if ( iType == EDisplayTime )
|
|
335 |
{
|
|
336 |
FormatTextFromResourceL( iText, R_QTN_DATE_USUAL_WITH_ZERO );
|
|
337 |
}
|
|
338 |
else
|
|
339 |
{
|
|
340 |
Model().SharedDataInterface()->GetDisplayObjectText( iText );
|
|
341 |
}
|
|
342 |
|
|
343 |
SetAmPmIndicatorPayloadL();
|
|
344 |
// Convert numbers according to language
|
|
345 |
}
|
|
346 |
|
|
347 |
// -----------------------------------------------------------------------------
|
|
348 |
// CScreensaverCtrlMovingText::GenerateDisplayAttributesForScreensaverBar
|
|
349 |
// -----------------------------------------------------------------------------
|
|
350 |
//
|
|
351 |
void CScreensaverCtrlMovingText::GenerateDisplayAttributesForScreensaverBar( )
|
|
352 |
{
|
|
353 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::GenerateDisplayAttributesForScreensaverBar start") );
|
|
354 |
// Zero out power save area, it should then be set before power save
|
|
355 |
// mode can be activated (also by plugins)
|
|
356 |
iPowerSaveDisplayActiveArea.SetRect( 0, 0, 0, 0 );
|
|
357 |
|
|
358 |
// Cool! We got scalable layouts. Use them.
|
|
359 |
TAknWindowComponentLayout barLayoutComponent =
|
|
360 |
AknLayoutScalable_Avkon::power_save_pane();
|
|
361 |
iLayoutBar.LayoutRect( Rect(), barLayoutComponent.LayoutLine() );
|
|
362 |
|
|
363 |
// Add bar height from layout to get total bar height
|
|
364 |
TInt barHeight = iLayoutBar.Rect().Height();
|
|
365 |
|
|
366 |
// Plain refresh, no move?
|
|
367 |
if ( iMoveBar )
|
|
368 |
{
|
|
369 |
// Get random values for bar position and color.
|
|
370 |
GetRandomTopValue( iLayoutBar.Rect().Height() );
|
|
371 |
}
|
|
372 |
|
|
373 |
// Create a rect with the new top to be used as layout rect
|
|
374 |
TRect fakeScreen( Rect() );
|
|
375 |
fakeScreen.iTl.iY = iTop;
|
|
376 |
|
|
377 |
// Layout components
|
|
378 |
|
|
379 |
// Bar itself
|
|
380 |
iLayoutBar.LayoutRect( fakeScreen, barLayoutComponent.LayoutLine() );
|
|
381 |
TRect barRect = iLayoutBar.Rect();
|
|
382 |
|
|
383 |
// Clock (area + text)
|
|
384 |
GetClockLayout( barRect );
|
|
385 |
|
|
386 |
// Date (area + text)
|
|
387 |
GetDateLayout( barRect );
|
|
388 |
|
|
389 |
// Indicators (area + text)
|
|
390 |
GetIndicatorAreaLayout( barRect );
|
|
391 |
|
|
392 |
// Update current time
|
|
393 |
TRAP_IGNORE( UpdateCurrentTimeL() );
|
|
394 |
|
|
395 |
// Since it is known for sure at this point that screensaver
|
|
396 |
// bar will be drawn the partial mode can activated for bar area
|
|
397 |
// if it is supported by display hardware.
|
|
398 |
const TScreensaverColorModel& colorModel = Model().GetColorModel();
|
|
399 |
|
|
400 |
if ( colorModel.iNumberOfPartialModes > 0 )
|
|
401 |
{
|
|
402 |
TRect psRect( iLayoutBar.Rect() );
|
|
403 |
SetPowerSaveDisplayActiveArea( psRect );
|
|
404 |
}
|
|
405 |
}
|
|
406 |
|
|
407 |
// -----------------------------------------------------------------------------
|
|
408 |
// CScreensaverCtrlMovingText::GetRandomTopValue
|
|
409 |
// -----------------------------------------------------------------------------
|
|
410 |
//
|
|
411 |
void CScreensaverCtrlMovingText::GetRandomTopValue( TInt aBarHight )
|
|
412 |
{
|
|
413 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::GetRandomTopValue start") );
|
|
414 |
TInt range( iCoeEnv->ScreenDevice()->SizeInPixels().iHeight - aBarHight - 1 - 4 );
|
|
415 |
TInt rand = Math::Rand( iRandSeed );
|
|
416 |
rand %= range;
|
|
417 |
iTop = ( rand > 3 ) ? ( rand/4 ) * 4 : 4;
|
|
418 |
}
|
|
419 |
|
|
420 |
// -----------------------------------------------------------------------------
|
|
421 |
// CScreensaverCtrlMovingText::RandomValue
|
|
422 |
// -----------------------------------------------------------------------------
|
|
423 |
//
|
|
424 |
TInt CScreensaverCtrlMovingText::RandomSeed()
|
|
425 |
{
|
|
426 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::RandomSeed start") );
|
|
427 |
TTime time;
|
|
428 |
time.HomeTime();
|
|
429 |
return time.DateTime().MicroSecond();
|
|
430 |
}
|
|
431 |
|
|
432 |
// -----------------------------------------------------------------------------
|
|
433 |
// CScreensaverCtrlMovingText::GetTextAndBgColor
|
|
434 |
// -----------------------------------------------------------------------------
|
|
435 |
//
|
|
436 |
void CScreensaverCtrlMovingText::GetTextAndBgColor()
|
|
437 |
{
|
|
438 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::GetTextAndBgColor start") );
|
|
439 |
if( Model().SharedDataInterface()->IsInvertedColors() == KInvertedColors )
|
|
440 |
{
|
|
441 |
iBgColor = KInvertedBgColor;
|
|
442 |
iTextColor = KInvertedTextColor;
|
|
443 |
iTextBgColor = KInvertedTextBgColor;
|
|
444 |
}
|
|
445 |
else
|
|
446 |
{
|
|
447 |
iBgColor = KBgColor;
|
|
448 |
iTextColor = KTextColor;
|
|
449 |
iTextBgColor = KTextBgColor;
|
|
450 |
}
|
|
451 |
}
|
|
452 |
|
|
453 |
// -----------------------------------------------------------------------------
|
|
454 |
// CScreensaverCtrlMovingText::FormatTextL
|
|
455 |
// -----------------------------------------------------------------------------
|
|
456 |
//
|
|
457 |
void CScreensaverCtrlMovingText::FormatTextL( TDes& aText, const TDesC& aFormat )
|
|
458 |
{
|
|
459 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::FormatTextL start") );
|
|
460 |
TTime curTime;
|
|
461 |
curTime.HomeTime();
|
|
462 |
// Since screensaver is updated on the minute, make sure it displays
|
|
463 |
// the time of the passing minute by adding a few seconds to the
|
|
464 |
// time at the moment of the update.
|
|
465 |
curTime += TTimeIntervalSeconds( 5 );
|
|
466 |
|
|
467 |
TRAPD( err, curTime.FormatL( aText, aFormat ) );
|
|
468 |
if ( err != KErrNone )
|
|
469 |
{
|
|
470 |
// If time can't be displayed then display an empty text
|
|
471 |
aText = KNullDesC;
|
|
472 |
}
|
|
473 |
}
|
|
474 |
|
|
475 |
// -----------------------------------------------------------------------------
|
|
476 |
// CScreensaverCtrlMovingText::SetAmPmIndicatorPayload
|
|
477 |
// -----------------------------------------------------------------------------
|
|
478 |
//
|
|
479 |
void CScreensaverCtrlMovingText::SetAmPmIndicatorPayloadL()
|
|
480 |
{
|
|
481 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::SetAmPmIndicatorPayloadL start") );
|
|
482 |
_LIT(KAmPmFormat, "%*A");
|
|
483 |
TBuf<10> textAmPm;
|
|
484 |
FormatTextL( textAmPm, KAmPmFormat );
|
|
485 |
|
|
486 |
TIndicatorPayload payload;
|
|
487 |
payload.iType = EPayloadTypeText;
|
|
488 |
payload.iText.Zero();
|
|
489 |
payload.iText.Append( textAmPm );
|
|
490 |
Array().SetIndicatorPayload( ESsAmPmInd, payload );
|
|
491 |
}
|
|
492 |
|
|
493 |
// -----------------------------------------------------------------------------
|
|
494 |
// CScreensaverCtrlMovingText::FormatTextFromResourceL
|
|
495 |
// -----------------------------------------------------------------------------
|
|
496 |
//
|
|
497 |
void CScreensaverCtrlMovingText::FormatTextFromResourceL( TDes &aText, TInt aResourceId )
|
|
498 |
{
|
|
499 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::FormatTextFromResourceL start") );
|
|
500 |
TBuf<30> timeFormat;
|
|
501 |
iCoeEnv->ReadResourceL( timeFormat, aResourceId );
|
|
502 |
FormatTextL( aText, timeFormat );
|
|
503 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion( aText );
|
|
504 |
}
|
|
505 |
|
|
506 |
// -----------------------------------------------------------------------------
|
|
507 |
// CScreensaverCtrlMovingText::GetClockLayout
|
|
508 |
// -----------------------------------------------------------------------------
|
|
509 |
//
|
|
510 |
void CScreensaverCtrlMovingText::GetClockLayout( const TRect& aRect )
|
|
511 |
{
|
|
512 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::GetClockLayout start") );
|
|
513 |
TAknWindowComponentLayout clockarea =
|
|
514 |
AknLayoutScalable_Avkon::aid_ps_clock_pane( 0 );
|
|
515 |
TAknWindowLineLayout clockline = clockarea.LayoutLine();
|
|
516 |
clockline.iC = iBgColor;
|
|
517 |
iLayoutClock.LayoutRect( aRect, clockarea.LayoutLine() );
|
|
518 |
|
|
519 |
TAknTextComponentLayout clocktext =
|
|
520 |
AknLayoutScalable_Avkon::power_save_t2( 0 );
|
|
521 |
clocktext.SetC( iTextColor );
|
|
522 |
iLayoutClockText.LayoutText( aRect, clocktext.LayoutLine() );
|
|
523 |
}
|
|
524 |
|
|
525 |
// -----------------------------------------------------------------------------
|
|
526 |
// CScreensaverCtrlMovingText::GetClockLayout
|
|
527 |
// -----------------------------------------------------------------------------
|
|
528 |
//
|
|
529 |
void CScreensaverCtrlMovingText::GetDateLayout( const TRect& aRect )
|
|
530 |
{
|
|
531 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::GetDateLayout start") );
|
|
532 |
TAknWindowComponentLayout datearea =
|
|
533 |
AknLayoutScalable_Avkon::power_save_pane_g1( 0 );
|
|
534 |
TAknWindowLineLayout dateline = datearea.LayoutLine();
|
|
535 |
dateline.iC = iTextBgColor;
|
|
536 |
iLayoutDate.LayoutRect( aRect, dateline );
|
|
537 |
|
|
538 |
TAknTextComponentLayout datetext =
|
|
539 |
AknLayoutScalable_Avkon::power_save_pane_t1( 0 );
|
|
540 |
TAknTextLineLayout datetextline = datetext.LayoutLine();
|
|
541 |
iLayoutDateText.LayoutText( aRect, datetextline );
|
|
542 |
}
|
|
543 |
|
|
544 |
// -----------------------------------------------------------------------------
|
|
545 |
// CScreensaverCtrlMovingText::GetClockLayout
|
|
546 |
// -----------------------------------------------------------------------------
|
|
547 |
//
|
|
548 |
void CScreensaverCtrlMovingText::GetIndicatorAreaLayout( const TRect& aRect )
|
|
549 |
{
|
|
550 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::GetIndicatorAreaLayout start") );
|
|
551 |
TAknWindowComponentLayout indicatorarea =
|
|
552 |
AknLayoutScalable_Avkon::aid_ps_indicator_pane( 0 );
|
|
553 |
TAknWindowLineLayout indicatorline = indicatorarea.LayoutLine();
|
|
554 |
indicatorline.iC = iBgColor;
|
|
555 |
TAknLayoutRect layoutIndicatorArea;
|
|
556 |
layoutIndicatorArea.LayoutRect( aRect, indicatorline );
|
|
557 |
|
|
558 |
// Indicator texts
|
|
559 |
TAknTextComponentLayout indtext =
|
|
560 |
AknLayoutScalable_Avkon::power_save_pane_t4( 0 );
|
|
561 |
TAknTextLineLayout indline = indtext.LayoutLine();
|
|
562 |
TAknLayoutText layoutIndicatorText;
|
|
563 |
layoutIndicatorText.LayoutText( aRect, indline );
|
|
564 |
|
|
565 |
// Indicator icons
|
|
566 |
TAknWindowComponentLayout inds =
|
|
567 |
AknLayoutScalable_Avkon::indicator_ps_pane( 0 );
|
|
568 |
TAknWindowLineLayout indsline = inds.LayoutLine();
|
|
569 |
TAknLayoutRect layoutInds;
|
|
570 |
layoutInds.LayoutRect( aRect, indsline );
|
|
571 |
|
|
572 |
// Tell indicator array where to draw (this should be moved to
|
|
573 |
// the array itself)
|
|
574 |
Array().Setup( layoutIndicatorArea, layoutIndicatorText, layoutInds );
|
|
575 |
}
|
|
576 |
|
|
577 |
// -----------------------------------------------------------------------------
|
|
578 |
// CScreensaverCtrlMovingText::StartBarRefreshTimer
|
|
579 |
// -----------------------------------------------------------------------------
|
|
580 |
//
|
|
581 |
void CScreensaverCtrlMovingText::StartBarRefreshTimer()
|
|
582 |
{
|
|
583 |
SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlMovingText::StartBarRefreshTimer start") );
|
|
584 |
DeleteTimer( iBarRefreshTimer );
|
|
585 |
|
|
586 |
TRAP_IGNORE( iBarRefreshTimer = CPeriodic::NewL( CActive::EPriorityStandard ) );
|
|
587 |
|
|
588 |
TInt initialRefreshRate = InitialRefreshRate();
|
|
589 |
|
|
590 |
iBarRefreshTimer->Start( initialRefreshRate, KRefreshRate, TCallBack(
|
|
591 |
HandleRefreshTimerExpiry, this ) );
|
|
592 |
|
|
593 |
SCRLOGGER_WRITEF( _L("SCR: BarRefreshTimer->Start(%d, %d, HandleRefreshTimerExpiry)"),
|
|
594 |
initialRefreshRate, KRefreshRate );
|
|
595 |
}
|
|
596 |
|
|
597 |
#endif //USE_DATE_AND_TEXT
|
|
598 |
// End of file.
|