|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // GFXTRANSEFFECT.CPP |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 #include "TransitionControl.h" |
|
20 #include "RegisteredControl.h" |
|
21 #include "GfxTransUtils.h" |
|
22 #include "GfxTransEffect.h" |
|
23 #include <coecntrl.h> |
|
24 |
|
25 //---------------- |
|
26 // InTransition List |
|
27 //---------------- |
|
28 TInt RInTransitionList::Append(CTransitionControl* aTransControl) |
|
29 { |
|
30 TInt err = RPointerArray<CTransitionControl>::Append(aTransControl); |
|
31 return err; |
|
32 } |
|
33 |
|
34 void RInTransitionList::Remove(TInt aIndex) |
|
35 { |
|
36 RPointerArray<CTransitionControl>::Remove(aIndex); |
|
37 #ifdef _DEBUG |
|
38 Compress(); // so that __UHEAP_MARK can be used |
|
39 #endif |
|
40 } |
|
41 |
|
42 TInt RInTransitionList::Find(const CRegisteredControl * aRegControl) const |
|
43 { |
|
44 const TInt count = Count(); |
|
45 for(TInt i=0; i<count; i++) |
|
46 { |
|
47 if(aRegControl == (*this)[i]->RegControl()) |
|
48 { |
|
49 return i; |
|
50 } |
|
51 } |
|
52 return KErrNotFound; |
|
53 } |
|
54 |
|
55 TInt RInTransitionList::Find(TInt aHandle) const |
|
56 { |
|
57 const TInt count = Count(); |
|
58 for(TInt i=0; i<count; i++) |
|
59 { |
|
60 if(aHandle == (*this)[i]->Handle()) |
|
61 { |
|
62 return i; |
|
63 } |
|
64 } |
|
65 return KErrNotFound; |
|
66 } |
|
67 //---------------- |
|
68 // Active Stack |
|
69 //---------------- |
|
70 TInt RActiveStack::Push(CTransitionControl* aTransControl) |
|
71 { |
|
72 TInt err = Append(aTransControl); |
|
73 return err; |
|
74 } |
|
75 |
|
76 TInt RActiveStack::PushLC(CTransitionControl* aTransControl) |
|
77 { |
|
78 TInt err = Append(aTransControl); |
|
79 if(err == KErrNone) |
|
80 { |
|
81 //push to cleanupstack |
|
82 aTransControl->iOnCleanupStack = ETrue; |
|
83 CleanupStack::PushL(TCleanupItem(CleanupOperation,this)); |
|
84 } |
|
85 return err; |
|
86 } |
|
87 |
|
88 CTransitionControl* RActiveStack::Pop() |
|
89 { |
|
90 TInt last = Count()-1; |
|
91 CTransitionControl* ctrl = (*this)[last]; |
|
92 if(ctrl->iOnCleanupStack) |
|
93 { |
|
94 CleanupStack::Pop(this); |
|
95 ctrl->iOnCleanupStack = EFalse; |
|
96 } |
|
97 Remove(last); |
|
98 #ifdef _DEBUG |
|
99 Compress(); // so that __UHEAP_MARK can be used |
|
100 #endif |
|
101 return ctrl; |
|
102 } |
|
103 |
|
104 |
|
105 void RActiveStack::CleanupOperation(TAny *aAny) |
|
106 { |
|
107 RActiveStack* activeStack = reinterpret_cast<RActiveStack*>(aAny); |
|
108 TInt last = activeStack->Count()-1; |
|
109 CTransitionControl* ctrl = (*activeStack)[last]; |
|
110 activeStack->Remove(last); |
|
111 delete ctrl; |
|
112 #ifdef _DEBUG |
|
113 activeStack->Compress(); // so that __UHEAP_MARK can be used |
|
114 #endif |
|
115 } |
|
116 |
|
117 CTransitionControl* RActiveStack::Top() |
|
118 { |
|
119 TInt last = Count()-1; |
|
120 return last < 0 ? NULL :(*this)[last]; |
|
121 } |
|
122 |
|
123 TInt RActiveStack::ClearAbove(TInt aIndex) |
|
124 { |
|
125 for(TInt i = Count()-1; i > aIndex; i--) |
|
126 { |
|
127 CTransitionControl* ctrl = Pop(); |
|
128 delete ctrl; |
|
129 } |
|
130 return KErrNone; |
|
131 } |
|
132 |
|
133 |
|
134 TInt RActiveStack::Find(const CRegisteredControl * aRegControl) const |
|
135 { |
|
136 const TInt count = Count(); |
|
137 for(TInt i=count-1; i>=0; i--) |
|
138 { |
|
139 if(aRegControl == (*this)[i]->RegControl()) |
|
140 { |
|
141 return i; |
|
142 } |
|
143 } |
|
144 return KErrNotFound; |
|
145 } |
|
146 |
|
147 TInt RActiveStack::Find(const CCoeControl * aControl) const |
|
148 { |
|
149 CRegisteredControl* regctrl; |
|
150 const TInt count = Count(); |
|
151 for(TInt i=count-1; i>=0; i--) |
|
152 { |
|
153 if((NULL != (regctrl = (*this)[i]->RegControl())) && |
|
154 (aControl == regctrl->Control())) |
|
155 { |
|
156 return i; |
|
157 } |
|
158 } |
|
159 return KErrNotFound; |
|
160 } |
|
161 |
|
162 TInt RActiveStack::FindView(TVwsViewId const &aView) const |
|
163 { |
|
164 CRegisteredControl* regctrl; |
|
165 const TInt count = Count(); |
|
166 for(TInt i=count-1; i>=0; i--) |
|
167 { |
|
168 if((NULL != (regctrl = (*this)[i]->RegControl())) && |
|
169 (aView == regctrl->ViewId())) |
|
170 { |
|
171 return i; |
|
172 } |
|
173 } |
|
174 return KErrNotFound; |
|
175 } |
|
176 |
|
177 TInt RActiveStack::Find(TInt aHandle) const |
|
178 { |
|
179 const TInt count = Count(); |
|
180 for(TInt i=count-1; i>=0; i--) |
|
181 { |
|
182 if(aHandle == (*this)[i]->Handle()) |
|
183 { |
|
184 return i; |
|
185 } |
|
186 } |
|
187 return KErrNotFound; |
|
188 } |
|
189 |
|
190 //---------------- |
|
191 // Transition Control |
|
192 //---------------- |
|
193 |
|
194 CTransitionControl* CTransitionControl::New(CRegisteredControl* aRegControl, MTransitionControlObserver *aObserver, |
|
195 TUint aAction, TPolicy aPolicy, TInt aHandle) |
|
196 { |
|
197 CTransitionControl *control = new CTransitionControl(aRegControl, aObserver, aHandle); |
|
198 if(!control) |
|
199 { |
|
200 return NULL; |
|
201 } |
|
202 control->iData = new CTransitionData(); |
|
203 if(!(control->iData)) |
|
204 { |
|
205 delete control; |
|
206 return NULL; |
|
207 } |
|
208 control->iData->iAction = aAction; |
|
209 control->iData->iPolicy = aPolicy; |
|
210 return control; |
|
211 } |
|
212 |
|
213 CTransitionControl::CTransitionControl( CRegisteredControl* aRegControl, MTransitionControlObserver *aObserver, |
|
214 TInt aHandle) : |
|
215 iObserver (aObserver), |
|
216 iRegControl (aRegControl), |
|
217 iBaseControl (NULL), |
|
218 iHandle (aHandle), |
|
219 iHasBeginWOPos (EFalse) |
|
220 { |
|
221 } |
|
222 |
|
223 CTransitionControl::~CTransitionControl() |
|
224 { |
|
225 RegControl()->RemoveTransition(this); |
|
226 delete iData; |
|
227 |
|
228 iSubControls.ResetAndDestroy(); |
|
229 delete iBaseControl; |
|
230 |
|
231 iSubControls.Close(); |
|
232 } |
|
233 |
|
234 void CTransitionControl::Reset() |
|
235 { |
|
236 iData->iFailed = ETrue; // if active it has failed, if in transition the data is invalid |
|
237 //reset |
|
238 iSubControls.ResetAndDestroy(); |
|
239 if(iBaseControl) |
|
240 { |
|
241 delete iBaseControl; |
|
242 iBaseControl = NULL; |
|
243 } |
|
244 } |
|
245 |
|
246 //---------------- |
|
247 // Capture |
|
248 //---------------- |
|
249 void CTransitionControl::CaptureBegin() |
|
250 { |
|
251 TInt zdepth = 0; |
|
252 const CCoeControl *control = iRegControl->Control(); |
|
253 iScreenDevice = control->ControlEnv()->ScreenDevice(); |
|
254 //copy data to CTransitionData |
|
255 iData->iUid = iRegControl->Uid(); |
|
256 iData->iNLayered = iRegControl->IsNLayered(); |
|
257 iData->iKey = control; |
|
258 iData->iFailed = EFalse; |
|
259 |
|
260 if(!control->IsVisible() || control->Size() == TSize(0,0)) |
|
261 { |
|
262 //Create even though invisible for non-N-layered controls. |
|
263 if(Policy() == ESupported && !iRegControl->IsNLayered()) |
|
264 { |
|
265 TUint flags = iRegControl->Flags(); |
|
266 if(NULL == (iBaseControl = CTransitionParticipant::New(control, this, flags))) |
|
267 { |
|
268 Fallback(); |
|
269 return; |
|
270 } |
|
271 iData->iBaseControl = iBaseControl->Data(); |
|
272 control->SetGc(iBaseControl->RemoteGc()); |
|
273 } |
|
274 return; |
|
275 } |
|
276 |
|
277 //get/set screen coords |
|
278 if(control->OwnsWindow()) |
|
279 { |
|
280 iData->iBeginWOPos = control->PositionRelativeToScreen(); |
|
281 } |
|
282 else |
|
283 { |
|
284 iData->iBeginWOPos = control->PositionRelativeToScreen() - control->Position(); |
|
285 } |
|
286 |
|
287 iHasBeginWOPos = ETrue; |
|
288 |
|
289 TUint flags = iRegControl->Flags(); |
|
290 //create and capture base control |
|
291 if(NULL == (iBaseControl = CTransitionParticipant::New(control, this, flags))) |
|
292 { |
|
293 Fallback(); |
|
294 return; |
|
295 } |
|
296 //add base control data to transition data |
|
297 iData->iBaseControl = iBaseControl->Data(); |
|
298 |
|
299 |
|
300 if(KErrNone != iBaseControl->CaptureBegin( control, iData->iNLayered ? |
|
301 CTransitionParticipant::EShallow : CTransitionParticipant::EDeep, |
|
302 zdepth++)) |
|
303 { |
|
304 Fallback(); |
|
305 return; |
|
306 } |
|
307 |
|
308 //create and capture child controls |
|
309 if(iData->iNLayered) |
|
310 { |
|
311 TInt count = control->CountComponentControls(); |
|
312 for(TInt i=0; i<count; i++) |
|
313 { |
|
314 const CCoeControl *childcontrol = control->ComponentControl(i); |
|
315 if(childcontrol->IsVisible() && childcontrol->Size() != TSize(0,0)) |
|
316 { |
|
317 //create and capture participant |
|
318 CTransitionParticipant *subcontrol = CreateSubControl(childcontrol, flags); |
|
319 if(!subcontrol) |
|
320 { |
|
321 Fallback(); |
|
322 return; |
|
323 } |
|
324 if(KErrNone != subcontrol->CaptureBegin( childcontrol, CTransitionParticipant::EDeep, zdepth++ )) |
|
325 { |
|
326 Fallback(); |
|
327 return; |
|
328 } |
|
329 } |
|
330 } |
|
331 } |
|
332 } |
|
333 |
|
334 void CTransitionControl::CaptureEnd() |
|
335 { |
|
336 TInt zdepth = 0; |
|
337 if(iData->iFailed) |
|
338 return; |
|
339 |
|
340 const CCoeControl *control = iRegControl->Control(); |
|
341 |
|
342 if(!iBaseControl) |
|
343 { |
|
344 //iFailed if no start state exists |
|
345 Fallback(); |
|
346 return; |
|
347 } |
|
348 |
|
349 //capture end state |
|
350 if(control->IsVisible() && control->Size() != TSize(0,0)) |
|
351 { |
|
352 if(control->OwnsWindow()) |
|
353 { |
|
354 iData->iEndWOPos = control->PositionRelativeToScreen(); |
|
355 } |
|
356 else |
|
357 { |
|
358 iData->iEndWOPos = control->PositionRelativeToScreen() - control->Position(); |
|
359 } |
|
360 |
|
361 //Set beginWOpos if not allready existing |
|
362 if(!iHasBeginWOPos) |
|
363 { |
|
364 iData->iBeginWOPos = iData->iEndWOPos; |
|
365 } |
|
366 |
|
367 if(KErrNone != iBaseControl->CaptureEnd(control, iData->iNLayered ? |
|
368 CTransitionParticipant::EShallow : CTransitionParticipant::EDeep, |
|
369 zdepth++)) |
|
370 { |
|
371 Fallback(); |
|
372 return; |
|
373 } |
|
374 |
|
375 if(iData->iNLayered) |
|
376 { |
|
377 const TInt count = control->CountComponentControls(); |
|
378 for(TInt i = 0; i < count; i++) |
|
379 { |
|
380 const CCoeControl *childcontrol = control->ComponentControl(i); |
|
381 if(childcontrol->IsVisible() && childcontrol->Size() != TSize(0,0)) |
|
382 { |
|
383 TInt idx = FindParticipant(childcontrol); |
|
384 if(!IsValidIndex(idx)) |
|
385 { |
|
386 Fallback(); |
|
387 return; |
|
388 } |
|
389 if(KErrNone != iSubControls[idx]->CaptureEnd(childcontrol, CTransitionParticipant::EDeep, zdepth++)) |
|
390 { |
|
391 Fallback(); |
|
392 return; |
|
393 } |
|
394 } |
|
395 } |
|
396 } |
|
397 } |
|
398 else |
|
399 { |
|
400 iData->iEndWOPos = iData->iBeginWOPos; |
|
401 } |
|
402 |
|
403 // check so that there are no errors |
|
404 // it is an error if not all participants has both begin coordinates (EBeginCapture) |
|
405 // and end coordinates (EEndCapture). All participants must also have at least one |
|
406 // image capture |
|
407 if( !(iBaseControl->CaptureState() == |
|
408 (CTransitionParticipant::EBeginCapture | CTransitionParticipant::EEndCapture)) || |
|
409 ((Policy() == ESupported) && !iBaseControl->HaveImageCapture())) |
|
410 { |
|
411 Fallback(); |
|
412 return; |
|
413 } |
|
414 iBaseControl->ModifyCoordinates(iData->iBeginWOPos, iData->iEndWOPos); |
|
415 if(iData->iNLayered) |
|
416 { |
|
417 const TInt count = iSubControls.Count(); |
|
418 for(TInt i = 0; i < count; i++) |
|
419 { |
|
420 if( ((Policy() == ESupported) && !iSubControls[i]->HaveImageCapture()) || |
|
421 !(iSubControls[i]->CaptureState() == |
|
422 (CTransitionParticipant::EBeginCapture | CTransitionParticipant::EEndCapture))) |
|
423 { |
|
424 Fallback(); |
|
425 return; |
|
426 } |
|
427 iSubControls[i]->ModifyCoordinates(iData->iBeginWOPos, iData->iEndWOPos); |
|
428 } |
|
429 } |
|
430 } |
|
431 |
|
432 //---------------- |
|
433 // Demarcations |
|
434 //---------------- |
|
435 |
|
436 void CTransitionControl::DoSetDemarcation(const CCoeControl *aKey, TRect aDemarcation) |
|
437 { |
|
438 if(iData->iFailed) |
|
439 return; |
|
440 if((aKey == iData->iKey)) |
|
441 { |
|
442 if(iBaseControl) |
|
443 { |
|
444 //exists |
|
445 if(iBaseControl->CaptureState() & CTransitionParticipant::EBeginCapture) |
|
446 { //set end demarcation |
|
447 iBaseControl->SetEndDemarcation(aDemarcation, aKey->OwnsWindow() ? CTransitionParticipant::EScreen : |
|
448 CTransitionParticipant::EWindowOwning); |
|
449 } |
|
450 else |
|
451 { //set begin demarcation |
|
452 iBaseControl->SetBeginDemarcation( aDemarcation, aKey->OwnsWindow() ? CTransitionParticipant::EScreen : |
|
453 CTransitionParticipant::EWindowOwning); |
|
454 } |
|
455 } |
|
456 else |
|
457 { |
|
458 //create it |
|
459 if(NULL == (iBaseControl = CTransitionParticipant::New(aKey, this, iRegControl->Flags()))) |
|
460 { |
|
461 Fallback(); |
|
462 return; |
|
463 } |
|
464 iData->iBaseControl = iBaseControl->Data(); |
|
465 //set begin demarcation |
|
466 iBaseControl->SetBeginDemarcation( aDemarcation, aKey->OwnsWindow() ? CTransitionParticipant::EScreen : |
|
467 CTransitionParticipant::EWindowOwning); |
|
468 } |
|
469 } |
|
470 else if(iData->iNLayered) |
|
471 { |
|
472 TInt idx = FindParticipant(aKey); |
|
473 if(IsValidIndex(idx)) |
|
474 { |
|
475 if(iSubControls[idx]->CaptureState() & CTransitionParticipant::EBeginCapture) |
|
476 { //set end demarcation |
|
477 iSubControls[idx]->SetEndDemarcation( aDemarcation, aKey->OwnsWindow() ? CTransitionParticipant::EScreen : |
|
478 CTransitionParticipant::EWindowOwning); |
|
479 } |
|
480 else |
|
481 { //set begin demarcation |
|
482 iSubControls[idx]->SetBeginDemarcation( aDemarcation, aKey->OwnsWindow() ? CTransitionParticipant::EScreen : |
|
483 CTransitionParticipant::EWindowOwning); |
|
484 } |
|
485 } |
|
486 else |
|
487 { |
|
488 //create it |
|
489 CTransitionParticipant *subcontrol = CreateSubControl(aKey, iRegControl->Flags()); |
|
490 if(!subcontrol) |
|
491 { |
|
492 Fallback(); |
|
493 return; |
|
494 } |
|
495 //set begin demarcation |
|
496 subcontrol->SetBeginDemarcation(aDemarcation, aKey->OwnsWindow() ? CTransitionParticipant::EScreen : |
|
497 CTransitionParticipant::EWindowOwning); |
|
498 } |
|
499 } |
|
500 } |
|
501 |
|
502 void CTransitionControl::DoSetDemarcation(const CCoeControl *aKey, const CCoeControl *aSrc, TRect aDemarcation) |
|
503 { |
|
504 if(iData->iFailed) |
|
505 return; |
|
506 TPoint screenPos = aSrc->PositionRelativeToScreen(); |
|
507 aDemarcation.iTl += screenPos; |
|
508 aDemarcation.iBr += screenPos; |
|
509 if(aKey == iData->iKey) |
|
510 { |
|
511 if(iBaseControl) |
|
512 { |
|
513 //exists |
|
514 if(iBaseControl->CaptureState() & CTransitionParticipant::EBeginCapture) |
|
515 { //set end demarcation |
|
516 iBaseControl->SetEndDemarcation(aDemarcation, CTransitionParticipant::EScreen); |
|
517 } |
|
518 else |
|
519 { //set begin demarcation |
|
520 iBaseControl->SetBeginDemarcation(aDemarcation, CTransitionParticipant::EScreen); |
|
521 } |
|
522 } |
|
523 else |
|
524 { |
|
525 //create it |
|
526 if(NULL == (iBaseControl = CTransitionParticipant::New(aKey, this, iRegControl->Flags()))) |
|
527 { |
|
528 Fallback(); |
|
529 return; |
|
530 } |
|
531 iData->iBaseControl = iBaseControl->Data(); |
|
532 //set begin demarcation |
|
533 iBaseControl->SetBeginDemarcation(aDemarcation, CTransitionParticipant::EScreen); |
|
534 } |
|
535 } |
|
536 else if(iData->iNLayered) |
|
537 { |
|
538 TInt idx = FindParticipant(aKey); |
|
539 if(IsValidIndex(idx)) |
|
540 { |
|
541 if(iSubControls[idx]->CaptureState() & CTransitionParticipant::EBeginCapture) |
|
542 { //set end demarcation |
|
543 iSubControls[idx]->SetEndDemarcation(aDemarcation, CTransitionParticipant::EScreen); |
|
544 } |
|
545 else |
|
546 { //set begin demarcation |
|
547 iSubControls[idx]->SetBeginDemarcation(aDemarcation, CTransitionParticipant::EScreen); |
|
548 } |
|
549 } |
|
550 else |
|
551 { |
|
552 //create it |
|
553 CTransitionParticipant *subcontrol = CreateSubControl(aKey, iRegControl->Flags()); |
|
554 if(!subcontrol) |
|
555 { |
|
556 Fallback(); |
|
557 return; |
|
558 } |
|
559 //set begin demarcation |
|
560 subcontrol->SetBeginDemarcation(aDemarcation, CTransitionParticipant::EScreen); |
|
561 } |
|
562 } |
|
563 } |
|
564 |
|
565 void CTransitionControl::DoSetBeginDemarcation(const CCoeControl *aKey, TRect aDemarcation) |
|
566 { |
|
567 if(iData->iFailed) |
|
568 return; |
|
569 if(aKey == iData->iKey) |
|
570 { |
|
571 if(!iBaseControl) |
|
572 { |
|
573 //create it |
|
574 if(NULL == (iBaseControl = CTransitionParticipant::New(aKey, this, iRegControl->Flags()))) |
|
575 { |
|
576 Fallback(); |
|
577 return; |
|
578 } |
|
579 iData->iBaseControl = iBaseControl->Data(); |
|
580 } |
|
581 iBaseControl->SetBeginDemarcation( aDemarcation, aKey->OwnsWindow() ? CTransitionParticipant::EScreen : |
|
582 CTransitionParticipant::EWindowOwning); |
|
583 } |
|
584 else if(iData->iNLayered) |
|
585 { |
|
586 TInt idx = FindParticipant(aKey); |
|
587 CTransitionParticipant *subcontrol; |
|
588 if(!IsValidIndex(idx)) |
|
589 { |
|
590 //Create it |
|
591 if(NULL == (subcontrol = CreateSubControl(aKey, iRegControl->Flags()))) |
|
592 { |
|
593 Fallback(); |
|
594 return; |
|
595 } |
|
596 } |
|
597 else |
|
598 { |
|
599 subcontrol = iSubControls[idx]; |
|
600 } |
|
601 subcontrol->SetBeginDemarcation(aDemarcation, aKey->OwnsWindow() ? CTransitionParticipant::EScreen : |
|
602 CTransitionParticipant::EWindowOwning); |
|
603 } |
|
604 } |
|
605 |
|
606 void CTransitionControl::DoSetEndDemarcation(const CCoeControl *aKey, TRect aDemarcation) |
|
607 { |
|
608 if(iData->iFailed) |
|
609 return; |
|
610 if(aKey == iData->iKey) |
|
611 { |
|
612 if(!iBaseControl) |
|
613 { |
|
614 return; |
|
615 } |
|
616 iBaseControl->SetEndDemarcation(aDemarcation, aKey->OwnsWindow() ? CTransitionParticipant::EScreen : |
|
617 CTransitionParticipant::EWindowOwning); |
|
618 } |
|
619 else if(iData->iNLayered) |
|
620 { |
|
621 TInt idx = FindParticipant(aKey); |
|
622 if(!IsValidIndex(idx)) |
|
623 { |
|
624 return; |
|
625 } |
|
626 iSubControls[idx]->SetEndDemarcation(aDemarcation, aKey->OwnsWindow() ? CTransitionParticipant::EScreen : |
|
627 CTransitionParticipant::EWindowOwning); |
|
628 } |
|
629 } |
|
630 |
|
631 |
|
632 //---------------- |
|
633 // Hints |
|
634 //---------------- |
|
635 |
|
636 void CTransitionControl::Invalidate(const CCoeControl *aKey) |
|
637 { |
|
638 if(iData->iFailed) |
|
639 return; |
|
640 if((aKey == iData->iKey) && iBaseControl) |
|
641 { |
|
642 iBaseControl->Invalidate(); |
|
643 } |
|
644 else |
|
645 { |
|
646 TInt idx = FindParticipant(aKey); |
|
647 if(IsValidIndex(idx)) |
|
648 { |
|
649 iSubControls[idx]->Invalidate(); |
|
650 } |
|
651 } |
|
652 } |
|
653 |
|
654 void CTransitionControl::SetHints(const CCoeControl *aKey, TUid aLayerType) |
|
655 { |
|
656 if(iData->iFailed) |
|
657 return; |
|
658 if(aKey == iRegControl->Control()) |
|
659 { |
|
660 //basecontrol layertype is the Registered Uid |
|
661 } |
|
662 else if(iData->iNLayered) |
|
663 { |
|
664 TInt idx = FindParticipant(aKey); |
|
665 if(!IsValidIndex(idx)) |
|
666 { |
|
667 // create the subcontrol |
|
668 CTransitionParticipant *subcontrol = CreateSubControl(aKey, iRegControl->Flags()); |
|
669 if(!subcontrol) |
|
670 { |
|
671 Fallback(); |
|
672 return; |
|
673 } |
|
674 subcontrol->SetLayerType(aLayerType); |
|
675 } |
|
676 else |
|
677 { |
|
678 iSubControls[idx]->SetLayerType(aLayerType); |
|
679 } |
|
680 } |
|
681 } |
|
682 |
|
683 void CTransitionControl::SetHints(const CCoeControl *aKey, TUint aFlags) |
|
684 { |
|
685 if(iData->iFailed) |
|
686 return; |
|
687 if(aKey == iRegControl->Control()) |
|
688 { |
|
689 //the main ctrl |
|
690 iRegControl->SetFlags(aFlags); |
|
691 if(iBaseControl) |
|
692 { |
|
693 iBaseControl->SetFlags(aFlags); |
|
694 } |
|
695 //set the flags on all existing layers |
|
696 if(iData->iNLayered) |
|
697 { |
|
698 const TInt count = iSubControls.Count(); |
|
699 for(TInt i = 0; i < count; i++) |
|
700 { |
|
701 iSubControls[i]->SetFlags(aFlags); |
|
702 } |
|
703 } |
|
704 } |
|
705 else if(iData->iNLayered) |
|
706 { |
|
707 TInt idx = FindParticipant(aKey); |
|
708 if(!IsValidIndex(idx)) |
|
709 { |
|
710 //create the subcontrol |
|
711 CTransitionParticipant *subcontrol = CreateSubControl(aKey, aFlags); |
|
712 if(!subcontrol) |
|
713 { |
|
714 Fallback(); |
|
715 return; |
|
716 } |
|
717 } |
|
718 else |
|
719 { |
|
720 //set flags |
|
721 iSubControls[idx]->SetFlags(aFlags); |
|
722 } |
|
723 } |
|
724 } |
|
725 |
|
726 TUint CTransitionControl::GetHints(const CCoeControl *aKey) |
|
727 { |
|
728 if(iData->iFailed) |
|
729 return GfxTransEffect::ENone; |
|
730 if(aKey == iRegControl->Control()) |
|
731 { |
|
732 return iRegControl->Flags(); |
|
733 } |
|
734 else if(iData->iNLayered) |
|
735 { |
|
736 TInt idx = FindParticipant(aKey); |
|
737 if(IsValidIndex(idx)) |
|
738 { |
|
739 return iSubControls[idx]->Flags(); |
|
740 } |
|
741 } |
|
742 return GfxTransEffect::ENone; |
|
743 } |
|
744 |
|
745 //---------------- |
|
746 // Get/set data |
|
747 //---------------- |
|
748 |
|
749 void CTransitionControl::SetTransitionData(TUint aType, const TDesC8& aData) |
|
750 { |
|
751 iData->iExDataType = aType; |
|
752 iData->iExData = &aData; |
|
753 } |
|
754 |
|
755 void CTransitionControl::GetTransitionData(const CTransitionData*& aTransData) |
|
756 { |
|
757 aTransData = iData; |
|
758 } |
|
759 |
|
760 TInt CTransitionControl::GetUpdatedRegion(RRegion& aRegion) |
|
761 { |
|
762 if(iData->iFailed) |
|
763 return KErrAbort; |
|
764 aRegion.Clear(); |
|
765 if((iBaseControl->Data()->iBeginRect != iBaseControl->Data()->iEndRect) || |
|
766 iBaseControl->Invalidated()) |
|
767 { |
|
768 aRegion.AddRect(RegControl()->Control()->Rect()); |
|
769 } |
|
770 else if(iData->iNLayered) |
|
771 { |
|
772 const TInt count = iSubControls.Count(); |
|
773 CTransitionParticipant *subcontrol; |
|
774 for(TInt i = 0; i < count; i++) |
|
775 { |
|
776 subcontrol = iSubControls[i]; |
|
777 if(subcontrol->Data()->iBeginRect != subcontrol->Data()->iEndRect) |
|
778 { |
|
779 aRegion.AddRect(subcontrol->Data()->iBeginRect); |
|
780 aRegion.AddRect(subcontrol->Data()->iEndRect); |
|
781 } |
|
782 else if(subcontrol->Invalidated()) |
|
783 { |
|
784 aRegion.AddRect(subcontrol->Data()->iEndRect); |
|
785 } |
|
786 } |
|
787 } |
|
788 return KErrNone; |
|
789 } |
|
790 //--------------------------------- |
|
791 // participant callback |
|
792 //--------------------------------- |
|
793 void CTransitionControl::ParticipantUpdated(CTransitionParticipant *aParticipant, |
|
794 RWsGraphicMsgBuf* aCommandBuffer, const TRect& aDrawRect, const TRect& aBoundingRect) |
|
795 { |
|
796 iObserver->ParticipantUpdated(this, aParticipant, aCommandBuffer,aDrawRect, aBoundingRect); |
|
797 } |
|
798 |
|
799 //--------------------------------- |
|
800 // private functions |
|
801 //--------------------------------- |
|
802 |
|
803 void CTransitionControl::Fallback() |
|
804 { |
|
805 iData->iFailed = ETrue; |
|
806 //reset |
|
807 Reset(); |
|
808 } |
|
809 |
|
810 TInt CTransitionControl::FindParticipant(const CCoeControl *aKey) |
|
811 { |
|
812 TInt count = iSubControls.Count(); |
|
813 for(TInt i = 0 ; i < count; i++) |
|
814 { |
|
815 if(iSubControls[i]->Control() == aKey) |
|
816 { |
|
817 return i; |
|
818 } |
|
819 } |
|
820 return KErrNotFound; |
|
821 } |
|
822 |
|
823 CTransitionParticipant *CTransitionControl::CreateSubControl(const CCoeControl *aKey, TUint aFlags) |
|
824 { |
|
825 CTransitionParticipant *subcontrol; |
|
826 if(NULL == (subcontrol = CTransitionParticipant::New(aKey, this, aFlags))) |
|
827 { |
|
828 return NULL; |
|
829 } |
|
830 //add to list |
|
831 if(KErrNone != iSubControls.Append(subcontrol)) |
|
832 { |
|
833 delete subcontrol; |
|
834 return NULL; |
|
835 } |
|
836 //add subcontrol data to transition data |
|
837 if(KErrNone != iData->iSubControls.Append(subcontrol->Data())) |
|
838 { |
|
839 return NULL; |
|
840 } |
|
841 return subcontrol; |
|
842 } |
|
843 |
|
844 void CTransitionControl::SetListenForUpdates(TBool aListen) |
|
845 { |
|
846 if(iBaseControl) |
|
847 { |
|
848 iBaseControl->SetListenForUpdates(aListen); |
|
849 } |
|
850 for(TInt i = iSubControls.Count() - 1; i >= 0; i--) |
|
851 { |
|
852 iSubControls[i]->SetListenForUpdates(aListen); |
|
853 } |
|
854 } |
|
855 |
|
856 |