|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Content for stylus activated pop-up. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <AknUtils.h> |
|
20 #include <AknPanic.h> |
|
21 #include <AknPreviewPopUpController.h> |
|
22 #include <barsread.h> // TResourceReader |
|
23 #include <eiklabel.h> |
|
24 #include <fbs.h> |
|
25 #include <aknappui.h> |
|
26 #include <aknlayoutscalable_avkon.cdl.h> |
|
27 #include <AknsDrawUtils.h> |
|
28 #include <AknBidiTextUtils.h> |
|
29 #include <touchfeedback.h> |
|
30 |
|
31 #include "akntextcontrol.h" |
|
32 #include "aknstylusactivatedpopupcontent.h" |
|
33 |
|
34 #ifdef RD_SCALABLE_UI_V2 |
|
35 // CONSTANTS |
|
36 const TInt KMaxNbrOfInfoLines = 2; |
|
37 const TInt KMaxNbrOfCmdLinks = 2; |
|
38 const TInt KNoItemHighlighted = -1; |
|
39 |
|
40 #endif // RD_SCALABLE_UI_V2 |
|
41 |
|
42 |
|
43 NONSHARABLE_CLASS( CAknStylusActivatedItem ) : public CBase |
|
44 { |
|
45 public: |
|
46 CAknStylusActivatedItem(); |
|
47 ~CAknStylusActivatedItem(); |
|
48 void ConstructL( TDesC& aText, TInt aCommandId ); |
|
49 public: |
|
50 //Member data |
|
51 TRect iRect; |
|
52 HBufC* iText; |
|
53 TInt iCommandId; |
|
54 }; |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // Default constructor |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CAknStylusActivatedItem::CAknStylusActivatedItem() |
|
61 { |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CAknStylusActivatedItem::ConstructL |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void CAknStylusActivatedItem::ConstructL( TDesC& aText, TInt aCommandId ) |
|
69 { |
|
70 iText = aText.AllocL(); |
|
71 iCommandId = aCommandId; |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // Destructor |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 CAknStylusActivatedItem::~CAknStylusActivatedItem() |
|
79 { |
|
80 delete iText; |
|
81 } |
|
82 |
|
83 |
|
84 // ======== MEMBER FUNCTIONS ======== |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // Default constructor. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 #ifdef RD_SCALABLE_UI_V2 |
|
91 CAknStylusActivatedPopUpContent::CAknStylusActivatedPopUpContent(): |
|
92 iHighlightedItem( KNoItemHighlighted ) |
|
93 { |
|
94 } |
|
95 #endif // RD_SCALABLE_UI_V2 |
|
96 |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CAknStylusActivatedPopUpContent::NewL |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 #ifdef RD_SCALABLE_UI_V2 |
|
103 EXPORT_C CAknStylusActivatedPopUpContent* |
|
104 CAknStylusActivatedPopUpContent::NewL( |
|
105 const TDesC& aTitleText, |
|
106 const TDesC& aText ) |
|
107 { |
|
108 CAknStylusActivatedPopUpContent* self = |
|
109 new ( ELeave ) CAknStylusActivatedPopUpContent(); |
|
110 |
|
111 CleanupStack::PushL( self ); |
|
112 self->ConstructL( aTitleText, aText ); |
|
113 CleanupStack::Pop(); // self |
|
114 return self; |
|
115 } |
|
116 #else |
|
117 EXPORT_C CAknStylusActivatedPopUpContent* |
|
118 CAknStylusActivatedPopUpContent::NewL( |
|
119 const TDesC& /*aTitleText*/, |
|
120 const TDesC& /*aText*/ ) |
|
121 { |
|
122 return NULL; |
|
123 } |
|
124 #endif // RD_SCALABLE_UI_V2 |
|
125 |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CAknStylusActivatedPopUpContent::NewL |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 #ifdef RD_SCALABLE_UI_V2 |
|
132 EXPORT_C CAknStylusActivatedPopUpContent* |
|
133 CAknStylusActivatedPopUpContent::NewL( |
|
134 const TDesC& aTitleText, |
|
135 const TDesC& aText, |
|
136 const RArray<TAknContentLink>& aLinkArray ) |
|
137 { |
|
138 CAknStylusActivatedPopUpContent* self = |
|
139 new ( ELeave ) CAknStylusActivatedPopUpContent(); |
|
140 |
|
141 CleanupStack::PushL( self ); |
|
142 self->ConstructL( aTitleText, aText, aLinkArray ); |
|
143 CleanupStack::Pop(); // self |
|
144 return self; |
|
145 } |
|
146 #else |
|
147 EXPORT_C CAknStylusActivatedPopUpContent* |
|
148 CAknStylusActivatedPopUpContent::NewL( |
|
149 const TDesC& /*aTitleText*/, |
|
150 const TDesC& /*aText*/, |
|
151 const RArray<TAknContentLink>& /*&aLinkArray*/ ) |
|
152 { |
|
153 return NULL; |
|
154 } |
|
155 #endif // RD_SCALABLE_UI_V2 |
|
156 |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CAknStylusActivatedPopUpContent::NewL |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 #ifdef RD_SCALABLE_UI_V2 |
|
163 EXPORT_C CAknStylusActivatedPopUpContent* |
|
164 CAknStylusActivatedPopUpContent::NewL( TResourceReader& aReader ) |
|
165 { |
|
166 CAknStylusActivatedPopUpContent* self = |
|
167 new ( ELeave ) CAknStylusActivatedPopUpContent(); |
|
168 |
|
169 CleanupStack::PushL( self ); |
|
170 self->ConstructFromResourceL( aReader ); |
|
171 CleanupStack::Pop(); // self |
|
172 return self; |
|
173 } |
|
174 #else |
|
175 EXPORT_C CAknStylusActivatedPopUpContent* |
|
176 CAknStylusActivatedPopUpContent::NewL( TResourceReader& /*aReader*/ ) |
|
177 { |
|
178 return NULL; |
|
179 } |
|
180 #endif // RD_SCALABLE_UI_V2 |
|
181 |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // CAknStylusActivatedPopUpContent::NewL |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 #ifdef RD_SCALABLE_UI_V2 |
|
188 EXPORT_C CAknStylusActivatedPopUpContent* |
|
189 CAknStylusActivatedPopUpContent::NewL( const TInt aResourceId ) |
|
190 { |
|
191 CAknStylusActivatedPopUpContent* self = |
|
192 new ( ELeave ) CAknStylusActivatedPopUpContent(); |
|
193 |
|
194 CleanupStack::PushL( self ); |
|
195 self->ConstructFromResourceL( aResourceId ); |
|
196 CleanupStack::Pop(); // self |
|
197 return self; |
|
198 } |
|
199 #else |
|
200 EXPORT_C CAknStylusActivatedPopUpContent* |
|
201 CAknStylusActivatedPopUpContent::NewL( const TInt /*aResourceId*/ ) |
|
202 { |
|
203 return NULL; |
|
204 } |
|
205 #endif // RD_SCALABLE_UI_V2 |
|
206 |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // Destructor |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 #ifdef RD_SCALABLE_UI_V2 |
|
213 CAknStylusActivatedPopUpContent::~CAknStylusActivatedPopUpContent() |
|
214 { |
|
215 iLinkArray.ResetAndDestroy(); |
|
216 delete iTitleText; |
|
217 delete iText; |
|
218 } |
|
219 #endif // RD_SCALABLE_UI_V2 |
|
220 |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CAknStylusActivatedPopUpContent::ConstructFromResourceL |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 #ifdef RD_SCALABLE_UI_V2 |
|
227 EXPORT_C void CAknStylusActivatedPopUpContent::ConstructFromResourceL( |
|
228 const TInt aResourceId ) |
|
229 { |
|
230 if ( aResourceId ) |
|
231 { |
|
232 TResourceReader reader; |
|
233 iCoeEnv->CreateResourceReaderLC( reader, aResourceId ); |
|
234 ConstructFromResourceL( reader ); |
|
235 CleanupStack::PopAndDestroy(); // reader |
|
236 } |
|
237 } |
|
238 #else |
|
239 EXPORT_C void CAknStylusActivatedPopUpContent::ConstructFromResourceL( |
|
240 const TInt /*aResourceId*/ ) |
|
241 { |
|
242 } |
|
243 #endif // RD_SCALABLE_UI_V2 |
|
244 |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // CAknStylusActivatedPopUpContent::SetCommandObserver |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 #ifdef RD_SCALABLE_UI_V2 |
|
251 EXPORT_C void CAknStylusActivatedPopUpContent::SetCommandObserver( |
|
252 MEikCommandObserver& aCommandObserver ) |
|
253 { |
|
254 iCommandObserver = &aCommandObserver; |
|
255 } |
|
256 #else |
|
257 EXPORT_C void CAknStylusActivatedPopUpContent::SetCommandObserver( |
|
258 MEikCommandObserver& /*aCommandObserver*/ ) |
|
259 { |
|
260 } |
|
261 #endif // RD_SCALABLE_UI_V2 |
|
262 |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // From class CCoeControl. |
|
266 // CAknStylusActivatedPopUpContent::ConstructFromResourceL |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 #ifdef RD_SCALABLE_UI_V2 |
|
270 EXPORT_C void CAknStylusActivatedPopUpContent::ConstructFromResourceL( |
|
271 TResourceReader& aReader ) |
|
272 { |
|
273 // read title and info texts |
|
274 TPtrC titleText = aReader.ReadTPtrC(); |
|
275 TPtrC infotext = aReader.ReadTPtrC(); |
|
276 |
|
277 // read function link count |
|
278 TInt numberOfLinks = aReader.ReadInt16(); |
|
279 |
|
280 __ASSERT_ALWAYS( numberOfLinks <= KMaxNbrOfCmdLinks, |
|
281 Panic( EAknPanicOutOfRange ) ); |
|
282 |
|
283 if ( numberOfLinks > 0 ) |
|
284 { |
|
285 RArray<TAknContentLink> linkArray; |
|
286 CleanupClosePushL( linkArray ); |
|
287 for ( TInt i = 0; i < numberOfLinks; i++ ) |
|
288 { |
|
289 TAknContentLink link; |
|
290 link.iLinkId = aReader.ReadInt8(); |
|
291 TPtrC linkTextTPtrC = aReader.ReadTPtrC(); |
|
292 HBufC* buf = linkTextTPtrC.AllocLC(); |
|
293 |
|
294 link.iLinkText = buf; |
|
295 linkArray.AppendL( link ); |
|
296 |
|
297 // possible extension |
|
298 aReader.ReadInt32(); |
|
299 } |
|
300 ConstructL( titleText, infotext, linkArray ); |
|
301 CleanupStack::PopAndDestroy( numberOfLinks ); |
|
302 CleanupStack::PopAndDestroy( &linkArray ); |
|
303 } |
|
304 else |
|
305 { |
|
306 ConstructL( titleText, infotext ); |
|
307 } |
|
308 } |
|
309 #else |
|
310 EXPORT_C void CAknStylusActivatedPopUpContent::ConstructFromResourceL( |
|
311 TResourceReader& /*aReader*/ ) |
|
312 { |
|
313 } |
|
314 #endif // RD_SCALABLE_UI_V2 |
|
315 |
|
316 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // From class CCoeControl. |
|
319 // CAknStylusActivatedPopUpContent::HandleResourceChange |
|
320 // ----------------------------------------------------------------------------- |
|
321 // |
|
322 #ifdef RD_SCALABLE_UI_V2 |
|
323 EXPORT_C void CAknStylusActivatedPopUpContent::HandleResourceChange( |
|
324 TInt aType ) |
|
325 { |
|
326 CCoeControl::HandleResourceChange( aType ); |
|
327 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
328 { |
|
329 SizeChanged(); |
|
330 } |
|
331 } |
|
332 #else |
|
333 EXPORT_C void CAknStylusActivatedPopUpContent::HandleResourceChange( |
|
334 TInt /*aType*/ ) |
|
335 { |
|
336 } |
|
337 #endif // RD_SCALABLE_UI_V2 |
|
338 |
|
339 |
|
340 // ----------------------------------------------------------------------------- |
|
341 // From class CCoeControl. |
|
342 // CAknStylusActivatedPopUpContent::SetContainerWindowL |
|
343 // ----------------------------------------------------------------------------- |
|
344 // |
|
345 #ifdef RD_SCALABLE_UI_V2 |
|
346 EXPORT_C void CAknStylusActivatedPopUpContent::SetContainerWindowL( |
|
347 const CCoeControl& aContainer ) |
|
348 { |
|
349 CCoeControl::SetContainerWindowL( aContainer ); |
|
350 |
|
351 if( iText ) |
|
352 { |
|
353 iText->SetContainerWindowL( aContainer ); |
|
354 } |
|
355 |
|
356 iTitleText->SetContainerWindowL( aContainer ); |
|
357 } |
|
358 #else |
|
359 EXPORT_C void CAknStylusActivatedPopUpContent::SetContainerWindowL( |
|
360 const CCoeControl& /*aContainer*/ ) |
|
361 { |
|
362 } |
|
363 #endif // RD_SCALABLE_UI_V2 |
|
364 |
|
365 |
|
366 // ----------------------------------------------------------------------------- |
|
367 // From class MCoeControlObserver. |
|
368 // CAknStylusActivatedPopUpContent::HandleControlEventL |
|
369 // ----------------------------------------------------------------------------- |
|
370 // |
|
371 EXPORT_C void CAknStylusActivatedPopUpContent::HandleControlEventL( |
|
372 CCoeControl* /*aControl*/, |
|
373 TCoeEvent /*aEventType*/ ) |
|
374 { |
|
375 } |
|
376 |
|
377 #ifdef RD_SCALABLE_UI_V2 |
|
378 |
|
379 // ----------------------------------------------------------------------------- |
|
380 // CAknStylusActivatedPopUpContent::ConstructL |
|
381 // ----------------------------------------------------------------------------- |
|
382 // |
|
383 void CAknStylusActivatedPopUpContent::ConstructL( const TDesC& aTitleText, |
|
384 const TDesC& aText ) |
|
385 { |
|
386 // titletext must be always given |
|
387 __ASSERT_ALWAYS( aTitleText.Length(), Panic( EAknPanicNullPointer ) ); |
|
388 // either of infotext or cmds must be given |
|
389 __ASSERT_ALWAYS( aText.Length() > 0 || iLinkArray.Count() > 0, |
|
390 Panic( EAknPanicOutOfRange ) ); |
|
391 |
|
392 iTitleText = new ( ELeave ) CEikLabel; |
|
393 iTitleText->SetTextL( aTitleText ); |
|
394 |
|
395 if( aText.Length() > 0 ) |
|
396 { |
|
397 iText = CAknTextControl::NewL(); |
|
398 iText->SetTextL( aText ); |
|
399 } |
|
400 TInt numOfLines = iLinkArray.Count(); |
|
401 if ( iText ) |
|
402 { |
|
403 numOfLines++; |
|
404 } |
|
405 |
|
406 TInt variety = GetVariety( numOfLines ); |
|
407 |
|
408 TRect rectPopUpWindow = PopUpWindowRectFromLayout( |
|
409 AknLayoutScalable_Avkon::popup_touch_info_window( variety ) ); |
|
410 |
|
411 TRect rectHeadingSubPane = RectFromLayout( rectPopUpWindow, |
|
412 AknLayoutScalable_Avkon::heading_sub_pane() ); |
|
413 |
|
414 TAknLayoutText layoutText; |
|
415 layoutText.LayoutText( rectHeadingSubPane, |
|
416 AknLayoutScalable_Avkon::heading_sub_pane_t1() ); |
|
417 |
|
418 iTitleText->SetFont( layoutText.Font() ); |
|
419 |
|
420 TAknWindowComponentLayout infoPaneLayout = |
|
421 AknLayoutScalable_Avkon::list_touch_info_pane( 1 ); // with heading |
|
422 TRect rectInfoPane = RectFromLayout( rectPopUpWindow, infoPaneLayout ); |
|
423 |
|
424 TAknTextComponentLayout textLayout = |
|
425 AknLayoutScalable_Avkon::list_single_touch_info_pane_t1(); |
|
426 TAknLayoutText textRect; |
|
427 textRect.LayoutText( rectInfoPane, textLayout ); |
|
428 |
|
429 |
|
430 TRgb textColor = KRgbBlack; |
|
431 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), textColor, |
|
432 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG55 ); |
|
433 AknLayoutUtils::OverrideControlColorL( *iTitleText, EColorLabelText, |
|
434 textColor ); |
|
435 |
|
436 |
|
437 // Font for command links |
|
438 iFont = textRect.Font(); |
|
439 |
|
440 if( iText ) |
|
441 { |
|
442 textRect.LayoutText( rectInfoPane, textLayout ); |
|
443 |
|
444 CArrayFixFlat<TInt>* lineWidths |
|
445 = new ( ELeave ) CArrayFixFlat<TInt>( KMaxNbrOfInfoLines ); |
|
446 CleanupStack::PushL( lineWidths ); |
|
447 |
|
448 for ( TInt i = 0; i < KMaxNbrOfInfoLines; i++ ) |
|
449 { |
|
450 lineWidths->AppendL( textRect.TextRect().Width() ); |
|
451 } |
|
452 |
|
453 // get correct font from layout |
|
454 const CFont *font = textRect.Font(); |
|
455 |
|
456 // parse text |
|
457 iText->ParseTextL( font, lineWidths ); |
|
458 CleanupStack::PopAndDestroy( lineWidths ); |
|
459 |
|
460 if ( iText->Line( 1 ) ) |
|
461 { |
|
462 // text didn't fit in one line -> change layout to allow 2 lines |
|
463 variety++; |
|
464 |
|
465 rectPopUpWindow = PopUpWindowRectFromLayout( |
|
466 AknLayoutScalable_Avkon::popup_touch_info_window( variety ) ); |
|
467 |
|
468 rectInfoPane = RectFromLayout( rectPopUpWindow, infoPaneLayout ); |
|
469 textRect.LayoutText( rectInfoPane, textLayout ); |
|
470 |
|
471 lineWidths |
|
472 = new ( ELeave ) CArrayFixFlat<TInt>( KMaxNbrOfInfoLines ); |
|
473 CleanupStack::PushL( lineWidths ); |
|
474 for ( TInt i = 0; i < KMaxNbrOfInfoLines; i++ ) |
|
475 { |
|
476 lineWidths->AppendL( textRect.TextRect().Width() ); |
|
477 } |
|
478 // parse text |
|
479 iText->ParseTextL( font, lineWidths ); |
|
480 CleanupStack::PopAndDestroy( lineWidths ); |
|
481 } |
|
482 AknLayoutUtils::OverrideControlColorL( *iText, EColorLabelText, |
|
483 textColor ); |
|
484 } |
|
485 } |
|
486 |
|
487 |
|
488 // ----------------------------------------------------------------------------- |
|
489 // CAknStylusActivatedPopUpContent::ConstructL |
|
490 // ----------------------------------------------------------------------------- |
|
491 // |
|
492 void CAknStylusActivatedPopUpContent::ConstructL( |
|
493 const TDesC& aTitleText, |
|
494 const TDesC& aText, |
|
495 const RArray<TAknContentLink>& aLinkArray ) |
|
496 { |
|
497 if ( &aLinkArray ) |
|
498 { |
|
499 __ASSERT_ALWAYS( ( aLinkArray.Count() > 0 ) && |
|
500 ( aLinkArray.Count() <= KMaxNbrOfCmdLinks ), |
|
501 Panic( EAknPanicOutOfRange ) ); |
|
502 |
|
503 |
|
504 for ( TInt i = 0; i < aLinkArray.Count(); i++ ) |
|
505 { |
|
506 CAknStylusActivatedItem* item = |
|
507 new (ELeave) CAknStylusActivatedItem; |
|
508 CleanupStack::PushL( item ); |
|
509 item->ConstructL( *( aLinkArray[i].iLinkText ), |
|
510 aLinkArray[i].iLinkId ); |
|
511 iLinkArray.AppendL( item ); |
|
512 CleanupStack::Pop( item ); |
|
513 } |
|
514 ConstructL( aTitleText, aText ); |
|
515 } |
|
516 } |
|
517 #endif // RD_SCALABLE_UI_V2 |
|
518 |
|
519 |
|
520 // ----------------------------------------------------------------------------- |
|
521 // From class CCoeControl. |
|
522 // CAknStylusActivatedPopUpContent::ComponentControl |
|
523 // ----------------------------------------------------------------------------- |
|
524 // |
|
525 #ifdef RD_SCALABLE_UI_V2 |
|
526 EXPORT_C CCoeControl* CAknStylusActivatedPopUpContent::ComponentControl( |
|
527 TInt aIndex ) const |
|
528 { |
|
529 switch ( aIndex ) |
|
530 { |
|
531 case 0: |
|
532 return iTitleText; |
|
533 case 1: |
|
534 if( iText ) |
|
535 { |
|
536 return iText; |
|
537 } |
|
538 default: |
|
539 __ASSERT_ALWAYS( aIndex >= 0, Panic( EAknPanicOutOfRange ) ); |
|
540 return NULL; |
|
541 } |
|
542 } |
|
543 #else |
|
544 EXPORT_C CCoeControl* CAknStylusActivatedPopUpContent::ComponentControl( |
|
545 TInt /*aIndex*/ ) const |
|
546 { |
|
547 return NULL; |
|
548 } |
|
549 #endif // RD_SCALABLE_UI_V2 |
|
550 |
|
551 |
|
552 // ----------------------------------------------------------------------------- |
|
553 // From class CCoeControl. |
|
554 // CAknStylusActivatedPopUpContent::CountComponentControls |
|
555 // ----------------------------------------------------------------------------- |
|
556 // |
|
557 EXPORT_C TInt CAknStylusActivatedPopUpContent::CountComponentControls() const |
|
558 { |
|
559 #ifdef RD_SCALABLE_UI_V2 |
|
560 TInt count = 0; |
|
561 if( iTitleText ) |
|
562 { |
|
563 count++; |
|
564 } |
|
565 if( iText ) |
|
566 { |
|
567 count++; |
|
568 } |
|
569 return count; |
|
570 #else |
|
571 return 0; |
|
572 #endif // RD_SCALABLE_UI_V2 |
|
573 } |
|
574 |
|
575 |
|
576 // ----------------------------------------------------------------------------- |
|
577 // From class CCoeControl. |
|
578 // CAknStylusActivatedPopUpContent::Draw |
|
579 // ----------------------------------------------------------------------------- |
|
580 // |
|
581 EXPORT_C void CAknStylusActivatedPopUpContent::Draw( |
|
582 const TRect& aRect ) const |
|
583 { |
|
584 #ifdef RD_SCALABLE_UI_V2 |
|
585 CWindowGc& gc = SystemGc(); |
|
586 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
587 |
|
588 if ( aRect.Intersects( Rect() ) ) |
|
589 { |
|
590 TRect rect( Rect() ); |
|
591 |
|
592 TRect headingAreaRect( AlignedRectFromLayout( |
|
593 AknLayoutScalable_Avkon::heading_sub_pane() ) ); |
|
594 |
|
595 TRect headingBgRect( RectFromLayout( headingAreaRect, |
|
596 AknLayoutScalable_Avkon::bg_popup_heading_pane_cp() ) ); |
|
597 |
|
598 TRect headingCenterRect( RectFromLayout( headingBgRect, |
|
599 AknLayoutScalable_Avkon::bg_popup_heading_pane_g1() ) ); |
|
600 |
|
601 AknsDrawUtils::DrawFrame( skin, gc, headingBgRect, headingCenterRect, |
|
602 KAknsIIDQsnFrPopupHeading, |
|
603 KAknsIIDQsnFrPopupHeadingCenter ); |
|
604 } |
|
605 |
|
606 gc.Reset(); |
|
607 |
|
608 TRgb textColor; |
|
609 AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnHighlightColors, |
|
610 EAknsCIQsnHighlightColorsCG3 ); |
|
611 |
|
612 gc.SetPenStyle( CGraphicsContext::ESolidPen ); |
|
613 gc.SetPenColor( textColor ); |
|
614 |
|
615 TRgb highlightcolor = AKN_LAF_COLOR( 244 ); |
|
616 AknsUtils::GetCachedColor( skin, highlightcolor, |
|
617 KAknsIIDQsnHighlightColors, EAknsCIQsnHighlightColorsCG1 ); |
|
618 |
|
619 gc.SetBrushColor( highlightcolor ); |
|
620 const CFont* font = iFont; |
|
621 if ( !font ) |
|
622 { |
|
623 font = iCoeEnv->NormalFont(); |
|
624 } |
|
625 gc.UseFont( font ); |
|
626 |
|
627 gc.SetUnderlineStyle( EUnderlineOn ); |
|
628 |
|
629 for ( TInt i=0; i < iLinkArray.Count(); i++ ) |
|
630 { |
|
631 if ( !aRect.Intersects( iLinkArray[i]->iRect ) ) |
|
632 { |
|
633 continue; |
|
634 } |
|
635 |
|
636 TRect rect( iLinkArray[i]->iRect ); |
|
637 if ( Background() ) |
|
638 { |
|
639 Background()->Draw( gc, *this, rect ); |
|
640 } |
|
641 |
|
642 // buffer for visually ordered text |
|
643 HBufC* visualText(NULL); |
|
644 TRAPD( err, visualText = HBufC::NewL( 255 + |
|
645 KAknBidiExtraSpacePerLine ) ); |
|
646 if ( err != KErrNone ) |
|
647 { |
|
648 return; |
|
649 } |
|
650 TPtr ptr = visualText->Des(); |
|
651 TInt clipWidth = rect.Width(); |
|
652 |
|
653 if ( iHighlightedItem == i ) |
|
654 { |
|
655 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
656 } |
|
657 else |
|
658 { |
|
659 gc.SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
660 } |
|
661 |
|
662 // bidi processing - using AknBidiTextUtils. |
|
663 AknBidiTextUtils::ConvertToVisualAndClip( |
|
664 *(iLinkArray[i]->iText), |
|
665 ptr, |
|
666 *font, |
|
667 clipWidth, |
|
668 clipWidth ); |
|
669 |
|
670 TInt baselineOffset = 0; |
|
671 baselineOffset = font->AscentInPixels() + |
|
672 ( rect.Height() - font->AscentInPixels() ) / 2; |
|
673 gc.DrawText( ptr, rect, baselineOffset, |
|
674 CGraphicsContext::ELeft ); |
|
675 delete visualText; |
|
676 } |
|
677 #endif // RD_SCALABLE_UI_V2 |
|
678 } |
|
679 |
|
680 |
|
681 // ----------------------------------------------------------------------------- |
|
682 // From class CCoeControl. |
|
683 // CAknStylusActivatedPopUpContent::MinimumSize |
|
684 // ----------------------------------------------------------------------------- |
|
685 // |
|
686 EXPORT_C TSize CAknStylusActivatedPopUpContent::MinimumSize() |
|
687 { |
|
688 #ifdef RD_SCALABLE_UI_V2 |
|
689 TInt nbrOfInfoLines = 0; |
|
690 if( iText ) |
|
691 { |
|
692 nbrOfInfoLines = iText->NumberOfLines(); |
|
693 } |
|
694 |
|
695 TPtrC ptrLabel =( *iTitleText->Text() ); |
|
696 TInt minWidth = iTitleText->CalcMinimumSize( ptrLabel ).iWidth; |
|
697 |
|
698 CEikLabel* textLabel; |
|
699 for ( TInt i=0; i < nbrOfInfoLines; i++ ) |
|
700 { |
|
701 textLabel = static_cast<CEikLabel*>(iText->ComponentControl(i)); |
|
702 TPtrC ptrText = ( *textLabel->Text() ); |
|
703 minWidth = Max( textLabel->CalcMinimumSize( ptrText ).iWidth, minWidth ); |
|
704 } |
|
705 |
|
706 // choose the longest one |
|
707 for ( TInt i = 0; i < iLinkArray.Count(); i++ ) |
|
708 { |
|
709 TInt tempWidth = iFont->TextWidthInPixels( *( iLinkArray[i]->iText ) ); |
|
710 minWidth = Max( minWidth, tempWidth ); |
|
711 } |
|
712 |
|
713 TRect tempRect; |
|
714 TInt rectWidth = 0; |
|
715 TAknWindowComponentLayout infoPaneLayout = |
|
716 AknLayoutScalable_Avkon::list_touch_info_pane( 1 ); // with heading |
|
717 |
|
718 // Check layout data varieties from largest to smallest |
|
719 for ( TInt i=7; i >= 4; i-- ) |
|
720 { |
|
721 tempRect = RectFromLayout( iAvkonAppUi->ApplicationRect(), |
|
722 AknLayoutScalable_Avkon::popup_touch_info_window( i ) ); |
|
723 |
|
724 TRect rectInfoPane = RectFromLayout( tempRect, infoPaneLayout ); |
|
725 |
|
726 TAknTextComponentLayout textLayout = |
|
727 AknLayoutScalable_Avkon::list_single_touch_info_pane_t1(); |
|
728 TAknLayoutText textRect; |
|
729 textRect.LayoutText( rectInfoPane, textLayout ); |
|
730 |
|
731 |
|
732 if ( textRect.TextRect().Width() > minWidth || !rectWidth ) |
|
733 { |
|
734 rectWidth = rectInfoPane.Width(); |
|
735 } |
|
736 else |
|
737 { |
|
738 break; |
|
739 } |
|
740 } |
|
741 TInt variety = GetVariety( nbrOfInfoLines + |
|
742 iLinkArray.Count() ); |
|
743 TRect rectPopUpWindow = PopUpWindowRectFromLayout( |
|
744 AknLayoutScalable_Avkon::popup_touch_info_window( variety ) ); |
|
745 |
|
746 TAknWindowComponentLayout headingPaneLayout = |
|
747 AknLayoutScalable_Avkon::heading_sub_pane(); // with heading |
|
748 |
|
749 TRect rectInfoPane = RectFromLayout( rectPopUpWindow, infoPaneLayout ); |
|
750 TRect rectHeadingPane = RectFromLayout( rectPopUpWindow, headingPaneLayout ); |
|
751 TInt rectHeight = rectInfoPane.Height() + rectHeadingPane.Height(); |
|
752 |
|
753 return TSize( rectWidth, rectHeight ); |
|
754 #else |
|
755 return TSize(); |
|
756 #endif // RD_SCALABLE_UI_V2 |
|
757 } |
|
758 |
|
759 |
|
760 // ----------------------------------------------------------------------------- |
|
761 // From class CCoeControl. |
|
762 // CAknStylusActivatedPopUpContent::SizeChanged |
|
763 // ----------------------------------------------------------------------------- |
|
764 // |
|
765 EXPORT_C void CAknStylusActivatedPopUpContent::SizeChanged() |
|
766 { |
|
767 #ifdef RD_SCALABLE_UI_V2 |
|
768 TInt nbrOfInfoLines = 0; |
|
769 if( iText ) |
|
770 { |
|
771 nbrOfInfoLines = iText->NumberOfLines(); |
|
772 } |
|
773 TInt nbrOfCmdLines = iLinkArray.Count(); |
|
774 |
|
775 TInt variety = GetVariety( nbrOfInfoLines + nbrOfCmdLines ); |
|
776 |
|
777 TRect rectHeadingSubPane( AlignedRectFromLayout( |
|
778 AknLayoutScalable_Avkon::heading_sub_pane() ) ); |
|
779 |
|
780 TAknLayoutText layoutText; |
|
781 layoutText.LayoutText( rectHeadingSubPane, |
|
782 AknLayoutScalable_Avkon::heading_sub_pane_t1() ); |
|
783 |
|
784 iTitleText->SetRect( layoutText.TextRect() ); |
|
785 iTitleText->SetFont( layoutText.Font() ); |
|
786 |
|
787 TAknTextLineLayout textLayout; |
|
788 TRect rectSingleInfoPane; |
|
789 TInt textrow = 0; |
|
790 |
|
791 // with heading |
|
792 TRect rectInfoPane( AlignedRectFromLayout( |
|
793 AknLayoutScalable_Avkon::list_touch_info_pane( 1 ) ) ); |
|
794 |
|
795 if( iText ) |
|
796 { |
|
797 iText->SetRect( rectInfoPane ); |
|
798 textLayout = |
|
799 AknLayoutScalable_Avkon::list_single_touch_info_pane_t1(); |
|
800 TAknLayoutText layoutText; |
|
801 |
|
802 // set rects/layouts for info text lines |
|
803 for ( ; textrow < nbrOfInfoLines; textrow++ ) |
|
804 { |
|
805 rectSingleInfoPane = RectFromLayout( rectInfoPane, |
|
806 AknLayoutScalable_Avkon::list_single_touch_info_pane( textrow ) ); |
|
807 layoutText.LayoutText( rectSingleInfoPane, textLayout ); |
|
808 iText->Line( textrow )->SetRect( layoutText.TextRect() ); |
|
809 iText->Line( textrow )->SetFont( layoutText.Font() ); |
|
810 } |
|
811 } |
|
812 |
|
813 // layout data for cmd texts |
|
814 textLayout = AknLayoutScalable_Avkon::list_single_touch_info_pane_t2(); |
|
815 |
|
816 // set rects/layouts for cmd links |
|
817 for ( TInt i = 0; i < nbrOfCmdLines; i++ ) |
|
818 { |
|
819 rectSingleInfoPane = RectFromLayout( rectInfoPane, |
|
820 AknLayoutScalable_Avkon::list_single_touch_info_pane( textrow++ ) ); |
|
821 |
|
822 layoutText.LayoutText( rectSingleInfoPane, textLayout ); |
|
823 if ( i == 0 ) |
|
824 { |
|
825 iFont = layoutText.Font(); |
|
826 } |
|
827 TInt tempWidth = iFont->TextWidthInPixels( *(iLinkArray[i]->iText) ); |
|
828 TRect tempRect = TRect( layoutText.TextRect() ); |
|
829 tempRect.SetWidth( Min( tempWidth, layoutText.TextRect().Width() ) ); |
|
830 |
|
831 iLinkArray[i]->iRect = tempRect; |
|
832 } |
|
833 #endif // RD_SCALABLE_UI_V2 |
|
834 } |
|
835 |
|
836 // ----------------------------------------------------------------------------- |
|
837 // RectFromLayout |
|
838 // ----------------------------------------------------------------------------- |
|
839 // |
|
840 TRect CAknStylusActivatedPopUpContent::RectFromLayout( const TRect& aParent, |
|
841 const TAknWindowComponentLayout& aComponentLayout ) const |
|
842 { |
|
843 TAknWindowLineLayout lineLayout = aComponentLayout.LayoutLine(); |
|
844 TAknLayoutRect layoutRect; |
|
845 layoutRect.LayoutRect( aParent, lineLayout ); |
|
846 return layoutRect.Rect(); |
|
847 } |
|
848 |
|
849 // ----------------------------------------------------------------------------- |
|
850 // PopUpWindowRectFromLayout |
|
851 // ----------------------------------------------------------------------------- |
|
852 // |
|
853 TRect CAknStylusActivatedPopUpContent::PopUpWindowRectFromLayout( const |
|
854 TAknWindowComponentLayout& aComponentLayout ) const |
|
855 { |
|
856 // get popup window width from the widest variety |
|
857 TAknWindowLineLayout lineLayout = aComponentLayout.LayoutLine(); |
|
858 lineLayout.iW = AknLayoutScalable_Avkon:: |
|
859 popup_touch_info_window( 3 ).LayoutLine().iW; |
|
860 TAknLayoutRect layoutRect; |
|
861 layoutRect.LayoutRect( iAvkonAppUi->ApplicationRect(), lineLayout ); |
|
862 |
|
863 return layoutRect.Rect(); |
|
864 } |
|
865 |
|
866 // ----------------------------------------------------------------------------- |
|
867 // AlignedRectFromLayout |
|
868 // ----------------------------------------------------------------------------- |
|
869 // |
|
870 TRect CAknStylusActivatedPopUpContent::AlignedRectFromLayout( |
|
871 const TAknWindowComponentLayout& aComponentLayout ) const |
|
872 { |
|
873 TAknWindowLineLayout lineLayout = aComponentLayout.LayoutLine(); |
|
874 TAknLayoutRect layoutRect; |
|
875 |
|
876 TRect rect( Rect() ); |
|
877 layoutRect.LayoutRect( rect, lineLayout ); |
|
878 |
|
879 TRect result( rect.iTl.iX, layoutRect.Rect().iTl.iY - rect.iTl.iY, rect.iBr.iX, |
|
880 layoutRect.Rect().iBr.iY - rect.iTl.iY ); |
|
881 |
|
882 return result; |
|
883 } |
|
884 |
|
885 // ----------------------------------------------------------------------------- |
|
886 // GetVariety |
|
887 // ----------------------------------------------------------------------------- |
|
888 // |
|
889 TInt CAknStylusActivatedPopUpContent::GetVariety( const TInt aNbrOfLines ) |
|
890 { |
|
891 // Heading is mandatory -> varieties 0...3 are omitted |
|
892 switch ( aNbrOfLines ) |
|
893 { |
|
894 case 1: |
|
895 // 1 row of text (info/command) |
|
896 return 4; |
|
897 case 2: |
|
898 // 2 rows of text (2 info / 2 cmds / 1 info, 1 cmds) |
|
899 return 5; |
|
900 case 3: |
|
901 // 3 rows of text (1 info, 2 cmds / 2 info, 1 cmd) |
|
902 return 6; |
|
903 case 4: |
|
904 // 4 rows of text (2 info, 2 cmds) |
|
905 return 7; |
|
906 default: |
|
907 return 4; |
|
908 } |
|
909 } |
|
910 |
|
911 |
|
912 // ----------------------------------------------------------------------------- |
|
913 // From class CCoeControl |
|
914 // CAknStylusActivatedPopUpContent::HandlePointerEventL |
|
915 // ----------------------------------------------------------------------------- |
|
916 // |
|
917 void CAknStylusActivatedPopUpContent::HandlePointerEventL( |
|
918 const TPointerEvent& aPointerEvent ) |
|
919 { |
|
920 #ifdef RD_SCALABLE_UI_V2 |
|
921 for ( TInt i=0; i < iLinkArray.Count(); i++ ) |
|
922 { |
|
923 if ( iLinkArray[i]->iRect.Contains( aPointerEvent.iPosition ) ) |
|
924 { |
|
925 if ( iHighlightedItem != i ) |
|
926 { |
|
927 TInt previousItem = iHighlightedItem; |
|
928 iHighlightedItem = i; |
|
929 if ( previousItem != KNoItemHighlighted ) |
|
930 { |
|
931 DrawNow( iLinkArray[previousItem]->iRect ); |
|
932 } |
|
933 DrawNow( iLinkArray[iHighlightedItem]->iRect ); |
|
934 } |
|
935 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
936 { |
|
937 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
938 |
|
939 if ( feedback ) |
|
940 { |
|
941 feedback->InstantFeedback( ETouchFeedbackBasic ); |
|
942 } |
|
943 } |
|
944 |
|
945 // Nofity command observer |
|
946 if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
947 { |
|
948 iCommandObserver->ProcessCommandL( iLinkArray[i]->iCommandId ); |
|
949 } |
|
950 } |
|
951 } |
|
952 #endif // RD_SCALABLE_UI_V2 |
|
953 } |
|
954 |