|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <eikimage.h> |
|
21 #include <eikprogi.h> |
|
22 |
|
23 #include <avkon.mbg> |
|
24 #include <aknconsts.h> |
|
25 #include <AknPanic.h> |
|
26 #include <AknUtils.h> |
|
27 #include <AknLayoutDef.h> |
|
28 #include <AknLayout.lag> |
|
29 |
|
30 #include "aknnotecontrol.h" |
|
31 #include "notelaf.h" |
|
32 #include "aknnoteattributes.h" |
|
33 #include "akntextcontrol.h" |
|
34 |
|
35 #include <aknlayoutscalable_avkon.cdl.h> |
|
36 #include <AknsDrawUtils.h> |
|
37 #include <AknsFrameBackgroundControlContext.h> |
|
38 #include <eikbtgpc.h> // CEikButtonGroupContainer |
|
39 |
|
40 // Skin layout macros |
|
41 #include <skinlayout.cdl.h> |
|
42 using namespace SkinLayout; |
|
43 |
|
44 #include <AknIconUtils.h> |
|
45 #include "aknappui.h" |
|
46 |
|
47 #include <eikdialg.h> |
|
48 #include <eikdialogext.h> |
|
49 #include <touchfeedback.h> |
|
50 |
|
51 #include <AknTasHook.h> // for testability hooks |
|
52 const TInt KRate = 95; // 95% similar rate |
|
53 const TInt KFullColor = 255; |
|
54 |
|
55 // --------------------------------------------- |
|
56 // CONSTRUCTION - DESTRUCTION |
|
57 // --------------------------------------------- |
|
58 |
|
59 /** |
|
60 * The class default constructor. |
|
61 * |
|
62 * |
|
63 */ |
|
64 EXPORT_C CAknNoteControl::CAknNoteControl() |
|
65 { |
|
66 AKNTASHOOK_ADD( this, "CAknNoteControl" ); |
|
67 } |
|
68 |
|
69 /** |
|
70 * The class destructor. |
|
71 * |
|
72 * |
|
73 */ |
|
74 EXPORT_C CAknNoteControl::~CAknNoteControl() |
|
75 { |
|
76 AKNTASHOOK_REMOVE(); |
|
77 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
78 if ( feedback ) |
|
79 { |
|
80 feedback->RemoveFeedbackForControl( this ); |
|
81 } |
|
82 |
|
83 delete iAttributes; |
|
84 delete iLineWidths; |
|
85 } |
|
86 |
|
87 void CAknNoteControl::ConstructFromResourceL(TResourceReader &aRes) |
|
88 { |
|
89 |
|
90 delete iLineWidths; |
|
91 iLineWidths = 0; |
|
92 |
|
93 iLineWidths = new(ELeave)CArrayFixFlat<TInt>(5); |
|
94 iNoteLayout = aRes.ReadUint16(); |
|
95 |
|
96 delete iAttributes; |
|
97 iAttributes = NULL; |
|
98 iAttributes = new (ELeave)CAknNoteAttributes(this); |
|
99 iAttributes->ConstructFromResourceL(aRes); |
|
100 |
|
101 CreateDefaultImageL(); |
|
102 ReduceImageIfNeeded(); |
|
103 |
|
104 ParseTextL(); |
|
105 |
|
106 iAttributes->iBgContext->SetCenter(KAknsIIDQsnFrPopupCenterNote); |
|
107 |
|
108 if( CAknEnv::Static()->TransparencyEnabled() ) |
|
109 { |
|
110 CEikDialog* dlg; |
|
111 MopGetObject( dlg ); |
|
112 if ( dlg ) |
|
113 { |
|
114 dlg->Extension()->iPublicFlags.Set( CEikDialogExtension::EClipChildControlRect ); |
|
115 } |
|
116 } |
|
117 } |
|
118 |
|
119 void CAknNoteControl::Reset() |
|
120 { |
|
121 // Used by sleeping notes when going to background, |
|
122 // in order to stop and delete animations |
|
123 CancelAnimation(); |
|
124 } |
|
125 |
|
126 |
|
127 // ----------------------------------------- |
|
128 // CCOECONTROL METHODS |
|
129 // ----------------------------------------- |
|
130 void CAknNoteControl::Draw(const TRect& /*aRect*/) const |
|
131 { |
|
132 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
133 |
|
134 MAknsControlContext* cc = iAttributes->iBgContext; |
|
135 |
|
136 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
|
137 //Controls _have_to_ get gc through CCoeControl::SystemGc to be transition compatible. |
|
138 CWindowGc& gc = SystemGc(); |
|
139 #else |
|
140 //iAttributes->iBgRect should be always valid |
|
141 CWindowGc& gc = iCoeEnv->SystemGc(); |
|
142 #endif |
|
143 |
|
144 TBool oomError = EFalse; |
|
145 if( CAknEnv::Static()->TransparencyEnabled() ) |
|
146 { |
|
147 oomError = !AknsDrawUtils::Background( skin, cc, this, gc, |
|
148 iAttributes->iBgRect.IsEmpty()?LayoutRect():iAttributes->iBgRect, KAknsDrawParamNoClearUnderImage); |
|
149 } |
|
150 else |
|
151 { |
|
152 oomError = !AknsDrawUtils::Background( skin, cc, this, gc, |
|
153 iAttributes->iBgRect.IsEmpty()?LayoutRect():iAttributes->iBgRect, KAknsDrawParamDefault); |
|
154 } |
|
155 |
|
156 if( oomError ) |
|
157 { |
|
158 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
159 TRgb color; |
|
160 TInt error = AknsUtils::GetCachedColor( skin, color, |
|
161 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19 ); |
|
162 |
|
163 TInt redcolor = color.Red(); |
|
164 TInt bluecolor = color.Blue(); |
|
165 TInt greencolor = color.Green(); |
|
166 // test if the color is too similar to white color |
|
167 if ( redcolor > KFullColor * KRate / 100 || |
|
168 bluecolor > KFullColor * KRate / 100 || |
|
169 greencolor > KFullColor * KRate / 100 ) |
|
170 { |
|
171 color = KRgbBlack; |
|
172 } |
|
173 for (TInt i=0; i < NumberOfLines(); i++) |
|
174 { |
|
175 AknLayoutUtils::LayoutLabel |
|
176 ( TextControl()->Line( i ),LayoutRect(),AKN_LAYOUT_TEXT_Note_pop_up_window_texts_Line_1( i ) ); |
|
177 |
|
178 if (!error) |
|
179 { |
|
180 // Ignore error |
|
181 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( *TextControl()->Line(i), |
|
182 EColorLabelText, color ) ); |
|
183 } |
|
184 } |
|
185 } |
|
186 if (iImageHasShadow) |
|
187 { |
|
188 iShadowRect.DrawRect( gc ); |
|
189 } |
|
190 } |
|
191 |
|
192 EXPORT_C void CAknNoteControl::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
193 { |
|
194 CAknControl::HandlePointerEventL(aPointerEvent); |
|
195 if (iAttributes->iFlags.IsSet( ENoteLeftSKWhenTapped ) && |
|
196 (aPointerEvent.iType == TPointerEvent::EButton1Up) && |
|
197 Rect().Contains( aPointerEvent.iPosition ) ) |
|
198 { |
|
199 // Left soft key press |
|
200 TRawEvent event; |
|
201 event.Set(TRawEvent::EKeyDown, EStdKeyDevice0); |
|
202 CEikonEnv::Static()->WsSession().SimulateRawEvent(event); |
|
203 event.Set(TRawEvent::EKeyUp, EStdKeyDevice0); |
|
204 CEikonEnv::Static()->WsSession().SimulateRawEvent(event); |
|
205 } |
|
206 } |
|
207 |
|
208 EXPORT_C void* CAknNoteControl::ExtensionInterface( TUid /*aInterface*/ ) |
|
209 { |
|
210 return NULL; |
|
211 } |
|
212 |
|
213 CCoeControl* CAknNoteControl::ComponentControl(TInt aIndex) const |
|
214 { |
|
215 const CCoeControl* controls[] = {Icon(),TextControl(),ProgressBar(), |
|
216 Image(),Animation()}; |
|
217 for (TUint ii=0;ii<sizeof(controls)/sizeof(CCoeControl*);ii++) |
|
218 if (controls[ii] && aIndex-- == 0) |
|
219 return const_cast<CCoeControl*>(controls[ii]); |
|
220 return NULL; |
|
221 } |
|
222 |
|
223 |
|
224 TInt CAknNoteControl::CountComponentControls() const |
|
225 { |
|
226 if (!Attributes()) |
|
227 { |
|
228 return 0; |
|
229 } |
|
230 TInt count = 0; |
|
231 const CCoeControl* controls[] = { Icon(),TextControl(),ProgressBar(), |
|
232 Image(), Animation() }; |
|
233 for (TUint ii=0;ii<sizeof(controls)/sizeof(CCoeControl*);ii++) |
|
234 if (controls[ii]) |
|
235 count++; |
|
236 return count; |
|
237 } |
|
238 |
|
239 TSize CAknNoteControl::MinimumSize() |
|
240 { |
|
241 TAknWindowLineLayout dialogLay; |
|
242 WindowLayout( dialogLay ); |
|
243 |
|
244 TAknLayoutRect dialogLayRect; |
|
245 dialogLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(), dialogLay); |
|
246 TSize dialogSize = dialogLayRect.Rect().Size(); |
|
247 #ifndef RD_NO_DIALOG_BORDERS |
|
248 TRect parent(TPoint(0,0),dialogSize); |
|
249 |
|
250 TAknWindowLineLayout internalLay = AKN_LAYOUT_WINDOW_Note_pop_up_window_graphics_Line_5(parent); |
|
251 |
|
252 if ( iNoteLayout == ENotificationWithGraphicsLayout || |
|
253 iNoteLayout == ETextualNotificationLayout ) |
|
254 { |
|
255 internalLay = AKN_LAYOUT_WINDOW_Notification_pop_up_window_graphics__text__Line_5(parent); |
|
256 } |
|
257 |
|
258 TAknLayoutRect internalLayRect; |
|
259 internalLayRect.LayoutRect(parent, internalLay); |
|
260 |
|
261 return internalLayRect.Rect().Size(); |
|
262 #else |
|
263 return dialogSize; |
|
264 #endif |
|
265 } |
|
266 |
|
267 /** |
|
268 * Do layout. |
|
269 * |
|
270 * Always do layout even when there might be no need for it (e.g. |
|
271 * because nothing has changed). This method is called by the |
|
272 * CONE framework when the size or position of the control is |
|
273 * changed and hence layout must always be done. |
|
274 * |
|
275 * Do not call this method when you need to do layout for reasons |
|
276 * different than the size or position of the control changing. |
|
277 * Call Layout instead. |
|
278 */ |
|
279 void CAknNoteControl::SizeChanged() |
|
280 { |
|
281 DoLayout(); |
|
282 } |
|
283 |
|
284 /** |
|
285 * Code shared between SizeChanged() and Layout(). |
|
286 * |
|
287 */ |
|
288 void CAknNoteControl::DoLayout() |
|
289 { |
|
290 TextControl()->SetRect(LayoutRect()); |
|
291 switch(iNoteLayout) |
|
292 { |
|
293 case EGeneralLayout: |
|
294 GeneralNoteLayout(); |
|
295 if(iAttributes->iFlags.IsSet(ENoteAnimationStarted)) |
|
296 { |
|
297 CancelAnimation(); |
|
298 TRAP_IGNORE(StartAnimationL()); |
|
299 } |
|
300 break; |
|
301 case EProgressLayout: |
|
302 case EWaitLayout: |
|
303 { |
|
304 ProgressNoteLayout(); |
|
305 if(iAttributes->iFlags.IsSet(ENoteAnimationStarted)) |
|
306 { |
|
307 iAttributes->CancelAnimation(); |
|
308 TRAP_IGNORE(iAttributes->StartAnimationL()); |
|
309 } |
|
310 break; |
|
311 } |
|
312 case ENoteWithImageLayout: |
|
313 case ETextualNotificationLayout: |
|
314 case ENotificationWithGraphicsLayout: |
|
315 ImageNoteLayout(); |
|
316 break; |
|
317 } |
|
318 |
|
319 Attributes()->SetLayoutDone(CAknNoteAttributes::EControl); |
|
320 |
|
321 if ( iAttributes->iFlags.IsSet( ENoteLeftSKWhenTapped ) ) |
|
322 { |
|
323 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
324 CFeedbackSpec* spec = CFeedbackSpec::New(); |
|
325 if ( feedback && spec ) |
|
326 { |
|
327 spec->AddFeedback( ETouchEventStylusDown, |
|
328 ETouchFeedbackBasicButton ); |
|
329 spec->AddFeedback( ETouchEventStylusUp, |
|
330 ETouchFeedbackBasicButton, |
|
331 ETouchFeedbackVibra ); |
|
332 feedback->SetFeedbackArea( this, 0, Rect(), spec ); |
|
333 delete spec; |
|
334 } |
|
335 } |
|
336 } |
|
337 |
|
338 /** |
|
339 * |
|
340 * This is used by a dialog to layout the control correctly. |
|
341 * |
|
342 */ |
|
343 void CAknNoteControl::WindowLayout( TAknWindowLineLayout& aLayout ) const |
|
344 { |
|
345 TIndex laf(NumberOfLines()); |
|
346 AknLayoutUtils::TAknCbaLocation cbaLocation( AknLayoutUtils::CbaLocation() ); |
|
347 TInt variety( 0 ); |
|
348 |
|
349 switch(iNoteLayout) |
|
350 { |
|
351 case ENoteWithImageLayout: |
|
352 if ( cbaLocation == AknLayoutUtils::EAknCbaLocationRight ) |
|
353 { |
|
354 variety = 1; |
|
355 } |
|
356 else if ( cbaLocation == AknLayoutUtils::EAknCbaLocationLeft ) |
|
357 { |
|
358 variety = 2; |
|
359 } |
|
360 else |
|
361 { |
|
362 variety = 0; |
|
363 } |
|
364 |
|
365 aLayout = AknLayoutScalable_Avkon::popup_note_image_window( variety ); |
|
366 break; |
|
367 case ETextualNotificationLayout: |
|
368 if ( cbaLocation == AknLayoutUtils::EAknCbaLocationRight ) |
|
369 { |
|
370 variety = 4; |
|
371 } |
|
372 else if ( cbaLocation == AknLayoutUtils::EAknCbaLocationLeft ) |
|
373 { |
|
374 variety = 8; |
|
375 } |
|
376 else |
|
377 { |
|
378 variety = 0; |
|
379 } |
|
380 |
|
381 aLayout = AknLayoutScalable_Avkon::popup_snote_single_text_window( variety + |
|
382 (laf.Lines() >= 2 ? laf.Lines() - 1 : 0) ); |
|
383 break; |
|
384 case ENotificationWithGraphicsLayout: |
|
385 if ( cbaLocation == AknLayoutUtils::EAknCbaLocationRight ) |
|
386 { |
|
387 variety = 4; |
|
388 } |
|
389 else if ( cbaLocation == AknLayoutUtils::EAknCbaLocationLeft ) |
|
390 { |
|
391 variety = 8; |
|
392 } |
|
393 else |
|
394 { |
|
395 variety = 0; |
|
396 } |
|
397 |
|
398 aLayout = AknLayoutScalable_Avkon::popup_snote_single_graphic_window( variety + |
|
399 (laf.Lines() >= 2 ? laf.Lines() - 1 : 0) ); |
|
400 break; |
|
401 case EProgressLayout: |
|
402 case EWaitLayout: |
|
403 if ( cbaLocation == AknLayoutUtils::EAknCbaLocationRight ) |
|
404 { |
|
405 variety = 3; |
|
406 } |
|
407 else if ( cbaLocation == AknLayoutUtils::EAknCbaLocationLeft ) |
|
408 { |
|
409 variety = 6; |
|
410 } |
|
411 else |
|
412 { |
|
413 variety = 0; |
|
414 } |
|
415 |
|
416 aLayout = AknLayoutScalable_Avkon::popup_note_wait_window( variety + |
|
417 laf.PopupNoteWaitWindow() ); |
|
418 break; |
|
419 |
|
420 case EGeneralLayout: |
|
421 default: //default case should never be the case |
|
422 if ( cbaLocation == AknLayoutUtils::EAknCbaLocationRight ) |
|
423 { |
|
424 variety = 3; |
|
425 } |
|
426 else if ( cbaLocation == AknLayoutUtils::EAknCbaLocationLeft ) |
|
427 { |
|
428 variety = 6; |
|
429 } |
|
430 else |
|
431 { |
|
432 variety = 0; |
|
433 } |
|
434 |
|
435 aLayout = AknLayoutScalable_Avkon::popup_note_window( variety + |
|
436 laf.PopupNoteWindow() ); |
|
437 break; |
|
438 } |
|
439 } |
|
440 |
|
441 /** |
|
442 * Return the note height |
|
443 * |
|
444 * The note height is taken from the layout compiler and |
|
445 * depends on number of lines and the note layout type. |
|
446 * |
|
447 * @return The note height in pixels. |
|
448 */ |
|
449 EXPORT_C TInt CAknNoteControl::NoteHeight() const |
|
450 { |
|
451 TAknWindowLineLayout dialogLay; |
|
452 WindowLayout( dialogLay ); |
|
453 |
|
454 TAknLayoutRect windowLayRect; |
|
455 windowLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(), dialogLay); |
|
456 return windowLayRect.Rect().Height(); |
|
457 } |
|
458 |
|
459 /** |
|
460 * Return the note width |
|
461 * |
|
462 * The note width is taken from the layout compiler. |
|
463 * Contrary to the note height, the note width does not depend on |
|
464 * from note layout type or on number of lines. |
|
465 * |
|
466 * @return The note width in pixels |
|
467 */ |
|
468 EXPORT_C TInt CAknNoteControl::NoteWidth() const |
|
469 { |
|
470 TAknWindowLineLayout dialogLay; |
|
471 WindowLayout( dialogLay ); |
|
472 |
|
473 TAknLayoutRect windowLayRect; |
|
474 windowLayRect.LayoutRect(iAvkonAppUi->ApplicationRect(), dialogLay); |
|
475 return windowLayRect.Rect().Width(); |
|
476 } |
|
477 |
|
478 |
|
479 // ---------------------------------------- |
|
480 // LAYOUT METHODS |
|
481 // ---------------------------------------- |
|
482 |
|
483 /** |
|
484 * GENERAL NOTES LAYOUT |
|
485 */ |
|
486 void CAknNoteControl::GeneralNoteLayout() |
|
487 { |
|
488 GeneralNoteLabelLayout(); |
|
489 GeneralNoteIconLayout(); |
|
490 } |
|
491 |
|
492 /** |
|
493 * Layout for text in general notes |
|
494 */ |
|
495 void CAknNoteControl::GeneralNoteLabelLayout() |
|
496 { |
|
497 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
498 TRgb color; |
|
499 TInt error = AknsUtils::GetCachedColor( skin, color, |
|
500 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19 ); |
|
501 |
|
502 for (TInt i=0; i < NumberOfLines(); i++) |
|
503 { |
|
504 AknLayoutUtils::LayoutLabel |
|
505 (TextControl()->Line(i),LayoutRect(),AKN_LAYOUT_TEXT_Note_pop_up_window_texts_Line_1(i)); |
|
506 |
|
507 if (!error) |
|
508 { |
|
509 // Ignore error |
|
510 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( *TextControl()->Line(i), |
|
511 EColorLabelText, color ) ); |
|
512 } |
|
513 } |
|
514 } |
|
515 |
|
516 /** |
|
517 * Layout for image or animation in general notes |
|
518 */ |
|
519 void CAknNoteControl::GeneralNoteIconLayout() |
|
520 { |
|
521 if (Image()) |
|
522 AknLayoutUtils::LayoutImage(Image(), LayoutRect(), AKN_LAYOUT_WINDOW_Note_pop_up_window_elements_Line_1); |
|
523 |
|
524 if (Animation()) |
|
525 AknLayoutUtils::LayoutControl(Animation(), LayoutRect(), AKN_LAYOUT_WINDOW_Note_pop_up_window_elements_Line_1); |
|
526 } |
|
527 |
|
528 |
|
529 |
|
530 /** |
|
531 * PROGRESS NOTES LAYOUT |
|
532 */ |
|
533 void CAknNoteControl::ProgressNoteLayout() |
|
534 { |
|
535 ProgressNoteLabelLayout(); |
|
536 ProgressNoteProgressBarLayout(); |
|
537 ProgressNoteIconLayout(); |
|
538 ProgressNoteNumberTypeIndicationLayout(); |
|
539 } |
|
540 |
|
541 /** |
|
542 * Layout for text in progress notes |
|
543 */ |
|
544 void CAknNoteControl::ProgressNoteLabelLayout() |
|
545 { |
|
546 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
547 TRgb color; |
|
548 TInt error = AknsUtils::GetCachedColor( skin, color, |
|
549 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19 ); |
|
550 |
|
551 TInt nLines = Min (KPNMaxNumLines, NumberOfLines()); |
|
552 TIndex lafIndex(nLines,Icon()!=NULL); |
|
553 |
|
554 for (TInt i=0; i < nLines; i++) |
|
555 { |
|
556 AknLayoutUtils::LayoutLabel( TextControl()->Line(i), |
|
557 LayoutRect(),AKN_LAYOUT_TEXT_Wait_or_progress_note_pop_up_window_texts_Line_1 |
|
558 (lafIndex.WNPWindowTextsLine1(i),i,i)); |
|
559 |
|
560 if (!error) |
|
561 { |
|
562 // Ignore error |
|
563 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( *TextControl()->Line(i), |
|
564 EColorLabelText, color ) ); |
|
565 } |
|
566 } |
|
567 } |
|
568 |
|
569 /** |
|
570 * Layout for progress bar in progress notes |
|
571 */ |
|
572 void CAknNoteControl::ProgressNoteProgressBarLayout() |
|
573 { |
|
574 TInt nLines = Min (KPNMaxNumLines, NumberOfLines()); |
|
575 |
|
576 // New parameter added to Wait_or_progress_note_pop_up_window_elements_Line_2 layout API. |
|
577 TInt tIndex = 0; |
|
578 if (nLines == 3) |
|
579 { |
|
580 tIndex = 1; |
|
581 } |
|
582 if (nLines >= 4) |
|
583 { |
|
584 tIndex = 2; |
|
585 } |
|
586 |
|
587 if (ProgressBar()) |
|
588 AknLayoutUtils::LayoutControl(ProgressBar(), LayoutRect(), AKN_LAYOUT_WINDOW_Wait_or_progress_note_pop_up_window_elements_Line_2(tIndex)); |
|
589 |
|
590 if(Animation()) //Progress Bar Animation |
|
591 AknLayoutUtils::LayoutControl(Animation(), LayoutRect(), AKN_LAYOUT_WINDOW_Wait_or_progress_note_pop_up_window_elements_Line_2(tIndex)); |
|
592 } |
|
593 |
|
594 /** |
|
595 * Layout for icon in progress notes |
|
596 */ |
|
597 void CAknNoteControl::ProgressNoteIconLayout() |
|
598 { |
|
599 if (Image()) |
|
600 AknLayoutUtils::LayoutImage(Image(), LayoutRect(), AKN_LAYOUT_WINDOW_Wait_or_progress_note_pop_up_window_elements_Line_1); |
|
601 } |
|
602 |
|
603 /** |
|
604 * Layout for nti (number type indication) icon in progress notes |
|
605 */ |
|
606 void CAknNoteControl::ProgressNoteNumberTypeIndicationLayout() |
|
607 { |
|
608 if (Icon()) |
|
609 AknLayoutUtils::LayoutImage(Icon(), LayoutRect(), AKN_LAYOUT_WINDOW_Wait_or_progress_note_pop_up_window_elements_Line_4); |
|
610 } |
|
611 |
|
612 /** |
|
613 * IMAGE NOTES LAYOUT |
|
614 */ |
|
615 void CAknNoteControl::ImageNoteLayout() |
|
616 { |
|
617 ImageNoteLabelLayout(); |
|
618 if ( iNoteLayout != ENotificationWithGraphicsLayout && |
|
619 iNoteLayout != ETextualNotificationLayout ) |
|
620 { |
|
621 ImageNoteShadowLayout(); |
|
622 } |
|
623 else if ( iAttributes ) |
|
624 { |
|
625 iAttributes->iBgContext->SetCenter(KAknsIIDQsnFrPopupCenterSnote); |
|
626 } |
|
627 |
|
628 ImageNoteImageLayout(); |
|
629 AnimationNoteLayout(); |
|
630 ImageNoteNumberTypeIndicationLayout(); |
|
631 } |
|
632 |
|
633 /** |
|
634 * Layout for text in image notes |
|
635 */ |
|
636 void CAknNoteControl::ImageNoteLabelLayout() |
|
637 { |
|
638 |
|
639 TInt nLines = NumberOfLines(); |
|
640 |
|
641 TSize imageSize = Image() ? Image()->Bitmap()->SizeInPixels() : |
|
642 Animation() ? Animation()->BitmapAnimData()->Size() : TSize(0,0); |
|
643 |
|
644 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
645 TRgb color; |
|
646 TInt error = AknsUtils::GetCachedColor( skin, color, |
|
647 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19 ); |
|
648 |
|
649 if ( iNoteLayout == ENoteWithImageLayout ) |
|
650 { |
|
651 nLines = Min(KINMaxNumLines, nLines); |
|
652 |
|
653 TIndex lafIndex(nLines,Icon()!=NULL,imageSize); |
|
654 |
|
655 for (TInt i=0; i < nLines; i++) |
|
656 { |
|
657 |
|
658 AknLayoutUtils::LayoutLabel(TextControl()->Line(i),LayoutRect(), |
|
659 AKN_LAYOUT_TEXT_Note_with_an_image_pop_up_window_texts_Line_1( |
|
660 lafIndex.NWIPWindowTextsLine1L(i),lafIndex.NWIPWindowTextsLine1R(i), |
|
661 lafIndex.NWIPWindowTextsLine1B(i),lafIndex.NWIPWindowTextsLine1W(i))); |
|
662 |
|
663 if (!error) |
|
664 { |
|
665 // Ignore error |
|
666 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( |
|
667 *TextControl()->Line(i), |
|
668 EColorLabelText, color ) ); |
|
669 } |
|
670 } |
|
671 } |
|
672 else // Soft Notification layouts |
|
673 { |
|
674 for (TInt i=0; i < nLines; i++) |
|
675 { |
|
676 AknLayoutUtils::LayoutLabel( |
|
677 TextControl()->Line(i), |
|
678 LayoutRect(), |
|
679 (!imageSize.iWidth)? |
|
680 AKN_LAYOUT_TEXT_Notification_pop_up_window_texts__text__Line_1(i): |
|
681 AKN_LAYOUT_TEXT_Notification_pop_up_window_texts__graphic__Line_1(i)); |
|
682 |
|
683 if (!error) |
|
684 { |
|
685 // Ignore error |
|
686 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( |
|
687 *TextControl()->Line(i), |
|
688 EColorLabelText, color ) ); |
|
689 } |
|
690 } |
|
691 |
|
692 } |
|
693 } |
|
694 |
|
695 /** |
|
696 * Layout for animation in image notes |
|
697 */ |
|
698 void CAknNoteControl::AnimationNoteLayout() |
|
699 { |
|
700 if (Animation()) |
|
701 AknLayoutUtils::LayoutControl(Animation(), LayoutRect(), |
|
702 GetImageLayout(Animation()->BitmapAnimData()->Size()) ); |
|
703 } |
|
704 |
|
705 |
|
706 /** |
|
707 * Layout for image in image notes |
|
708 */ |
|
709 void CAknNoteControl::ImageNoteImageLayout() |
|
710 { |
|
711 if (Image()) |
|
712 { |
|
713 AknLayoutUtils::LayoutImage(Image(), LayoutRect(), |
|
714 GetImageLayout(Image()->Bitmap()->SizeInPixels())); |
|
715 } |
|
716 } |
|
717 |
|
718 /** |
|
719 * Layout for image shadow in image notes |
|
720 */ |
|
721 void CAknNoteControl::ImageNoteShadowLayout() |
|
722 { |
|
723 if (Image()) |
|
724 { |
|
725 iShadowRect.LayoutRect( LayoutRect(), |
|
726 GetImageShadowLayout(Image()->Bitmap()->SizeInPixels()) ); |
|
727 |
|
728 iImageHasShadow = ETrue; |
|
729 } |
|
730 } |
|
731 |
|
732 /** |
|
733 * Layout for number type indication in image notes |
|
734 */ |
|
735 void CAknNoteControl::ImageNoteNumberTypeIndicationLayout() |
|
736 { |
|
737 if ( iNoteLayout == ETextualNotificationLayout || iNoteLayout == ENotificationWithGraphicsLayout ) |
|
738 { |
|
739 return; |
|
740 } |
|
741 |
|
742 if (Icon()) |
|
743 { |
|
744 AknLayoutUtils::LayoutImage(Icon(), LayoutRect(), AKN_LAYOUT_WINDOW_Note_with_an_image_pop_up_window_elements_Line_13); |
|
745 } |
|
746 } |
|
747 |
|
748 /** |
|
749 * Return layout table to be used for images in image notes. |
|
750 * Table is different according to image size, |
|
751 * |
|
752 * Images with a size different from the supported sizes are laid out |
|
753 * as if they were 44X48 images. If they are smaller their |
|
754 * size is used. If they are bigger the are cropped to 44X48 |
|
755 * (@see ReduceImageIfNeeded) |
|
756 */ |
|
757 TAknWindowLineLayout CAknNoteControl::GetImageLayout(const TSize& /*aSize*/) |
|
758 { |
|
759 // can go on with the biggest |
|
760 TAknWindowLineLayout lay (AKN_LAYOUT_WINDOW_Note_with_an_image_pop_up_window_elements_Line_12); |
|
761 |
|
762 if ( iNoteLayout == ENotificationWithGraphicsLayout ) |
|
763 { |
|
764 lay = AKN_LAYOUT_WINDOW_Notification_pop_up_window_elements__graphic__Line_2; |
|
765 } |
|
766 |
|
767 return lay; |
|
768 } |
|
769 |
|
770 /** |
|
771 * Return layout table to be used for image shadows in image notes. |
|
772 * Table is different according to image size. |
|
773 * |
|
774 * Shadows for images with a size different than the supported sizes are laid |
|
775 * out as if they were biggest supported images. If they are smaller their |
|
776 * size is used. If they are bigger the are cropped to the biggest supported size |
|
777 * (@see ReduceImageIfNeeded) |
|
778 */ |
|
779 TAknWindowLineLayout CAknNoteControl::GetImageShadowLayout(const TSize& /*aSize*/) |
|
780 { |
|
781 // can go on with the biggest |
|
782 TAknWindowLineLayout lay (AKN_LAYOUT_WINDOW_Note_with_an_image_pop_up_window_elements_Line_11); |
|
783 return lay; |
|
784 } |
|
785 |
|
786 |
|
787 /** |
|
788 * Do layout. |
|
789 * |
|
790 * Before doing layout parse the text (This might be redundant except |
|
791 * when the control attributs are trasfered but is left here to avoid |
|
792 * breaking the functionality of this exported method). |
|
793 * |
|
794 * Layout is done only if it is needed, i.e. if the attributes indicates |
|
795 * that something has changed in such a way that layout needs to be performed |
|
796 * again, e.g. a line of text has been added. |
|
797 * |
|
798 * This method assumes that the rect of the control has not been changed. On the |
|
799 * contrary, SizeChanged does not assume that the rect is the same and hence |
|
800 * always performs layout. |
|
801 */ |
|
802 EXPORT_C void CAknNoteControl::Layout() |
|
803 { |
|
804 TRAP_IGNORE(ParseTextL()); |
|
805 |
|
806 if (!Attributes()->IsLayoutNeeded(CAknNoteAttributes::EControl)) |
|
807 return; |
|
808 |
|
809 DoLayout(); |
|
810 |
|
811 } |
|
812 |
|
813 /** |
|
814 * Return rectangle used in layout operations. |
|
815 * |
|
816 * Layout information in LAF is relative to the size of the dialog and not to the |
|
817 * size of the internal area (dialog size - margins from UIKLAF). Therefore when |
|
818 * doing layout do not use Rect(), but LayoutRect() - which returns the size of the |
|
819 * dialog. Position is always (0,0) - top |
|
820 * |
|
821 * @return Rectangle equal to dialog rectangle only shifted by the dialog margins |
|
822 */ |
|
823 TRect CAknNoteControl::LayoutRect() const |
|
824 { |
|
825 TAknLayoutRect layout; |
|
826 |
|
827 TAknWindowLineLayout window; |
|
828 WindowLayout( window ); |
|
829 |
|
830 TRect mainPane; |
|
831 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EPopupParent, mainPane ); |
|
832 layout.LayoutRect( mainPane, window ); |
|
833 TRect rect = layout.Rect().Size(); |
|
834 |
|
835 if ( iNoteLayout == ENotificationWithGraphicsLayout || |
|
836 iNoteLayout == ETextualNotificationLayout ) |
|
837 { |
|
838 TAknLayoutRect layRect; |
|
839 TPoint topLeft = Position(); |
|
840 layRect.LayoutRect(rect, AknLayoutScalable_Avkon::bg_popup_window_pane_cp9(0)); |
|
841 |
|
842 topLeft.iX -= layRect.Rect().iTl.iX; |
|
843 topLeft.iY -= layRect.Rect().iTl.iY; |
|
844 |
|
845 TPoint bottomRight (topLeft); |
|
846 bottomRight.iY += rect.Height(); |
|
847 bottomRight.iX += rect.Width(); |
|
848 |
|
849 rect = TRect(topLeft,bottomRight); |
|
850 } |
|
851 return rect; |
|
852 } |
|
853 |
|
854 /** |
|
855 * Use layout information to determine line widths |
|
856 */ |
|
857 void CAknNoteControl::SetLineWidthsL() |
|
858 { |
|
859 if (!iLineWidths) |
|
860 return; |
|
861 |
|
862 iLineWidths->Reset(); |
|
863 |
|
864 TAknLayoutText text; |
|
865 switch(iNoteLayout) |
|
866 { |
|
867 case EGeneralLayout: |
|
868 { |
|
869 for (TInt i=0; i < KGNMaxNumLines; i++) |
|
870 { |
|
871 TAknTextLineLayout lay = AKN_LAYOUT_TEXT_Note_pop_up_window_texts_Line_1(i); |
|
872 text.LayoutText(LayoutRect(), lay); |
|
873 TInt width = text.TextRect().Width(); |
|
874 |
|
875 iLineWidths->AppendL(width,1); |
|
876 } |
|
877 } |
|
878 break; |
|
879 case EProgressLayout: |
|
880 case EWaitLayout: |
|
881 { |
|
882 TIndex lafIndex(KPNMaxNumLines,Icon()!=NULL); |
|
883 for (TInt i=0; i < KPNMaxNumLines; i++) |
|
884 { |
|
885 TAknTextLineLayout lay = AKN_LAYOUT_TEXT_Wait_or_progress_note_pop_up_window_texts_Line_1 |
|
886 (lafIndex.WNPWindowTextsLine1(i),i,i); |
|
887 text.LayoutText(LayoutRect(), lay); |
|
888 TInt width = text.TextRect().Width(); |
|
889 |
|
890 iLineWidths->AppendL(width,1); |
|
891 } |
|
892 |
|
893 } |
|
894 break; |
|
895 case ENoteWithImageLayout: |
|
896 { |
|
897 TSize imageSize = Image() ? Image()->Bitmap()->SizeInPixels() : |
|
898 Animation() ? Animation()->BitmapAnimData()->Size() : TSize(0,0); |
|
899 |
|
900 TIndex lafIndex(KINMaxNumLines,Icon()!=NULL,imageSize); |
|
901 |
|
902 for (TInt i=0; i < KINMaxNumLines; i++) |
|
903 { |
|
904 TAknTextLineLayout lay = AKN_LAYOUT_TEXT_Note_with_an_image_pop_up_window_texts_Line_1( |
|
905 lafIndex.NWIPWindowTextsLine1L(i),lafIndex.NWIPWindowTextsLine1R(i), |
|
906 lafIndex.NWIPWindowTextsLine1B(i),lafIndex.NWIPWindowTextsLine1W(i)); |
|
907 text.LayoutText(LayoutRect(), lay); |
|
908 TInt width = text.TextRect().Width(); |
|
909 |
|
910 iLineWidths->AppendL(width,1); |
|
911 } |
|
912 } |
|
913 break; |
|
914 case ETextualNotificationLayout: |
|
915 { |
|
916 TAknTextLineLayout lay = AKN_LAYOUT_TEXT_Notification_pop_up_window_texts__text__Line_1(0); |
|
917 for (TInt i=0; i < KGNMaxNumLines; i++) |
|
918 { |
|
919 text.LayoutText(LayoutRect(), lay); |
|
920 TInt width = text.TextRect().Width(); |
|
921 iLineWidths->AppendL(width,1); |
|
922 } |
|
923 } |
|
924 break; |
|
925 |
|
926 case ENotificationWithGraphicsLayout: |
|
927 { |
|
928 for (TInt i=0; i < KGNMaxNumLines; i++) |
|
929 { |
|
930 TAknTextLineLayout lay = AKN_LAYOUT_TEXT_Notification_pop_up_window_texts__graphic__Line_1(i>=2?i-1:0); |
|
931 text.LayoutText(LayoutRect(), lay); |
|
932 TInt width = text.TextRect().Width(); |
|
933 iLineWidths->AppendL(width,1); |
|
934 } |
|
935 } |
|
936 break; |
|
937 } |
|
938 } |
|
939 |
|
940 void CAknNoteControl::CreateDefaultImageL() |
|
941 { |
|
942 |
|
943 if (iNoteLayout == EWaitLayout || iNoteLayout == EProgressLayout) |
|
944 { |
|
945 CEikImage* image = new(ELeave) CEikImage; |
|
946 CleanupStack::PushL(image); |
|
947 |
|
948 // Check if skinned image could be used |
|
949 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
950 |
|
951 CFbsBitmap* bitmap = NULL; |
|
952 CFbsBitmap* mask = NULL; |
|
953 |
|
954 AknsUtils::CreateIconL( |
|
955 skin, KAknsIIDQgnNoteProgress, |
|
956 bitmap, mask, |
|
957 KAvkonBitmapFile, |
|
958 EMbmAvkonQgn_note_progress, EMbmAvkonQgn_note_progress_mask); |
|
959 |
|
960 image->SetPicture(bitmap,mask); |
|
961 |
|
962 CleanupStack::Pop(); //image |
|
963 Attributes()->SetImageL(image); |
|
964 } |
|
965 } |
|
966 |
|
967 /** |
|
968 * |
|
969 * The CONST CAST is ok because the bitmap is owned by the image |
|
970 */ |
|
971 void CAknNoteControl::ReduceImageIfNeeded() |
|
972 { |
|
973 if (Image()) |
|
974 { |
|
975 // set the size of the image |
|
976 TAknLayoutRect rect; |
|
977 rect.LayoutRect( Rect(), |
|
978 AKN_LAYOUT_WINDOW_Note_with_an_image_pop_up_window_elements_Line_12 ); |
|
979 AknIconUtils::SetSize( CONST_CAST( CFbsBitmap*, Image()->Bitmap() ), |
|
980 rect.Rect().Size() ); |
|
981 |
|
982 // see if the bitmap size needs to be reduced |
|
983 TSize size = Image()->Bitmap()->SizeInPixels(); |
|
984 |
|
985 TInt width = rect.Rect().Width(); |
|
986 TInt height = rect.Rect().Height(); |
|
987 if ( size.iWidth >= width || size.iHeight >= height ) |
|
988 {//image does not fit |
|
989 TInt newWidth = Min( size.iWidth, width ); |
|
990 TInt newHeight = Min( size.iHeight, height ); |
|
991 |
|
992 if (Image()->Bitmap()) |
|
993 CONST_CAST(CFbsBitmap*,Image()->Bitmap())->Resize(TSize(newWidth,newHeight)); |
|
994 |
|
995 if (Image()->Mask()) |
|
996 CONST_CAST(CFbsBitmap*,Image()->Mask())->Resize(TSize(newWidth,newHeight)); |
|
997 } |
|
998 } |
|
999 } |
|
1000 |
|
1001 void CAknNoteControl::ParseTextL() |
|
1002 { |
|
1003 TAknLayoutText textRect; |
|
1004 |
|
1005 if ( iNoteLayout == ENotificationWithGraphicsLayout || iNoteLayout == ETextualNotificationLayout ) |
|
1006 { |
|
1007 textRect.LayoutText(LayoutRect(), AKN_LAYOUT_TEXT_Notification_pop_up_window_texts__text__Line_1(1)); |
|
1008 } |
|
1009 else |
|
1010 { |
|
1011 textRect.LayoutText(LayoutRect(), AKN_LAYOUT_TEXT_Wait_or_progress_note_pop_up_window_texts_Line_1(1,1,1)); |
|
1012 } |
|
1013 |
|
1014 const CFont *font = textRect.Font(); |
|
1015 |
|
1016 SetLineWidthsL(); // Make the division again to prevent errors when resolution has changed |
|
1017 Attributes()->ParseTextL( font, iLineWidths); |
|
1018 } |
|
1019 |
|
1020 |
|
1021 // ------------------------------------------- |
|
1022 // EXPORTED API |
|
1023 // ------------------------------------------- |
|
1024 |
|
1025 /** |
|
1026 * Set the note image |
|
1027 * |
|
1028 * Set the image in the note attributes. This reduces the |
|
1029 * size of the image if necessary (only fixed set of |
|
1030 * image sizes if supported). Perform layout only for |
|
1031 * the control. The dialog will not be resized. |
|
1032 * |
|
1033 */ |
|
1034 EXPORT_C void CAknNoteControl::SetImageL(CEikImage* aImage) |
|
1035 { |
|
1036 Attributes()->SetImageL(aImage); |
|
1037 Layout(); |
|
1038 } |
|
1039 |
|
1040 /** |
|
1041 * Set the note animation |
|
1042 * |
|
1043 * Set the animation in the note attributes. |
|
1044 * Perform layout only for the control. |
|
1045 * The dialog will not be resized. |
|
1046 * |
|
1047 */ |
|
1048 EXPORT_C void CAknNoteControl::SetAnimationL(TInt aResource) |
|
1049 { |
|
1050 Attributes()->SetAnimationL(aResource); |
|
1051 Layout(); |
|
1052 } |
|
1053 |
|
1054 /** |
|
1055 * Set the note icon |
|
1056 * |
|
1057 * Set the icon in the note attributes. |
|
1058 * Perform layout only for the control. |
|
1059 * The dialog will not be resized. |
|
1060 * |
|
1061 */ |
|
1062 EXPORT_C void CAknNoteControl::SetIconL(CEikImage* aIcon) |
|
1063 { |
|
1064 Attributes()->SetIconL(aIcon); |
|
1065 Layout(); |
|
1066 } |
|
1067 |
|
1068 /** |
|
1069 * Set the progress bar final value |
|
1070 * |
|
1071 * Set the progress bar final value in the note attributes. |
|
1072 * |
|
1073 */ |
|
1074 EXPORT_C void CAknNoteControl::SetFinalProgressValue(TInt aValue) |
|
1075 { |
|
1076 Attributes()->SetFinalProgressValue(aValue); |
|
1077 } |
|
1078 |
|
1079 /** |
|
1080 * Increment the progress bar and draw |
|
1081 * |
|
1082 * @see CEikProgressInfo |
|
1083 */ |
|
1084 EXPORT_C TInt CAknNoteControl::IncrementBarsAndDraw(TInt aIncrement) |
|
1085 { |
|
1086 return Attributes()->IncrementBarsAndDraw(aIncrement); |
|
1087 } |
|
1088 |
|
1089 /** |
|
1090 * Create the progress bar |
|
1091 * |
|
1092 * @see CEikProgressInfo |
|
1093 */ |
|
1094 EXPORT_C void CAknNoteControl::CreateProgressBarL() |
|
1095 { |
|
1096 if ( ( iNoteLayout == EProgressLayout ) || ( iNoteLayout == EWaitLayout ) ) |
|
1097 { |
|
1098 Attributes()->CreateProgressBarL(); |
|
1099 } |
|
1100 else |
|
1101 { |
|
1102 User::Leave( KErrGeneral ); |
|
1103 } |
|
1104 } |
|
1105 |
|
1106 /** |
|
1107 * Return the progress bar |
|
1108 * |
|
1109 * @return The progress bar |
|
1110 * |
|
1111 * @see CEikProgressInfo |
|
1112 */ |
|
1113 |
|
1114 EXPORT_C CEikProgressInfo* CAknNoteControl::GetProgressInfo() |
|
1115 { |
|
1116 return ProgressBar(); |
|
1117 } |
|
1118 |
|
1119 /** |
|
1120 * Start the note animation |
|
1121 * |
|
1122 * @see CAknBitmapAnimation |
|
1123 */ |
|
1124 EXPORT_C void CAknNoteControl::StartAnimationL() |
|
1125 { |
|
1126 Attributes()->StartAnimationL(); |
|
1127 } |
|
1128 |
|
1129 /** |
|
1130 * Stop the note animation |
|
1131 * |
|
1132 * @see CAknBitmapAnimation |
|
1133 */ |
|
1134 EXPORT_C TInt CAknNoteControl::CancelAnimation() |
|
1135 { |
|
1136 return Attributes()->CancelAnimation(); |
|
1137 } |
|
1138 |
|
1139 /** |
|
1140 * Reset the note text |
|
1141 * |
|
1142 * Perform layout only for the control. |
|
1143 * The dialog will not be resized. |
|
1144 * |
|
1145 * @see CAknTextControl |
|
1146 */ |
|
1147 EXPORT_C void CAknNoteControl::ResetText() |
|
1148 { |
|
1149 // This can not Leave so no need to use TRAP |
|
1150 Attributes()->SetTextL(KNullDesC); |
|
1151 Layout(); |
|
1152 } |
|
1153 |
|
1154 /** |
|
1155 * Set whole text for the note control. |
|
1156 * |
|
1157 * Perform layout only for the control. |
|
1158 * The dialog will not be resized. |
|
1159 * |
|
1160 */ |
|
1161 EXPORT_C void CAknNoteControl::SetTextL(const TDesC& aText) |
|
1162 { |
|
1163 Attributes()->SetTextL(aText); |
|
1164 Layout(); |
|
1165 } |
|
1166 |
|
1167 /** |
|
1168 * Set text for a specific line. Any previous text will be overwritten, |
|
1169 * except for the text that was set for other lines via this method. |
|
1170 * |
|
1171 * This method prevents ParseTextL from having any effect, hence text |
|
1172 * control needs to know font and line width to allocate space. |
|
1173 * |
|
1174 * This method is kept for backwards compatibility as the same |
|
1175 * results could be achieved by the other SetTextL with no wrapping |
|
1176 * enabled (flag in note attributes) and newline characters in the text to indicate |
|
1177 * a new line. |
|
1178 * |
|
1179 * Perform layout only for the control. |
|
1180 * The dialog will not be resized. |
|
1181 * |
|
1182 */ |
|
1183 EXPORT_C void CAknNoteControl::SetTextL(const TDesC& aText, TInt aLineNum) |
|
1184 { |
|
1185 TAknLayoutText textRect; |
|
1186 |
|
1187 if ( iNoteLayout == ENotificationWithGraphicsLayout || iNoteLayout == ETextualNotificationLayout ) |
|
1188 { |
|
1189 textRect.LayoutText(LayoutRect(), AKN_LAYOUT_TEXT_Notification_pop_up_window_texts__text__Line_1(1)); |
|
1190 } |
|
1191 else |
|
1192 { |
|
1193 textRect.LayoutText(LayoutRect(), AKN_LAYOUT_TEXT_Wait_or_progress_note_pop_up_window_texts_Line_1(1,1,1)); |
|
1194 } |
|
1195 |
|
1196 const CFont *font = textRect.Font(); |
|
1197 |
|
1198 Attributes()->SetTextL(aText, aLineNum, font, iLineWidths); |
|
1199 Layout(); |
|
1200 } |
|
1201 |
|
1202 /** |
|
1203 * Set the number inside the note text. The text must have been |
|
1204 * previously set via resource or via SetTextL and must have a |
|
1205 * \%d or \%N in it. |
|
1206 * |
|
1207 * Note:- This method could be replaced by a SetTextL method with |
|
1208 * a variable number of arguments. |
|
1209 * |
|
1210 * Perform layout only for the control. |
|
1211 * The dialog will not be resized. |
|
1212 * |
|
1213 */ |
|
1214 EXPORT_C void CAknNoteControl::SetTextNumberL(const TInt aNumber) |
|
1215 { |
|
1216 Attributes()->SetTextNumberL(aNumber); |
|
1217 Layout(); |
|
1218 } |
|
1219 |
|
1220 /** |
|
1221 * Determine which text is to be used, either the text for |
|
1222 * singular notes, e.g. "You have 1 new message" or the text |
|
1223 * for plural notes, e.g. "You have %N new messages". These |
|
1224 * texts must have been set via resource. |
|
1225 * |
|
1226 * Note:- This method could be replaced by a SetTextL method with |
|
1227 * a variable number of arguments. |
|
1228 * |
|
1229 * Perform layout only for the control. |
|
1230 * The dialog will not be resized. |
|
1231 * |
|
1232 */ |
|
1233 EXPORT_C void CAknNoteControl::SetTextPluralityL(const TBool aIsPlural) |
|
1234 { |
|
1235 Attributes()->SetTextPluralityL(aIsPlural); |
|
1236 Layout(); |
|
1237 } |
|
1238 |
|
1239 /** |
|
1240 * Return the number of lines. |
|
1241 * |
|
1242 */ |
|
1243 EXPORT_C TInt CAknNoteControl::NumberOfLines() const |
|
1244 { |
|
1245 return TextControl()->NumberOfLines(); |
|
1246 } |
|
1247 |
|
1248 /** |
|
1249 * @deprecated - use SetTextL instead |
|
1250 */ |
|
1251 EXPORT_C void CAknNoteControl::SetDynamicTextL(const TDesC& aText) |
|
1252 { |
|
1253 SetTextL(aText); |
|
1254 } |
|
1255 |
|
1256 /** |
|
1257 * @deprecated - use SetTextL instead |
|
1258 */ |
|
1259 EXPORT_C void CAknNoteControl::UpdateAndFormatLabelsL(const TDesC& aLabels) |
|
1260 { |
|
1261 SetTextL(aLabels); |
|
1262 } |
|
1263 |
|
1264 /** |
|
1265 * @deprecated - use SetTextL instead |
|
1266 */ |
|
1267 EXPORT_C void CAknNoteControl::UpdateLabelsL(const TDesC& aLabel1, const TDesC& aLabel2, const TDesC& aLabel3) |
|
1268 { |
|
1269 SetTextL(aLabel1, 0); |
|
1270 SetTextL(aLabel2, 1); |
|
1271 SetTextL(aLabel3, 2); |
|
1272 } |
|
1273 |
|
1274 /** |
|
1275 * @deprecated - use SetTextL instead |
|
1276 */ |
|
1277 EXPORT_C void CAknNoteControl::UpdateLabels(const TDesC& aLabel1, const TDesC& aLabel2, const TDesC& aLabel3) |
|
1278 { |
|
1279 TRAP_IGNORE(UpdateLabelsL(aLabel1,aLabel2,aLabel3)); |
|
1280 } |
|
1281 |
|
1282 /** |
|
1283 * @deprecated - label length is taken care of already |
|
1284 * |
|
1285 * Don't use this method anymore. |
|
1286 */ |
|
1287 EXPORT_C void CAknNoteControl::SetLabelReserveLengthL(TInt /*aLength1*/, TInt /*aLength2*/, TInt /*aLength3*/) |
|
1288 { |
|
1289 } |
|
1290 |
|
1291 /** |
|
1292 * Following methods give access to note attributes |
|
1293 * Because these attributes are stored in CAknNoteAttributes, |
|
1294 * I've used indirection in case this changes in future |
|
1295 */ |
|
1296 |
|
1297 CAknNoteAttributes* CAknNoteControl::Attributes() const |
|
1298 { |
|
1299 return iAttributes; |
|
1300 } |
|
1301 |
|
1302 CAknTextControl* CAknNoteControl::TextControl() const |
|
1303 { |
|
1304 if (iAttributes) |
|
1305 return iAttributes->iNoteText; |
|
1306 return NULL; |
|
1307 } |
|
1308 |
|
1309 CEikImage* CAknNoteControl::Image() const |
|
1310 { |
|
1311 if (iAttributes) |
|
1312 return iAttributes->iImage; |
|
1313 return NULL; |
|
1314 } |
|
1315 |
|
1316 CEikImage* CAknNoteControl::Icon() const |
|
1317 { |
|
1318 if (iAttributes) |
|
1319 return iAttributes->iIcon; |
|
1320 return NULL; |
|
1321 } |
|
1322 |
|
1323 CEikProgressInfo* CAknNoteControl::ProgressBar() const |
|
1324 { |
|
1325 if (iAttributes) |
|
1326 return iAttributes->iProgressBar; |
|
1327 return NULL; |
|
1328 } |
|
1329 |
|
1330 CAknProgressTimer* CAknNoteControl::Timer() const |
|
1331 { |
|
1332 if (iAttributes) |
|
1333 return iAttributes->iTimer; |
|
1334 return NULL; |
|
1335 } |
|
1336 |
|
1337 CAknBitmapAnimation* CAknNoteControl::Animation() const |
|
1338 { |
|
1339 if (iAttributes) |
|
1340 return iAttributes->iAnimation; |
|
1341 return NULL; |
|
1342 } |
|
1343 |
|
1344 TBitFlags& CAknNoteControl::Flags() const |
|
1345 { |
|
1346 return Attributes()->iFlags; |
|
1347 } |
|
1348 |
|
1349 /***************************************************************** |
|
1350 * CAknNoteControl::TIndex |
|
1351 * |
|
1352 * Manage indexes into LAF tables |
|
1353 * |
|
1354 * NP stands for "Note Popup" |
|
1355 * WNP stands for "Waiting/progress Note Popup" |
|
1356 * NWIP stands for "Note With Image Popup" |
|
1357 * |
|
1358 ******************************************************************/ |
|
1359 |
|
1360 |
|
1361 CAknNoteControl::TIndex::TIndex(TInt aNumberOfLines,TBool aHasNti, TSize aImageSize) |
|
1362 : iNumberOfLines(aNumberOfLines),iHasNti(aHasNti), iImageSize (aImageSize) |
|
1363 { |
|
1364 } |
|
1365 |
|
1366 void CAknNoteControl::TIndex::SelfTest() const |
|
1367 { |
|
1368 __ASSERT_DEBUG(iNumberOfLines >= 0 && iNumberOfLines <= 5, |
|
1369 Panic(EAknPanicInvalidValue)); |
|
1370 } |
|
1371 |
|
1372 TInt CAknNoteControl::TIndex::ImageWidthIndex() const |
|
1373 { |
|
1374 TInt ret = 0; |
|
1375 TRect rect(0,0,0,0); |
|
1376 if (iImageSize.iWidth == 0) |
|
1377 return ret; |
|
1378 else |
|
1379 { |
|
1380 TAknLayoutRect layRect; |
|
1381 layRect.LayoutRect(rect, AKN_LAYOUT_WINDOW_Note_with_an_image_pop_up_window_elements_Line_6); |
|
1382 ret++; |
|
1383 if (iImageSize.iWidth > layRect.Rect().Width()) |
|
1384 { |
|
1385 layRect.LayoutRect(rect, AKN_LAYOUT_WINDOW_Note_with_an_image_pop_up_window_elements_Line_2); |
|
1386 ret++; |
|
1387 if (iImageSize.iWidth > layRect.Rect().Width()) |
|
1388 { |
|
1389 layRect.LayoutRect(rect, AKN_LAYOUT_WINDOW_Note_with_an_image_pop_up_window_elements_Line_8); |
|
1390 ret++; |
|
1391 if (iImageSize.iWidth > layRect.Rect().Width()) |
|
1392 { |
|
1393 ret++; |
|
1394 } |
|
1395 } |
|
1396 } |
|
1397 } |
|
1398 return ret; |
|
1399 } |
|
1400 |
|
1401 TInt CAknNoteControl::TIndex::ImageHeightIndex() const |
|
1402 { |
|
1403 TInt ret = 0; |
|
1404 TRect rect(0,0,0,0); |
|
1405 if (iImageSize.iHeight == 0) |
|
1406 return ret; |
|
1407 else |
|
1408 { |
|
1409 TAknLayoutRect layRect; |
|
1410 layRect.LayoutRect(rect, AKN_LAYOUT_WINDOW_Note_with_an_image_pop_up_window_elements_Line_6); |
|
1411 ret++; |
|
1412 if (iImageSize.iHeight > layRect.Rect().Height()) |
|
1413 { |
|
1414 layRect.LayoutRect(rect, AKN_LAYOUT_WINDOW_Note_with_an_image_pop_up_window_elements_Line_2); |
|
1415 ret++; |
|
1416 if (iImageSize.iHeight > layRect.Rect().Height()) |
|
1417 { |
|
1418 layRect.LayoutRect(rect, AKN_LAYOUT_WINDOW_Note_with_an_image_pop_up_window_elements_Line_8); |
|
1419 ret++; |
|
1420 if (iImageSize.iHeight > layRect.Rect().Height()) |
|
1421 { |
|
1422 ret++; |
|
1423 } |
|
1424 } |
|
1425 } |
|
1426 } |
|
1427 return ret; |
|
1428 } |
|
1429 |
|
1430 TInt CAknNoteControl::TIndex::HasNtiIndex() const |
|
1431 { |
|
1432 if (iHasNti) |
|
1433 return 1; |
|
1434 return 0; |
|
1435 } |
|
1436 |
|
1437 TInt CAknNoteControl::TIndex::Lines() const |
|
1438 { |
|
1439 SelfTest(); |
|
1440 return iNumberOfLines > 0 ? iNumberOfLines - 1 : 0; |
|
1441 } |
|
1442 |
|
1443 /** |
|
1444 * Return index into table "Waiting/progress Note Popup Window Texts Line 1" |
|
1445 * Index depends on the number of text lines and whether or not there is a |
|
1446 * number type indication (NTI). See table in *.lay and |
|
1447 * LAF specs for working out indexes. |
|
1448 */ |
|
1449 TInt CAknNoteControl::TIndex::WNPWindowTextsLine1(TInt aLineNum) const |
|
1450 { |
|
1451 SelfTest(); |
|
1452 |
|
1453 if(iHasNti && aLineNum == 1) |
|
1454 return KPNMaxNumLines; |
|
1455 |
|
1456 return aLineNum; |
|
1457 } |
|
1458 |
|
1459 |
|
1460 /** |
|
1461 * Return Left index into table "Note With Image Popup Window Texts Line 1" |
|
1462 * Index depends on number of text lines, whether or not there is a |
|
1463 * number type indication (NTI). See table in *.lay and |
|
1464 * LAF specs for working out indexes. |
|
1465 */ |
|
1466 TInt CAknNoteControl::TIndex::NWIPWindowTextsLine1L(TInt aLineNum) const |
|
1467 { |
|
1468 SelfTest(); |
|
1469 static const TInt KNWIPWindowTextsLine1IndexL[2][3] = |
|
1470 { |
|
1471 {0, 0, 0}, //NO NTI |
|
1472 {0, 0, 2} //NTI |
|
1473 }; |
|
1474 |
|
1475 return KNWIPWindowTextsLine1IndexL[HasNtiIndex()][aLineNum]; |
|
1476 } |
|
1477 |
|
1478 /** |
|
1479 * Return Right index into table "Note With Image Popup Window Texts Line 1" |
|
1480 * Index depends on number of text lines and image size. |
|
1481 * See table in *.lay and LAF specs for working out indexes. |
|
1482 * |
|
1483 * Table has 3 dimensions:- |
|
1484 * - Dimension 1 is the line number |
|
1485 * - Dimension 2 is the image width |
|
1486 * - Dimension 3 is the image height |
|
1487 */ |
|
1488 TInt CAknNoteControl::TIndex::NWIPWindowTextsLine1R(TInt aLineNum) const |
|
1489 { |
|
1490 SelfTest(); |
|
1491 |
|
1492 static const TInt KNWIPWindowTextsLine1IndexR[3][5][5] = |
|
1493 { |
|
1494 {{0, 0, 0, 0, 0}, {0, 3, 3, 3, 3}, {0, 5, 5, 5, 5}, {0, 7, 7, 7, 7}, {0, 9, 9, 9, 9} }, //FIRST LINE |
|
1495 {{0, 0, 0, 0, 0}, {0, 3, 3, 3, 3}, {0, 5, 5, 5, 5}, {0, 7, 7, 7, 7}, {0, 9, 9, 9, 9} }, //SECOND LINE |
|
1496 {{0, 0, 0, 0, 0}, {0, 0, 0, 3, 3}, {0, 0, 0, 5, 5}, {0, 0, 0, 7, 7}, {0, 0, 0, 9, 9} } //THIRD LINE |
|
1497 }; |
|
1498 |
|
1499 return KNWIPWindowTextsLine1IndexR[aLineNum][ImageWidthIndex()][ImageHeightIndex()]; |
|
1500 |
|
1501 } |
|
1502 |
|
1503 /** |
|
1504 * Return Bottom index into table "Note With Image Popup Window Texts Line 1" |
|
1505 * Index is the same as the number of text lines minus one. See table in *.lay and |
|
1506 * LAF specs for working out indexes. |
|
1507 */ |
|
1508 TInt CAknNoteControl::TIndex::NWIPWindowTextsLine1B(TInt aLineNum) const |
|
1509 { |
|
1510 return aLineNum; |
|
1511 } |
|
1512 |
|
1513 /** |
|
1514 * Return Width index into table "Note With Image Popup Window Texts Line 1" |
|
1515 * Index depends on number of text lines, whether or not there is a |
|
1516 * number type indication (NTI) and image size. See table in *.lay and |
|
1517 * LAF specs for working out indexes. |
|
1518 * |
|
1519 * Table has 4 dimensions:- |
|
1520 * - Dimension 1 indicates the presence of an NTI (index 0 = NO NTI, index 1 = NTI) |
|
1521 * - Dimension 2 is the line number |
|
1522 * - Dimension 3 is the image width |
|
1523 * - Dimension 4 is the image height |
|
1524 */ |
|
1525 TInt CAknNoteControl::TIndex::NWIPWindowTextsLine1W(TInt aLineNum) const |
|
1526 { |
|
1527 SelfTest(); |
|
1528 |
|
1529 static const TInt KNWIPWindowTextsLine1IndexW[2][3][5][5] = |
|
1530 { |
|
1531 { |
|
1532 {{0, 0, 0, 0, 0}, {0, 3, 3, 3, 3}, {0, 5, 5, 5, 5}, {0, 7, 7, 7, 7}, {0, 9, 9, 9, 9} }, //FIRST LINE |
|
1533 {{0, 0, 0, 0, 0}, {0, 3, 3, 3, 3}, {0, 5, 5, 5, 5}, {0, 7, 7, 7, 7}, {0, 9, 9, 9, 9} }, //SECOND LINE |
|
1534 {{0, 0, 0, 0, 0}, {0, 0, 0, 3, 3}, {0, 0, 0, 5, 5}, {0, 0, 0, 7, 7}, {0, 0, 0, 9, 9} } //THIRD LINE |
|
1535 },//NO NTI |
|
1536 { |
|
1537 {{0, 0, 0, 0, 0}, {0, 3, 3, 3, 3}, {0, 5, 5, 5, 5}, {0, 7, 7, 7, 7}, {0, 9, 9, 9, 9} }, //FIRST LINE |
|
1538 {{0, 0, 0, 0, 0}, {0, 3, 3, 3, 3}, {0, 5, 5, 5, 5}, {0, 7, 7, 7, 7}, {0, 9, 9, 9, 9} }, //SECOND LINE |
|
1539 {{2, 2, 2, 2, 2}, {2, 2, 2, 4, 4}, {2, 2, 2, 6, 6}, {2, 2, 2, 8, 8}, {2, 2, 2, 10, 10} }//THIRD LINE |
|
1540 }//NTI |
|
1541 }; |
|
1542 |
|
1543 return KNWIPWindowTextsLine1IndexW[HasNtiIndex()][aLineNum][ImageWidthIndex()][ImageHeightIndex()]; |
|
1544 |
|
1545 } |
|
1546 |
|
1547 /** |
|
1548 * Return indexes for table AKN_LAYOUT_WINDOW_popup_note_window |
|
1549 * If there are 0-2 lines the |
|
1550 * index is 0. If there are 3 lines the index is 1, if there |
|
1551 * are 4 or more lines the index is 2. |
|
1552 */ |
|
1553 TInt CAknNoteControl::TIndex::PopupNoteWindow() const |
|
1554 { |
|
1555 if (Lines() >= 4) |
|
1556 return 2; |
|
1557 |
|
1558 else if (Lines() == 3) |
|
1559 return 1; |
|
1560 |
|
1561 else |
|
1562 return 0; |
|
1563 } |
|
1564 |
|
1565 /** |
|
1566 * Return indexes for table AKN_LAYOUT_WINDOW_popup_note_wait_window |
|
1567 * If there are 0-2 lines the |
|
1568 * index is 0. If there are 3 lines the index is 1, if there are 4 lines the |
|
1569 * index is 2. |
|
1570 */ |
|
1571 TInt CAknNoteControl::TIndex::PopupNoteWaitWindow() const |
|
1572 { |
|
1573 if (Lines() >= 3) |
|
1574 return 2; |
|
1575 |
|
1576 else if (Lines() == 2) |
|
1577 return 1; |
|
1578 |
|
1579 else |
|
1580 return 0; |
|
1581 } |
|
1582 |
|
1583 EXPORT_C TTypeUid::Ptr CAknNoteControl::MopSupplyObject(TTypeUid aId) |
|
1584 { |
|
1585 |
|
1586 if (Attributes()) |
|
1587 { |
|
1588 return MAknsControlContext::SupplyMopObject(aId, iAttributes->iBgContext ); |
|
1589 } |
|
1590 |
|
1591 return CCoeControl::MopSupplyObject(aId); |
|
1592 } |
|
1593 |
|
1594 EXPORT_C void CAknNoteControl::SetBgRect(const TRect& aRect, const TPoint& aPos, TBool /*aOwnerNotDialog*/) |
|
1595 { |
|
1596 if (Attributes()) |
|
1597 { |
|
1598 TRect windowRect = aRect; |
|
1599 |
|
1600 TAknLayoutRect topLeft; |
|
1601 topLeft.LayoutRect(windowRect, Popup_windows_skin_placing__frame_general__Line_2()); |
|
1602 |
|
1603 TAknLayoutRect bottomRight; |
|
1604 bottomRight.LayoutRect(windowRect, Popup_windows_skin_placing__frame_general__Line_5()); |
|
1605 |
|
1606 TRect outerRect = TRect(topLeft.Rect().iTl, bottomRight.Rect().iBr); |
|
1607 TRect innerRect = TRect(topLeft.Rect().iBr, bottomRight.Rect().iTl); |
|
1608 |
|
1609 if (Attributes()->iBgContext) |
|
1610 { |
|
1611 Attributes()->iBgContext->SetFrameRects( outerRect, innerRect ); |
|
1612 Attributes()->iBgContext->SetParentPos(aPos); |
|
1613 } |
|
1614 |
|
1615 Attributes()->iBgRect = outerRect; |
|
1616 } |
|
1617 } |
|
1618 |
|
1619 TInt CAknNoteControl::NoteLayout() const |
|
1620 { |
|
1621 return iNoteLayout; |
|
1622 } |
|
1623 |
|
1624 // End of File |