|
1 /* |
|
2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <eikimage.h> |
|
19 #include <eikcapc.h> |
|
20 |
|
21 #include <eikon.hrh> |
|
22 #include <touchfeedback.h> |
|
23 #include "AknUtils.h" |
|
24 #include "AknPanic.h" |
|
25 |
|
26 #include "aknborders.h" |
|
27 #include "aknappui.h" |
|
28 #include "aknsoundsystem.h" |
|
29 |
|
30 #include "aknnotedialog.h" |
|
31 #include "aknnotecontrol.h" |
|
32 #include "aknnoteattributes.h" |
|
33 #include "AknDef.h" |
|
34 |
|
35 #include <AknsFrameBackgroundControlContext.h> |
|
36 #include "AknDebug.h" |
|
37 |
|
38 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
|
39 #include <gfxtranseffect/gfxtranseffect.h> |
|
40 #include <akntransitionutils.h> |
|
41 #include <akntranseffect.h> |
|
42 |
|
43 #include <e32property.h> |
|
44 #include <avkondomainpskeys.h> |
|
45 #include <aknglobalpopupprioritycontroller.h> |
|
46 #endif |
|
47 |
|
48 #include <AknTasHook.h> // for testability hooks |
|
49 const TInt EEikDialogFlagSleeping =0x20000; |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // Finds out if this control belongs to the window group that is in focus. |
|
53 // This information can be used to skip effects when the window group is |
|
54 // not visible. |
|
55 // |
|
56 // @param aThis The control in question. |
|
57 // |
|
58 // @return ETrue if the window group is in focus, otherwise EFalse |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 TBool IsFocusedWindowGroup( CAknNoteDialog* aThis ) |
|
62 { |
|
63 RWindowTreeNode* node = aThis->DrawableWindow(); |
|
64 // this code finds out if this control belongs to window group |
|
65 // that is in focus, there are some rare cases when the latest opened |
|
66 // popup goes behind another one (e.g. system lock query -> power key menu) |
|
67 // we don't want transition in that case |
|
68 RWsSession& wsSession = CEikonEnv::Static()->WsSession(); |
|
69 |
|
70 if ( !node ) |
|
71 { |
|
72 return EFalse; |
|
73 } |
|
74 TInt nodeWindowGroupId = node->WindowGroupId(); |
|
75 TInt focusedWindowGroupId = wsSession.GetFocusWindowGroup(); |
|
76 |
|
77 if ( nodeWindowGroupId == focusedWindowGroupId ) |
|
78 { |
|
79 return ETrue; |
|
80 } |
|
81 |
|
82 TInt count = wsSession.NumWindowGroups( 0 ); |
|
83 |
|
84 // because there is not leave here,so no need to use CleanupStack. |
|
85 CArrayFixFlat<TInt>* wgIds = new CArrayFixFlat<TInt>( count ); |
|
86 if ( wgIds ) |
|
87 { |
|
88 // Get list of window group ids from WServ |
|
89 wsSession.WindowGroupList( 0, wgIds ); |
|
90 |
|
91 // Select the first in the list (which will always be the forground app) |
|
92 // and we assume that there always will be at least one window group with zero priority |
|
93 TInt wgId = (*wgIds)[0]; |
|
94 |
|
95 delete wgIds; |
|
96 |
|
97 if ( focusedWindowGroupId == wgId ) |
|
98 { |
|
99 return ETrue; |
|
100 } |
|
101 } |
|
102 return EFalse; |
|
103 } |
|
104 |
|
105 ////////////////////////////////////////////////////////////////////// |
|
106 // CAknNoteDialogExtension |
|
107 ////////////////////////////////////////////////////////////////////// |
|
108 NONSHARABLE_CLASS(CAknNoteDialogExtension) : public CBase |
|
109 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
|
110 ,public MAknTransitionUtilsObserver |
|
111 #endif |
|
112 { |
|
113 public: |
|
114 static CAknNoteDialogExtension* NewL( CAknNoteDialog& aOwner ); |
|
115 ~CAknNoteDialogExtension(); |
|
116 |
|
117 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
|
118 // From MAknTransitionUtilsObserver |
|
119 TInt AknTransitionCallback(TInt aEvent, TInt aState = 0, |
|
120 const TDesC8* aParams = NULL); |
|
121 #endif |
|
122 private: |
|
123 CAknNoteDialogExtension( CAknNoteDialog& aOwner ); |
|
124 void ConstructL(); |
|
125 |
|
126 public: |
|
127 CAknNoteDialog& iOwner; |
|
128 |
|
129 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
|
130 // NoteControl() is now protected in CAknNoteDialog, so we need this |
|
131 // to start the animation from the callback. |
|
132 public: |
|
133 CAknNoteControl* iControl; |
|
134 #endif |
|
135 }; |
|
136 |
|
137 CAknNoteDialogExtension::CAknNoteDialogExtension( CAknNoteDialog& aOwner ) |
|
138 : iOwner( aOwner ) |
|
139 { |
|
140 } |
|
141 |
|
142 CAknNoteDialogExtension* CAknNoteDialogExtension::NewL( CAknNoteDialog& aOwner ) |
|
143 { |
|
144 CAknNoteDialogExtension* self = new( ELeave ) CAknNoteDialogExtension( aOwner ); |
|
145 CleanupStack::PushL( self ); |
|
146 self->ConstructL(); |
|
147 CleanupStack::Pop(); |
|
148 return self; |
|
149 } |
|
150 |
|
151 void CAknNoteDialogExtension::ConstructL() |
|
152 { |
|
153 } |
|
154 |
|
155 CAknNoteDialogExtension::~CAknNoteDialogExtension() |
|
156 { |
|
157 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
|
158 CAknTransitionUtils::RemoveObserver( this, |
|
159 CAknTransitionUtils::EEventControlTransitionFinished ); |
|
160 #endif |
|
161 } |
|
162 |
|
163 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
|
164 TInt CAknNoteDialogExtension::AknTransitionCallback(TInt /*aEvent*/, |
|
165 TInt /*aState*/, |
|
166 const TDesC8* /*aParams*/) |
|
167 { |
|
168 TRAP_IGNORE(iControl->StartAnimationL()); |
|
169 |
|
170 CAknTransitionUtils::RemoveObserver( this, |
|
171 CAknTransitionUtils::EEventControlTransitionFinished ); |
|
172 |
|
173 return KErrNone; |
|
174 } |
|
175 #endif |
|
176 |
|
177 ////////////////////////////////////////////////////////////////////// |
|
178 // Construction/Destruction |
|
179 ////////////////////////////////////////////////////////////////////// |
|
180 |
|
181 EXPORT_C CAknNoteDialog::CAknNoteDialog() : CEikDialog(), |
|
182 iTimeoutInMicroseconds(ENoTimeout), iTone(ENoTone) |
|
183 { |
|
184 AKNTASHOOK_ADD( this, "CAknNoteDialog" ); |
|
185 } |
|
186 |
|
187 EXPORT_C CAknNoteDialog::CAknNoteDialog(const TTone& aTone, const TTimeout& aTimeout) : |
|
188 CEikDialog(), iTimeoutInMicroseconds(aTimeout), iTone(aTone) |
|
189 { |
|
190 AKNTASHOOK_ADD( this, "CAknNoteDialog" ); |
|
191 } |
|
192 |
|
193 EXPORT_C CAknNoteDialog::CAknNoteDialog(CEikDialog** aSelfPtr,const TTone& aTone, const TTimeout& aTimeout) : |
|
194 CEikDialog(), iTimeoutInMicroseconds(aTimeout), iSelfPtr(aSelfPtr), iTone(aTone) |
|
195 { |
|
196 AKNTASHOOK_ADD( this, "CAknNoteDialog" ); |
|
197 } |
|
198 |
|
199 EXPORT_C CAknNoteDialog::~CAknNoteDialog() |
|
200 { |
|
201 AKNTASHOOK_REMOVE(); |
|
202 // FIXME: Experimental heuristics for determining popup type |
|
203 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
|
204 |
|
205 if ( GfxTransEffect::IsRegistered( this ) ) |
|
206 { |
|
207 // abort component effects (possibly appear effect) |
|
208 // if aknnote gets destroyed without user interaction or timers |
|
209 GfxTransEffect::NotifyExternalState( ENotifyGlobalAbort ); |
|
210 GfxTransEffect::Deregister(this); //Always deregister in destructor. |
|
211 } |
|
212 CAknTransitionUtils::RemoveData( ( TInt )NoteControl() ); |
|
213 #endif |
|
214 |
|
215 delete iTimer; |
|
216 #if defined _DEBUG && defined __WINS__ |
|
217 if (!(DialogFlags()&EEikDialogFlagWait)) |
|
218 DbgCheckSelfPtr(iSelfPtr); |
|
219 #endif |
|
220 if (iSelfPtr) |
|
221 { |
|
222 *iSelfPtr = NULL; |
|
223 iSelfPtr = NULL; |
|
224 } |
|
225 |
|
226 delete iControlAttributes; |
|
227 delete iNoteExtension; |
|
228 } |
|
229 |
|
230 EXPORT_C void CAknNoteDialog::SetTimeout(const TTimeout& aTimeout) |
|
231 { |
|
232 iTimeoutInMicroseconds = aTimeout; |
|
233 } |
|
234 |
|
235 |
|
236 EXPORT_C void CAknNoteDialog::SetTone(const TTone& aTone) |
|
237 { |
|
238 iTone = aTone; |
|
239 } |
|
240 |
|
241 EXPORT_C void CAknNoteDialog::SetTextWrapping(TBool aEnabled) |
|
242 { |
|
243 CAknNoteAttributes* attr = ControlAttributes(); |
|
244 if ( !attr ) |
|
245 { |
|
246 return; // Nothing else we can do |
|
247 } |
|
248 if (aEnabled) |
|
249 { |
|
250 attr->iClearFlags.Set(ENoteNoTextWrapping); |
|
251 } |
|
252 else |
|
253 { |
|
254 attr->iFlags.Set(ENoteNoTextWrapping); |
|
255 } |
|
256 |
|
257 LayoutAndDraw(); |
|
258 } |
|
259 |
|
260 EXPORT_C void CAknNoteDialog::SetTextProcessing(TBool aEnabled) |
|
261 { |
|
262 CAknNoteAttributes* attr = ControlAttributes(); |
|
263 if ( !attr ) |
|
264 { |
|
265 return; // Nothing else we can do |
|
266 } |
|
267 if (aEnabled) |
|
268 { |
|
269 attr->iClearFlags.Set(ENoteNoTextProcessing); |
|
270 } |
|
271 else |
|
272 { |
|
273 attr->iFlags.Set(ENoteNoTextProcessing); |
|
274 } |
|
275 |
|
276 LayoutAndDraw(); |
|
277 } |
|
278 |
|
279 EXPORT_C void CAknNoteDialog::SetImageL(CEikImage* aImage) |
|
280 { |
|
281 CAknNoteAttributes* attr = ControlAttributes(); |
|
282 if ( !attr ) |
|
283 { |
|
284 User::Leave(KErrNoMemory); |
|
285 } |
|
286 attr->SetImageL(aImage); |
|
287 |
|
288 if (attr->IsLayoutNeeded()) |
|
289 { |
|
290 LayoutAndDraw(); |
|
291 } |
|
292 } |
|
293 |
|
294 EXPORT_C void CAknNoteDialog::SetIconL(CEikImage* aIcon) |
|
295 { |
|
296 CAknNoteAttributes* attr = ControlAttributes(); |
|
297 if ( !attr ) |
|
298 { |
|
299 User::Leave(KErrNoMemory); |
|
300 } |
|
301 attr->SetIconL(aIcon); |
|
302 |
|
303 if (attr->IsLayoutNeeded()) |
|
304 { |
|
305 LayoutAndDraw(); |
|
306 } |
|
307 } |
|
308 |
|
309 EXPORT_C void CAknNoteDialog::SetTextNumberL(TInt aNumber) |
|
310 { |
|
311 CAknNoteAttributes* attr = ControlAttributes(); |
|
312 if ( !attr ) |
|
313 { |
|
314 User::Leave(KErrNoMemory); |
|
315 } |
|
316 attr->SetTextNumberL(aNumber); |
|
317 |
|
318 if (attr->IsLayoutNeeded()) |
|
319 { |
|
320 LayoutAndDraw(); |
|
321 } |
|
322 } |
|
323 |
|
324 EXPORT_C void CAknNoteDialog::SetTextPluralityL(const TBool aIsPlural) |
|
325 { |
|
326 CAknNoteAttributes* attr = ControlAttributes(); |
|
327 if ( !attr ) |
|
328 { |
|
329 User::Leave(KErrNoMemory); |
|
330 } |
|
331 attr->SetTextPluralityL(aIsPlural); |
|
332 |
|
333 if (attr->IsLayoutNeeded()) |
|
334 { |
|
335 LayoutAndDraw(); |
|
336 } |
|
337 |
|
338 } |
|
339 |
|
340 EXPORT_C void CAknNoteDialog::SetTextL(const TDesC& aLabel) |
|
341 { |
|
342 CAknNoteAttributes* attr = ControlAttributes(); |
|
343 if ( !attr ) |
|
344 { |
|
345 User::Leave(KErrNoMemory); |
|
346 } |
|
347 if (attr->Text().Compare( aLabel ) ) |
|
348 { |
|
349 attr->SetTextL(aLabel); |
|
350 if (attr->IsLayoutNeeded()) |
|
351 { |
|
352 LayoutAndDraw(); |
|
353 } |
|
354 } |
|
355 } |
|
356 |
|
357 /** |
|
358 * @deprecated - use SetTextL |
|
359 */ |
|
360 EXPORT_C void CAknNoteDialog::SetCurrentLabelL(TInt /*aControlId*/,const TDesC& aLabel) |
|
361 { |
|
362 SetTextL(aLabel); |
|
363 } |
|
364 |
|
365 EXPORT_C TKeyResponse CAknNoteDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
366 { |
|
367 /// Only interested in standard key events |
|
368 if (aType != EEventKey || |
|
369 (aType == EEventKey && aKeyEvent.iCode == EKeyEscape) |
|
370 ) // must pass escape event to dialog. |
|
371 { |
|
372 return CEikDialog::OfferKeyEventL(aKeyEvent,aType); |
|
373 } |
|
374 |
|
375 /// All short keypresses dismisses the note |
|
376 if ( !aKeyEvent.iRepeats ) |
|
377 { |
|
378 StaticDeleteL(this); |
|
379 } |
|
380 return EKeyWasConsumed; |
|
381 } |
|
382 |
|
383 EXPORT_C void CAknNoteDialog::LayoutAndDraw() |
|
384 { |
|
385 if (IsActivated()) |
|
386 { |
|
387 TRect screenRect = iAvkonAppUi->ApplicationRect(); |
|
388 SetSizeAndPosition(PreferredSize( screenRect.Size()/*TSize(AKN_LAYOUT_WINDOW_screen.iW,AKN_LAYOUT_WINDOW_screen.iH)*/)); |
|
389 DrawNow(); |
|
390 |
|
391 // Tell the attributes that the note has been fully drawn. |
|
392 // Optimized text drawing is allowed only after this. |
|
393 CAknNoteAttributes* attr = ControlAttributes(); |
|
394 if ( attr ) |
|
395 { |
|
396 RDebug::Print(_L("CAknNoteDialog allowing opt. draw, %d"), (TUint)this ); |
|
397 attr->AllowOptimizedDrawing(); |
|
398 } |
|
399 } |
|
400 } |
|
401 |
|
402 EXPORT_C TInt CAknNoteDialog::RunLD() |
|
403 { |
|
404 PlayTone(); |
|
405 ReportUserActivity(); |
|
406 |
|
407 // FIXME: Experimental heuristics for finding out popup context from image/animation |
|
408 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
|
409 TInt uid = ( TInt )CAknTransitionUtils::GetData( ( TInt )NoteControl() ); |
|
410 // only change registration, if not registered, don't register |
|
411 if ( uid != 0 && GfxTransEffect::IsRegistered( this ) ) |
|
412 { |
|
413 GfxTransEffect::Register( this, TUid::Uid( uid ) ); |
|
414 CAknTransitionUtils::RemoveData( ( TInt )NoteControl() ); |
|
415 } |
|
416 #endif |
|
417 |
|
418 return CEikDialog::RunLD(); |
|
419 } |
|
420 |
|
421 EXPORT_C TInt CAknNoteDialog::StaticDeleteL(TAny *aThis) |
|
422 { |
|
423 CAknNoteDialog* self = REINTERPRET_CAST(CAknNoteDialog*,aThis); |
|
424 |
|
425 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
|
426 if ( self->IsVisible() && GfxTransEffect::IsRegistered( self ) && |
|
427 IsFocusedWindowGroup( self ) ) |
|
428 { |
|
429 TBool rsWasEnabled( EFalse ); |
|
430 if( !CAknEnv::Static()->TransparencyEnabled() && self->DrawableWindow() && self->Window().IsRedrawStoreEnabled() ) |
|
431 { |
|
432 rsWasEnabled = ETrue; |
|
433 // disable redrawstore during transition to avoid |
|
434 // drawing problems behind control |
|
435 self->Window().EnableRedrawStore( EFalse ); |
|
436 } |
|
437 |
|
438 GfxTransEffect::NotifyExternalState( ENotifyGlobalAbort ); |
|
439 |
|
440 //If still visible, do a transition to invisible state. |
|
441 CAknTransitionUtils::SetAllParents(self); |
|
442 GfxTransEffect::Begin(self, KGfxControlDisappearAction); |
|
443 GfxTransEffect::NotifyExternalState(ECaptureComponentsBegin, (const TDesC8*)self); |
|
444 |
|
445 TRect demarcation; |
|
446 CAknTransitionUtils::GetDemarcation(CAknTransitionUtils::EPopup, |
|
447 demarcation); |
|
448 GfxTransEffect::SetDemarcation(self, demarcation); |
|
449 |
|
450 self->MakeVisible(EFalse); |
|
451 |
|
452 GfxTransEffect::NotifyExternalState(ECaptureComponentsEnd, (const TDesC8*)self); |
|
453 GfxTransEffect::End(self); |
|
454 |
|
455 if( !CAknEnv::Static()->TransparencyEnabled() && rsWasEnabled ) |
|
456 { |
|
457 // if redrawstore was on before transition, |
|
458 // enable it again |
|
459 self->Window().EnableRedrawStore( ETrue ); |
|
460 } |
|
461 |
|
462 |
|
463 } |
|
464 |
|
465 #endif // RD_UI_TRANSITION_EFFECTS_POPUPS |
|
466 // Only actual delete the note if it's not a sleeping note |
|
467 // Deleting a sleeping note is really bad! |
|
468 if (!(self->DialogFlags()&EEikDialogFlagSleeping)) |
|
469 { |
|
470 delete self; |
|
471 } |
|
472 else |
|
473 { |
|
474 // Tell subclasses that the dialog is going to sleep |
|
475 if (self->iTimer) |
|
476 self->iTimer->Cancel(); |
|
477 self->OkToExitL(KErrCancel); |
|
478 self->ExitSleepingDialog(); |
|
479 self->NoteControl()->Reset(); |
|
480 } |
|
481 return EFalse; |
|
482 } |
|
483 |
|
484 |
|
485 EXPORT_C void CAknNoteDialog::SetSizeAndPosition( const TSize& aSize ) |
|
486 { |
|
487 SetBorder( TGulBorder::ENone ); |
|
488 CAknNoteControl* note = NoteControl(); |
|
489 if (note) |
|
490 { |
|
491 if (!ControlAttributes()->IsLayoutNeeded()) // if we have a note control, there must be attributes also |
|
492 return; |
|
493 |
|
494 if ( AknLayoutUtils::PenEnabled() ) |
|
495 { |
|
496 CEikDialog::SetSizeAndPosition( aSize ); |
|
497 } |
|
498 else |
|
499 { |
|
500 TRect mainPane; |
|
501 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EPopupParent, |
|
502 mainPane ); |
|
503 |
|
504 TAknWindowLineLayout dialogLay; |
|
505 note->WindowLayout( dialogLay ); |
|
506 |
|
507 AknLayoutUtils::LayoutControl(this, mainPane, dialogLay); |
|
508 } |
|
509 |
|
510 ControlAttributes()->SetLayoutDone(); |
|
511 } |
|
512 } |
|
513 |
|
514 EXPORT_C void CAknNoteDialog::PreLayoutDynInitL() |
|
515 { |
|
516 TransferControlAttributes(); |
|
517 |
|
518 if ( AknLayoutUtils::PenEnabled() ) |
|
519 { |
|
520 // set to capture globally, if dialog have to be closed when tapped to screen |
|
521 if ( DialogFlags()&EEikDialogFlagCloseDialogWhenTapped ) |
|
522 { |
|
523 SetGloballyCapturing(ETrue); |
|
524 } |
|
525 SetPointerCapture(ETrue); |
|
526 } |
|
527 } |
|
528 |
|
529 EXPORT_C void CAknNoteDialog::PostLayoutDynInitL() |
|
530 { |
|
531 __ASSERT_DEBUG(NoteControl(), Panic(EAknPanicNullPointer)); |
|
532 |
|
533 CreateExtensionL(); |
|
534 |
|
535 // In some cases the animation completes it's cycle in wserv |
|
536 // before the note appears on screen, so we're delaying the |
|
537 // start of the animation with an idle object. |
|
538 // -- fix withdrawn -- |
|
539 //iNoteExtension->iIdle = CIdle::NewL( CActive::EPriorityIdle ); |
|
540 //iNoteExtension->iIdle->Start(TCallBack(CallbackStartAnimationL, this)); |
|
541 |
|
542 NoteControl()->StartAnimationL(); |
|
543 |
|
544 if ( iTimeoutInMicroseconds != ENoTimeout ) |
|
545 { |
|
546 if (!iTimer) |
|
547 { |
|
548 iTimer = CPeriodic::NewL(0); |
|
549 } |
|
550 if (iTimer->IsActive()) |
|
551 { |
|
552 iTimer->Cancel(); |
|
553 } |
|
554 iTimer->Start(iTimeoutInMicroseconds,iTimeoutInMicroseconds,TCallBack(StaticDeleteL,this)); |
|
555 } |
|
556 } |
|
557 |
|
558 EXPORT_C void CAknNoteDialog::PlayTone() |
|
559 { |
|
560 if (iTone != 0 && SoundSystem()) |
|
561 { |
|
562 SoundSystem()->PlaySound(iTone); |
|
563 } |
|
564 } |
|
565 |
|
566 EXPORT_C void CAknNoteDialog::ReportUserActivity() const |
|
567 { |
|
568 #ifdef AVKON_RDEBUG_INFO |
|
569 RDebug::Print(_L("Reset user inactivity")); |
|
570 #endif |
|
571 User::ResetInactivityTime(); |
|
572 } |
|
573 |
|
574 EXPORT_C CAknNoteControl* CAknNoteDialog::NoteControl() |
|
575 { |
|
576 CEikCaptionedControl* linePtr = GetFirstLineOnFirstPageOrNull(); |
|
577 if (linePtr) |
|
578 { |
|
579 return STATIC_CAST( CAknNoteControl*, linePtr->iControl); |
|
580 } |
|
581 return NULL; |
|
582 } |
|
583 |
|
584 EXPORT_C CAknKeySoundSystem* CAknNoteDialog::SoundSystem() const |
|
585 { |
|
586 if (iEikonEnv->AppUi()) |
|
587 { |
|
588 return iAvkonAppUiBase->KeySounds(); |
|
589 } |
|
590 return NULL; |
|
591 } |
|
592 |
|
593 EXPORT_C CAknNoteAttributes* CAknNoteDialog::ControlAttributes() |
|
594 { |
|
595 if (NoteControl() && !iControlAttributes) |
|
596 { |
|
597 return NoteControl()->Attributes(); |
|
598 } |
|
599 else |
|
600 { |
|
601 if (!iControlAttributes) |
|
602 { |
|
603 iControlAttributes = new CAknNoteAttributes(); |
|
604 } |
|
605 return iControlAttributes; |
|
606 } |
|
607 } |
|
608 |
|
609 EXPORT_C void CAknNoteDialog::TransferControlAttributes() |
|
610 { |
|
611 if (iControlAttributes) |
|
612 { |
|
613 __ASSERT_DEBUG(NoteControl(),Panic(EAknPanicNullPointer)); |
|
614 __ASSERT_DEBUG(NoteControl()->Attributes(),Panic(EAknPanicNullPointer)); |
|
615 *(NoteControl()->Attributes()) = *iControlAttributes; |
|
616 |
|
617 delete iControlAttributes; |
|
618 iControlAttributes = NULL; |
|
619 } |
|
620 |
|
621 NoteControl()->Attributes()->InvalidateLayout(); |
|
622 NoteControl()->Layout(); |
|
623 } |
|
624 |
|
625 /** |
|
626 * Check that the self pointer is not a stack pointer and points to this. |
|
627 * |
|
628 * |
|
629 * |
|
630 * @param aAddr The pointer to be checked |
|
631 */ |
|
632 #if defined _DEBUG && defined __WINS__ |
|
633 void CAknNoteDialog::DbgCheckSelfPtr(CEikDialog** aSelfPtr) |
|
634 { |
|
635 TUint32 addrSeg = TUint32(aSelfPtr) & 0xffff0000; |
|
636 TUint32 stackAddrSeg = TUint32(&aSelfPtr) & 0xffff0000; |
|
637 |
|
638 // If this assert triggers, it looks like your code is using a stack based pointer |
|
639 // as the self-ptr passed in to a non-waiting note dialog. This is a cause of |
|
640 // obscure fatal errors and must not be done. |
|
641 ASSERT(addrSeg != stackAddrSeg); |
|
642 |
|
643 // new check that the self pointer points to this object |
|
644 if (aSelfPtr) |
|
645 { |
|
646 TUint32 self = TUint32(this); |
|
647 TUint32 selfPointedTo = TUint32(*aSelfPtr); |
|
648 |
|
649 // If this assert triggers, it looks like your code has given this dialog |
|
650 // a self-ptr which does not point to itself. Perhaps it was member data of |
|
651 // an object which has been deleted, or the pointer has been overwritten. |
|
652 ASSERT(self == selfPointedTo || selfPointedTo == NULL); |
|
653 } |
|
654 } |
|
655 #else |
|
656 void CAknNoteDialog::DbgCheckSelfPtr(CEikDialog** /*aSelfPtr*/) |
|
657 { |
|
658 } |
|
659 #endif |
|
660 |
|
661 |
|
662 EXPORT_C void CAknNoteDialog::HandleResourceChange(TInt aType) |
|
663 { |
|
664 if(aType==KEikDynamicLayoutVariantSwitch) |
|
665 { |
|
666 if (!IsVisible()) |
|
667 { |
|
668 // a invisible note dialog is assumed to be a sleeping dialog |
|
669 // in which case it will update layout when it is roused. |
|
670 return; |
|
671 } |
|
672 CEikDialog::HandleResourceChange(aType); |
|
673 ControlAttributes()->InvalidateLayout(); |
|
674 LayoutAndDraw(); |
|
675 SizeChanged(); |
|
676 return; // we already did the base call |
|
677 } |
|
678 else if( aType == KAknsMessageSkinChange ) |
|
679 { |
|
680 if (!IsVisible() && (DialogFlags() & EEikDialogFlagSleeping) ) |
|
681 { |
|
682 // a invisible note dialog is assumed to be a sleeping dialog |
|
683 // in which case it will update skin when it is roused. |
|
684 return; |
|
685 } |
|
686 SetSkinBackGroundRect(); |
|
687 if ( NoteControl() && NoteControl()->Attributes() ) |
|
688 { |
|
689 ControlAttributes()->InvalidateLayout(); |
|
690 |
|
691 // Gets the correct image for the skin. |
|
692 TRAP_IGNORE(NoteControl()->Attributes()->HandleSkinChangeL()); |
|
693 TRAP_IGNORE(NoteControl()-> CreateDefaultImageL() ); |
|
694 |
|
695 NoteControl()->Layout(); |
|
696 } |
|
697 } |
|
698 |
|
699 CEikDialog::HandleResourceChange(aType); |
|
700 } |
|
701 |
|
702 /** |
|
703 * Deprecated methods |
|
704 */ |
|
705 |
|
706 /** |
|
707 * @deprecated |
|
708 */ |
|
709 EXPORT_C TInt CAknNoteDialog::ExecuteDlgLD(const TTimeout aTimeout,const TTone aTone,TInt aResourceID) |
|
710 { |
|
711 SetTimeout(aTimeout); |
|
712 SetTone(aTone); |
|
713 return ExecuteLD(aResourceID); |
|
714 } |
|
715 |
|
716 /** |
|
717 * @deprecated |
|
718 */ |
|
719 EXPORT_C TInt CAknNoteDialog::ExecuteDlgLD(const TTone aTone,TInt aResourceID) |
|
720 { |
|
721 SetTone(aTone); |
|
722 return ExecuteLD(aResourceID); |
|
723 } |
|
724 |
|
725 /** |
|
726 * @deprecated |
|
727 */ |
|
728 EXPORT_C TInt CAknNoteDialog::ExecuteDlgLD(TInt aResourceId, TInt /*aNoteControlId*/) |
|
729 { |
|
730 return ExecuteLD(aResourceId); |
|
731 } |
|
732 |
|
733 /** |
|
734 * @deprecated |
|
735 */ |
|
736 EXPORT_C TInt CAknNoteDialog::RunDlgLD(const TTimeout aTimeout,const TTone aTone) |
|
737 { |
|
738 SetTimeout(aTimeout); |
|
739 SetTone(aTone); |
|
740 return RunLD(); |
|
741 } |
|
742 |
|
743 /** |
|
744 * @deprecated |
|
745 */ |
|
746 EXPORT_C TInt CAknNoteDialog::RunDlgLD(const TTone aTone) |
|
747 { |
|
748 SetTone(aTone); |
|
749 return RunLD(); |
|
750 } |
|
751 |
|
752 /** |
|
753 * @deprecated |
|
754 */ |
|
755 EXPORT_C TInt CAknNoteDialog::RunDlgLD() |
|
756 { |
|
757 return RunLD(); |
|
758 } |
|
759 |
|
760 /** |
|
761 * @deprecated |
|
762 */ |
|
763 EXPORT_C TInt CAknNoteDialog::RunDlgLD(TInt /*aNoteControlId*/) |
|
764 { |
|
765 return RunLD(); |
|
766 } |
|
767 |
|
768 EXPORT_C void CAknNoteDialog::CEikDialog_Reserved_1() |
|
769 { |
|
770 } |
|
771 |
|
772 EXPORT_C void CAknNoteDialog::CEikDialog_Reserved_2() |
|
773 { |
|
774 } |
|
775 |
|
776 EXPORT_C void CAknNoteDialog::CAknNoteDialog_Reserved() |
|
777 { |
|
778 } |
|
779 |
|
780 EXPORT_C void CAknNoteDialog::SizeChanged() |
|
781 { |
|
782 |
|
783 CEikDialog::SizeChanged(); |
|
784 |
|
785 SetSkinBackGroundRect(); |
|
786 |
|
787 if ( NoteControl() ) |
|
788 { |
|
789 NoteControl()->Layout(); |
|
790 } |
|
791 |
|
792 } |
|
793 |
|
794 void CAknNoteDialog::SetSkinBackGroundRect() |
|
795 { |
|
796 if (!NoteControl() || !NoteControl()->Attributes()) |
|
797 { |
|
798 return; |
|
799 } |
|
800 NoteControl()->SetBgRect(Rect(),PositionRelativeToScreen()); |
|
801 } |
|
802 |
|
803 EXPORT_C void CAknNoteDialog::SetNoMemoryAllocation() |
|
804 { |
|
805 if (!NoteControl() || !NoteControl()->Attributes()) |
|
806 { |
|
807 User::Invariant(); |
|
808 } |
|
809 NoteControl()->Attributes()->iFlags.Set(ENoteDoNotAllocateMem); |
|
810 } |
|
811 |
|
812 void CAknNoteDialog::CreateExtensionL() |
|
813 { |
|
814 if ( !iNoteExtension ) |
|
815 { |
|
816 iNoteExtension = CAknNoteDialogExtension::NewL(*this); |
|
817 } |
|
818 } |
|
819 |
|
820 TInt CAknNoteDialog::CallbackStartAnimationL(TAny* aThis) |
|
821 { |
|
822 CAknNoteDialog* me = static_cast<CAknNoteDialog*>(aThis); |
|
823 me->NoteControl()->StartAnimationL(); |
|
824 return 0; |
|
825 } |
|
826 //------------------------------------------------------------------------------ |
|
827 // CAknNoteDialog::HandlePointerEventL() |
|
828 // HandlePointerEventL processes the pointer event directed to the notedialog. |
|
829 //------------------------------------------------------------------------------ |
|
830 // |
|
831 |
|
832 EXPORT_C void CAknNoteDialog::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
833 { |
|
834 if ( AknLayoutUtils::PenEnabled() ) |
|
835 { |
|
836 CCoeControl* ctrl = GrabbingComponent(); |
|
837 CCoeControl::HandlePointerEventL(aPointerEvent); |
|
838 |
|
839 if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
840 { |
|
841 if ( DialogFlags()&EEikDialogFlagCloseDialogWhenTapped ) |
|
842 { |
|
843 //Touch release gives pop-up effect if note can be dismissed. |
|
844 if ( ctrl ) |
|
845 { |
|
846 // if grabbingComponent and dialog has 'close dialog when |
|
847 // tapped flag', then close dialog here because tapping happened. |
|
848 if ( !IsBeingDestroyed() ) |
|
849 { |
|
850 StaticDeleteL( this ); |
|
851 } |
|
852 |
|
853 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
854 if ( feedback ) |
|
855 { |
|
856 feedback->InstantFeedback( ETouchFeedbackPopUp ); |
|
857 } |
|
858 } |
|
859 } |
|
860 } |
|
861 } |
|
862 } |
|
863 |
|
864 |
|
865 EXPORT_C void* CAknNoteDialog::ExtensionInterface( TUid /*aInterface*/ ) |
|
866 { |
|
867 return NULL; |
|
868 } |
|
869 |
|
870 EXPORT_C void CAknNoteDialog::ExitSleepingDialog() |
|
871 { |
|
872 CAknNoteControl* ctrl = 0; |
|
873 ctrl = NoteControl(); |
|
874 if ( ctrl ) |
|
875 { // if there is no animation, just returns KErrGeneral |
|
876 ctrl->CancelAnimation(); |
|
877 } |
|
878 CEikDialog::ExitSleepingDialog(); |
|
879 } |
|
880 |
|
881 // End of File |