46 { |
46 { |
47 if(iIsShowing) // is showing |
47 if(iIsShowing) // is showing |
48 { |
48 { |
49 //do nothing |
49 //do nothing |
50 } |
50 } |
|
51 delete iExt; |
51 } |
52 } |
52 |
53 |
53 // --------------------------------------------------------------------------- |
54 // --------------------------------------------------------------------------- |
54 // CFepLayoutPopupWnd::ConsructL() |
55 // CFepLayoutPopupWnd::ConsructL() |
55 // Symbian 2nd phase constructor |
56 // Symbian 2nd phase constructor |
56 // (other items were commented in a header). |
57 // (other items were commented in a header). |
57 // --------------------------------------------------------------------------- |
58 // --------------------------------------------------------------------------- |
58 EXPORT_C void CFepLayoutPopupWnd::ConstructL() |
59 EXPORT_C void CFepLayoutPopupWnd::ConstructL() |
59 { |
60 { |
60 BaseConstructL(); |
61 BaseConstructL(); |
|
62 iExt = CPopupWndExt::NewL(); |
|
63 //check whether we need create backup bmp. Some pop up window is created after UI layout is created |
|
64 //If a pop up window is created during layout constructing, it will create the backup bitmap in Handleresourcechange |
|
65 if (UiLayout()->NotDrawToLayoutDevice()) |
|
66 { |
|
67 iExt->ContructBkDeviceL(Rect().Size(), |
|
68 UiLayout()->LayoutOwner()->BitmapDevice()->DisplayMode()); |
|
69 } |
61 } |
70 } |
62 |
71 |
63 EXPORT_C void CFepLayoutPopupWnd::ReDrawRect(const TRect& /*aRect*/) |
72 EXPORT_C void CFepLayoutPopupWnd::ReDrawRect(const TRect& /*aRect*/) |
64 { |
73 { |
65 Draw(); |
74 Draw(); |
256 if(iIsShowing) |
265 if(iIsShowing) |
257 return; |
266 return; |
258 RootControl()->SetActiveCtrl(this); |
267 RootControl()->SetActiveCtrl(this); |
259 ReportEvent(EEventCapturePointer); |
268 ReportEvent(EEventCapturePointer); |
260 |
269 |
|
270 //When preparing the pop up window, it causes redraw the underlying control sometimes. |
|
271 DisableDrawingInGroup();//disable any drawing during preparation to avoid it dirty the background |
|
272 |
261 //let pop up window do preparation |
273 //let pop up window do preparation |
262 OnDisplay(); |
274 OnDisplay(); |
263 |
275 |
264 //determine the directoin |
276 //determine the directoin |
265 TRect rtPopup; //final position |
277 TRect rtPopup; //final position |
357 layoutOwner->LayoutSizeChanged(rtFinal.Size(), EFalse); |
369 layoutOwner->LayoutSizeChanged(rtFinal.Size(), EFalse); |
358 layoutOwner->SetPosition(rtFinal.iTl); |
370 layoutOwner->SetPosition(rtFinal.iTl); |
359 //RootControl()->Clear(); |
371 //RootControl()->Clear(); |
360 DrawTransparentMaskBackground( TRect( TPoint(), rtFinal.Size() ) ); |
372 DrawTransparentMaskBackground( TRect( TPoint(), rtFinal.Size() ) ); |
361 RootControl()->Move(iLayoutMoveOff); |
373 RootControl()->Move(iLayoutMoveOff); |
362 RootControl()->Draw(); |
374 EnableDrawingInGroup(); |
|
375 RootControl()->Draw(); |
|
376 DisableDrawingInGroup(); |
363 //UpdateArea( TRect( TPoint(), rtFinal.Size()), ETrue); |
377 //UpdateArea( TRect( TPoint(), rtFinal.Size()), ETrue); |
364 } |
378 } |
365 else |
379 else |
366 { |
380 { |
367 iPrevLayoutRect.SetSize(TSize(0,0)); |
381 iPrevLayoutRect.SetSize(TSize(0,0)); |
375 iWndControl->MakeVisible(ETrue); |
389 iWndControl->MakeVisible(ETrue); |
376 } |
390 } |
377 |
391 |
378 //iRect = rtPopup; |
392 //iRect = rtPopup; |
379 Move( rtPopup.iTl - Rect().iTl); |
393 Move( rtPopup.iTl - Rect().iTl); |
|
394 //copy and save the bitmap |
|
395 if (UiLayout()->NotDrawToLayoutDevice()) |
|
396 { |
|
397 iExt->SetRect(Rect()); |
|
398 |
|
399 CFbsBitGc* gc = iExt->BackupGc(); |
|
400 gc->Activate( iExt->BackupDevice() ); |
|
401 CFbsBitGc* layoutGc = static_cast<CFbsBitGc*>( |
|
402 UiLayout()->LayoutOwner()->BitmapContext()); |
|
403 gc->BitBlt(TPoint(0,0),*layoutGc,Rect()); |
|
404 |
|
405 Hide(EFalse); |
|
406 } |
|
407 |
|
408 EnableDrawingInGroup(); |
|
409 |
380 UiLayout()->LockArea(iRect,this); |
410 UiLayout()->LockArea(iRect,this); |
381 Hide(EFalse); |
411 |
|
412 SetReady(ETrue);//enalbe it as in Close, the flag is reset. |
|
413 if (UiLayout()->NotDrawToLayoutDevice()) |
|
414 Draw();//force draw |
|
415 else |
|
416 Hide(EFalse); |
|
417 UpdateArea(iRect, EFalse); |
382 |
418 |
383 iIsShowing = ETrue; |
419 iIsShowing = ETrue; |
384 AfterDisplayed(); |
420 AfterDisplayed(); |
385 |
421 |
386 TRect rectOfPopup =Rect(); //in new layout coord-sys |
422 TRect rectOfPopup =Rect(); //in new layout coord-sys |
432 UiLayout()->SignalOwner(ESignalPopupWndClosed); |
468 UiLayout()->SignalOwner(ESignalPopupWndClosed); |
433 |
469 |
434 iIsShowing = EFalse; |
470 iIsShowing = EFalse; |
435 if(iWndControl) |
471 if(iWndControl) |
436 iWndControl->MakeVisible(EFalse); |
472 iWndControl->MakeVisible(EFalse); |
437 Hide(ETrue); |
473 SetReady(EFalse);//disable redraw |
|
474 TRect popRect = iRect; |
|
475 UiLayout()->UnLockArea(iRect, this); |
|
476 |
|
477 //restore the background bitmap |
|
478 TBool bRedraw = ETrue; |
|
479 if (UiLayout()->NotDrawToLayoutDevice()) |
|
480 { |
|
481 CFbsBitGc* layoutGc = static_cast<CFbsBitGc*>( |
|
482 UiLayout()->LayoutOwner()->BitmapContext()); |
|
483 |
|
484 iExt->BackupGc(); |
|
485 layoutGc->Activate( UiLayout()->LayoutOwner()->BitmapDevice()); |
|
486 TRect r; |
|
487 r.SetSize(iExt->Rect().Size()); |
|
488 layoutGc->BitBlt(iExt->Rect().iTl,iExt->BackupBitmap(),r); |
|
489 bRedraw = EFalse; |
|
490 } |
|
491 |
|
492 Hide(ETrue); |
438 UiLayout()->UnLockArea(iRect,this); |
493 UiLayout()->UnLockArea(iRect,this); |
439 iRect.Move(-iRect.iTl); |
494 iRect.Move(-iRect.iTl); |
440 MLayoutOwner* layoutOwner = UiLayout()->LayoutOwner(); |
495 MLayoutOwner* layoutOwner = UiLayout()->LayoutOwner(); |
441 if(!iPrevLayoutRect.IsEmpty()) |
496 if(!iPrevLayoutRect.IsEmpty()) |
442 { |
497 { |
446 layoutOwner->SetPosition(iPrevLayoutRect.iTl); |
501 layoutOwner->SetPosition(iPrevLayoutRect.iTl); |
447 layoutOwner->LayoutSizeChanged(iPrevLayoutRect.Size()); |
502 layoutOwner->LayoutSizeChanged(iPrevLayoutRect.Size()); |
448 RootControl()->GraphicDeviceSizeChanged(); |
503 RootControl()->GraphicDeviceSizeChanged(); |
449 } |
504 } |
450 |
505 |
451 RootControl()->Draw(); |
506 if (bRedraw) |
|
507 { |
|
508 RootControl()->Draw(); |
|
509 } |
452 |
510 |
453 iIsShowing = EFalse; |
511 iIsShowing = EFalse; |
454 |
512 |
455 TRect rect( TPoint(0,0),iPrevLayoutRect.Size() ); |
513 //TRect rect(TPoint(0, 0), iPrevLayoutRect.Size()); |
456 UpdateArea( rect, EFalse ); |
514 UpdateArea(popRect, EFalse); |
457 } |
515 } |
458 |
516 |
459 // --------------------------------------------------------------------------- |
517 // --------------------------------------------------------------------------- |
460 // CFepLayoutPopupWnd::SetRect |
518 // CFepLayoutPopupWnd::SetRect |
461 // Set the pop up window's rect |
519 // Set the pop up window's rect |
494 // |
552 // |
495 EXPORT_C void CFepLayoutPopupWnd::AfterDisplayed() |
553 EXPORT_C void CFepLayoutPopupWnd::AfterDisplayed() |
496 { |
554 { |
497 //do nothing |
555 //do nothing |
498 } |
556 } |
|
557 EXPORT_C void CFepLayoutPopupWnd::HandleResourceChange(TInt aType) |
|
558 { |
|
559 if (aType == KPenInputOwnDeviceChange) |
|
560 { |
|
561 if (UiLayout()->NotDrawToLayoutDevice()) |
|
562 { |
|
563 TRAP_IGNORE(iExt->ContructBkDeviceL(Rect().Size(), |
|
564 UiLayout()->LayoutOwner()->BitmapDevice()->DisplayMode())); |
|
565 } |
|
566 } |
|
567 else |
|
568 CControlGroup::HandleResourceChange(aType); |
|
569 } |
|
570 void CFepLayoutPopupWnd::DisableDrawingInGroup() |
|
571 { |
|
572 |
|
573 UiLayout()->DisableLayoutDrawing(ETrue); |
|
574 SetReady(EFalse); |
|
575 for(TInt i = 0; i < NumOfControls(); ++i) |
|
576 { |
|
577 //There is potential defect that if the child control is a group control, its children not set. |
|
578 //This can be solved by locking the area so no one can update until we unlock it in Enalbegroup |
|
579 ControlList()[i]->SetReady(EFalse); |
|
580 } |
|
581 } |
|
582 void CFepLayoutPopupWnd::EnableDrawingInGroup() |
|
583 { |
|
584 SetReady(ETrue); |
|
585 for(TInt i = 0; i < NumOfControls(); ++i) |
|
586 { |
|
587 //There is potential defect that if the child control is a group control, its children not set. |
|
588 //This can be solved by locking the area so no one can update until we unlock it in Enalbegroup |
|
589 ControlList()[i]->SetReady(ETrue); |
|
590 } |
|
591 UiLayout()->DisableLayoutDrawing(EFalse); |
|
592 } |
|
593 |
|
594 |
|
595 |
|
596 CFepLayoutPopupWnd::CPopupWndExt* CFepLayoutPopupWnd::CPopupWndExt::NewL() |
|
597 { |
|
598 CPopupWndExt* self = new (ELeave)CPopupWndExt(); |
|
599 return self; |
|
600 } |
|
601 |
|
602 void CFepLayoutPopupWnd::CPopupWndExt::ContructBkDeviceL(const TSize& aSize,const TDisplayMode& aMode) |
|
603 { |
|
604 TBool bNewBmp = EFalse; |
|
605 if(!iBitmap || iBitmap->DisplayMode() != aMode) |
|
606 { |
|
607 delete iBitmap; |
|
608 iBitmap = 0; |
|
609 iBitmap = new (ELeave) CFbsBitmap; |
|
610 User::LeaveIfError( iBitmap->Create( aSize,aMode)); |
|
611 delete iBitmapDevice; |
|
612 iBitmapDevice = 0; |
|
613 iBitmapDevice = CFbsBitmapDevice::NewL(iBitmap); |
|
614 bNewBmp = ETrue; |
|
615 } |
|
616 if(!iGc) |
|
617 iGc = CFbsBitGc::NewL(); |
|
618 |
|
619 if(!bNewBmp && aSize != iBitmap->SizeInPixels()) |
|
620 { |
|
621 ResizeBackupDeviceL(aSize); |
|
622 } |
|
623 } |
|
624 void CFepLayoutPopupWnd::CPopupWndExt::ResizeBackupDeviceL(const TSize& aSize) |
|
625 { |
|
626 |
|
627 iBitmap->Resize(aSize); |
|
628 iBitmapDevice->Resize( aSize); |
|
629 iGc->Activate(iBitmapDevice); |
|
630 iGc->Resized(); |
|
631 } |
|
632 void CFepLayoutPopupWnd::CPopupWndExt::SetRect(const TRect& aRect) |
|
633 { |
|
634 iRect = aRect; |
|
635 if(iBitmap && iBitmap->SizeInPixels() != aRect.Size()) |
|
636 { |
|
637 ResizeBackupDeviceL(aRect.Size()); |
|
638 } |
|
639 } |
|
640 // End of File |