|
1 /* |
|
2 * Copyright (c) 2009 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: Discreet popup drawer |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <AknBidiTextUtils.h> |
|
19 #include "akndiscreetpopupcontrol.h" |
|
20 #include <AknIconUtils.h> |
|
21 #include <aknlayoutscalable_avkon.cdl.h> |
|
22 #include <AknsDrawUtils.h> |
|
23 #include <AknUtils.h> |
|
24 #include <gulicon.h> |
|
25 |
|
26 |
|
27 #include "akndiscreetpopupdrawer.h" |
|
28 |
|
29 const TInt KTextBufSize( 255 ); |
|
30 const TInt KMaxNumOfLines( 2 ); |
|
31 |
|
32 // Help structure for layout data |
|
33 class TPopupLayoutData |
|
34 { |
|
35 public: |
|
36 TUint16 iWindowVariety; |
|
37 TUint16 iIconVariety; |
|
38 TUint16 i1stRowVariety; |
|
39 TUint16 i2ndRowVariety; |
|
40 }; |
|
41 |
|
42 // Layout data indexes in layout data array |
|
43 const TInt KLayoutUnresolved( -1 ); |
|
44 const TInt KLayout2RowsIcon( 0 ); |
|
45 const TInt KLayout2Rows( 1 ); |
|
46 const TInt KLayout1RowIcon( 2 ); |
|
47 const TInt KLayout1Row( 3 ); |
|
48 const TInt KLayout2RowsWrappedIcon( 4 ); |
|
49 const TInt KLayout2RowsWrapped( 5 ); |
|
50 |
|
51 // Layout data array |
|
52 static const TPopupLayoutData KPopupLayoutData[] = |
|
53 { |
|
54 { 0, 0, 0, 0 }, |
|
55 { 0, 0, 1, 1 }, |
|
56 { 0, 1, 2, 0 }, |
|
57 { 0, 1, 3, 0 }, |
|
58 { 0, 4, 4, 4 }, |
|
59 { 0, 0, 5, 5 } |
|
60 }; |
|
61 |
|
62 // ======== MEMBER FUNCTIONS ======== |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CAknDiscreetPopupDrawer::NewL |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 CAknDiscreetPopupDrawer* CAknDiscreetPopupDrawer::NewL( |
|
69 CAknDiscreetPopupControl* aControl, |
|
70 const TDesC& aTitleText, |
|
71 const TDesC& aBodyText, |
|
72 CGulIcon* aIcon, |
|
73 const TAknsItemID& aSkinId, |
|
74 const TDesC& aBitmapFile, |
|
75 const TInt& aBitmapId, |
|
76 const TInt& aMaskId, |
|
77 const TBool& aAction ) |
|
78 { |
|
79 CAknDiscreetPopupDrawer* self = |
|
80 CAknDiscreetPopupDrawer::NewLC( aControl, |
|
81 aTitleText, |
|
82 aBodyText, |
|
83 aIcon, |
|
84 aSkinId, |
|
85 aBitmapFile, |
|
86 aBitmapId, |
|
87 aMaskId, |
|
88 aAction ); |
|
89 CleanupStack::Pop( self ); |
|
90 return self; |
|
91 } |
|
92 |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // CAknDiscreetPopupDrawer::NewLC |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 CAknDiscreetPopupDrawer* CAknDiscreetPopupDrawer::NewLC( |
|
99 CAknDiscreetPopupControl* aControl, |
|
100 const TDesC& aTitleText, |
|
101 const TDesC& aBodyText, |
|
102 CGulIcon* aIcon, |
|
103 const TAknsItemID& aSkinId, |
|
104 const TDesC& aBitmapFile, |
|
105 const TInt& aBitmapId, |
|
106 const TInt& aMaskId, |
|
107 const TBool& aAction ) |
|
108 { |
|
109 CAknDiscreetPopupDrawer* self |
|
110 = new ( ELeave ) CAknDiscreetPopupDrawer( aControl, aIcon, aAction ); |
|
111 CleanupStack::PushL( self ); |
|
112 self->ConstructL( aTitleText, |
|
113 aBodyText, |
|
114 aSkinId, |
|
115 aBitmapFile, |
|
116 aBitmapId, |
|
117 aMaskId ); |
|
118 return self; |
|
119 } |
|
120 |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // CAknDiscreetPopupDrawer::~CAknDiscreetPopupDrawer |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 CAknDiscreetPopupDrawer::~CAknDiscreetPopupDrawer() |
|
127 { |
|
128 delete iIcon; |
|
129 delete iBodyText; |
|
130 delete iTitleText; |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CAknDiscreetPopupDrawer::LayoutPopup |
|
135 // Sets popup and its components size and position. |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 TRect CAknDiscreetPopupDrawer::LayoutPopup() |
|
139 { |
|
140 ResolvePopupLayout(); |
|
141 |
|
142 TPopupLayoutData data( KPopupLayoutData[ iPopupLayoutType ] ); |
|
143 |
|
144 TRect popupRect; |
|
145 TRect popupBitmapRect; |
|
146 |
|
147 GetPopupRect( data.iWindowVariety, popupRect ); |
|
148 |
|
149 // Calculate sub rects according to popup bitmap rect |
|
150 popupBitmapRect = TRect( 0, 0, popupRect.Width(), popupRect.Height() ); |
|
151 |
|
152 // Possible icon rect |
|
153 if ( iPopupLayoutType == KLayout2RowsIcon |
|
154 || iPopupLayoutType == KLayout1RowIcon |
|
155 || iPopupLayoutType == KLayout2RowsWrappedIcon ) |
|
156 { |
|
157 iIconRect = RectFromLayout( popupBitmapRect, |
|
158 AknLayoutScalable_Avkon::popup_discreet_window_g1( |
|
159 data.iIconVariety ) ); |
|
160 if( iIcon && iIcon->Bitmap() ) |
|
161 { |
|
162 AknIconUtils::SetSize( iIcon->Bitmap(), iIconRect.Size() ); |
|
163 } |
|
164 if( iIcon && iIcon->Mask() ) |
|
165 { |
|
166 AknIconUtils::SetSize( iIcon->Mask(), iIconRect.Size() ); |
|
167 } |
|
168 } |
|
169 |
|
170 // Title text font |
|
171 TextDataFromLayout( |
|
172 iTitleTextData, |
|
173 popupBitmapRect, |
|
174 AknLayoutScalable_Avkon::popup_discreet_window_t1( |
|
175 data.i1stRowVariety ) ); |
|
176 |
|
177 // Two rows - no wrapping |
|
178 if ( iPopupLayoutType == KLayout2RowsIcon |
|
179 || iPopupLayoutType == KLayout2Rows ) |
|
180 { |
|
181 // Body text font |
|
182 TextDataFromLayout( |
|
183 iBodyTextData, |
|
184 popupBitmapRect, |
|
185 AknLayoutScalable_Avkon::popup_discreet_window_t2( |
|
186 data.i2ndRowVariety ) ); |
|
187 } |
|
188 // Two wrapped rows |
|
189 else if ( iPopupLayoutType == KLayout2RowsWrappedIcon |
|
190 || iPopupLayoutType == KLayout2RowsWrapped ) |
|
191 { |
|
192 // Body text |
|
193 TextDataFromLayout( |
|
194 iBodyTextData, |
|
195 popupBitmapRect, |
|
196 AknLayoutScalable_Avkon::popup_discreet_window_t3( |
|
197 data.i2ndRowVariety ) ); |
|
198 // Text should be wrapped if in two-row layout and no bodytext |
|
199 if ( iBodyText->Des() == KNullDesC ) |
|
200 { |
|
201 TRAP_IGNORE( WrapTitleTextL() ); |
|
202 } |
|
203 } |
|
204 |
|
205 return popupRect; |
|
206 } |
|
207 |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // CAknDiscreetPopupDrawer::Draw |
|
211 // Draws popup to given graphics context. |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 void CAknDiscreetPopupDrawer::Draw( CWindowGc& aGc, |
|
215 const TRect& aRect ) const |
|
216 { |
|
217 // draw background of the popup |
|
218 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
219 AknsDrawUtils::DrawFrame( skin, aGc, aRect, aRect, |
|
220 KAknsIIDQsnFrPopupPreview, KAknsIIDDefault ); |
|
221 |
|
222 // Draw the texts |
|
223 TRgb textColor( EikonEnv()->ControlColor( EColorControlText, *iControl ) ); |
|
224 |
|
225 if ( iAction ) |
|
226 { |
|
227 aGc.SetUnderlineStyle( EUnderlineOn ); |
|
228 AknsUtils::GetCachedColor( skin, |
|
229 textColor, |
|
230 KAknsIIDQsnHighlightColors, |
|
231 EAknsCIQsnHighlightColorsCG3 ); |
|
232 } |
|
233 else |
|
234 { |
|
235 AknsUtils::GetCachedColor( skin, |
|
236 textColor, |
|
237 KAknsIIDQsnTextColors, |
|
238 EAknsCIQsnTextColorsCG55 ); |
|
239 } |
|
240 aGc.SetPenColor( textColor ); |
|
241 DrawTexts( &aGc ); |
|
242 aGc.SetUnderlineStyle( EUnderlineOff ); |
|
243 |
|
244 // draw the icon |
|
245 if ( iIcon && iIcon->Bitmap() && iIcon->Mask() ) |
|
246 { |
|
247 aGc.BitBltMasked( iIconRect.iTl, |
|
248 iIcon->Bitmap(), |
|
249 iIcon->Bitmap()->SizeInPixels(), |
|
250 iIcon->Mask(), |
|
251 EFalse ); |
|
252 |
|
253 } |
|
254 else if( iIcon && iIcon->Bitmap() ) |
|
255 { |
|
256 aGc.BitBlt( iIconRect.iTl, iIcon->Bitmap() ); |
|
257 } |
|
258 } |
|
259 |
|
260 |
|
261 // --------------------------------------------------------------------------- |
|
262 // CAknDiscreetPopupDrawer::CAknDiscreetPopupDrawer |
|
263 // --------------------------------------------------------------------------- |
|
264 // |
|
265 CAknDiscreetPopupDrawer::CAknDiscreetPopupDrawer( |
|
266 CAknDiscreetPopupControl* aControl, |
|
267 CGulIcon* aIcon, |
|
268 const TBool& aAction ) |
|
269 : |
|
270 iControl( aControl ), |
|
271 iTitleText( NULL ), |
|
272 iBodyText( NULL ), |
|
273 iIcon( aIcon ), |
|
274 iPopupLayoutType( KLayoutUnresolved ), |
|
275 iAction( aAction ) |
|
276 { |
|
277 } |
|
278 |
|
279 |
|
280 // --------------------------------------------------------------------------- |
|
281 // CAknDiscreetPopupDrawer::ConstructL |
|
282 // --------------------------------------------------------------------------- |
|
283 // |
|
284 void CAknDiscreetPopupDrawer::ConstructL( const TDesC& aTitleText, |
|
285 const TDesC& aBodyText, |
|
286 const TAknsItemID& aSkinId, |
|
287 const TDesC& aBitmapFile, |
|
288 const TInt& aBitmapId, |
|
289 const TInt& aMaskId ) |
|
290 { |
|
291 // Body text to title text if title text is empty |
|
292 if ( aTitleText == KNullDesC && aBodyText != KNullDesC ) |
|
293 { |
|
294 iTitleText = aBodyText.AllocL(); |
|
295 } |
|
296 else |
|
297 { |
|
298 iTitleText = aTitleText.AllocL(); |
|
299 iBodyText = aBodyText.AllocL(); |
|
300 } |
|
301 |
|
302 if ( !iIcon ) |
|
303 { |
|
304 iIcon = CreatePopupIconL( aSkinId, |
|
305 aBitmapFile, |
|
306 aBitmapId, |
|
307 aMaskId ); |
|
308 } |
|
309 } |
|
310 |
|
311 |
|
312 // --------------------------------------------------------------------------- |
|
313 // CAknDiscreetPopupDrawer::DrawTexts |
|
314 // --------------------------------------------------------------------------- |
|
315 // |
|
316 void CAknDiscreetPopupDrawer::DrawTexts( CWindowGc* aGc ) const |
|
317 { |
|
318 aGc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
319 |
|
320 DrawBidiEnabledText( aGc, iTitleTextData, *iTitleText ); |
|
321 |
|
322 if ( iBodyTextData.iTextRect != TRect() ) |
|
323 { |
|
324 DrawBidiEnabledText( aGc, iBodyTextData, *iBodyText ); |
|
325 } |
|
326 } |
|
327 |
|
328 |
|
329 // --------------------------------------------------------------------------- |
|
330 // CAknDiscreetPopupDrawer::ResolvePopupLayout |
|
331 // Resolves popup layout type. |
|
332 // --------------------------------------------------------------------------- |
|
333 // |
|
334 void CAknDiscreetPopupDrawer::ResolvePopupLayout() |
|
335 { |
|
336 // Layout already resolved, do nothing |
|
337 if ( iPopupLayoutType != KLayoutUnresolved ) |
|
338 { |
|
339 return; |
|
340 } |
|
341 |
|
342 TBool withIcon( iIcon && iIcon->Bitmap() ); |
|
343 TBool twoRowsText( |
|
344 iTitleText->Des() != KNullDesC |
|
345 && iBodyText->Des() != KNullDesC ); |
|
346 |
|
347 // Two rows of text |
|
348 if ( twoRowsText ) |
|
349 { |
|
350 if ( withIcon ) |
|
351 { |
|
352 iPopupLayoutType = KLayout2RowsIcon; |
|
353 } |
|
354 else |
|
355 { |
|
356 iPopupLayoutType = KLayout2Rows; |
|
357 } |
|
358 } |
|
359 // One row of text |
|
360 else |
|
361 { |
|
362 if ( withIcon ) |
|
363 { |
|
364 iPopupLayoutType = KLayout1RowIcon; |
|
365 } |
|
366 else |
|
367 { |
|
368 iPopupLayoutType = KLayout1Row; |
|
369 } |
|
370 |
|
371 // Check if text should be wrapped to two lines |
|
372 if ( TitleTextNeedsWrapping( iPopupLayoutType ) ) |
|
373 { |
|
374 if ( withIcon ) |
|
375 { |
|
376 iPopupLayoutType = KLayout2RowsWrappedIcon; |
|
377 } |
|
378 else |
|
379 { |
|
380 iPopupLayoutType = KLayout2RowsWrapped; |
|
381 } |
|
382 } |
|
383 } |
|
384 } |
|
385 |
|
386 |
|
387 // --------------------------------------------------------------------------- |
|
388 // CAknDiscreetPopupDrawer::EikonEnv |
|
389 // Provides control eikon env. |
|
390 // --------------------------------------------------------------------------- |
|
391 // |
|
392 CEikonEnv* CAknDiscreetPopupDrawer::EikonEnv() const |
|
393 { |
|
394 if ( iControl ) |
|
395 { |
|
396 return static_cast<CEikonEnv*>( iControl->ControlEnv() ); |
|
397 } |
|
398 return NULL; |
|
399 } |
|
400 |
|
401 |
|
402 // --------------------------------------------------------------------------- |
|
403 // CAknDiscreetPopupDrawer::TitleTextNeedsWrapping |
|
404 // Returns ETrue if title text needs wrapping. |
|
405 // --------------------------------------------------------------------------- |
|
406 // |
|
407 TBool CAknDiscreetPopupDrawer::TitleTextNeedsWrapping( |
|
408 const TInt& aLayoutType ) |
|
409 { |
|
410 const CFont* textFont( NULL ); |
|
411 TRect textRect; |
|
412 TRect popupRect; |
|
413 TPopupLayoutData data( KPopupLayoutData[ aLayoutType ] ); |
|
414 GetPopupRect( data.iWindowVariety, popupRect ); |
|
415 popupRect.Move( 0, 0 ); |
|
416 |
|
417 textFont = FontFromLayout( |
|
418 popupRect, |
|
419 AknLayoutScalable_Avkon::popup_discreet_window_t1( |
|
420 data.i1stRowVariety ), textRect ); |
|
421 if ( textFont->TextCount( *iTitleText, textRect.Width() ) |
|
422 < iTitleText->Length() ) |
|
423 { |
|
424 return ETrue; |
|
425 } |
|
426 return EFalse; |
|
427 } |
|
428 |
|
429 |
|
430 // --------------------------------------------------------------------------- |
|
431 // CAknDiscreetPopupDrawer::WrapTitleTextL |
|
432 // Wraps long text to two lines. |
|
433 // --------------------------------------------------------------------------- |
|
434 // |
|
435 void CAknDiscreetPopupDrawer::WrapTitleTextL() |
|
436 { |
|
437 CArrayFixFlat<TInt>* lineWidths |
|
438 = new ( ELeave ) CArrayFixFlat<TInt>( KMaxNumOfLines ); |
|
439 CleanupStack::PushL( lineWidths ); |
|
440 CArrayFixFlat<TPtrC>* wrappedArray |
|
441 = new ( ELeave ) CArrayFixFlat<TPtrC>( KMaxNumOfLines ); |
|
442 CleanupStack::PushL( wrappedArray ); |
|
443 |
|
444 for ( TInt i = 0; i < KMaxNumOfLines; i++ ) |
|
445 { |
|
446 lineWidths->AppendL( iTitleTextData.iTextRect.Width() ); |
|
447 } |
|
448 |
|
449 HBufC* visualBuffer = HBufC::NewLC( |
|
450 iTitleText->Length() + KMaxNumOfLines * KAknBidiExtraSpacePerLine ); |
|
451 *visualBuffer = *iTitleText; |
|
452 TPtr ptr( visualBuffer->Des() ); |
|
453 |
|
454 AknBidiTextUtils::ConvertToVisualAndWrapToArrayL( |
|
455 ptr, *lineWidths, *iTitleTextData.iTextFont, *wrappedArray, ETrue ); |
|
456 |
|
457 if ( wrappedArray->Count() && wrappedArray->At( 1 ) != KNullDesC ) |
|
458 { |
|
459 delete iTitleText; |
|
460 iTitleText = NULL; |
|
461 delete iBodyText; |
|
462 iBodyText = NULL; |
|
463 iTitleText = wrappedArray->At( 0 ).AllocL(); |
|
464 iBodyText = wrappedArray->At( 1 ).AllocL(); |
|
465 } |
|
466 |
|
467 CleanupStack::PopAndDestroy( visualBuffer ); |
|
468 CleanupStack::PopAndDestroy( wrappedArray ); |
|
469 CleanupStack::PopAndDestroy( lineWidths ); |
|
470 } |
|
471 |
|
472 |
|
473 // --------------------------------------------------------------------------- |
|
474 // CAknDiscreetPopupDrawer::DrawBidiEnabledText |
|
475 // --------------------------------------------------------------------------- |
|
476 // |
|
477 void CAknDiscreetPopupDrawer::DrawBidiEnabledText( |
|
478 CWindowGc* aGc, |
|
479 const TAknDiscreetPopupTextData& aTextData, |
|
480 const TDesC& aText ) const |
|
481 { |
|
482 // Buffer for visually ordered text |
|
483 TBuf<KTextBufSize + KAknBidiExtraSpacePerLine> visualText; |
|
484 TInt clipWidth( aTextData.iTextRect.Width() ); |
|
485 |
|
486 // Bidi processing - using AknBidiTextUtils. |
|
487 AknBidiTextUtils::ConvertToVisualAndClip( |
|
488 aText, visualText, *aTextData.iTextFont, clipWidth, clipWidth ); |
|
489 |
|
490 TInt baselineOffset( |
|
491 aTextData.iTextFont->AscentInPixels() |
|
492 + ( aTextData.iTextRect.Height() |
|
493 - aTextData.iTextFont->AscentInPixels() ) / 2 ); |
|
494 |
|
495 aGc->UseFont( aTextData.iTextFont ); |
|
496 aGc->DrawText( |
|
497 visualText, |
|
498 aTextData.iTextRect, |
|
499 baselineOffset, |
|
500 aTextData.iTextAlignment ); |
|
501 } |
|
502 |
|
503 |
|
504 // --------------------------------------------------------------------------- |
|
505 // CAknDiscreetPopupDrawer::CreatePopupIconL |
|
506 // Creates icon of given parameters. |
|
507 // --------------------------------------------------------------------------- |
|
508 // |
|
509 CGulIcon* CAknDiscreetPopupDrawer::CreatePopupIconL( const TAknsItemID& aSkinId, |
|
510 const TDesC& aBitmapFile, |
|
511 const TInt& aBitmapId, |
|
512 const TInt& aMaskId ) |
|
513 { |
|
514 if ( !ImageInfoAvailable( aSkinId, aBitmapFile, aBitmapId ) ) |
|
515 { |
|
516 return NULL; |
|
517 } |
|
518 |
|
519 CGulIcon* icon = NULL; |
|
520 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
521 |
|
522 // Only skin id defined |
|
523 if ( aBitmapFile == KNullDesC || aBitmapId == -1 ) |
|
524 { |
|
525 if ( aSkinId != KAknsIIDNone && skin ) |
|
526 { |
|
527 icon = AknsUtils::CreateGulIconL( skin, aSkinId, EFalse ); |
|
528 } |
|
529 } |
|
530 else |
|
531 { |
|
532 // Skin id and bitmap file info defined |
|
533 if ( aSkinId != KAknsIIDNone && skin ) |
|
534 { |
|
535 icon = AknsUtils::CreateGulIconL( skin, |
|
536 aSkinId, |
|
537 aBitmapFile, |
|
538 aBitmapId, |
|
539 aMaskId); |
|
540 } |
|
541 |
|
542 // Only bitmap file info defined |
|
543 else |
|
544 { |
|
545 CFbsBitmap* bmp; |
|
546 CFbsBitmap* mask; |
|
547 AknIconUtils::CreateIconLC( bmp, |
|
548 mask, |
|
549 aBitmapFile, |
|
550 aBitmapId, |
|
551 aMaskId ); |
|
552 icon = CGulIcon::NewL( bmp, mask ); // ownership passed |
|
553 CleanupStack::Pop( mask ); |
|
554 CleanupStack::Pop( bmp ); |
|
555 } |
|
556 } |
|
557 return icon; |
|
558 } |
|
559 |
|
560 |
|
561 // --------------------------------------------------------------------------- |
|
562 // CAknDiscreetPopupDrawer::ImageInfoAvailable |
|
563 // --------------------------------------------------------------------------- |
|
564 // |
|
565 TBool CAknDiscreetPopupDrawer::ImageInfoAvailable( const TAknsItemID& aSkinId, |
|
566 const TDesC& aBitmapFile, |
|
567 const TInt& aBitmapId ) |
|
568 { |
|
569 if ( aSkinId != KAknsIIDNone && aSkinId != KAknsIIDDefault ) |
|
570 { |
|
571 return ETrue; |
|
572 } |
|
573 if ( aBitmapFile != KNullDesC && aBitmapId > 0 ) |
|
574 { |
|
575 return ETrue; |
|
576 } |
|
577 return EFalse; |
|
578 } |
|
579 |
|
580 |
|
581 // --------------------------------------------------------------------------- |
|
582 // CAknDiscreetPopupDrawer::RectFromLayout |
|
583 // Returns the specified layout rectangle. |
|
584 // --------------------------------------------------------------------------- |
|
585 // |
|
586 TRect CAknDiscreetPopupDrawer::RectFromLayout( const TRect& aParent, |
|
587 const TAknWindowComponentLayout& aComponentLayout ) |
|
588 { |
|
589 TAknLayoutRect layoutRect; |
|
590 layoutRect.LayoutRect( aParent, aComponentLayout.LayoutLine() ); |
|
591 return layoutRect.Rect(); |
|
592 } |
|
593 |
|
594 |
|
595 // --------------------------------------------------------------------------- |
|
596 // CAknDiscreetPopupDrawer::TextDataFromLayout |
|
597 // Fills text data according to text layout. |
|
598 // --------------------------------------------------------------------------- |
|
599 // |
|
600 void CAknDiscreetPopupDrawer::TextDataFromLayout( |
|
601 TAknDiscreetPopupTextData& aTextData, |
|
602 const TRect& aParent, |
|
603 const TAknTextComponentLayout& aComponentLayout ) |
|
604 { |
|
605 aTextData.iTextFont = |
|
606 FontFromLayout( aParent, aComponentLayout, aTextData.iTextRect ); |
|
607 switch ( aComponentLayout.J() ) |
|
608 { |
|
609 case ELayoutAlignRight: |
|
610 { |
|
611 aTextData.iTextAlignment = CGraphicsContext::ERight; |
|
612 break; |
|
613 } |
|
614 case ELayoutAlignLeft: |
|
615 { |
|
616 aTextData.iTextAlignment = CGraphicsContext::ELeft; |
|
617 break; |
|
618 } |
|
619 case ELayoutAlignCenter: |
|
620 { |
|
621 aTextData.iTextAlignment = CGraphicsContext::ECenter; |
|
622 break; |
|
623 } |
|
624 default: |
|
625 { |
|
626 aTextData.iTextAlignment = CGraphicsContext::ECenter; |
|
627 break; |
|
628 } |
|
629 } |
|
630 } |
|
631 |
|
632 |
|
633 // --------------------------------------------------------------------------- |
|
634 // CAknDiscreetPopupDrawer::FontFromLayout |
|
635 // Returns the specified text layout font. |
|
636 // --------------------------------------------------------------------------- |
|
637 // |
|
638 const CFont* CAknDiscreetPopupDrawer::FontFromLayout( |
|
639 const TRect& aParent, |
|
640 const TAknTextComponentLayout& aComponentLayout, |
|
641 TRect& aTextRect ) |
|
642 { |
|
643 TAknLayoutText layoutRect; |
|
644 layoutRect.LayoutText( aParent, aComponentLayout.LayoutLine() ); |
|
645 aTextRect = layoutRect.TextRect(); |
|
646 return layoutRect.Font(); |
|
647 } |
|
648 |
|
649 |
|
650 // --------------------------------------------------------------------------- |
|
651 // CAknDiscreetPopupDrawer::GetPopupRect |
|
652 // Provides popup rect. |
|
653 // --------------------------------------------------------------------------- |
|
654 // |
|
655 void CAknDiscreetPopupDrawer::GetPopupRect( |
|
656 const TInt& aWindowVariety, TRect& aRect ) |
|
657 { |
|
658 TRect appRect; |
|
659 AknLayoutUtils::LayoutMetricsRect( |
|
660 AknLayoutUtils::EApplicationWindow, appRect); |
|
661 |
|
662 // Popup rect |
|
663 aRect = RectFromLayout( |
|
664 appRect, |
|
665 AknLayoutScalable_Avkon::popup_discreet_window( |
|
666 aWindowVariety ) ); |
|
667 |
|
668 } |
|
669 |