|
1 /* |
|
2 * Copyright (c) 2002-2006 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: Popup form for adding custom controls to popup dialog |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <barsread.h> |
|
21 #include <eikdpage.h> |
|
22 #include <eikdpsel.h> |
|
23 #include <eikcapc.h> |
|
24 #include <eikspace.h> |
|
25 #include <eikprogi.h> |
|
26 #include <eikrted.h> |
|
27 #include <w32std.h> |
|
28 |
|
29 #include <aknappui.h> |
|
30 #include <AknsDrawUtils.h> |
|
31 #include <aknconsts.h> |
|
32 #include <AknUtils.h> |
|
33 #include <AknsBasicBackgroundControlContext.h> |
|
34 #include <AknsFrameBackgroundControlContext.h> |
|
35 |
|
36 #include <layoutmetadata.cdl.h> |
|
37 |
|
38 #include <aknsoundsystem.h> |
|
39 #include <AknBidiTextUtils.h> |
|
40 #include <AknBitmapAnimation.h> |
|
41 |
|
42 #include <AknPanic.h> |
|
43 #include <AknPopupform.h> |
|
44 #include <AknPictographInterface.h> |
|
45 #include <AknPictographDrawerInterface.h> |
|
46 #include <avkon.mbg> |
|
47 #include <AknIconUtils.h> |
|
48 #include <aknlayoutscalable_avkon.cdl.h> |
|
49 |
|
50 #include <AknTasHook.h> |
|
51 |
|
52 // CONSTANTS |
|
53 const TInt KMaxNoOfEditorLines = 6; |
|
54 |
|
55 NONSHARABLE_CLASS(CAknPopupFormExtension) : |
|
56 public CCoeControl, |
|
57 public MAknPictographAnimatorCallBack, |
|
58 public MEikScrollBarObserver |
|
59 { |
|
60 public: |
|
61 static CAknPopupFormExtension* NewL( CAknPopupForm& aOwner ); |
|
62 ~CAknPopupFormExtension(); |
|
63 void Draw( const TRect& aRect ) const; |
|
64 |
|
65 private: // From MAknPictographAnimatorCallBack |
|
66 void DrawPictographArea(); |
|
67 |
|
68 protected: // From MEikScrollBarObserver |
|
69 virtual void HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType); |
|
70 private: |
|
71 CAknPopupFormExtension( CAknPopupForm& aOwner ); |
|
72 void ConstructL(); |
|
73 |
|
74 public: |
|
75 CAknPopupForm& iOwner; |
|
76 CAknPictographInterface* iPictoInterface; |
|
77 TInt iWaitAnimationResourceIndex; |
|
78 TBool iHasLabelBackground; |
|
79 TInt iCursorLine; |
|
80 TBool iToBold; |
|
81 }; |
|
82 |
|
83 |
|
84 CAknPopupFormExtension::CAknPopupFormExtension( CAknPopupForm& aOwner ) |
|
85 : iOwner( aOwner ), iWaitAnimationResourceIndex ( -1 ), iHasLabelBackground( EFalse ) |
|
86 { |
|
87 } |
|
88 |
|
89 CAknPopupFormExtension* CAknPopupFormExtension::NewL( CAknPopupForm& aOwner ) |
|
90 { |
|
91 CAknPopupFormExtension* self = new( ELeave ) CAknPopupFormExtension( aOwner ); |
|
92 CleanupStack::PushL( self ); |
|
93 self->ConstructL(); |
|
94 CleanupStack::Pop(); |
|
95 return self; |
|
96 } |
|
97 |
|
98 void CAknPopupFormExtension::ConstructL() |
|
99 { |
|
100 } |
|
101 |
|
102 CAknPopupFormExtension::~CAknPopupFormExtension() |
|
103 { |
|
104 delete iPictoInterface; |
|
105 } |
|
106 |
|
107 void CAknPopupFormExtension::DrawPictographArea() |
|
108 { |
|
109 iOwner.RedrawHeading(); |
|
110 } |
|
111 |
|
112 void CAknPopupFormExtension::HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType) |
|
113 { |
|
114 if ( AknLayoutUtils::PenEnabled() ) |
|
115 { |
|
116 CEikCaptionedControl* captionedControl = iOwner.GetControlByControlType( EEikCtRichTextEditor ); |
|
117 CEikRichTextEditor* ed = NULL; |
|
118 if ( captionedControl ) |
|
119 { |
|
120 CCoeControl* coe = captionedControl->iControl; |
|
121 ed = reinterpret_cast<CEikRichTextEditor*>( coe ); |
|
122 } |
|
123 TInt lpp = KMaxNoOfEditorLines; |
|
124 if ( ed && iOwner.TextIsScrollable() ) |
|
125 { |
|
126 if ( iOwner.iFlags.IsSet ( EPopupFormHasEditor ) ) |
|
127 { |
|
128 if ( !iOwner.iFlags.IsSet( EPopupFormUsesPlainFont ) ) |
|
129 { |
|
130 lpp--; |
|
131 } |
|
132 if ( iOwner.iFlags.IsSet( EPopupFormHasProgbar )|| iOwner.iFlags.IsSet( EPopupFormHasWaitAnim ) ) |
|
133 { |
|
134 lpp--; |
|
135 } |
|
136 } |
|
137 // Using ed->MoveDisplayL to scroll text will cause some display |
|
138 // error, so use ed->MoveCursorL to instead of it. |
|
139 switch (aEventType) |
|
140 { |
|
141 case EEikScrollUp: |
|
142 if ( (iOwner.iCurrentLine-1) >= 1 ) |
|
143 { |
|
144 iOwner.iCurrentLine--; |
|
145 iOwner.UpdateScrollIndicatorL(); |
|
146 while( iCursorLine > iOwner.iCurrentLine ) |
|
147 { |
|
148 ed->MoveCursorL( TCursorPosition::EFLineUp, EFalse ); |
|
149 iCursorLine--; |
|
150 } |
|
151 } |
|
152 break; |
|
153 case EEikScrollPageUp: |
|
154 { |
|
155 if ( iOwner.iCurrentLine - lpp >= 1) |
|
156 { |
|
157 iOwner.iCurrentLine = iOwner.iCurrentLine - lpp + 1; |
|
158 } |
|
159 else |
|
160 { |
|
161 iOwner.iCurrentLine=1; |
|
162 } |
|
163 iOwner.UpdateScrollIndicatorL(); |
|
164 while ( iCursorLine > iOwner.iCurrentLine ) |
|
165 { |
|
166 ed->MoveCursorL( TCursorPosition::EFLineUp, EFalse ); |
|
167 iCursorLine--; |
|
168 } |
|
169 } |
|
170 break; |
|
171 case EEikScrollDown: |
|
172 if ( (iOwner.iNoOfEditorLines - iOwner.iCurrentLine) >= lpp ) |
|
173 { |
|
174 iOwner.iCurrentLine++; |
|
175 iOwner.UpdateScrollIndicatorL(); |
|
176 while ( iCursorLine < iOwner.iCurrentLine - 1 + lpp ) |
|
177 { |
|
178 ed->MoveCursorL( TCursorPosition::EFLineDown, EFalse ); |
|
179 iCursorLine++; |
|
180 } |
|
181 } |
|
182 break; |
|
183 case EEikScrollPageDown: |
|
184 { |
|
185 if ( (iOwner.iNoOfEditorLines - iOwner.iCurrentLine - lpp) >= (lpp - 1)) |
|
186 { |
|
187 iOwner.iCurrentLine = iOwner.iCurrentLine + lpp - 1; |
|
188 } |
|
189 else |
|
190 { |
|
191 iOwner.iCurrentLine = iOwner.iNoOfEditorLines - lpp + 1; |
|
192 } |
|
193 iOwner.UpdateScrollIndicatorL(); |
|
194 TInt bottomLine = iOwner.iCurrentLine - 1 + lpp; |
|
195 TInt destLine = bottomLine > iOwner.iNoOfEditorLines ? |
|
196 iOwner.iNoOfEditorLines : bottomLine; |
|
197 while ( iCursorLine < destLine ) |
|
198 { |
|
199 ed->MoveCursorL( TCursorPosition::EFLineDown, EFalse ); |
|
200 iCursorLine++; |
|
201 } |
|
202 } |
|
203 break; |
|
204 case EEikScrollThumbDragVert: |
|
205 { |
|
206 TInt currentLine = aScrollBar->Model()->iThumbPosition + 1; |
|
207 if ( ( currentLine >= 1 ) && ( currentLine <= iOwner.iNoOfEditorLines ) ) |
|
208 { |
|
209 if (currentLine>iOwner.iCurrentLine) |
|
210 { |
|
211 iOwner.iCurrentLine = currentLine; |
|
212 iOwner.UpdateScrollIndicatorL(); |
|
213 TInt bottomLine = currentLine - 1 + lpp; |
|
214 TInt destLine = bottomLine > iOwner.iNoOfEditorLines ? |
|
215 iOwner.iNoOfEditorLines : bottomLine; |
|
216 while ( iCursorLine < destLine ) |
|
217 { |
|
218 ed->MoveCursorL( TCursorPosition::EFLineDown, EFalse ); |
|
219 iCursorLine++; |
|
220 } |
|
221 } |
|
222 if (currentLine<iOwner.iCurrentLine) |
|
223 { |
|
224 iOwner.iCurrentLine = currentLine; |
|
225 iOwner.UpdateScrollIndicatorL(); |
|
226 while( iCursorLine > currentLine ) |
|
227 { |
|
228 ed->MoveCursorL( TCursorPosition::EFLineUp, EFalse ); |
|
229 iCursorLine--; |
|
230 } |
|
231 } |
|
232 } |
|
233 } |
|
234 break; |
|
235 default: |
|
236 // Do nothing |
|
237 break; |
|
238 } |
|
239 } |
|
240 } |
|
241 } |
|
242 |
|
243 void CAknPopupFormExtension::Draw( const TRect& /* aRect */ ) const |
|
244 { |
|
245 if ( iHasLabelBackground ) |
|
246 { |
|
247 CWindowGc &gc = SystemGc(); |
|
248 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
249 |
|
250 TAknLayoutRect headingArea; |
|
251 TAknLayoutRect headingBackground; |
|
252 TAknLayoutRect headingCenter; |
|
253 |
|
254 headingArea.LayoutRect( Parent()->Rect(), AknLayoutScalable_Avkon::heading_pane( 0 ).LayoutLine() ); |
|
255 headingBackground.LayoutRect( headingArea.Rect(), AknLayoutScalable_Avkon::bg_popup_heading_pane( 0 ).LayoutLine() ); |
|
256 headingCenter.LayoutRect( headingBackground.Rect(), AknLayoutScalable_Avkon::bg_popup_heading_pane_g1().LayoutLine() ); |
|
257 |
|
258 AknsDrawUtils::DrawFrame( skin, gc, headingBackground.Rect(), headingCenter.Rect(), |
|
259 KAknsIIDQsnFrPopupHeading, |
|
260 KAknsIIDQsnFrPopupHeadingCenter); |
|
261 |
|
262 } |
|
263 } |
|
264 |
|
265 |
|
266 |
|
267 // ============================ MEMBER FUNCTIONS =============================== |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // CAknPopupForm::CAknPopupForm |
|
271 // C++ default constructor can NOT contain any code, that |
|
272 // might leave. |
|
273 // ----------------------------------------------------------------------------- |
|
274 // |
|
275 EXPORT_C CAknPopupForm::CAknPopupForm(): |
|
276 iTimeoutInSeconds( 0 ), iTone( ENoTone ), iType( EAknNote ) |
|
277 { |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // CAknPopupForm::CAknPopupForm |
|
282 // C++ default constructor can NOT contain any code, that |
|
283 // might leave. |
|
284 // ----------------------------------------------------------------------------- |
|
285 // |
|
286 EXPORT_C CAknPopupForm::CAknPopupForm( const TTone& aTone, const TInt aTimeout, |
|
287 const TPopupFormType& aType ) : |
|
288 iTimeoutInSeconds( aTimeout ), iTone( aTone ), iType( aType ) |
|
289 { |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // CAknPopupForm::ConstructL |
|
294 // Symbian 2nd phase constructor can leave. |
|
295 // ----------------------------------------------------------------------------- |
|
296 // |
|
297 EXPORT_C void CAknPopupForm::ConstructL() |
|
298 { |
|
299 iExtension = CAknPopupFormExtension::NewL( *this ); |
|
300 } |
|
301 |
|
302 // ----------------------------------------------------------------------------- |
|
303 // CAknPopupForm::NewLC |
|
304 // Two-phased constructor. |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 EXPORT_C CAknPopupForm* CAknPopupForm::NewLC( const TTone& aTone, |
|
308 const TInt aTimeout, |
|
309 const TPopupFormType& aType ) |
|
310 { |
|
311 CAknPopupForm* self = new ( ELeave ) CAknPopupForm( aTone, aTimeout, aType ); |
|
312 CleanupStack::PushL( self ); |
|
313 self->ConstructL(); |
|
314 AKNTASHOOK_ADDL( self, "CAknPopupForm" ); |
|
315 return self; |
|
316 } |
|
317 // ----------------------------------------------------------------------------- |
|
318 // CAknPopupForm::NewL |
|
319 // Two-phased constructor. |
|
320 // ----------------------------------------------------------------------------- |
|
321 // |
|
322 EXPORT_C CAknPopupForm* CAknPopupForm::NewL( const TTone& aTone, |
|
323 const TInt aTimeout, |
|
324 const TPopupFormType& aType ) |
|
325 { |
|
326 CAknPopupForm* self = NewLC( aTone, aTimeout, aType ); |
|
327 CleanupStack::Pop( self ); |
|
328 return self; |
|
329 } |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // CAknPopupForm::NewLC |
|
333 // Two-phased constructor. |
|
334 // ----------------------------------------------------------------------------- |
|
335 // |
|
336 EXPORT_C CAknPopupForm* CAknPopupForm::NewLC() |
|
337 { |
|
338 CAknPopupForm* self = new ( ELeave ) CAknPopupForm(); |
|
339 CleanupStack::PushL( self ); |
|
340 self->ConstructL(); |
|
341 AKNTASHOOK_ADDL( self, "CAknPopupForm" ); |
|
342 return self; |
|
343 } |
|
344 |
|
345 // ----------------------------------------------------------------------------- |
|
346 // CAknPopupForm::NewL |
|
347 // Two-phased constructor. |
|
348 // ----------------------------------------------------------------------------- |
|
349 // |
|
350 EXPORT_C CAknPopupForm* CAknPopupForm::NewL() |
|
351 { |
|
352 CAknPopupForm* self = NewLC(); |
|
353 CleanupStack::Pop( self ); |
|
354 return self; |
|
355 } |
|
356 |
|
357 // Destructor |
|
358 EXPORT_C CAknPopupForm::~CAknPopupForm() |
|
359 { |
|
360 AKNTASHOOK_REMOVE(); |
|
361 delete iTimer; |
|
362 delete iSBFrame; |
|
363 delete iBrushAndPenContext; |
|
364 delete iExtension; |
|
365 } |
|
366 |
|
367 // ----------------------------------------------------------------------------- |
|
368 // CAknPopupForm::SetTimeout |
|
369 // |
|
370 // |
|
371 // ----------------------------------------------------------------------------- |
|
372 // |
|
373 EXPORT_C void CAknPopupForm::SetTimeout( const TInt aTimeoutInSeconds ) |
|
374 { |
|
375 iTimeoutInSeconds = aTimeoutInSeconds; |
|
376 |
|
377 if ( IsVisible() ) |
|
378 { |
|
379 TRAP_IGNORE( StartTimeoutTimerL() ); |
|
380 } |
|
381 } |
|
382 |
|
383 |
|
384 // ----------------------------------------------------------------------------- |
|
385 // CAknPopupForm::SetTone |
|
386 // |
|
387 // |
|
388 // ----------------------------------------------------------------------------- |
|
389 // |
|
390 EXPORT_C void CAknPopupForm::SetTone( const TTone aTone ) |
|
391 { |
|
392 iTone = aTone; |
|
393 } |
|
394 |
|
395 // ----------------------------------------------------------------------------- |
|
396 // CAknPopupForm::SetPopupFormType |
|
397 // |
|
398 // |
|
399 // ----------------------------------------------------------------------------- |
|
400 // |
|
401 EXPORT_C void CAknPopupForm::SetPopupFormType( const TPopupFormType aType ) |
|
402 { |
|
403 iType = aType; |
|
404 } |
|
405 |
|
406 // ----------------------------------------------------------------------------- |
|
407 // CAknPopupForm::SetTitleL |
|
408 // Set the title text. If the given text is too long, truncate it. |
|
409 // |
|
410 // ----------------------------------------------------------------------------- |
|
411 // |
|
412 EXPORT_C void CAknPopupForm::SetTitleL( const TDesC& aTitle ) |
|
413 { |
|
414 CEikCaptionedControl* captionedControl = GetControlByControlType( EEikCtLabel ); |
|
415 CEikLabel* head = NULL; |
|
416 if ( captionedControl ) |
|
417 { |
|
418 CCoeControl* coe = captionedControl->iControl; |
|
419 head = reinterpret_cast<CEikLabel*>( coe ); |
|
420 } |
|
421 |
|
422 if ( head ) |
|
423 { |
|
424 HBufC* clippedString = HBufC::NewLC( aTitle.Length() + KAknBidiExtraSpacePerLine ); |
|
425 *clippedString = aTitle; |
|
426 TPtr clippedStringPtr = clippedString->Des(); |
|
427 |
|
428 // get the parent rect before it necessarily has been calculated in SetSizeAndPosition |
|
429 TRect parentRect = PopupWindowRect(); |
|
430 |
|
431 TAknLayoutRect layRect; |
|
432 layRect.LayoutRect( parentRect, AknLayoutScalable_Avkon::heading_pane( 0 ) ); |
|
433 TAknLayoutText txtLay; |
|
434 txtLay.LayoutText(layRect.Rect(), AknLayoutScalable_Avkon::heading_pane_t1( 0 ) ); |
|
435 TInt width = txtLay.TextRect().Width(); |
|
436 if ( clippedString->Length() > 0 ) |
|
437 { |
|
438 _LIT( KCR, "\r" ); |
|
439 _LIT( KLF, "\n" ); |
|
440 _LIT( KLS, "\x2028" ); |
|
441 _LIT( KLS1, "\u2028" ); |
|
442 |
|
443 TInt run = ETrue; |
|
444 while( run ) |
|
445 { |
|
446 TInt lf = clippedStringPtr. Find( KLF ); |
|
447 if ( lf != KErrNotFound ) |
|
448 { |
|
449 clippedStringPtr.Replace( lf, 1, KNullDesC ); |
|
450 } |
|
451 TInt cr = clippedStringPtr.Find( KCR ); |
|
452 if ( cr != KErrNotFound ) |
|
453 { |
|
454 clippedStringPtr.Replace( cr, 1, KNullDesC ); |
|
455 } |
|
456 TInt ls = clippedStringPtr.Find( KLS ); |
|
457 if ( ls != KErrNotFound ) |
|
458 { |
|
459 clippedStringPtr.Replace( ls, 1, KNullDesC ); |
|
460 } |
|
461 else |
|
462 { |
|
463 ls = clippedStringPtr.Find( KLS1 ); |
|
464 if ( ls != KErrNotFound ) |
|
465 { |
|
466 clippedStringPtr.Replace( ls, 1, KNullDesC ); |
|
467 } |
|
468 } |
|
469 if ( lf == KErrNotFound && cr == KErrNotFound && |
|
470 ls == KErrNotFound ) |
|
471 { |
|
472 run = EFalse; |
|
473 } |
|
474 } |
|
475 } |
|
476 |
|
477 AknBidiTextUtils::ConvertToVisualAndClipL( |
|
478 clippedStringPtr, *( head->Font() ), width, width ); |
|
479 |
|
480 head->SetTextL( clippedStringPtr ); |
|
481 head->UseLogicalToVisualConversion( EFalse ); |
|
482 CleanupStack::PopAndDestroy(); // clippedString |
|
483 if ( aTitle.Length() == NULL ) |
|
484 { |
|
485 UpdateFlags( EPopupFormHeading, EFalse ); |
|
486 } |
|
487 else if ( !iFlags.IsSet( EPopupFormHasHeading ) ) |
|
488 { |
|
489 UpdateFlags( EPopupFormHeading, ETrue ); |
|
490 } |
|
491 |
|
492 if ( IsActivated() ) |
|
493 { |
|
494 LayoutAndDraw(); |
|
495 } |
|
496 } |
|
497 } |
|
498 |
|
499 // ----------------------------------------------------------------------------- |
|
500 // CAknPopupForm::SetTextL |
|
501 // Set the text. Move the cursor to the start of the text. |
|
502 // |
|
503 // ----------------------------------------------------------------------------- |
|
504 // |
|
505 EXPORT_C void CAknPopupForm::SetTextL( const TDesC* aText ) |
|
506 { |
|
507 CEikCaptionedControl* captionedControl = GetControlByControlType( EEikCtRichTextEditor ); |
|
508 if ( captionedControl ) |
|
509 { |
|
510 CCoeControl* coe = captionedControl->iControl; |
|
511 CEikRichTextEditor* ed = reinterpret_cast<CEikRichTextEditor*>( coe ); |
|
512 if ( ed ) |
|
513 { |
|
514 TInt oldNoOfLines = iNoOfEditorLines; |
|
515 |
|
516 // In CTextView, only \f is a newline character, |
|
517 // so '\n', '\r' and '\u2028' have to be onverted to '\f'. |
|
518 HBufC* text = aText->AllocL(); |
|
519 CleanupStack::PushL( text ); |
|
520 TPtr ptr = text->Des(); |
|
521 |
|
522 if ( ptr.Length() > 0 ) |
|
523 { |
|
524 _LIT( KLF, "\n" ); |
|
525 _LIT( KCR, "\r" ); |
|
526 _LIT( KLS, "\u2028" ); |
|
527 _LIT( KLS1, "\x2028" ); |
|
528 _LIT( KLineBreak, "\f" ); |
|
529 |
|
530 //'\n\r' and '\r\n' are newline characters, and individual |
|
531 //'\n' or '\r' is also newline character. |
|
532 TBool run = ETrue; |
|
533 while ( run ) |
|
534 { |
|
535 //if newline character is the form of '\n\r' or '\r\n', |
|
536 //the first character will be replaced with a '\f' and |
|
537 //the redundant second character will be removed |
|
538 TBool removeCR = EFalse; |
|
539 TInt ret = ptr.Find( KLF ); |
|
540 TInt rcr = ptr.Find( KCR ); |
|
541 |
|
542 if ( ret == KErrNotFound ) |
|
543 { |
|
544 ret = rcr; |
|
545 } |
|
546 else if ( rcr != KErrNotFound ) |
|
547 { |
|
548 if ( rcr < ret ) |
|
549 { |
|
550 //make sure the conversion is happened in order, |
|
551 //from the begining to the end. |
|
552 TInt temp = ret; |
|
553 ret = rcr; |
|
554 rcr = temp; |
|
555 } |
|
556 if ( ( rcr - ret ) == 1 ) |
|
557 { |
|
558 //'\n' and '\r' are adjacent, remove |
|
559 //the second character |
|
560 removeCR = ETrue; |
|
561 } |
|
562 } |
|
563 if ( ret == KErrNotFound ) |
|
564 { |
|
565 //'\u2028' is always a newline character |
|
566 ret = ptr.Find( KLS ); |
|
567 } |
|
568 if ( ret == KErrNotFound ) |
|
569 { |
|
570 //'\u2028' is always a newline character |
|
571 ret = ptr.Find( KLS1 ); |
|
572 } |
|
573 if ( ret == KErrNotFound ) |
|
574 { |
|
575 run = EFalse; |
|
576 } |
|
577 else |
|
578 { |
|
579 ptr.Replace( ret, 1, KLineBreak ); |
|
580 } |
|
581 if ( removeCR ) |
|
582 { |
|
583 ptr.Replace( rcr, 1, KNullDesC ); |
|
584 } |
|
585 } |
|
586 } |
|
587 iCurrentLine = 1; |
|
588 iExtension->iCursorLine = 1; |
|
589 ed->SetCursorPosL( 0, EFalse ); |
|
590 |
|
591 ed->SetTextL( &ptr ); |
|
592 CleanupStack::PopAndDestroy( text ); |
|
593 |
|
594 CalculateNumberOfScreens(); |
|
595 if (oldNoOfLines != iNoOfEditorLines && IsActivated() ) |
|
596 { |
|
597 ClearArea( Rect() ); |
|
598 UpdateScrollIndicatorL(); |
|
599 LayoutAndDraw(); |
|
600 } |
|
601 else if ( IsActivated() ) |
|
602 { |
|
603 ClearArea( ed->Rect() ); |
|
604 ed->DrawNow(); |
|
605 } |
|
606 } |
|
607 } |
|
608 } |
|
609 |
|
610 // ----------------------------------------------------------------------------- |
|
611 // CAknPopupForm::IncrementProgressBarAndDraw |
|
612 // If there is a progress bar, increment it with the given value |
|
613 // |
|
614 // ----------------------------------------------------------------------------- |
|
615 // |
|
616 EXPORT_C void CAknPopupForm::IncrementProgressBarAndDraw( const TInt aIncrement ) |
|
617 { |
|
618 CEikCaptionedControl* captionedControl = GetControlByControlType( EEikCtProgInfo ); |
|
619 if ( captionedControl ) |
|
620 { |
|
621 CCoeControl* coe = captionedControl->iControl; |
|
622 CEikProgressInfo* pri = reinterpret_cast<CEikProgressInfo*>( coe ); |
|
623 if ( pri ) |
|
624 { |
|
625 pri->IncrementAndDraw( aIncrement ); |
|
626 } |
|
627 } |
|
628 } |
|
629 |
|
630 // ----------------------------------------------------------------------------- |
|
631 // CAknPopupForm::SetProgressBarAndDraw |
|
632 // If there is a progress bar, sets it with the given value |
|
633 // |
|
634 // ----------------------------------------------------------------------------- |
|
635 // |
|
636 EXPORT_C void CAknPopupForm::SetProgressBarAndDraw( const TInt aIncrement ) |
|
637 { |
|
638 CEikCaptionedControl* captionedControl = GetControlByControlType( EEikCtProgInfo ); |
|
639 if ( captionedControl ) |
|
640 { |
|
641 CCoeControl* coe = captionedControl->iControl; |
|
642 CEikProgressInfo* pri = reinterpret_cast<CEikProgressInfo*>( coe ); |
|
643 if ( pri ) |
|
644 { |
|
645 pri->SetAndDraw( aIncrement ); |
|
646 } |
|
647 } |
|
648 } |
|
649 |
|
650 // ----------------------------------------------------------------------------- |
|
651 // CAknPopupForm::Draw |
|
652 // Draw the dialog |
|
653 // |
|
654 // ----------------------------------------------------------------------------- |
|
655 // |
|
656 EXPORT_C void CAknPopupForm::Draw( const TRect& /*aRect*/ ) const |
|
657 { |
|
658 CWindowGc& gc=SystemGc(); |
|
659 TRect rect( Rect() ); |
|
660 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
661 |
|
662 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
663 |
|
664 if( CAknEnv::Static()->TransparencyEnabled() ) |
|
665 { |
|
666 AknsDrawUtils::Background( skin, cc, this, gc, rect, KAknsDrawParamNoClearUnderImage ); |
|
667 } |
|
668 else |
|
669 { |
|
670 AknsDrawUtils::Background( skin, cc, this, gc, rect ); |
|
671 } |
|
672 } |
|
673 |
|
674 // ----------------------------------------------------------------------------- |
|
675 // CAknPopupForm::GetControlByControlType |
|
676 // Loop through the array and return the control of given type. If a control of |
|
677 // the given type was not found, return NULL |
|
678 // ----------------------------------------------------------------------------- |
|
679 // |
|
680 EXPORT_C CEikCaptionedControl* CAknPopupForm::GetControlByControlType( TInt aControlType ) const |
|
681 { |
|
682 CEikCaptionedControl* controlPtr; |
|
683 TInt activePage = ActivePageIndex(); |
|
684 |
|
685 for ( TInt i = 0; i < iNoOfDialogLines; i++ ) |
|
686 { |
|
687 controlPtr = GetLineByLineAndPageIndex( i, activePage); |
|
688 if ( controlPtr && controlPtr->iControlType == aControlType ) |
|
689 { |
|
690 TRAP_IGNORE( controlPtr->iControl->SetContainerWindowL( *this ) ); |
|
691 controlPtr->iControl->SetControlContext( iBrushAndPenContext ); |
|
692 return controlPtr; |
|
693 } |
|
694 } |
|
695 return NULL; |
|
696 } |
|
697 |
|
698 |
|
699 // ----------------------------------------------------------------------------- |
|
700 // CAknPopupForm::PrepareLC |
|
701 // Call the base class' PrepareLC to handle the construction. |
|
702 // ----------------------------------------------------------------------------- |
|
703 // |
|
704 EXPORT_C void CAknPopupForm::PrepareLC( TInt aResourceID ) |
|
705 { |
|
706 |
|
707 iBrushAndPenContext = CCoeBrushAndPenContext::NewL(); |
|
708 iBrushAndPenContext->SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
709 |
|
710 SetControlContext( iBrushAndPenContext ); |
|
711 |
|
712 CAknDialog::PrepareLC( aResourceID ); |
|
713 |
|
714 TInt activePage = ActivePageIndex(); |
|
715 iNoOfDialogLines = GetNumberOfLinesOnPage( activePage ); |
|
716 |
|
717 for ( TInt i = 0; i < iNoOfDialogLines; i++ ) |
|
718 { |
|
719 CEikCaptionedControl* item = ( CEikCaptionedControl* ) |
|
720 GetLineByLineAndPageIndex( i, activePage ); |
|
721 item->SetContainerWindowL( *this ); |
|
722 item->SetMopParent( this ); |
|
723 item->SetDrawNoWhiteBackground( ETrue ); |
|
724 item->SetControlContext( iBrushAndPenContext ); |
|
725 |
|
726 if( item->iControlType == EAknCtBitmapAnimation ) |
|
727 { |
|
728 if( i == iExtension->iWaitAnimationResourceIndex ) |
|
729 { |
|
730 UpdateFlags( EPopupFormWaitAnim, ETrue ); |
|
731 SetAnimationSize( EPopupFormWaitAnim, item ); |
|
732 SetWaitAnimationResourceIndex( item->iId ); |
|
733 } |
|
734 else |
|
735 { |
|
736 UpdateFlags( EPopupFormAnimation, ETrue ); |
|
737 SetAnimationSize( EPopupFormAnimation, item ); |
|
738 } |
|
739 } |
|
740 else |
|
741 { |
|
742 TPopupFormControlType aPFCtrl = PopupFormControlType( item ); |
|
743 UpdateFlags( aPFCtrl, ETrue ); |
|
744 } |
|
745 } |
|
746 |
|
747 if ( iFlags.IsSet( EPopupFormHasHeading ) ) |
|
748 { |
|
749 // background context for the label |
|
750 if ( !iExtension->iHasLabelBackground ) |
|
751 { |
|
752 iExtension->iHasLabelBackground = ETrue; |
|
753 iExtension->SetRect( TRect( 0, 0, 1, 1 ) ); |
|
754 iExtension->SetParent( this ); |
|
755 iExtension->SetControlContext( iBrushAndPenContext ); |
|
756 } |
|
757 |
|
758 // Pictograph drawer is only needed here if heading exists. |
|
759 // Editor has its own. |
|
760 Extension()->iPictoInterface = |
|
761 CAknPictographInterface::NewL( *this, *Extension() ); |
|
762 |
|
763 CCoeControl* ctrl = GetControlByControlType( EEikCtLabel ); |
|
764 if ( Extension()->iPictoInterface ) |
|
765 { |
|
766 if ( ctrl ) |
|
767 { |
|
768 static_cast<CEikLabel*>( ctrl )->EnablePictographsL( |
|
769 *( Extension()->iPictoInterface ) ); |
|
770 } |
|
771 } |
|
772 } |
|
773 } |
|
774 |
|
775 // ----------------------------------------------------------------------------- |
|
776 // CAknPopupForm::HandleResourceChange |
|
777 // |
|
778 // |
|
779 // ----------------------------------------------------------------------------- |
|
780 // |
|
781 EXPORT_C void CAknPopupForm::HandleResourceChange( TInt aType ) |
|
782 { |
|
783 CEikDialog::HandleResourceChange( aType ); |
|
784 if( aType == KEikDynamicLayoutVariantSwitch || aType == KAknsMessageSkinChange ) |
|
785 { |
|
786 LayoutAndDraw(); |
|
787 } |
|
788 return; |
|
789 } |
|
790 |
|
791 |
|
792 // ----------------------------------------------------------------------------- |
|
793 // CAknPopupForm::RunLD |
|
794 // |
|
795 // |
|
796 // ----------------------------------------------------------------------------- |
|
797 // |
|
798 EXPORT_C TInt CAknPopupForm::RunLD() |
|
799 { |
|
800 PlayTone(); |
|
801 ReportUserActivity(); |
|
802 return CAknDialog::RunLD(); |
|
803 } |
|
804 |
|
805 // ----------------------------------------------------------------------------- |
|
806 // CAknPopupForm::SetSizeAndPosition |
|
807 // Get layout information for the control and use this layout |
|
808 // information to do the layout. |
|
809 // ----------------------------------------------------------------------------- |
|
810 // |
|
811 EXPORT_C void CAknPopupForm::SetSizeAndPosition( const TSize& aSize ) |
|
812 { |
|
813 TRect mainPaneRect; |
|
814 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EPopupParent, mainPaneRect ); |
|
815 |
|
816 // Get the base 2-lines-of-text variety according to softkey location.. |
|
817 AknLayoutUtils::TAknCbaLocation cbaLocation( AknLayoutUtils::CbaLocation() ); |
|
818 TInt variety( 0 ); |
|
819 |
|
820 if ( cbaLocation == AknLayoutUtils::EAknCbaLocationRight ) |
|
821 { |
|
822 variety = 3; |
|
823 } |
|
824 else if ( cbaLocation == AknLayoutUtils::EAknCbaLocationLeft ) |
|
825 { |
|
826 variety = 6; |
|
827 } |
|
828 else |
|
829 { |
|
830 variety = 0; |
|
831 } |
|
832 |
|
833 TAknWindowLineLayout layout; |
|
834 if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() ) |
|
835 { |
|
836 layout = AknLayoutScalable_Avkon::popup_midp_note_alarm_window( variety ); |
|
837 } |
|
838 else |
|
839 { |
|
840 layout = AKN_LAYOUT_WINDOW_popup_note_window( 0 ); |
|
841 } |
|
842 |
|
843 if ( iFlags.IsSet( EPopupFormUsesPlainFont ) ) |
|
844 { |
|
845 layout = AknLayoutScalable_Avkon::popup_midp_note_alarm_window( variety + 2 ); |
|
846 iExtension->iToBold = EFalse; |
|
847 } |
|
848 else // bold font |
|
849 { |
|
850 if ( ( ( iFlags.IsSet( EPopupFormHasProgbar ) || iFlags.IsSet( EPopupFormHasWaitAnim ) ) |
|
851 && iNoOfEditorLines >= KMaxNoOfEditorLines - 2 ) |
|
852 || iNoOfEditorLines >= KMaxNoOfEditorLines - 1 ) |
|
853 { |
|
854 layout = AknLayoutScalable_Avkon::popup_midp_note_alarm_window( variety + 2 ); |
|
855 iExtension->iToBold = ETrue; |
|
856 } |
|
857 else if ( ( ( iFlags.IsSet( EPopupFormHasProgbar ) || iFlags.IsSet( EPopupFormHasWaitAnim ) ) |
|
858 && iNoOfEditorLines >= KMaxNoOfEditorLines - 3 ) |
|
859 || iNoOfEditorLines >= KMaxNoOfEditorLines - 2 ) |
|
860 { |
|
861 layout = AknLayoutScalable_Avkon::popup_midp_note_alarm_window( variety + 1 ); |
|
862 iExtension->iToBold = ETrue; |
|
863 } |
|
864 } |
|
865 |
|
866 TAknLayoutRect layoutWindow; |
|
867 layoutWindow.LayoutRect( mainPaneRect, layout ); |
|
868 TRect winRect( layoutWindow.Rect() ); |
|
869 |
|
870 CEikCba* cba( static_cast<CEikCba*>( ButtonGroupContainer().ButtonGroup() ) ); |
|
871 if ( cba->IsVisible() && !cba->IsEmpty() ) |
|
872 { |
|
873 TRect screen; |
|
874 AknLayoutUtils::LayoutMetricsRect( |
|
875 AknLayoutUtils::EScreen, screen ); |
|
876 |
|
877 TAknLayoutRect cbaRect; |
|
878 cbaRect.LayoutRect( screen, |
|
879 AknLayoutScalable_Avkon::popup_sk_window( 0 ).LayoutLine() ); |
|
880 |
|
881 winRect.iBr.iY += cbaRect.Rect().Height(); |
|
882 } |
|
883 |
|
884 if ( iFlags.IsSet ( EPopupFormHasHeading ) ) |
|
885 { |
|
886 |
|
887 TAknWindowLineLayout headingLayout = AknLayoutScalable_Avkon::heading_pane( 0 ); |
|
888 TAknLayoutRect headingRect; |
|
889 headingRect.LayoutRect( Rect(), headingLayout ); |
|
890 if ( cbaLocation == AknLayoutUtils::EAknCbaLocationRight || cbaLocation == AknLayoutUtils::EAknCbaLocationLeft ) |
|
891 { |
|
892 winRect.iTl.iY -= headingRect.Rect().Height() / 2; |
|
893 winRect.iBr.iY += headingRect.Rect().Height() / 2; |
|
894 |
|
895 } |
|
896 else |
|
897 { |
|
898 winRect.iTl.iY -= headingRect.Rect().Height(); |
|
899 } |
|
900 } |
|
901 |
|
902 if ( AknLayoutUtils::PenEnabled() ) |
|
903 { |
|
904 TSize dlgSize; |
|
905 dlgSize.iHeight = Max( winRect.Height(), aSize.iHeight ); |
|
906 dlgSize.iWidth = Max( winRect.Width(), aSize.iWidth ); |
|
907 CAknDialog::SetSizeAndPosition( dlgSize ); |
|
908 } |
|
909 else |
|
910 { |
|
911 // do the layout again, this time with corrected values |
|
912 SetRect( winRect ); |
|
913 SizeChanged(); |
|
914 } |
|
915 |
|
916 const TInt activePage = ActivePageIndex(); |
|
917 |
|
918 // Set captioned control's rect to be the same as the control's it contains |
|
919 CEikCaptionedControl* line; |
|
920 for ( TInt i=0; i < iNoOfDialogLines; i++ ) |
|
921 { |
|
922 line = ( CEikCaptionedControl* )GetLineByLineAndPageIndex( i, activePage ); |
|
923 line->SetRect( line->iControl->Rect() ); |
|
924 } |
|
925 } |
|
926 |
|
927 // ----------------------------------------------------------------------------- |
|
928 // CAknPopupForm::ActivateL |
|
929 // Set the correct initial value to scroll indicator. |
|
930 // |
|
931 // ----------------------------------------------------------------------------- |
|
932 // |
|
933 EXPORT_C void CAknPopupForm::ActivateL() |
|
934 { |
|
935 // put the popupform to the control stack with a lower |
|
936 // priority to allow the menu to have key events. |
|
937 iEikonEnv->EikAppUi()->RemoveFromStack(this); |
|
938 iEikonEnv->EikAppUi()->AddToStackL(this, ECoeStackPriorityDefault); |
|
939 |
|
940 CAknDialog::ActivateL(); |
|
941 LayoutAndDraw(); |
|
942 UpdateScrollIndicatorL(); |
|
943 } |
|
944 |
|
945 // ----------------------------------------------------------------------------- |
|
946 // CAknPopupForm::PlayTone |
|
947 // If there is a tone and a sound system, play the tone |
|
948 // |
|
949 // ----------------------------------------------------------------------------- |
|
950 // |
|
951 EXPORT_C void CAknPopupForm::PlayTone() |
|
952 { |
|
953 if ( iTone != 0 && SoundSystem() ) |
|
954 { |
|
955 SoundSystem()->PlaySound( iTone ); |
|
956 } |
|
957 } |
|
958 |
|
959 // ----------------------------------------------------------------------------- |
|
960 // CAknPopupForm::StaticDeleteL |
|
961 // Cancel the timer and delete the self-pointer received as a parameter. |
|
962 // |
|
963 // ----------------------------------------------------------------------------- |
|
964 // |
|
965 EXPORT_C TInt CAknPopupForm::StaticDeleteL( TAny *aThis ) |
|
966 { |
|
967 CAknPopupForm* self = reinterpret_cast<CAknPopupForm*>( aThis ); |
|
968 if ( self->iTimer ) |
|
969 self->iTimer->Cancel(); |
|
970 delete self; |
|
971 return KErrNone; |
|
972 } |
|
973 |
|
974 // ----------------------------------------------------------------------------- |
|
975 // CAknPopupForm::SoundSystem |
|
976 // Return the sound system. If AppUi doesn't exist, return NULL. |
|
977 // |
|
978 // ----------------------------------------------------------------------------- |
|
979 // |
|
980 EXPORT_C CAknKeySoundSystem* CAknPopupForm::SoundSystem() const |
|
981 { |
|
982 if ( iEikonEnv->AppUi() ) |
|
983 { |
|
984 return iAvkonAppUiBase->KeySounds(); |
|
985 } |
|
986 return NULL; |
|
987 } |
|
988 |
|
989 // ----------------------------------------------------------------------------- |
|
990 // CAknPopupForm::LayoutAndDraw |
|
991 // If control is activated re-do layout and draw |
|
992 // Hide the control during setting the size and position in order |
|
993 // to avoid unwanted drawing |
|
994 // ----------------------------------------------------------------------------- |
|
995 // |
|
996 EXPORT_C void CAknPopupForm::LayoutAndDraw() |
|
997 { |
|
998 SetSizeAndPosition( PreferredSize( iCoeEnv->ScreenDevice()->SizeInPixels() ) ); |
|
999 DrawDeferred(); |
|
1000 } |
|
1001 |
|
1002 // ----------------------------------------------------------------------------- |
|
1003 // CAknPopupForm::PostLayoutDynInitL |
|
1004 // Start the animation and the timer ( if needed). |
|
1005 // (other items were commented in a header). |
|
1006 // ----------------------------------------------------------------------------- |
|
1007 // |
|
1008 EXPORT_C void CAknPopupForm::PostLayoutDynInitL() |
|
1009 { |
|
1010 if ( iFlags.IsSet( EPopupFormHasAnimation ) || iFlags.IsSet( EPopupFormHasWaitAnim ) ) |
|
1011 { |
|
1012 StartAnimationL(); |
|
1013 } |
|
1014 |
|
1015 StartTimeoutTimerL(); |
|
1016 } |
|
1017 |
|
1018 |
|
1019 // ----------------------------------------------------------------------------- |
|
1020 // CAknPopupForm::SizeChanged |
|
1021 // Lay the controls out. |
|
1022 // |
|
1023 // ----------------------------------------------------------------------------- |
|
1024 // |
|
1025 EXPORT_C void CAknPopupForm::SizeChanged() |
|
1026 { |
|
1027 |
|
1028 CAknDialog::SizeChanged(); |
|
1029 |
|
1030 if ( iFlags.IsSet( EPopupFormHasHeading ) ) |
|
1031 { |
|
1032 LabelLayout(); |
|
1033 if ( iFlags.IsSet( EPopupFormHasSpacer ) ) |
|
1034 { |
|
1035 SpacerLayout(); |
|
1036 } |
|
1037 } |
|
1038 if ( iFlags.IsSet( EPopupFormHasAnimation ) ) |
|
1039 { |
|
1040 TRAP_IGNORE( AnimationLayoutL() ); |
|
1041 } |
|
1042 if ( iFlags.IsSet( EPopupFormHasWaitAnim ) ) |
|
1043 { |
|
1044 TRAP_IGNORE( WaitAnimationLayoutL() ); |
|
1045 } |
|
1046 if ( iFlags.IsSet( EPopupFormHasEditor ) ) |
|
1047 { |
|
1048 EditorLayout(); |
|
1049 } |
|
1050 if ( iFlags.IsSet( EPopupFormHasImage ) ) |
|
1051 { |
|
1052 ImageLayout(); |
|
1053 } |
|
1054 if( iFlags.IsSet( EPopupFormHasProgbar ) ) |
|
1055 { |
|
1056 ProgressBarLayout(); |
|
1057 } |
|
1058 } |
|
1059 |
|
1060 |
|
1061 |
|
1062 // ----------------------------------------------------------------------------- |
|
1063 // CAknPopupForm::OfferKeyEventL |
|
1064 // Grab the up/down arrow key events and scroll the text if needed. |
|
1065 // |
|
1066 // ----------------------------------------------------------------------------- |
|
1067 // |
|
1068 EXPORT_C TKeyResponse CAknPopupForm::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
1069 TEventCode /*aType*/ ) |
|
1070 { |
|
1071 if ( !iFlags.IsSet( EPopupFormHasEditor ) ) |
|
1072 { |
|
1073 return EKeyWasNotConsumed; |
|
1074 } |
|
1075 |
|
1076 TKeyResponse response = EKeyWasNotConsumed; |
|
1077 TInt code=aKeyEvent.iCode; |
|
1078 |
|
1079 CEikCaptionedControl* captionedControl = GetControlByControlType( EEikCtRichTextEditor ); |
|
1080 CEikRichTextEditor* ed = NULL; |
|
1081 if ( captionedControl ) |
|
1082 { |
|
1083 CCoeControl* coe = captionedControl->iControl; |
|
1084 ed = reinterpret_cast<CEikRichTextEditor*>( coe ); |
|
1085 } |
|
1086 TInt lpp = KMaxNoOfEditorLines; |
|
1087 if ( !iFlags.IsSet( EPopupFormUsesPlainFont ) ) |
|
1088 { |
|
1089 lpp--; |
|
1090 } |
|
1091 if ( iFlags.IsSet( EPopupFormHasProgbar )|| iFlags.IsSet( EPopupFormHasWaitAnim ) ) |
|
1092 { |
|
1093 lpp--; |
|
1094 } |
|
1095 switch ( code ) |
|
1096 { |
|
1097 case EKeyUpArrow: |
|
1098 if ( ed ) |
|
1099 { |
|
1100 if ( TextIsScrollable() ) |
|
1101 { |
|
1102 if ( iCurrentLine > 1 ) |
|
1103 { |
|
1104 iCurrentLine--; |
|
1105 UpdateScrollIndicatorL(); |
|
1106 while( iExtension->iCursorLine > iCurrentLine ) |
|
1107 { |
|
1108 ed->MoveCursorL( TCursorPosition::EFLineUp, EFalse ); |
|
1109 iExtension->iCursorLine--; |
|
1110 } |
|
1111 } |
|
1112 } |
|
1113 response = EKeyWasConsumed; |
|
1114 } |
|
1115 break; |
|
1116 case EKeyDownArrow: |
|
1117 if ( ed ) |
|
1118 { |
|
1119 if ( TextIsScrollable() ) |
|
1120 { |
|
1121 if ( iCurrentLine <= iNoOfEditorLines - lpp ) |
|
1122 { |
|
1123 iCurrentLine++; |
|
1124 UpdateScrollIndicatorL(); |
|
1125 while ( iExtension->iCursorLine < iCurrentLine - 1 + lpp ) |
|
1126 { |
|
1127 ed->MoveCursorL( TCursorPosition::EFLineDown, EFalse ); |
|
1128 iExtension->iCursorLine++; |
|
1129 } |
|
1130 } |
|
1131 } |
|
1132 response = EKeyWasConsumed; |
|
1133 } |
|
1134 break; |
|
1135 } |
|
1136 return response; |
|
1137 } |
|
1138 |
|
1139 |
|
1140 EXPORT_C void CAknPopupForm::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
1141 { |
|
1142 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
1143 } |
|
1144 |
|
1145 // ----------------------------------------------------------------------------- |
|
1146 // CAknPopupForm::CountComponentControls |
|
1147 // Return the number of controls in the dialog |
|
1148 // |
|
1149 // ----------------------------------------------------------------------------- |
|
1150 // |
|
1151 EXPORT_C TInt CAknPopupForm::CountComponentControls() const |
|
1152 { |
|
1153 // If the editor text is scrollable, scrollbar acts as an additional control |
|
1154 if ( ( iSBFrame && iNoOfScreens > 1 ) ) |
|
1155 { |
|
1156 return GetNumberOfLinesOnPage( ActivePageIndex() ) + 2; // plus backgroundcontext for heading and scrollbar |
|
1157 } |
|
1158 return GetNumberOfLinesOnPage( ActivePageIndex() ) + 1; // plus backgroundcontext for heading desc |
|
1159 } |
|
1160 |
|
1161 // ----------------------------------------------------------------------------- |
|
1162 // CAknPopupForm::ComponentControl |
|
1163 // Return a component at given index |
|
1164 // |
|
1165 // ----------------------------------------------------------------------------- |
|
1166 // |
|
1167 EXPORT_C CCoeControl* CAknPopupForm::ComponentControl( TInt aIndex ) const |
|
1168 { |
|
1169 // First control is the extension class |
|
1170 if ( aIndex == NULL ) |
|
1171 { |
|
1172 return iExtension; |
|
1173 } |
|
1174 // If the editor text is scrollable, scrollbar acts as an additional control |
|
1175 else if ( ( iSBFrame && iNoOfScreens > 1 ) && aIndex == iNoOfDialogLines + 1) |
|
1176 { |
|
1177 return iSBFrame->VerticalScrollBar(); |
|
1178 } |
|
1179 CEikCaptionedControl* captionedControl = GetLineByLineAndPageIndex( aIndex - 1, ActivePageIndex() ); |
|
1180 if ( captionedControl ) |
|
1181 { |
|
1182 return captionedControl->iControl; |
|
1183 } |
|
1184 return NULL; |
|
1185 } |
|
1186 |
|
1187 // ----------------------------------------------------------------------------- |
|
1188 // CAknPopupForm::LabelLayout |
|
1189 // Get layout information for the control and use this layout |
|
1190 // information to do the layout. |
|
1191 // ----------------------------------------------------------------------------- |
|
1192 // |
|
1193 void CAknPopupForm::LabelLayout() |
|
1194 { |
|
1195 |
|
1196 CEikCaptionedControl* captionedControl = GetControlByControlType( EEikCtLabel ); |
|
1197 CCoeControl* coe = NULL; |
|
1198 CEikLabel* head = NULL; |
|
1199 if ( captionedControl ) |
|
1200 { |
|
1201 coe = captionedControl->iControl; |
|
1202 head = reinterpret_cast<CEikLabel*>( coe ); |
|
1203 } |
|
1204 if ( head ) |
|
1205 { |
|
1206 TAknLayoutRect headingArea; |
|
1207 headingArea.LayoutRect( Rect(), AknLayoutScalable_Avkon::heading_pane( 0 ).LayoutLine()); |
|
1208 |
|
1209 |
|
1210 head->SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
1211 TAknTextComponentLayout headingText = AknLayoutScalable_Avkon::heading_pane_t1( 0 ); |
|
1212 |
|
1213 AknLayoutUtils::LayoutLabel( head, headingArea.Rect(), headingText, iEikonEnv->NormalFont()); |
|
1214 |
|
1215 // ceiklabel needs additional margins for the drawing |
|
1216 head->iMargin.iBottom = head->Size().iHeight - head->Font()->HeightInPixels(); |
|
1217 // heading background rect |
|
1218 iExtension->SetRect( headingArea.Rect() ); |
|
1219 |
|
1220 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
1221 |
|
1222 TRgb color; |
|
1223 TInt error = AknsUtils::GetCachedColor( skin, color, |
|
1224 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19 ); |
|
1225 if (!error) |
|
1226 { |
|
1227 // Ignore error |
|
1228 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( *head, |
|
1229 EColorLabelText, color ) ); |
|
1230 } |
|
1231 } |
|
1232 } |
|
1233 |
|
1234 |
|
1235 // ----------------------------------------------------------------------------- |
|
1236 // CAknPopupForm::EditorLayout |
|
1237 // Get layout information for the control and use this layout |
|
1238 // information to do the layout. |
|
1239 // ----------------------------------------------------------------------------- |
|
1240 // |
|
1241 void CAknPopupForm::EditorLayout() |
|
1242 { |
|
1243 CEikCaptionedControl* captionedControl = GetControlByControlType( EEikCtRichTextEditor ); |
|
1244 CEikRichTextEditor* ed = NULL; |
|
1245 if ( captionedControl ) |
|
1246 { |
|
1247 CCoeControl* coe = captionedControl->iControl; |
|
1248 ed = reinterpret_cast<CEikRichTextEditor*>( coe ); |
|
1249 } |
|
1250 |
|
1251 if ( ed ) |
|
1252 { |
|
1253 // update flags to get the font type |
|
1254 UpdateFlags( EPopupFormEditor, ETrue ); |
|
1255 |
|
1256 TRect layParent = Rect(); |
|
1257 |
|
1258 TAknMultiLineTextLayout layWin; |
|
1259 layWin = EditorTextLineLayout(); |
|
1260 if ( iFlags.IsSet( EPopupFormHasHeading ) ) |
|
1261 { |
|
1262 TAknWindowLineLayout headingLayout = AknLayoutScalable_Avkon::heading_pane( 0 ); |
|
1263 TAknLayoutRect headingRect; |
|
1264 headingRect.LayoutRect( Rect(), headingLayout ); |
|
1265 |
|
1266 // Add the height of the heading to the position of the editor |
|
1267 layParent.iTl.iY += headingRect.Rect().Height(); |
|
1268 } |
|
1269 AknLayoutUtils::LayoutEdwin( ed, layParent, layWin, /*EAknsCIQsnTextColorsCG27*/ EAknsCIQsnTextColorsCG19 ); |
|
1270 CalculateNumberOfScreens(); |
|
1271 TRAP_IGNORE( UpdateScrollIndicatorL() ); |
|
1272 } |
|
1273 } |
|
1274 |
|
1275 // ----------------------------------------------------------------------------- |
|
1276 // CAknPopupForm::ImageLayout |
|
1277 // Get layout information for the control and use this layout |
|
1278 // information to do the layout. |
|
1279 // ----------------------------------------------------------------------------- |
|
1280 // |
|
1281 void CAknPopupForm::ImageLayout() |
|
1282 { |
|
1283 CEikCaptionedControl* captionedControl = GetControlByControlType( EEikCtImage ); |
|
1284 CEikImage* img = NULL; |
|
1285 if ( captionedControl ) |
|
1286 { |
|
1287 CCoeControl* coe = captionedControl->iControl; |
|
1288 img = reinterpret_cast<CEikImage*>( coe ); |
|
1289 } |
|
1290 |
|
1291 TAknWindowLineLayout layWin; |
|
1292 // If scrollbar is enabled |
|
1293 if ( TextIsScrollable() ) |
|
1294 { |
|
1295 layWin = AknLayoutScalable_Avkon::popup_midp_note_alarm_window_g1(8); |
|
1296 } |
|
1297 else |
|
1298 { |
|
1299 layWin = AknLayoutScalable_Avkon::popup_midp_note_alarm_window_g1( 0 ); |
|
1300 } |
|
1301 |
|
1302 TRect layParent = Rect(); |
|
1303 if ( iFlags.IsSet( EPopupFormHasHeading ) ) |
|
1304 { |
|
1305 TAknWindowLineLayout headingLayout = AknLayoutScalable_Avkon::heading_pane( 0 ); |
|
1306 TAknLayoutRect headingRect; |
|
1307 headingRect.LayoutRect( Rect(), headingLayout ); |
|
1308 |
|
1309 // Add the height of the heading to the position of the editor |
|
1310 layParent.iTl.iY += headingRect.Rect().Height(); |
|
1311 } |
|
1312 if ( img ) |
|
1313 { |
|
1314 AknLayoutUtils::LayoutImage( img, layParent, layWin ); |
|
1315 } |
|
1316 } |
|
1317 |
|
1318 // ----------------------------------------------------------------------------- |
|
1319 // CAknPopupForm::ProgressBarLayout |
|
1320 // Get layout information for the control and use this layout |
|
1321 // information to do the layout. |
|
1322 // ----------------------------------------------------------------------------- |
|
1323 // |
|
1324 void CAknPopupForm::ProgressBarLayout() |
|
1325 { |
|
1326 CEikCaptionedControl* captionedControl = GetControlByControlType( EEikCtProgInfo ); |
|
1327 CEikProgressInfo* pri = NULL; |
|
1328 if ( captionedControl ) |
|
1329 { |
|
1330 CCoeControl* coe = captionedControl->iControl; |
|
1331 pri = reinterpret_cast<CEikProgressInfo*>( coe ); |
|
1332 } |
|
1333 |
|
1334 if ( pri ) |
|
1335 { |
|
1336 |
|
1337 TAknWindowLineLayout layWin = |
|
1338 AknLayoutScalable_Avkon::wait_bar_pane_cp1( DetermineBarLayoutVariant() ); |
|
1339 TRect layParent = Rect(); |
|
1340 if ( iFlags.IsSet( EPopupFormHasHeading ) ) |
|
1341 { |
|
1342 TAknWindowLineLayout headingLayout = AknLayoutScalable_Avkon::heading_pane( 0 ); |
|
1343 TAknLayoutRect headingRect; |
|
1344 headingRect.LayoutRect( Rect(), headingLayout ); |
|
1345 |
|
1346 // Add the height of the heading to the position of the progbar |
|
1347 layParent.iTl.iY += headingRect.Rect().Height(); |
|
1348 } |
|
1349 |
|
1350 AknLayoutUtils::LayoutControl( pri, layParent, layWin); |
|
1351 } |
|
1352 } |
|
1353 |
|
1354 // ----------------------------------------------------------------------------- |
|
1355 // CAknPopupForm::SpacerLayout |
|
1356 // Get layout information for the control and use this layout |
|
1357 // information to do the layout. |
|
1358 // ----------------------------------------------------------------------------- |
|
1359 // |
|
1360 void CAknPopupForm::SpacerLayout() |
|
1361 { |
|
1362 CEikCaptionedControl* captionedControl = GetControlByControlType( EEikCtSpacer ); |
|
1363 CEikSpacer* space = NULL; |
|
1364 if ( captionedControl ) |
|
1365 { |
|
1366 CCoeControl* coe = captionedControl->iControl; |
|
1367 space = reinterpret_cast<CEikSpacer*>( coe ); |
|
1368 } |
|
1369 |
|
1370 if ( space ) |
|
1371 { |
|
1372 space->MakeVisible( EFalse ); |
|
1373 } |
|
1374 } |
|
1375 |
|
1376 // ----------------------------------------------------------------------------- |
|
1377 // CAknPopupForm::AnimationLayoutL |
|
1378 // Get layout information for the control and use this layout |
|
1379 // information to do the layout. |
|
1380 // |
|
1381 // ----------------------------------------------------------------------------- |
|
1382 // |
|
1383 void CAknPopupForm::AnimationLayoutL() |
|
1384 { |
|
1385 CEikCaptionedControl* captionedControl = GetControlByControlTypeL( EPopupFormAnimation ); |
|
1386 |
|
1387 CAknBitmapAnimation* ani = NULL; |
|
1388 CCoeControl* coe = NULL; |
|
1389 if ( captionedControl ) |
|
1390 { |
|
1391 coe = captionedControl->iControl; |
|
1392 ani = reinterpret_cast<CAknBitmapAnimation*>( coe ); |
|
1393 } |
|
1394 |
|
1395 TAknWindowLineLayout layWin; |
|
1396 |
|
1397 if ( ani ) |
|
1398 { |
|
1399 // If scrollbar is enabled |
|
1400 if ( TextIsScrollable() ) |
|
1401 { |
|
1402 layWin = AknLayoutScalable_Avkon::popup_midp_note_alarm_window_g1( 8 ); |
|
1403 } |
|
1404 else |
|
1405 { |
|
1406 layWin = AknLayoutScalable_Avkon::popup_midp_note_alarm_window_g1( 0 ); |
|
1407 } |
|
1408 TRect layParent = Rect(); |
|
1409 if ( iFlags.IsSet( EPopupFormHasHeading ) ) |
|
1410 { |
|
1411 TAknWindowLineLayout headingLayout = AknLayoutScalable_Avkon::heading_pane( 0 ); |
|
1412 TAknLayoutRect headingRect; |
|
1413 headingRect.LayoutRect( Rect(), headingLayout ); |
|
1414 |
|
1415 // Add the height of the heading to the position of the editor |
|
1416 layParent.iTl.iY += headingRect.Rect().Height(); |
|
1417 } |
|
1418 AknLayoutUtils::LayoutControl( coe, layParent, layWin); |
|
1419 } |
|
1420 } |
|
1421 |
|
1422 // ----------------------------------------------------------------------------- |
|
1423 // CAknPopupForm::WaitAnimationLayoutL |
|
1424 // Get layout information for the control and use this layout |
|
1425 // information to do the layout. |
|
1426 // |
|
1427 // ----------------------------------------------------------------------------- |
|
1428 // |
|
1429 void CAknPopupForm::WaitAnimationLayoutL() |
|
1430 { |
|
1431 |
|
1432 CEikCaptionedControl* captionedControl = GetControlByControlTypeL( EPopupFormWaitAnim ); |
|
1433 CCoeControl* coe = NULL; |
|
1434 CAknBitmapAnimation* ani = NULL; |
|
1435 if ( captionedControl ) |
|
1436 { |
|
1437 coe =captionedControl->iControl; |
|
1438 ani = reinterpret_cast<CAknBitmapAnimation*>( coe ); |
|
1439 } |
|
1440 |
|
1441 if ( ani ) |
|
1442 { |
|
1443 TAknWindowLineLayout layWin = AknLayoutScalable_Avkon::wait_bar_pane_cp1( DetermineBarLayoutVariant() ); |
|
1444 TRect layParent = Rect(); |
|
1445 |
|
1446 if ( iFlags.IsSet( EPopupFormHasHeading ) ) |
|
1447 { |
|
1448 TAknWindowLineLayout headingLayout = AknLayoutScalable_Avkon::heading_pane( 0 ); |
|
1449 TAknLayoutRect headingRect; |
|
1450 headingRect.LayoutRect( Rect(), headingLayout ); |
|
1451 |
|
1452 // Add the height of the heading to the position of the wait animation |
|
1453 layParent.iTl.iY += headingRect.Rect().Height(); |
|
1454 } |
|
1455 |
|
1456 // make sure that the wait animation fills the whole wait animation rectangle |
|
1457 ani->SetScaleModeForAnimationFrames(EAspectRatioNotPreserved); |
|
1458 |
|
1459 AknLayoutUtils::LayoutControl( coe, layParent, layWin); |
|
1460 } |
|
1461 } |
|
1462 // ----------------------------------------------------------------------------- |
|
1463 // CAknPopupForm::CalculateNumberOfScreens |
|
1464 // Calculate the number of screens needed to show all the text in the editor. |
|
1465 // Text scrolls so that the last line of the previous page is the first line |
|
1466 // of the new page. |
|
1467 // Store the value to the iNoOfScreens member. |
|
1468 // ----------------------------------------------------------------------------- |
|
1469 // |
|
1470 void CAknPopupForm::CalculateNumberOfScreens() |
|
1471 { |
|
1472 if ( iFlags.IsSet ( EPopupFormHasEditor ) ) |
|
1473 { |
|
1474 TInt maxLines = KMaxNoOfEditorLines; |
|
1475 |
|
1476 if ( !iFlags.IsSet( EPopupFormUsesPlainFont ) ) |
|
1477 { |
|
1478 --maxLines; |
|
1479 } |
|
1480 CEikCaptionedControl* captionedControl = GetControlByControlType( EEikCtRichTextEditor ); |
|
1481 CEikRichTextEditor* ed = NULL; |
|
1482 if ( captionedControl ) |
|
1483 { |
|
1484 CCoeControl* coe = captionedControl->iControl; |
|
1485 ed = reinterpret_cast<CEikRichTextEditor*>( coe ); |
|
1486 } |
|
1487 if ( ed ) |
|
1488 { |
|
1489 |
|
1490 if ( ed->TextLength() >= ed->UpperFullFormattingLength() && ed->TextView() != NULL ) |
|
1491 { |
|
1492 // Force formatting of all text |
|
1493 ed->TextLayout()->SetAmountToFormat( CTextLayout::EFFormatAllText ); |
|
1494 TRAP_IGNORE(ed->TextView()->FormatTextL()); |
|
1495 TRAP_IGNORE(ed->TextView()->FinishBackgroundFormattingL()); |
|
1496 } |
|
1497 |
|
1498 iNoOfEditorLines = ed->TextLayout()->NumFormattedLines(); |
|
1499 |
|
1500 if ( iFlags.IsSet( EPopupFormHasProgbar ) |
|
1501 || iFlags.IsSet( EPopupFormHasWaitAnim ) ) |
|
1502 { |
|
1503 --maxLines; |
|
1504 } |
|
1505 if ( iNoOfEditorLines <= maxLines ) |
|
1506 { |
|
1507 iNoOfScreens = 1; |
|
1508 } |
|
1509 else |
|
1510 { |
|
1511 if ( ( ( iNoOfEditorLines - 1 ) % ( maxLines - 1 ) ) == 0 ) |
|
1512 { |
|
1513 iNoOfScreens = ( iNoOfEditorLines - 1 ) / ( maxLines - 1 ); |
|
1514 } |
|
1515 else |
|
1516 { |
|
1517 iNoOfScreens = ( iNoOfEditorLines - 1 ) / ( maxLines- 1 ) + 1; |
|
1518 } |
|
1519 } |
|
1520 |
|
1521 iCurrentLine = 1; |
|
1522 iExtension->iCursorLine = 1; |
|
1523 TRAP_IGNORE(ed->SetCursorPosL( 0, EFalse )); |
|
1524 } |
|
1525 } |
|
1526 else |
|
1527 { |
|
1528 iNoOfScreens = 1; |
|
1529 iNoOfEditorLines = 0; |
|
1530 } |
|
1531 } |
|
1532 |
|
1533 // ----------------------------------------------------------------------------- |
|
1534 // CAknPopupForm::UpdateScrollIndicatorL |
|
1535 // Updates the scroll indicator to reflect current text position. |
|
1536 // |
|
1537 // ----------------------------------------------------------------------------- |
|
1538 // |
|
1539 void CAknPopupForm::UpdateScrollIndicatorL() |
|
1540 { |
|
1541 if ( !iFlags.IsSet( EPopupFormHasEditor ) || iNoOfScreens <= 1 ) |
|
1542 { |
|
1543 if ( iSBFrame ) |
|
1544 { |
|
1545 delete iSBFrame; |
|
1546 iSBFrame = NULL; |
|
1547 } |
|
1548 return; |
|
1549 } |
|
1550 if ( !iSBFrame ) |
|
1551 { |
|
1552 iSBFrame=NULL; |
|
1553 |
|
1554 // EDoubleSpan type scrollbar |
|
1555 if( AknLayoutUtils::PenEnabled() ) |
|
1556 { |
|
1557 iSBFrame=new (ELeave) CEikScrollBarFrame( this, NULL, ETrue ); |
|
1558 iSBFrame->CreateDoubleSpanScrollBarsL( ETrue, EFalse, ETrue, EFalse ); // window owning scrollbar |
|
1559 } |
|
1560 else |
|
1561 { |
|
1562 iSBFrame=new (ELeave) CEikScrollBarFrame( this, NULL, ETrue ); |
|
1563 iSBFrame->CreateDoubleSpanScrollBarsL( EFalse, EFalse, ETrue, EFalse ); // non-window owning scrollbar |
|
1564 } |
|
1565 iSBFrame->SetTypeOfVScrollBar( CEikScrollBarFrame::EDoubleSpan ); |
|
1566 iSBFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, |
|
1567 CEikScrollBarFrame::EAuto ); |
|
1568 |
|
1569 } |
|
1570 TRect parentRect = Rect(); |
|
1571 |
|
1572 if ( AknLayoutUtils::PenEnabled() ) |
|
1573 { |
|
1574 CEikCba* cba = static_cast<CEikCba*>( |
|
1575 ButtonGroupContainer().ButtonGroup() ); |
|
1576 if ( cba->IsVisible() && !cba->IsEmpty() ) |
|
1577 { |
|
1578 parentRect.iBr.iY -= cba->Rect().Height(); |
|
1579 } |
|
1580 } |
|
1581 |
|
1582 if ( iFlags.IsSet( EPopupFormHasHeading ) ) |
|
1583 { |
|
1584 TAknWindowLineLayout headingLayout = AknLayoutScalable_Avkon::heading_pane( 0 ); |
|
1585 TAknLayoutRect headingRect; |
|
1586 headingRect.LayoutRect( Rect(), headingLayout ); |
|
1587 |
|
1588 // Add the height of the heading to the position of the wait animation |
|
1589 parentRect.iTl.iY += headingRect.Rect().Height(); |
|
1590 } |
|
1591 |
|
1592 AknLayoutUtils::LayoutVerticalScrollBar( iSBFrame, parentRect, AknLayoutScalable_Avkon::scroll_pane_cp17( 0 ).LayoutLine() ); //cp7 0-3 varietys |
|
1593 iSBFrame->SetScrollBarFrameObserver( iExtension ); |
|
1594 TEikScrollBarModel hSbarModel; |
|
1595 TEikScrollBarModel vSbarModel; |
|
1596 vSbarModel.iThumbPosition = iCurrentLine - 1; // -1 because the value has already |
|
1597 // been incremented in OfferKeyEvent |
|
1598 vSbarModel.iScrollSpan = iNoOfEditorLines; |
|
1599 |
|
1600 if( iFlags.IsSet( EPopupFormUsesPlainFont ) ) |
|
1601 { |
|
1602 vSbarModel.iThumbSpan = KMaxNoOfEditorLines; |
|
1603 } |
|
1604 else if( iFlags.IsSet( EPopupFormWaitAnim ) || iFlags.IsSet( EPopupFormProgbar )) |
|
1605 { |
|
1606 vSbarModel.iThumbSpan = KMaxNoOfEditorLines-2; |
|
1607 } |
|
1608 else |
|
1609 { |
|
1610 vSbarModel.iThumbSpan = KMaxNoOfEditorLines-1; |
|
1611 } |
|
1612 |
|
1613 |
|
1614 TEikScrollBarFrameLayout layout; |
|
1615 iSBFrame->TileL( &hSbarModel, &vSbarModel, parentRect, parentRect,layout ); |
|
1616 iSBFrame->SetVFocusPosToThumbPos( vSbarModel.iThumbPosition ); |
|
1617 iSBFrame->DrawScrollBarsNow(); |
|
1618 } |
|
1619 |
|
1620 // ----------------------------------------------------------------------------- |
|
1621 // CAknPopupForm::ReportUserInactivity |
|
1622 // |
|
1623 // |
|
1624 // ----------------------------------------------------------------------------- |
|
1625 // |
|
1626 void CAknPopupForm::ReportUserActivity() const |
|
1627 { |
|
1628 User::ResetInactivityTime(); |
|
1629 } |
|
1630 |
|
1631 // ----------------------------------------------------------------------------- |
|
1632 // CAknPopupForm::StartAnimationL |
|
1633 // If there is an animation, start it |
|
1634 // |
|
1635 // ----------------------------------------------------------------------------- |
|
1636 // |
|
1637 void CAknPopupForm::StartAnimationL() |
|
1638 { |
|
1639 // We can have two animations (wait and regular). |
|
1640 // Check if they exist and start them. |
|
1641 CEikCaptionedControl* captionedControl = GetControlByControlTypeL( EPopupFormAnimation ); |
|
1642 if ( captionedControl ) |
|
1643 { |
|
1644 CCoeControl* coe = captionedControl->iControl; |
|
1645 CAknBitmapAnimation* ani = reinterpret_cast<CAknBitmapAnimation*>( coe ); |
|
1646 if ( ani ) |
|
1647 { |
|
1648 ani->StartAnimationL(); |
|
1649 } |
|
1650 } |
|
1651 CEikCaptionedControl* cap2 = GetControlByControlTypeL( EPopupFormWaitAnim ); |
|
1652 if ( cap2 ) |
|
1653 { |
|
1654 CCoeControl* coe = cap2->iControl; |
|
1655 CAknBitmapAnimation* ani = reinterpret_cast<CAknBitmapAnimation*>( coe ); |
|
1656 if ( ani ) |
|
1657 { |
|
1658 ani->StartAnimationL(); |
|
1659 } |
|
1660 } |
|
1661 |
|
1662 } |
|
1663 |
|
1664 // ----------------------------------------------------------------------------- |
|
1665 // CAknPopupForm::DetermineAnimationType |
|
1666 // Check if wait animation resource index is defined to |
|
1667 // to see if popupform has a wait animation. |
|
1668 // ----------------------------------------------------------------------------- |
|
1669 // |
|
1670 TAnimationType CAknPopupForm::DetermineAnimationType( const CAknBitmapAnimation* anAnimation ) |
|
1671 { |
|
1672 // if wait animation hasn't been defined, animation has to be of regular type |
|
1673 if ( iExtension->iWaitAnimationResourceIndex < 0 ) |
|
1674 { |
|
1675 return ERegularAnimation; |
|
1676 } |
|
1677 |
|
1678 // the given control is the same as the wait animation |
|
1679 if ( Control( iExtension->iWaitAnimationResourceIndex ) == anAnimation ) |
|
1680 { |
|
1681 return EWaitAnimation; |
|
1682 } |
|
1683 // the given control is not wait animation, but regular animation |
|
1684 else |
|
1685 { |
|
1686 return ERegularAnimation; |
|
1687 } |
|
1688 } |
|
1689 |
|
1690 // ----------------------------------------------------------------------------- |
|
1691 // CAknPopupForm::ProgressInfo |
|
1692 // If there is a progress info control on the form, return it. |
|
1693 // |
|
1694 // ----------------------------------------------------------------------------- |
|
1695 // |
|
1696 EXPORT_C CEikProgressInfo* CAknPopupForm::ProgressInfo() |
|
1697 { |
|
1698 if( iFlags.IsSet( EPopupFormHasProgbar ) ) |
|
1699 { |
|
1700 CEikCaptionedControl* captionedControl = GetControlByControlType( EEikCtProgInfo ); |
|
1701 CEikProgressInfo* pri = NULL; |
|
1702 if ( captionedControl ) |
|
1703 { |
|
1704 CCoeControl* coe = captionedControl->iControl; |
|
1705 pri = reinterpret_cast<CEikProgressInfo*>( coe ); |
|
1706 } |
|
1707 return pri; |
|
1708 } |
|
1709 else |
|
1710 { |
|
1711 return NULL; |
|
1712 } |
|
1713 } |
|
1714 |
|
1715 // ----------------------------------------------------------------------------- |
|
1716 // CAknPopupForm::SetImage |
|
1717 // Change the image. |
|
1718 // |
|
1719 // ----------------------------------------------------------------------------- |
|
1720 // |
|
1721 EXPORT_C void CAknPopupForm::SetImageL( const CEikImage* aImage ) |
|
1722 { |
|
1723 // if the parameter is null, remove the image if there is one |
|
1724 if( !aImage ) |
|
1725 { |
|
1726 if ( iFlags.IsSet ( EPopupFormHasImage ) ) |
|
1727 { |
|
1728 DeleteControl( EEikCtImage ); |
|
1729 } |
|
1730 return; |
|
1731 } |
|
1732 |
|
1733 CEikCaptionedControl* captionedControl = GetControlByControlType( EEikCtImage ); |
|
1734 CEikImage* img = NULL; |
|
1735 if ( captionedControl ) |
|
1736 { |
|
1737 CCoeControl* coe = captionedControl->iControl; |
|
1738 img = reinterpret_cast<CEikImage*>( coe ); |
|
1739 } |
|
1740 |
|
1741 if ( img ) |
|
1742 { |
|
1743 // There must already be an image on the form. |
|
1744 __ASSERT_ALWAYS( img, Panic( EAknPanicNullPointer ) ); |
|
1745 |
|
1746 ClearArea( img->Rect() ); |
|
1747 |
|
1748 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap(); |
|
1749 CleanupStack::PushL( bitmap ); |
|
1750 |
|
1751 bitmap->Duplicate( aImage->Bitmap()->Handle() ); |
|
1752 img->SetPicture( bitmap ); // set the image |
|
1753 |
|
1754 const CFbsBitmap* maskImage = aImage->Mask(); |
|
1755 if( maskImage ) |
|
1756 { |
|
1757 CFbsBitmap* mask = new (ELeave) CFbsBitmap(); |
|
1758 CleanupStack::PushL( mask ); |
|
1759 mask->Duplicate( maskImage->Handle() ); |
|
1760 img->SetMask(mask); |
|
1761 //img->SetPicture( bitmap, mask); |
|
1762 CleanupStack::Pop(); // mask |
|
1763 } |
|
1764 |
|
1765 CleanupStack::Pop(); // bitmap |
|
1766 LayoutAndDraw(); |
|
1767 } |
|
1768 } |
|
1769 // ----------------------------------------------------------------------------- |
|
1770 // CAknPopupForm::SetCallback |
|
1771 // Set the callback pointer. |
|
1772 // |
|
1773 // ----------------------------------------------------------------------------- |
|
1774 // |
|
1775 EXPORT_C void CAknPopupForm::SetCallback( MPopupFormProgressCallback* aCallback ) |
|
1776 { |
|
1777 iCallback = aCallback; |
|
1778 } |
|
1779 |
|
1780 // ----------------------------------------------------------------------------- |
|
1781 // CAknPopupForm::OkToExitL |
|
1782 // Dismiss the dialog by calling the callback class' DialogDismissedL |
|
1783 // |
|
1784 // ----------------------------------------------------------------------------- |
|
1785 // |
|
1786 EXPORT_C TBool CAknPopupForm::OkToExitL(TInt aButtonId) |
|
1787 { |
|
1788 if ( aButtonId == EAknSoftkeyEmpty ) |
|
1789 { |
|
1790 return EFalse; |
|
1791 } |
|
1792 if ( iCallback ) |
|
1793 { |
|
1794 iCallback->DialogDismissedL( aButtonId ); |
|
1795 } |
|
1796 return ETrue; |
|
1797 } |
|
1798 |
|
1799 // ----------------------------------------------------------------------------- |
|
1800 // CAknPopupForm::ProcessFinishedL |
|
1801 // Called when the process the progress bar is measuring finishes. |
|
1802 // |
|
1803 // ----------------------------------------------------------------------------- |
|
1804 // |
|
1805 EXPORT_C void CAknPopupForm::ProcessFinishedL() |
|
1806 { |
|
1807 ReportUserActivity(); |
|
1808 PlayTone(); |
|
1809 TryExitL( EAknSoftkeyDone ); |
|
1810 } |
|
1811 |
|
1812 // ----------------------------------------------------------------------------- |
|
1813 |
|
1814 |
|
1815 |
|
1816 // CAknPopupForm::InsertControlL |
|
1817 // Insert a control to the popupform. |
|
1818 // Deprecated; use the three parameter version instead! |
|
1819 // ----------------------------------------------------------------------------- |
|
1820 // |
|
1821 EXPORT_C void CAknPopupForm::InsertControlL( const TInt aIndex, const TInt aResourceId ) |
|
1822 { |
|
1823 InsertControlL( aIndex, aResourceId, EFalse ); |
|
1824 } |
|
1825 |
|
1826 // ----------------------------------------------------------------------------- |
|
1827 // CAknPopupForm::DeleteControl |
|
1828 // Delete control on the popupform. |
|
1829 // |
|
1830 // ----------------------------------------------------------------------------- |
|
1831 // |
|
1832 EXPORT_C void CAknPopupForm::DeleteControl( const TInt aControlType ) |
|
1833 { |
|
1834 CEikCaptionedControl* ctrl; |
|
1835 ctrl = GetControlByControlType( aControlType ); |
|
1836 |
|
1837 TPopupFormControlType aPFCtrl = PopupFormControlType( ctrl ); |
|
1838 UpdateFlags( aPFCtrl, EFalse ); |
|
1839 |
|
1840 if ( ctrl ) |
|
1841 { |
|
1842 TRAP_IGNORE( DoDeleteControlL( ctrl ) ); |
|
1843 } |
|
1844 } |
|
1845 |
|
1846 |
|
1847 // ----------------------------------------------------------------------------- |
|
1848 // CAknPopupForm::UpdateFlags |
|
1849 // Set/clear flags. |
|
1850 // |
|
1851 // ----------------------------------------------------------------------------- |
|
1852 // |
|
1853 void CAknPopupForm::UpdateFlags( const TPopupFormControlType aControlType, const TBool aInsert ) |
|
1854 { |
|
1855 if ( aInsert ) |
|
1856 { |
|
1857 // add a flag if needed |
|
1858 switch ( aControlType ) |
|
1859 { |
|
1860 case EPopupFormImage: |
|
1861 iFlags.Set( EPopupFormHasImage ); |
|
1862 break; |
|
1863 |
|
1864 case EPopupFormAnimation: |
|
1865 iFlags.Set( EPopupFormHasAnimation ); |
|
1866 break; |
|
1867 |
|
1868 case EPopupFormWaitAnim: |
|
1869 iFlags.Set( EPopupFormHasWaitAnim ); |
|
1870 break; |
|
1871 |
|
1872 case EPopupFormHeading: |
|
1873 iFlags.Set( EPopupFormHasHeading ); |
|
1874 break; |
|
1875 |
|
1876 case EPopupFormSpacer: |
|
1877 iFlags.Set( EPopupFormHasSpacer ); |
|
1878 break; |
|
1879 |
|
1880 case EPopupFormProgbar: |
|
1881 iFlags.Set( EPopupFormHasProgbar ); |
|
1882 break; |
|
1883 |
|
1884 case EPopupFormEditor: |
|
1885 iFlags.Set( EPopupFormHasEditor ); |
|
1886 break; |
|
1887 case EPopupFormUnknown: |
|
1888 default: |
|
1889 break; |
|
1890 } |
|
1891 } |
|
1892 else |
|
1893 { |
|
1894 // remove a flag if needed |
|
1895 switch ( aControlType ) |
|
1896 { |
|
1897 case EPopupFormImage: |
|
1898 iFlags.Clear( EPopupFormHasImage ); |
|
1899 break; |
|
1900 |
|
1901 case EPopupFormAnimation: |
|
1902 iFlags.Clear( EPopupFormHasAnimation ); |
|
1903 break; |
|
1904 |
|
1905 case EPopupFormWaitAnim: |
|
1906 iFlags.Clear( EPopupFormHasWaitAnim ); |
|
1907 break; |
|
1908 |
|
1909 case EPopupFormHeading: |
|
1910 iFlags.Clear( EPopupFormHasHeading ); |
|
1911 iExtension->iHasLabelBackground = EFalse; |
|
1912 break; |
|
1913 |
|
1914 case EPopupFormSpacer: |
|
1915 iFlags.Clear( EPopupFormHasSpacer ); |
|
1916 break; |
|
1917 |
|
1918 case EPopupFormProgbar: |
|
1919 iFlags.Clear( EPopupFormHasProgbar ); |
|
1920 break; |
|
1921 |
|
1922 case EPopupFormEditor: |
|
1923 iFlags.Clear( EPopupFormHasEditor ); |
|
1924 break; |
|
1925 |
|
1926 case EPopupFormUnknown: |
|
1927 default: |
|
1928 break; |
|
1929 } |
|
1930 } |
|
1931 // set the font type, plain font is used only with scrollable |
|
1932 // text without icon, anim or progbar |
|
1933 if ( iFlags.IsSet( EPopupFormHasProgbar ) |
|
1934 || iFlags.IsSet( EPopupFormHasWaitAnim ) |
|
1935 || iFlags.IsSet( EPopupFormHasImage ) |
|
1936 || iFlags.IsSet( EPopupFormHasAnimation ) |
|
1937 || iNoOfEditorLines < KMaxNoOfEditorLines) |
|
1938 { |
|
1939 iFlags.Clear( EPopupFormUsesPlainFont ); |
|
1940 } |
|
1941 else |
|
1942 { |
|
1943 iFlags.Set( EPopupFormUsesPlainFont ); |
|
1944 } |
|
1945 } |
|
1946 |
|
1947 |
|
1948 // ----------------------------------------------------------------------------- |
|
1949 // CAknPopupForm::ClearArea |
|
1950 // ----------------------------------------------------------------------------- |
|
1951 // |
|
1952 void CAknPopupForm::ClearArea( const TRect& aRect ) |
|
1953 { |
|
1954 CWindowGc& gc = SystemGc(); |
|
1955 ActivateGc(); |
|
1956 gc.Clear( aRect ); |
|
1957 DeactivateGc(); |
|
1958 } |
|
1959 |
|
1960 |
|
1961 // ----------------------------------------------------------------------------- |
|
1962 // CAknPopupForm::RedrawHeading |
|
1963 // ----------------------------------------------------------------------------- |
|
1964 // |
|
1965 void CAknPopupForm::RedrawHeading() |
|
1966 { |
|
1967 if ( iFlags.IsSet( EPopupFormHasHeading ) ) |
|
1968 { |
|
1969 CEikCaptionedControl* captionedControl = GetControlByControlType( EEikCtLabel ); |
|
1970 CCoeControl* ctrl = NULL; |
|
1971 if ( captionedControl ) |
|
1972 { |
|
1973 ctrl = captionedControl->iControl; |
|
1974 if ( ctrl ) |
|
1975 { |
|
1976 ctrl->DrawNow(); |
|
1977 } |
|
1978 } |
|
1979 } |
|
1980 } |
|
1981 |
|
1982 // ----------------------------------------------------------------------------- |
|
1983 // CAknPopupForm::Extension |
|
1984 // ----------------------------------------------------------------------------- |
|
1985 // |
|
1986 CAknPopupFormExtension* CAknPopupForm::Extension() |
|
1987 { |
|
1988 __ASSERT_DEBUG( iExtension, |
|
1989 Panic( EAknPanicObjectNotFullyConstructed ) ); |
|
1990 |
|
1991 return iExtension; |
|
1992 } |
|
1993 |
|
1994 // ----------------------------------------------------------------------------- |
|
1995 // CAknPopupForm::StartTimeoutTimerL |
|
1996 // ----------------------------------------------------------------------------- |
|
1997 // |
|
1998 void CAknPopupForm::StartTimeoutTimerL() |
|
1999 { |
|
2000 if ( iTimeoutInSeconds > 0 ) |
|
2001 { |
|
2002 if ( !iTimer ) |
|
2003 { |
|
2004 TRAP_IGNORE( iTimer = CPeriodic::NewL( 0 ) ); |
|
2005 } |
|
2006 if ( iTimer->IsActive() ) |
|
2007 { |
|
2008 iTimer->Cancel(); |
|
2009 } |
|
2010 TInt timeoutInMicroseconds = iTimeoutInSeconds * 1000000; |
|
2011 iTimer->Start( timeoutInMicroseconds, timeoutInMicroseconds, |
|
2012 TCallBack( StaticDeleteL,this ) ); |
|
2013 } |
|
2014 else // iTimeoutInSeconds <= 0 |
|
2015 { |
|
2016 if ( iTimer && iTimeoutInSeconds == 0 ) |
|
2017 { |
|
2018 iTimer->Cancel(); |
|
2019 } |
|
2020 } |
|
2021 } |
|
2022 // ----------------------------------------------------------------------------- |
|
2023 // CAknPopupForm::TextIsScrollable |
|
2024 // ----------------------------------------------------------------------------- |
|
2025 // |
|
2026 EXPORT_C TBool CAknPopupForm::TextIsScrollable() |
|
2027 { |
|
2028 return ( ( iSBFrame && iNoOfScreens > 1 ) ? ETrue : EFalse ); |
|
2029 } |
|
2030 |
|
2031 // ----------------------------------------------------------------------------- |
|
2032 // CAknPopupForm::Flags() |
|
2033 // ----------------------------------------------------------------------------- |
|
2034 // |
|
2035 EXPORT_C TBitFlags& CAknPopupForm::Flags() |
|
2036 { |
|
2037 return iFlags; |
|
2038 } |
|
2039 |
|
2040 // ----------------------------------------------------------------------------- |
|
2041 // CAknPopupForm::GetControlByControlTypeL |
|
2042 // Loop through the array and return the control of given type. If a control of |
|
2043 // the given type was not found, return NULL |
|
2044 // ----------------------------------------------------------------------------- |
|
2045 // |
|
2046 EXPORT_C CEikCaptionedControl* CAknPopupForm::GetControlByControlTypeL( TPopupFormControlType aControl ) const |
|
2047 { |
|
2048 CEikCaptionedControl* controlPtr; |
|
2049 TInt activePage = ActivePageIndex(); |
|
2050 |
|
2051 // get the type of this control |
|
2052 TInt controlType = ControlType( aControl ); |
|
2053 |
|
2054 for ( TInt i = 0; i < iNoOfDialogLines; i++ ) |
|
2055 { |
|
2056 controlPtr = GetLineByLineAndPageIndex( i, activePage); |
|
2057 |
|
2058 if ( controlPtr && controlPtr->iControlType == controlType ) |
|
2059 { |
|
2060 if ( controlType == EAknCtBitmapAnimation ) |
|
2061 { |
|
2062 // wait animation is requested and this is it |
|
2063 if ( aControl == EPopupFormWaitAnim // function wants to find wait animation |
|
2064 && iExtension->iWaitAnimationResourceIndex >= 0 // wait animation exists |
|
2065 // it is the same as current control |
|
2066 && Line( iExtension->iWaitAnimationResourceIndex ) == controlPtr ) |
|
2067 { |
|
2068 controlPtr->iControl->SetContainerWindowL( *this ); |
|
2069 controlPtr->iControl->SetControlContext( iBrushAndPenContext ); |
|
2070 return controlPtr; |
|
2071 } |
|
2072 // regular animation is requested and this is it |
|
2073 else if ( aControl == EPopupFormAnimation // function wants to find regular animation |
|
2074 && ( ( iExtension->iWaitAnimationResourceIndex < 0 ) // and wait animation doesn't exists |
|
2075 // or wait animation exist but this is not it |
|
2076 || Line( iExtension->iWaitAnimationResourceIndex ) != controlPtr ) ) |
|
2077 { |
|
2078 controlPtr->iControl->SetContainerWindowL( *this ); |
|
2079 controlPtr->iControl->SetControlContext( iBrushAndPenContext ); |
|
2080 return controlPtr; |
|
2081 } |
|
2082 // no match |
|
2083 else |
|
2084 { |
|
2085 continue; |
|
2086 } |
|
2087 } |
|
2088 |
|
2089 controlPtr->iControl->SetContainerWindowL( *this ); |
|
2090 controlPtr->iControl->SetControlContext( iBrushAndPenContext ); |
|
2091 return controlPtr; |
|
2092 } |
|
2093 } |
|
2094 return NULL; |
|
2095 } |
|
2096 |
|
2097 // ----------------------------------------------------------------------------- |
|
2098 // CAknPopupForm::DeleteControl |
|
2099 // Delete control from the popup form. |
|
2100 // |
|
2101 // ----------------------------------------------------------------------------- |
|
2102 // |
|
2103 EXPORT_C void CAknPopupForm::DeleteControl( const TPopupFormControlType aControl) |
|
2104 { |
|
2105 CEikCaptionedControl* ctrl = NULL; |
|
2106 TRAP_IGNORE( { ctrl = GetControlByControlTypeL( aControl ); } ); |
|
2107 UpdateFlags( aControl, EFalse ); |
|
2108 if ( ctrl ) |
|
2109 { |
|
2110 TRAP_IGNORE( DoDeleteControlL( ctrl ) ); |
|
2111 } |
|
2112 } |
|
2113 |
|
2114 // ----------------------------------------------------------------------------- |
|
2115 // CAknPopupForm::DoDeleteControlL |
|
2116 // Really delete control from the popup form. |
|
2117 // |
|
2118 // ----------------------------------------------------------------------------- |
|
2119 // |
|
2120 void CAknPopupForm::DoDeleteControlL( CEikCaptionedControl* aControl ) |
|
2121 { |
|
2122 ClearArea( Rect() ); |
|
2123 |
|
2124 // If editor control is deleted, the popupform formats the number of editorlines to zero |
|
2125 if( aControl->iControlType == EEikCtRichTextEditor) |
|
2126 { |
|
2127 iNoOfEditorLines = 0; |
|
2128 } |
|
2129 // The location of waitanimationresourceindex is invalidated |
|
2130 // when the wait animation control is destroyed |
|
2131 else if ( aControl->iControlType == EAknCtBitmapAnimation ) |
|
2132 { |
|
2133 TAnimationType animType = DetermineAnimationType( reinterpret_cast<CAknBitmapAnimation*>( |
|
2134 aControl->iControl )); |
|
2135 if ( animType == EWaitAnimation ) |
|
2136 { |
|
2137 SetWaitAnimationResourceIndex( -1 ); |
|
2138 } |
|
2139 } |
|
2140 DeleteLine( aControl->iId, EFalse ); |
|
2141 iNoOfDialogLines = GetNumberOfLinesOnPage( ActivePageIndex() ); |
|
2142 |
|
2143 CalculateNumberOfScreens(); |
|
2144 LayoutAndDraw(); |
|
2145 TRAP_IGNORE( UpdateScrollIndicatorL() ); |
|
2146 } |
|
2147 |
|
2148 // ----------------------------------------------------------------------------- |
|
2149 // CAknPopupForm::ControlType |
|
2150 // |
|
2151 // ----------------------------------------------------------------------------- |
|
2152 // |
|
2153 TInt CAknPopupForm::ControlType( const TPopupFormControlType aControl ) const |
|
2154 { |
|
2155 switch( aControl ) |
|
2156 { |
|
2157 case EPopupFormHeading: |
|
2158 return EEikCtLabel; |
|
2159 |
|
2160 case EPopupFormImage: |
|
2161 return EEikCtImage; |
|
2162 |
|
2163 case EPopupFormAnimation: |
|
2164 return EAknCtBitmapAnimation; |
|
2165 |
|
2166 case EPopupFormWaitAnim: |
|
2167 return EAknCtBitmapAnimation; |
|
2168 |
|
2169 case EPopupFormProgbar: |
|
2170 return EEikCtProgInfo; |
|
2171 |
|
2172 case EPopupFormEditor: |
|
2173 return EEikCtRichTextEditor; |
|
2174 |
|
2175 case EPopupFormSpacer: |
|
2176 return EEikCtSpacer; |
|
2177 |
|
2178 default: |
|
2179 return KErrNotFound; |
|
2180 } |
|
2181 } |
|
2182 |
|
2183 // ----------------------------------------------------------------------------- |
|
2184 // CAknPopupForm::PopupFormControlType |
|
2185 // |
|
2186 // ----------------------------------------------------------------------------- |
|
2187 // |
|
2188 TPopupFormControlType CAknPopupForm::PopupFormControlType( CEikCaptionedControl* aControl ) |
|
2189 { |
|
2190 if ( !aControl ) |
|
2191 { |
|
2192 return EPopupFormUnknown; |
|
2193 } |
|
2194 TPopupFormControlType theControlType = EPopupFormUnknown; |
|
2195 switch ( aControl->iControlType ) |
|
2196 { |
|
2197 case EEikCtImage: |
|
2198 theControlType = EPopupFormImage; |
|
2199 break; |
|
2200 |
|
2201 case EAknCtBitmapAnimation: |
|
2202 switch ( DetermineAnimationType( |
|
2203 reinterpret_cast<CAknBitmapAnimation*>( aControl->iControl ) ) ) |
|
2204 { |
|
2205 case ERegularAnimation: |
|
2206 theControlType = EPopupFormAnimation; |
|
2207 break; |
|
2208 case EWaitAnimation: |
|
2209 theControlType = EPopupFormWaitAnim; |
|
2210 break; |
|
2211 } |
|
2212 break; |
|
2213 |
|
2214 case EEikCtLabel: |
|
2215 theControlType = EPopupFormHeading; |
|
2216 break; |
|
2217 |
|
2218 case EEikCtSpacer: |
|
2219 theControlType = EPopupFormSpacer; |
|
2220 break; |
|
2221 |
|
2222 case EEikCtProgInfo: |
|
2223 theControlType = EPopupFormProgbar; |
|
2224 break; |
|
2225 |
|
2226 case EEikCtRichTextEditor: |
|
2227 theControlType = EPopupFormEditor; |
|
2228 break; |
|
2229 |
|
2230 default: |
|
2231 theControlType = EPopupFormUnknown; |
|
2232 break; |
|
2233 } |
|
2234 return theControlType; |
|
2235 } |
|
2236 |
|
2237 // ----------------------------------------------------------------------------- |
|
2238 // CAknPopupForm::DetermineBarLayoutVariant |
|
2239 // |
|
2240 // ----------------------------------------------------------------------------- |
|
2241 // |
|
2242 TInt CAknPopupForm::DetermineBarLayoutVariant() const |
|
2243 { |
|
2244 |
|
2245 TInt numberOfLines = NumberOfVisibleLines(); |
|
2246 // Scrollbared popup form uses different layouts |
|
2247 if ( ( iSBFrame && iNoOfScreens > 1 ) ) |
|
2248 { |
|
2249 return 7; |
|
2250 } |
|
2251 else |
|
2252 { |
|
2253 switch( numberOfLines ) |
|
2254 { |
|
2255 case 0: |
|
2256 case 1: |
|
2257 case 2: |
|
2258 { |
|
2259 return 3; |
|
2260 } |
|
2261 case 3: |
|
2262 { |
|
2263 return 2; |
|
2264 } |
|
2265 case 4: |
|
2266 default: |
|
2267 { |
|
2268 return 0; |
|
2269 } |
|
2270 } |
|
2271 } |
|
2272 } |
|
2273 |
|
2274 // ----------------------------------------------------------------------------- |
|
2275 // CAknPopupForm::SetWaitAnimationResourceIndex |
|
2276 // |
|
2277 // ----------------------------------------------------------------------------- |
|
2278 // |
|
2279 EXPORT_C void CAknPopupForm::SetWaitAnimationResourceIndex( const TInt aIndex ) |
|
2280 { |
|
2281 iExtension->iWaitAnimationResourceIndex = aIndex; |
|
2282 } |
|
2283 // ----------------------------------------------------------------------------- |
|
2284 // CAknPopupForm::InsertControlL |
|
2285 // Insert control with info whether it is a wait animation or not |
|
2286 // ----------------------------------------------------------------------------- |
|
2287 // |
|
2288 EXPORT_C void CAknPopupForm::InsertControlL( const TInt aIndex, const TInt aResourceId, const TBool aIsWaitAnimation ) |
|
2289 { |
|
2290 TInt activePage = ActivePageIndex(); |
|
2291 |
|
2292 InsertLineL( aIndex, aResourceId, activePage ); |
|
2293 |
|
2294 CEikCaptionedControl* ctrl = ( CEikCaptionedControl* ) |
|
2295 GetLineByLineAndPageIndex( aIndex, activePage ); |
|
2296 if ( !ctrl ) |
|
2297 { |
|
2298 return; |
|
2299 } |
|
2300 ctrl->SetContainerWindowL( *this ); |
|
2301 ctrl->SetMopParent( this ); |
|
2302 ctrl->SetDrawNoWhiteBackground( ETrue ); |
|
2303 ctrl->SetControlContext( iBrushAndPenContext ); |
|
2304 iNoOfDialogLines = GetNumberOfLinesOnPage( activePage ); |
|
2305 |
|
2306 TPopupFormControlType ctrlType; |
|
2307 if( ctrl->iControlType == EAknCtBitmapAnimation ) |
|
2308 { |
|
2309 if( aIsWaitAnimation ) |
|
2310 { |
|
2311 ctrlType = EPopupFormWaitAnim; |
|
2312 SetAnimationSize( EPopupFormWaitAnim, ctrl ); |
|
2313 SetWaitAnimationResourceIndex( ctrl->iId ); |
|
2314 } |
|
2315 else |
|
2316 { |
|
2317 ctrlType = EPopupFormAnimation; |
|
2318 SetAnimationSize( EPopupFormAnimation, ctrl ); |
|
2319 } |
|
2320 } |
|
2321 else |
|
2322 { |
|
2323 ctrlType = PopupFormControlType( ctrl ); |
|
2324 |
|
2325 // background context for the label |
|
2326 if ( ctrlType == EPopupFormHeading && !iExtension->iHasLabelBackground ) |
|
2327 { |
|
2328 iExtension->iHasLabelBackground = ETrue; |
|
2329 iExtension->SetRect( Rect() ); |
|
2330 iExtension->SetParent( this ); |
|
2331 iExtension->SetControlContext( iBrushAndPenContext ); |
|
2332 } |
|
2333 } |
|
2334 |
|
2335 |
|
2336 UpdateFlags( ctrlType, ETrue ); |
|
2337 |
|
2338 CalculateNumberOfScreens(); |
|
2339 LayoutAndDraw(); |
|
2340 UpdateScrollIndicatorL(); |
|
2341 |
|
2342 if( ctrl->iControlType == EAknCtBitmapAnimation && IsActivated() ) |
|
2343 { |
|
2344 CAknBitmapAnimation* ani = reinterpret_cast<CAknBitmapAnimation*>( ctrl->iControl ); |
|
2345 if ( ani ) |
|
2346 { |
|
2347 ani->StartAnimationL(); |
|
2348 } |
|
2349 } |
|
2350 } |
|
2351 |
|
2352 |
|
2353 TInt CAknPopupForm::NumberOfVisibleLines() const |
|
2354 { |
|
2355 |
|
2356 TInt maxLines = KMaxNoOfEditorLines; |
|
2357 if ( !iFlags.IsSet( EPopupFormUsesPlainFont ) ) |
|
2358 { |
|
2359 // bold font |
|
2360 maxLines--; |
|
2361 |
|
2362 if ( iFlags.IsSet( EPopupFormHasProgbar ) |
|
2363 || iFlags.IsSet( EPopupFormHasWaitAnim ) ) |
|
2364 { |
|
2365 maxLines--; |
|
2366 } |
|
2367 } |
|
2368 return Min( maxLines, iNoOfEditorLines ); |
|
2369 } |
|
2370 |
|
2371 // ----------------------------------------------------------------------------- |
|
2372 // CAknPopupForm::SetAnimationSize |
|
2373 // |
|
2374 // ----------------------------------------------------------------------------- |
|
2375 // |
|
2376 void CAknPopupForm::SetAnimationSize( TPopupFormControlType aType, CEikCaptionedControl* anAnimation ) |
|
2377 { |
|
2378 if ( !anAnimation ) |
|
2379 { |
|
2380 return; |
|
2381 } |
|
2382 |
|
2383 CAknBitmapAnimation* ani = reinterpret_cast<CAknBitmapAnimation*>( anAnimation->iControl ); |
|
2384 if( ani ) |
|
2385 { |
|
2386 // Get the right rect for the animation |
|
2387 // (before it necessarily has been calculated in SetSizeAndPosition) |
|
2388 TRect parentRect = PopupWindowRect(); |
|
2389 |
|
2390 TAknLayoutRect layoutWindow; |
|
2391 if( aType == EPopupFormWaitAnim ) |
|
2392 { |
|
2393 layoutWindow.LayoutRect( parentRect, AknLayoutScalable_Avkon::wait_bar_pane_cp1( DetermineBarLayoutVariant() ) ); |
|
2394 } |
|
2395 else |
|
2396 { |
|
2397 layoutWindow.LayoutRect( parentRect, AknLayoutScalable_Avkon::popup_midp_note_alarm_window_g1( 0 ) ); |
|
2398 } |
|
2399 TRect animRect( layoutWindow.Rect() ); |
|
2400 |
|
2401 TInt endFrame = ani->BitmapAnimData()->FrameArray().Count() - 1; |
|
2402 |
|
2403 for ( TInt i=0; i<=endFrame; i++ ) |
|
2404 { |
|
2405 CFbsBitmap* bit = ani->BitmapAnimData()->FrameArray().At( i )->Bitmap(); |
|
2406 AknIconUtils::SetSize(bit, animRect.Size() ); |
|
2407 } |
|
2408 } |
|
2409 } |
|
2410 |
|
2411 // ----------------------------------------------------------------------------- |
|
2412 // CAknPopupForm::EditorTextLineLayout |
|
2413 // |
|
2414 // ----------------------------------------------------------------------------- |
|
2415 // |
|
2416 TAknMultiLineTextLayout CAknPopupForm::EditorTextLineLayout() |
|
2417 { |
|
2418 TInt numberOfLines = NumberOfVisibleLines(); |
|
2419 TInt firstVariant = 3; |
|
2420 |
|
2421 TAknTextComponentLayout firstlineLayout; |
|
2422 TAknTextComponentLayout secondlineLayout; |
|
2423 |
|
2424 // If no other controls inside dialog than text editor |
|
2425 if ( !( iFlags.IsSet( EPopupFormHasProgbar ) |
|
2426 || iFlags.IsSet( EPopupFormHasWaitAnim ) ) && |
|
2427 !( iFlags.IsSet( EPopupFormHasImage ) |
|
2428 || iFlags.IsSet( EPopupFormHasAnimation ) ) ) |
|
2429 { |
|
2430 firstlineLayout = AknLayoutScalable_Avkon::popup_midp_note_alarm_window_t6( 0 ); |
|
2431 secondlineLayout = AknLayoutScalable_Avkon::popup_midp_note_alarm_window_t7( 0 ); |
|
2432 } |
|
2433 else |
|
2434 { |
|
2435 // If uses scrollbar |
|
2436 if ( TextIsScrollable() ) |
|
2437 { |
|
2438 // Image |
|
2439 if ( iFlags.IsSet( EPopupFormHasImage ) || iFlags.IsSet( EPopupFormHasAnimation ) ) |
|
2440 { |
|
2441 firstVariant = 12; |
|
2442 } |
|
2443 // Progress bar, no image |
|
2444 else |
|
2445 { |
|
2446 firstVariant = 11; |
|
2447 } |
|
2448 } |
|
2449 else |
|
2450 { |
|
2451 // Image |
|
2452 if ( iFlags.IsSet( EPopupFormHasImage ) || iFlags.IsSet( EPopupFormHasAnimation ) ) |
|
2453 { |
|
2454 firstVariant = 0; |
|
2455 } |
|
2456 // Progress bar, no image |
|
2457 else |
|
2458 { |
|
2459 firstVariant = 4; |
|
2460 } |
|
2461 } |
|
2462 firstlineLayout = AknLayoutScalable_Avkon::popup_midp_note_alarm_window_t1( firstVariant ); |
|
2463 secondlineLayout = AknLayoutScalable_Avkon::popup_midp_note_alarm_window_t2( firstVariant ); |
|
2464 } |
|
2465 |
|
2466 TAknTextLineLayout fLayout = firstlineLayout.LayoutLine(); |
|
2467 |
|
2468 TAknMultiLineTextLayout multiline; |
|
2469 multiline.iC = fLayout.iC; |
|
2470 multiline.il = fLayout.il; |
|
2471 multiline.ir = fLayout.ir; |
|
2472 multiline.iW = fLayout.iW; |
|
2473 multiline.iJ = fLayout.iJ; |
|
2474 multiline.iFont = fLayout.iFont; |
|
2475 multiline.iB = fLayout.iB; |
|
2476 |
|
2477 if ( numberOfLines >= 2 ) |
|
2478 { |
|
2479 TAknTextLineLayout sLayout = secondlineLayout.LayoutLine(); |
|
2480 multiline.iBaselineSkip = secondlineLayout.t() - firstlineLayout.t(); |
|
2481 multiline.iNumberOfLinesShown = numberOfLines; |
|
2482 } |
|
2483 else |
|
2484 { |
|
2485 multiline.iBaselineSkip = 0; |
|
2486 multiline.iNumberOfLinesShown = 1; |
|
2487 } |
|
2488 return multiline; |
|
2489 } |
|
2490 |
|
2491 // ----------------------------------------------------------------------------- |
|
2492 // CAknPopupForm::PopupWindowRect |
|
2493 // |
|
2494 // ----------------------------------------------------------------------------- |
|
2495 // |
|
2496 TRect CAknPopupForm::PopupWindowRect() const |
|
2497 { |
|
2498 TRect mainPaneRect; |
|
2499 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EPopupParent, mainPaneRect ); |
|
2500 |
|
2501 AknLayoutUtils::TAknCbaLocation cbaLocation( AknLayoutUtils::CbaLocation() ); |
|
2502 TInt variety( 0 ); |
|
2503 |
|
2504 if ( cbaLocation == AknLayoutUtils::EAknCbaLocationRight ) |
|
2505 { |
|
2506 variety = 3; |
|
2507 } |
|
2508 else if ( cbaLocation == AknLayoutUtils::EAknCbaLocationLeft ) |
|
2509 { |
|
2510 variety = 6; |
|
2511 } |
|
2512 else |
|
2513 { |
|
2514 variety = 0; |
|
2515 } |
|
2516 TAknLayoutRect popupWindow; |
|
2517 popupWindow.LayoutRect( mainPaneRect, AknLayoutScalable_Avkon::popup_note_window( variety ) ); |
|
2518 |
|
2519 TRect popupRect = popupWindow.Rect(); |
|
2520 if ( iFlags.IsSet ( EPopupFormHasHeading ) ) |
|
2521 { |
|
2522 |
|
2523 TAknWindowLineLayout headingLayout = AknLayoutScalable_Avkon::heading_pane( 0 ); |
|
2524 TAknLayoutRect headingRect; |
|
2525 headingRect.LayoutRect( popupRect, headingLayout ); |
|
2526 if ( cbaLocation == AknLayoutUtils::EAknCbaLocationRight || cbaLocation == AknLayoutUtils::EAknCbaLocationLeft ) |
|
2527 { |
|
2528 popupRect.iTl.iY -= headingRect.Rect().Height() / 2; |
|
2529 popupRect.iBr.iY += headingRect.Rect().Height() / 2; |
|
2530 |
|
2531 } |
|
2532 else |
|
2533 { |
|
2534 popupRect.iTl.iY -= headingRect.Rect().Height(); |
|
2535 } |
|
2536 } |
|
2537 |
|
2538 return popupRect; |
|
2539 } |
|
2540 |
|
2541 |
|
2542 |
|
2543 // End of file |