diff -r c8fb4cf7b3ae -r 5e18d8c489d6 textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutpopupwnd.cpp --- a/textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutpopupwnd.cpp Tue May 11 16:31:42 2010 +0300 +++ b/textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutpopupwnd.cpp Tue May 25 13:03:44 2010 +0300 @@ -48,6 +48,7 @@ { //do nothing } + delete iExt; } // --------------------------------------------------------------------------- @@ -58,6 +59,14 @@ EXPORT_C void CFepLayoutPopupWnd::ConstructL() { BaseConstructL(); + iExt = CPopupWndExt::NewL(); + //check whether we need create backup bmp. Some pop up window is created after UI layout is created + //If a pop up window is created during layout constructing, it will create the backup bitmap in Handleresourcechange + if (UiLayout()->NotDrawToLayoutDevice()) + { + iExt->ContructBkDeviceL(Rect().Size(), + UiLayout()->LayoutOwner()->BitmapDevice()->DisplayMode()); + } } EXPORT_C void CFepLayoutPopupWnd::ReDrawRect(const TRect& /*aRect*/) @@ -258,6 +267,9 @@ RootControl()->SetActiveCtrl(this); ReportEvent(EEventCapturePointer); + //When preparing the pop up window, it causes redraw the underlying control sometimes. + DisableDrawingInGroup();//disable any drawing during preparation to avoid it dirty the background + //let pop up window do preparation OnDisplay(); @@ -359,7 +371,9 @@ //RootControl()->Clear(); DrawTransparentMaskBackground( TRect( TPoint(), rtFinal.Size() ) ); RootControl()->Move(iLayoutMoveOff); - RootControl()->Draw(); + EnableDrawingInGroup(); + RootControl()->Draw(); + DisableDrawingInGroup(); //UpdateArea( TRect( TPoint(), rtFinal.Size()), ETrue); } else @@ -377,8 +391,30 @@ //iRect = rtPopup; Move( rtPopup.iTl - Rect().iTl); + //copy and save the bitmap + if (UiLayout()->NotDrawToLayoutDevice()) + { + iExt->SetRect(Rect()); + + CFbsBitGc* gc = iExt->BackupGc(); + gc->Activate( iExt->BackupDevice() ); + CFbsBitGc* layoutGc = static_cast( + UiLayout()->LayoutOwner()->BitmapContext()); + gc->BitBlt(TPoint(0,0),*layoutGc,Rect()); + + Hide(EFalse); + } + + EnableDrawingInGroup(); + UiLayout()->LockArea(iRect,this); - Hide(EFalse); + + SetReady(ETrue);//enalbe it as in Close, the flag is reset. + if (UiLayout()->NotDrawToLayoutDevice()) + Draw();//force draw + else + Hide(EFalse); + UpdateArea(iRect, EFalse); iIsShowing = ETrue; AfterDisplayed(); @@ -434,7 +470,26 @@ iIsShowing = EFalse; if(iWndControl) iWndControl->MakeVisible(EFalse); - Hide(ETrue); + SetReady(EFalse);//disable redraw + TRect popRect = iRect; + UiLayout()->UnLockArea(iRect, this); + + //restore the background bitmap + TBool bRedraw = ETrue; + if (UiLayout()->NotDrawToLayoutDevice()) + { + CFbsBitGc* layoutGc = static_cast( + UiLayout()->LayoutOwner()->BitmapContext()); + + iExt->BackupGc(); + layoutGc->Activate( UiLayout()->LayoutOwner()->BitmapDevice()); + TRect r; + r.SetSize(iExt->Rect().Size()); + layoutGc->BitBlt(iExt->Rect().iTl,iExt->BackupBitmap(),r); + bRedraw = EFalse; + } + + Hide(ETrue); UiLayout()->UnLockArea(iRect,this); iRect.Move(-iRect.iTl); MLayoutOwner* layoutOwner = UiLayout()->LayoutOwner(); @@ -448,12 +503,15 @@ RootControl()->GraphicDeviceSizeChanged(); } - RootControl()->Draw(); + if (bRedraw) + { + RootControl()->Draw(); + } iIsShowing = EFalse; - TRect rect( TPoint(0,0),iPrevLayoutRect.Size() ); - UpdateArea( rect, EFalse ); + //TRect rect(TPoint(0, 0), iPrevLayoutRect.Size()); + UpdateArea(popRect, EFalse); } // --------------------------------------------------------------------------- @@ -496,3 +554,87 @@ { //do nothing } +EXPORT_C void CFepLayoutPopupWnd::HandleResourceChange(TInt aType) + { + if (aType == KPenInputOwnDeviceChange) + { + if (UiLayout()->NotDrawToLayoutDevice()) + { + TRAP_IGNORE(iExt->ContructBkDeviceL(Rect().Size(), + UiLayout()->LayoutOwner()->BitmapDevice()->DisplayMode())); + } + } + else + CControlGroup::HandleResourceChange(aType); + } +void CFepLayoutPopupWnd::DisableDrawingInGroup() + { + + UiLayout()->DisableLayoutDrawing(ETrue); + SetReady(EFalse); + for(TInt i = 0; i < NumOfControls(); ++i) + { + //There is potential defect that if the child control is a group control, its children not set. + //This can be solved by locking the area so no one can update until we unlock it in Enalbegroup + ControlList()[i]->SetReady(EFalse); + } + } +void CFepLayoutPopupWnd::EnableDrawingInGroup() + { + SetReady(ETrue); + for(TInt i = 0; i < NumOfControls(); ++i) + { + //There is potential defect that if the child control is a group control, its children not set. + //This can be solved by locking the area so no one can update until we unlock it in Enalbegroup + ControlList()[i]->SetReady(ETrue); + } + UiLayout()->DisableLayoutDrawing(EFalse); + } + + + +CFepLayoutPopupWnd::CPopupWndExt* CFepLayoutPopupWnd::CPopupWndExt::NewL() + { + CPopupWndExt* self = new (ELeave)CPopupWndExt(); + return self; + } + +void CFepLayoutPopupWnd::CPopupWndExt::ContructBkDeviceL(const TSize& aSize,const TDisplayMode& aMode) + { + TBool bNewBmp = EFalse; + if(!iBitmap || iBitmap->DisplayMode() != aMode) + { + delete iBitmap; + iBitmap = 0; + iBitmap = new (ELeave) CFbsBitmap; + User::LeaveIfError( iBitmap->Create( aSize,aMode)); + delete iBitmapDevice; + iBitmapDevice = 0; + iBitmapDevice = CFbsBitmapDevice::NewL(iBitmap); + bNewBmp = ETrue; + } + if(!iGc) + iGc = CFbsBitGc::NewL(); + + if(!bNewBmp && aSize != iBitmap->SizeInPixels()) + { + ResizeBackupDeviceL(aSize); + } + } +void CFepLayoutPopupWnd::CPopupWndExt::ResizeBackupDeviceL(const TSize& aSize) + { + + iBitmap->Resize(aSize); + iBitmapDevice->Resize( aSize); + iGc->Activate(iBitmapDevice); + iGc->Resized(); + } +void CFepLayoutPopupWnd::CPopupWndExt::SetRect(const TRect& aRect) + { + iRect = aRect; + if(iBitmap && iBitmap->SizeInPixels() != aRect.Size()) + { + ResizeBackupDeviceL(aRect.Size()); + } + } +// End of File