20
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2010 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: BatteryPopupControl implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <AknUtils.h>
|
|
20 |
#include <AknPanic.h>
|
|
21 |
#include <AknPreviewPopUpController.h>
|
|
22 |
#include <aknglobalpopupprioritycontroller.h>
|
|
23 |
#include <barsread.h> // TResourceReader
|
|
24 |
#include <eiklabel.h>
|
|
25 |
#include <fbs.h>
|
|
26 |
#include <aknappui.h>
|
|
27 |
#include <aknlayoutscalable_avkon.cdl.h>
|
|
28 |
#include <AknsDrawUtils.h>
|
|
29 |
#include <AknBidiTextUtils.h>
|
|
30 |
#include <data_caging_path_literals.hrh> // KDC_RESOURCE_FILES_DIR
|
|
31 |
#include <batterypopupcontrol.mbg>
|
|
32 |
// ----------- Touch feedback additions start
|
|
33 |
#ifdef RD_TACTILE_FEEDBACK
|
|
34 |
#include <touchfeedback.h>
|
|
35 |
#endif //RD_TACTILE_FEEDBACK
|
|
36 |
// ----------- Touch feedback additions end
|
|
37 |
#include <gulicon.h>
|
|
38 |
#include "batterypopupcontrol.h"
|
|
39 |
#include "trace.h"
|
|
40 |
|
|
41 |
// Constants
|
|
42 |
const TInt KPopupShowDelay = 0; // Show immediately
|
|
43 |
const TInt KPopupHideDelay = 3000000; // hide after 3 sec
|
|
44 |
const TInt KMaxLinkTextLength = 255;
|
|
45 |
|
|
46 |
// ======== MEMBER FUNCTIONS ========
|
|
47 |
|
|
48 |
// -----------------------------------------------------------------------------
|
|
49 |
// Default constructor.
|
|
50 |
// -----------------------------------------------------------------------------
|
|
51 |
//
|
|
52 |
CBatteryPopupControl::CBatteryPopupControl():
|
|
53 |
iHighlightedItem( EFalse )
|
|
54 |
{
|
|
55 |
FUNC_LOG
|
|
56 |
}
|
|
57 |
|
|
58 |
// -----------------------------------------------------------------------------
|
|
59 |
// CBatteryPopupControl::NewL
|
|
60 |
// -----------------------------------------------------------------------------
|
|
61 |
//
|
|
62 |
EXPORT_C CBatteryPopupControl* CBatteryPopupControl::NewL(
|
|
63 |
const TDesC& aContentText,
|
|
64 |
const TDesC& aLinkText )
|
|
65 |
{
|
|
66 |
FUNC_LOG
|
|
67 |
CBatteryPopupControl* self =
|
|
68 |
new ( ELeave ) CBatteryPopupControl();
|
|
69 |
|
|
70 |
CleanupStack::PushL( self );
|
|
71 |
self->ConstructL( aContentText, aLinkText );
|
|
72 |
CleanupStack::Pop( self );
|
|
73 |
return self;
|
|
74 |
}
|
|
75 |
|
|
76 |
// -----------------------------------------------------------------------------
|
|
77 |
// Destructor
|
|
78 |
// -----------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
EXPORT_C CBatteryPopupControl::~CBatteryPopupControl()
|
|
81 |
{
|
|
82 |
FUNC_LOG
|
|
83 |
delete iController;
|
|
84 |
delete iText;
|
|
85 |
delete iIcon;
|
|
86 |
delete iLinkText;
|
|
87 |
}
|
|
88 |
|
|
89 |
// -----------------------------------------------------------------------------
|
|
90 |
// CBatteryPopupControl::SetCommandObserver
|
|
91 |
// -----------------------------------------------------------------------------
|
|
92 |
//
|
|
93 |
EXPORT_C void CBatteryPopupControl::SetCommandObserver(
|
|
94 |
MEikCommandObserver& aCommandObserver )
|
|
95 |
{
|
|
96 |
FUNC_LOG
|
|
97 |
iCommandObserver = &aCommandObserver;
|
|
98 |
}
|
|
99 |
|
|
100 |
// -----------------------------------------------------------------------------
|
|
101 |
// CBatteryPopupControl::ShowPopUpL
|
|
102 |
// -----------------------------------------------------------------------------
|
|
103 |
//
|
|
104 |
EXPORT_C void CBatteryPopupControl::ShowPopUpL()
|
|
105 |
{
|
|
106 |
FUNC_LOG
|
|
107 |
|
|
108 |
iController = CAknPreviewPopUpController::NewL( *this, CAknPreviewPopUpController::ELayoutDefault | CAknPreviewPopUpController::EDontClose );
|
|
109 |
iController->AddObserverL( *this );
|
|
110 |
|
|
111 |
// Set popup's hide/show delays
|
|
112 |
iController->SetPopUpShowDelay( KPopupShowDelay );
|
|
113 |
iController->SetPopUpHideDelay( KPopupHideDelay );
|
|
114 |
|
|
115 |
// Position
|
|
116 |
TPoint uipRect;
|
|
117 |
if( AknLayoutUtils::LayoutMetricsPosition(
|
|
118 |
AknLayoutUtils::EBatteryPane, uipRect ) )
|
|
119 |
{
|
|
120 |
iController->SetPosition( uipRect );
|
|
121 |
}
|
|
122 |
|
|
123 |
// Launch
|
|
124 |
iController->ShowPopUp();
|
|
125 |
}
|
|
126 |
|
|
127 |
// -----------------------------------------------------------------------------
|
|
128 |
// From class CCoeControl.
|
|
129 |
// CBatteryPopupControl::HandleResourceChange
|
|
130 |
// -----------------------------------------------------------------------------
|
|
131 |
//
|
|
132 |
void CBatteryPopupControl::HandleResourceChange(
|
|
133 |
TInt aType )
|
|
134 |
{
|
|
135 |
FUNC_LOG
|
|
136 |
|
|
137 |
CCoeControl::HandleResourceChange( aType );
|
|
138 |
if ( aType == KEikDynamicLayoutVariantSwitch )
|
|
139 |
{
|
|
140 |
SizeChanged();
|
|
141 |
}
|
|
142 |
|
|
143 |
// Position
|
|
144 |
TPoint uipRect;
|
|
145 |
if( AknLayoutUtils::LayoutMetricsPosition( AknLayoutUtils::EBatteryPane, uipRect ) )
|
|
146 |
{
|
|
147 |
iController->SetPosition( uipRect );
|
|
148 |
}
|
|
149 |
}
|
|
150 |
|
|
151 |
|
|
152 |
// -----------------------------------------------------------------------------
|
|
153 |
// From class CCoeControl.
|
|
154 |
// CBatteryPopupControl::SetContainerWindowL
|
|
155 |
// -----------------------------------------------------------------------------
|
|
156 |
//
|
|
157 |
void CBatteryPopupControl::SetContainerWindowL(
|
|
158 |
const CCoeControl& aContainer )
|
|
159 |
{
|
|
160 |
FUNC_LOG
|
|
161 |
|
|
162 |
CCoeControl::SetContainerWindowL( aContainer );
|
|
163 |
|
|
164 |
if( iText )
|
|
165 |
{
|
|
166 |
iText->SetContainerWindowL( aContainer );
|
|
167 |
}
|
|
168 |
}
|
|
169 |
|
|
170 |
// -----------------------------------------------------------------------------
|
|
171 |
// From class MCoeControlObserver.
|
|
172 |
// CBatteryPopupControl::HandleControlEventL
|
|
173 |
// -----------------------------------------------------------------------------
|
|
174 |
//
|
|
175 |
void CBatteryPopupControl::HandleControlEventL(
|
|
176 |
CCoeControl* /*aControl*/,
|
|
177 |
TCoeEvent /*aEventType*/ )
|
|
178 |
{
|
|
179 |
FUNC_LOG
|
|
180 |
}
|
|
181 |
// ---------------------------------------------------------------------------
|
|
182 |
// From MAknPreviewPopUpObserver
|
|
183 |
// ---------------------------------------------------------------------------
|
|
184 |
//
|
|
185 |
void CBatteryPopupControl::HandlePreviewPopUpEventL(
|
|
186 |
CAknPreviewPopUpController* /*aController*/,
|
|
187 |
TPreviewPopUpEvent aEvent )
|
|
188 |
{
|
|
189 |
FUNC_LOG
|
|
190 |
|
|
191 |
switch ( aEvent )
|
|
192 |
{
|
|
193 |
case EPreviewPopUpShown:
|
|
194 |
AknGlobalPopupPriorityController::ShowPopup( *this, ETrue );
|
|
195 |
break;
|
|
196 |
case EPreviewPopUpHidden:
|
|
197 |
AknGlobalPopupPriorityController::RemovePopupPriority( *this );
|
|
198 |
break;
|
|
199 |
}
|
|
200 |
}
|
|
201 |
|
|
202 |
// -----------------------------------------------------------------------------
|
|
203 |
// CAknStylusActivatedPopUpContent::ConstructL
|
|
204 |
// -----------------------------------------------------------------------------
|
|
205 |
//
|
|
206 |
void CBatteryPopupControl::ConstructL( const TDesC& aContentText,
|
|
207 |
const TDesC& aLinkText )
|
|
208 |
{
|
|
209 |
FUNC_LOG
|
|
210 |
|
|
211 |
if( aContentText != KNullDesC )
|
|
212 |
{
|
|
213 |
iText = new ( ELeave ) CEikLabel;
|
|
214 |
iText->SetTextL( aContentText );
|
|
215 |
CreateIconL();
|
|
216 |
}
|
|
217 |
|
|
218 |
if( aLinkText != KNullDesC )
|
|
219 |
{
|
|
220 |
// Check if only link is displayed.
|
|
221 |
if( aContentText != KNullDesC )
|
|
222 |
{
|
|
223 |
iVariant = EVariantIconTextLink;
|
|
224 |
}
|
|
225 |
iLinkText = aLinkText.AllocL();
|
|
226 |
}
|
|
227 |
|
|
228 |
TRect rectPopUpWindow = PopUpWindowRectFromLayout(
|
|
229 |
AknLayoutScalable_Avkon::popup_battery_window( iVariant ) );
|
|
230 |
|
|
231 |
TAknWindowComponentLayout infoPaneLayout =
|
|
232 |
AknLayoutScalable_Avkon::bg_popup_sub_pane_cp25( iVariant );
|
|
233 |
|
|
234 |
TRect rectInfoPane = RectFromLayout( rectPopUpWindow, infoPaneLayout );
|
|
235 |
|
|
236 |
TAknTextComponentLayout textLayout =
|
|
237 |
AknLayoutScalable_Avkon::popup_battery_window_t1( iVariant );
|
|
238 |
TAknLayoutText textRect;
|
|
239 |
textRect.LayoutText( rectPopUpWindow, textLayout );
|
|
240 |
|
|
241 |
// Font for command links
|
|
242 |
iFont = textRect.Font();
|
|
243 |
}
|
|
244 |
|
|
245 |
// -----------------------------------------------------------------------------
|
|
246 |
// From class CCoeControl.
|
|
247 |
// CBatteryPopupControl::ComponentControl
|
|
248 |
// -----------------------------------------------------------------------------
|
|
249 |
//
|
|
250 |
CCoeControl* CBatteryPopupControl::ComponentControl(
|
|
251 |
TInt aIndex ) const
|
|
252 |
{
|
|
253 |
FUNC_LOG
|
|
254 |
switch ( aIndex )
|
|
255 |
{
|
|
256 |
case 0:
|
|
257 |
{
|
|
258 |
if( iText )
|
|
259 |
{
|
|
260 |
return iText;
|
|
261 |
}
|
|
262 |
}
|
|
263 |
default:
|
|
264 |
__ASSERT_ALWAYS( aIndex >= 0, User::Panic(
|
|
265 |
_L("CBatteryPopupControl::ComponentControl"), EAknPanicOutOfRange ) );
|
|
266 |
return NULL;
|
|
267 |
}
|
|
268 |
}
|
|
269 |
|
|
270 |
|
|
271 |
// -----------------------------------------------------------------------------
|
|
272 |
// From class CCoeControl.
|
|
273 |
// CBatteryPopupControl::CountComponentControls
|
|
274 |
// -----------------------------------------------------------------------------
|
|
275 |
//
|
|
276 |
TInt CBatteryPopupControl::CountComponentControls() const
|
|
277 |
{
|
|
278 |
FUNC_LOG
|
|
279 |
TInt count = 0;
|
|
280 |
|
|
281 |
if( iText )
|
|
282 |
{
|
|
283 |
count++;
|
|
284 |
}
|
|
285 |
|
|
286 |
return count;
|
|
287 |
}
|
|
288 |
|
|
289 |
|
|
290 |
// -----------------------------------------------------------------------------
|
|
291 |
// From class CCoeControl.
|
|
292 |
// CBatteryPopupControl::Draw
|
|
293 |
// -----------------------------------------------------------------------------
|
|
294 |
//
|
|
295 |
void CBatteryPopupControl::Draw( const TRect& /*aRect*/ ) const
|
|
296 |
{
|
|
297 |
FUNC_LOG
|
|
298 |
|
|
299 |
CWindowGc& gc = SystemGc();
|
|
300 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
|
|
301 |
|
|
302 |
if( iIcon )
|
|
303 |
{
|
|
304 |
TRgb color( KRgbWhite ); // Default never used
|
|
305 |
|
|
306 |
AknsUtils::GetCachedColor( skin, color,
|
|
307 |
KAknsIIDQsnIconColors, EAknsCIQsnIconColorsCG6 );
|
|
308 |
|
|
309 |
if (AknIconUtils::IsMifIcon(iIcon->Bitmap()))
|
|
310 |
{
|
|
311 |
AknIconUtils::SetIconColor( iIcon->Bitmap(), color );
|
|
312 |
}
|
|
313 |
|
|
314 |
AknIconUtils::SetSize( iIcon->Bitmap(), iBitmapLayout.Rect().Size() );
|
|
315 |
iBitmapLayout.DrawImage( gc, iIcon->Bitmap(), iIcon->Mask() );
|
|
316 |
|
|
317 |
gc.Reset();
|
|
318 |
}
|
|
319 |
|
|
320 |
gc.SetPenStyle( CGraphicsContext::ESolidPen );
|
|
321 |
const CFont* font = iFont;
|
|
322 |
if ( !font )
|
|
323 |
{
|
|
324 |
font = iCoeEnv->NormalFont();
|
|
325 |
}
|
|
326 |
gc.UseFont( font );
|
|
327 |
|
|
328 |
if(iText)
|
|
329 |
{
|
|
330 |
TRect rect( iLinkRect );
|
|
331 |
TRgb textContentColor;
|
|
332 |
TInt err = AknsUtils::GetCachedColor( skin, textContentColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 );
|
|
333 |
|
|
334 |
if (!err)
|
|
335 |
{
|
|
336 |
TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( *iText,
|
|
337 |
EColorLabelText, textContentColor ) );
|
|
338 |
}
|
|
339 |
|
|
340 |
gc.SetPenColor( textContentColor );
|
|
341 |
|
|
342 |
TInt textBaseLineOffset = 0;
|
|
343 |
textBaseLineOffset = (rect.Height() - font->FontMaxHeight())/2;
|
|
344 |
gc.DrawText( *(iText->Text()), rect, textBaseLineOffset, iAlign );
|
|
345 |
//gc.Reset();
|
|
346 |
|
|
347 |
}
|
|
348 |
|
|
349 |
TRgb textColor;
|
|
350 |
AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnHighlightColors,
|
|
351 |
EAknsCIQsnHighlightColorsCG3 );
|
|
352 |
|
|
353 |
gc.SetPenColor( textColor );
|
|
354 |
gc.SetUnderlineStyle( EUnderlineOn );
|
|
355 |
if(iLinkText)
|
|
356 |
{
|
|
357 |
TRect rect( iLinkRect );
|
|
358 |
if ( Background() )
|
|
359 |
{
|
|
360 |
Background()->Draw( gc, *this, rect );
|
|
361 |
}
|
|
362 |
|
|
363 |
// buffer for visually ordered text
|
|
364 |
HBufC* visualText = NULL;
|
|
365 |
TRAPD( err, visualText = HBufC::NewL( KMaxLinkTextLength +
|
|
366 |
KAknBidiExtraSpacePerLine ) );
|
|
367 |
if ( err != KErrNone )
|
|
368 |
{
|
|
369 |
return;
|
|
370 |
}
|
|
371 |
TPtr ptr = visualText->Des();
|
|
372 |
TInt clipWidth = rect.Width();
|
|
373 |
|
|
374 |
if ( iHighlightedItem )
|
|
375 |
{
|
|
376 |
TRgb highlightcolor = AKN_LAF_COLOR( 244 );
|
|
377 |
AknsUtils::GetCachedColor( skin, highlightcolor,
|
|
378 |
KAknsIIDQsnHighlightColors, EAknsCIQsnHighlightColorsCG1 );
|
|
379 |
|
|
380 |
gc.SetBrushColor( highlightcolor );
|
|
381 |
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
|
|
382 |
}
|
|
383 |
else
|
|
384 |
{
|
|
385 |
gc.SetBrushStyle( CGraphicsContext::ENullBrush );
|
|
386 |
}
|
|
387 |
|
|
388 |
// bidi processing - using AknBidiTextUtils.
|
|
389 |
AknBidiTextUtils::ConvertToVisualAndClip(
|
|
390 |
*(iLinkText),
|
|
391 |
ptr,
|
|
392 |
*font,
|
|
393 |
clipWidth,
|
|
394 |
clipWidth );
|
|
395 |
|
|
396 |
TInt baselineOffset = 0;
|
|
397 |
baselineOffset = font->AscentInPixels() +
|
|
398 |
( rect.Height() - font->AscentInPixels() ) / 2;
|
|
399 |
gc.DrawText( ptr, rect, baselineOffset,
|
|
400 |
iAlign );
|
|
401 |
delete visualText;
|
|
402 |
}
|
|
403 |
}
|
|
404 |
|
|
405 |
|
|
406 |
// -----------------------------------------------------------------------------
|
|
407 |
// From class CCoeControl.
|
|
408 |
// CBatteryPopupControl::MinimumSize
|
|
409 |
// -----------------------------------------------------------------------------
|
|
410 |
//
|
|
411 |
TSize CBatteryPopupControl::MinimumSize()
|
|
412 |
{
|
|
413 |
FUNC_LOG
|
|
414 |
TInt nbrOfInfoLines = 0;
|
|
415 |
TInt minWidth = 0;
|
|
416 |
|
|
417 |
if( iText )
|
|
418 |
{
|
|
419 |
nbrOfInfoLines = iText->NumberOfLines();
|
|
420 |
CEikLabel* textLabel;
|
|
421 |
for ( TInt i=0; i < nbrOfInfoLines; i++ )
|
|
422 |
{
|
|
423 |
textLabel = iText;
|
|
424 |
TPtrC ptrText = ( *textLabel->Text() );
|
|
425 |
minWidth = Max( textLabel->CalcMinimumSize( ptrText ).iWidth, minWidth );
|
|
426 |
}
|
|
427 |
}
|
|
428 |
if(iLinkText)
|
|
429 |
{
|
|
430 |
TInt tempWidth = iFont->TextWidthInPixels( *( iLinkText ) );
|
|
431 |
minWidth = Max( minWidth, tempWidth );
|
|
432 |
}
|
|
433 |
TInt rectWidth = 0;
|
|
434 |
|
|
435 |
TAknWindowComponentLayout infoPaneLayout =
|
|
436 |
AknLayoutScalable_Avkon::bg_popup_sub_pane_cp25( iVariant );
|
|
437 |
|
|
438 |
TRect rectPopUpWindow = PopUpWindowRectFromLayout(
|
|
439 |
AknLayoutScalable_Avkon::popup_battery_window( iVariant ) );
|
|
440 |
|
|
441 |
TRect rectInfoPane = RectFromLayout( rectPopUpWindow, infoPaneLayout );
|
|
442 |
|
|
443 |
rectWidth = Max( rectInfoPane.Width(), minWidth );
|
|
444 |
|
|
445 |
TInt rectHeight = rectInfoPane.Height();
|
|
446 |
|
|
447 |
return TSize( rectWidth, rectHeight );
|
|
448 |
}
|
|
449 |
|
|
450 |
|
|
451 |
// -----------------------------------------------------------------------------
|
|
452 |
// From class CCoeControl.
|
|
453 |
// CBatteryPopupControl::SizeChanged
|
|
454 |
// -----------------------------------------------------------------------------
|
|
455 |
//
|
|
456 |
void CBatteryPopupControl::SizeChanged()
|
|
457 |
{
|
|
458 |
FUNC_LOG
|
|
459 |
// Get popup window rect
|
|
460 |
TRect rectPopUpWindow = PopUpWindowRectFromLayout(
|
|
461 |
AknLayoutScalable_Avkon::bg_popup_sub_pane_cp25( iVariant ) );
|
|
462 |
|
|
463 |
// Get pane icon and text layouts
|
|
464 |
TAknWindowLineLayout paneIconLayout(
|
|
465 |
AknLayoutScalable_Avkon::popup_battery_window_g1(iVariant));
|
|
466 |
|
|
467 |
//Set icon and text rects
|
|
468 |
if( iIcon )
|
|
469 |
{
|
|
470 |
iBitmapLayout.LayoutRect( rectPopUpWindow, paneIconLayout );
|
|
471 |
}
|
|
472 |
|
|
473 |
if( iText )
|
|
474 |
{
|
|
475 |
TAknTextComponentLayout textLayout =
|
|
476 |
AknLayoutScalable_Avkon::popup_battery_window_t1( iVariant );
|
|
477 |
|
|
478 |
AknLayoutUtils::LayoutLabel(iText, rectPopUpWindow, textLayout);
|
|
479 |
|
|
480 |
}
|
|
481 |
|
|
482 |
// Set link text rect
|
|
483 |
if( iLinkText )
|
|
484 |
{
|
|
485 |
TAknLayoutText linkLayoutText;
|
|
486 |
// popup_battery_window_t2 doesn't have other variants as EVariantIconTextLink
|
|
487 |
linkLayoutText.LayoutText( rectPopUpWindow,
|
|
488 |
AknLayoutScalable_Avkon::popup_battery_window_t2( EVariantIconTextLink ) );
|
|
489 |
|
|
490 |
iAlign = linkLayoutText.Align();
|
|
491 |
|
|
492 |
iFont = linkLayoutText.Font();
|
|
493 |
|
|
494 |
TInt tempWidth = iFont->TextWidthInPixels( *(iLinkText) );
|
|
495 |
TRect tempRect;
|
|
496 |
|
|
497 |
if( iText )
|
|
498 |
{
|
|
499 |
tempRect = TRect( linkLayoutText.TextRect() );
|
|
500 |
}
|
|
501 |
else
|
|
502 |
{
|
|
503 |
TAknLayoutRect linkLayout;
|
|
504 |
|
|
505 |
linkLayout.LayoutRect( rectPopUpWindow, paneIconLayout );
|
|
506 |
|
|
507 |
tempRect = TRect( linkLayout.Rect() );
|
|
508 |
}
|
|
509 |
|
|
510 |
if( iAlign == CGraphicsContext::ERight )
|
|
511 |
{
|
|
512 |
tempRect.iTl.iX = tempWidth - tempRect.iBr.iX;
|
|
513 |
}
|
|
514 |
else
|
|
515 |
{
|
|
516 |
tempRect.SetWidth( tempWidth );
|
|
517 |
}
|
|
518 |
|
|
519 |
|
|
520 |
iLinkRect = tempRect;
|
|
521 |
}
|
|
522 |
}
|
|
523 |
|
|
524 |
// -----------------------------------------------------------------------------
|
|
525 |
// RectFromLayout
|
|
526 |
// -----------------------------------------------------------------------------
|
|
527 |
//
|
|
528 |
TRect CBatteryPopupControl::RectFromLayout( const TRect& aParent,
|
|
529 |
const TAknWindowComponentLayout& aComponentLayout ) const
|
|
530 |
{
|
|
531 |
TAknWindowLineLayout lineLayout = aComponentLayout.LayoutLine();
|
|
532 |
TAknLayoutRect layoutRect;
|
|
533 |
layoutRect.LayoutRect( aParent, lineLayout );
|
|
534 |
return layoutRect.Rect();
|
|
535 |
}
|
|
536 |
|
|
537 |
// -----------------------------------------------------------------------------
|
|
538 |
// PopUpWindowRectFromLayout
|
|
539 |
// -----------------------------------------------------------------------------
|
|
540 |
//
|
|
541 |
TRect CBatteryPopupControl::PopUpWindowRectFromLayout( const
|
|
542 |
TAknWindowComponentLayout& aComponentLayout ) const
|
|
543 |
{
|
|
544 |
FUNC_LOG
|
|
545 |
// get popup window width from the widest variety
|
|
546 |
TAknWindowLineLayout lineLayout = aComponentLayout.LayoutLine();
|
|
547 |
|
|
548 |
lineLayout.iW = AknLayoutScalable_Avkon::
|
|
549 |
popup_battery_window( iVariant ).LayoutLine().iW;
|
|
550 |
TAknLayoutRect layoutRect;
|
|
551 |
layoutRect.LayoutRect( iAvkonAppUi->ApplicationRect(), lineLayout );
|
|
552 |
|
|
553 |
return layoutRect.Rect();
|
|
554 |
}
|
|
555 |
|
|
556 |
// -----------------------------------------------------------------------------
|
|
557 |
// From class CCoeControl
|
|
558 |
// CBatteryPopupControl::HandlePointerEventL
|
|
559 |
// -----------------------------------------------------------------------------
|
|
560 |
//
|
|
561 |
void CBatteryPopupControl::HandlePointerEventL(
|
|
562 |
const TPointerEvent& aPointerEvent )
|
|
563 |
{
|
|
564 |
FUNC_LOG
|
|
565 |
if(iLinkText)
|
|
566 |
{
|
|
567 |
if ( iLinkRect.Contains( aPointerEvent.iPosition ) )
|
|
568 |
{
|
|
569 |
if ( !iHighlightedItem )
|
|
570 |
{
|
|
571 |
iHighlightedItem = ETrue;
|
|
572 |
DrawNow( iLinkRect );
|
|
573 |
}
|
|
574 |
#ifdef RD_TACTILE_FEEDBACK
|
|
575 |
if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
|
|
576 |
{
|
|
577 |
MTouchFeedback* feedback = MTouchFeedback::Instance();
|
|
578 |
|
|
579 |
if ( feedback )
|
|
580 |
{
|
|
581 |
feedback->InstantFeedback( ETouchFeedbackBasic );
|
|
582 |
}
|
|
583 |
}
|
|
584 |
#endif // RD_TACTILE_FEEDBACK
|
|
585 |
// Nofity command observer
|
|
586 |
if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
|
|
587 |
{
|
|
588 |
iCommandObserver->ProcessCommandL( ELinkFirst );
|
|
589 |
iHighlightedItem = EFalse;
|
|
590 |
}
|
|
591 |
}
|
|
592 |
else
|
|
593 |
{
|
|
594 |
if ( iHighlightedItem )
|
|
595 |
{
|
|
596 |
iHighlightedItem = EFalse;
|
|
597 |
DrawNow( iLinkRect );
|
|
598 |
}
|
|
599 |
}
|
|
600 |
}
|
|
601 |
}
|
|
602 |
// -----------------------------------------------------------------------------
|
|
603 |
// CBatteryPopupControl::CreateIconL()
|
|
604 |
//
|
|
605 |
//
|
|
606 |
// -----------------------------------------------------------------------------
|
|
607 |
//
|
|
608 |
void CBatteryPopupControl::CreateIconL( )
|
|
609 |
{
|
|
610 |
FUNC_LOG
|
|
611 |
|
|
612 |
TParse* fp = new( ELeave ) TParse();
|
|
613 |
CleanupStack::PushL( fp );
|
|
614 |
_LIT( KBIPPluginIconDirAndName, "z:\\resource\\apps\\batterypopupcontrol.mif");
|
|
615 |
fp->Set( KBIPPluginIconDirAndName, &KDC_BITMAP_DIR, NULL );
|
|
616 |
|
|
617 |
delete iIcon;
|
|
618 |
iIcon = NULL;
|
|
619 |
|
|
620 |
iIcon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(),
|
|
621 |
KAknsIIDQgnPropBatteryIcon,
|
|
622 |
fp->FullName(),
|
|
623 |
EMbmBatterypopupcontrolQgn_prop_battery_ps_deactivate,
|
|
624 |
EMbmBatterypopupcontrolQgn_prop_battery_ps_deactivate_mask );
|
|
625 |
|
|
626 |
CleanupStack::PopAndDestroy( fp );
|
|
627 |
}
|
|
628 |
// End of File
|