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; |
|
52 } |
51 } |
53 |
52 |
54 // --------------------------------------------------------------------------- |
53 // --------------------------------------------------------------------------- |
55 // CFepLayoutPopupWnd::ConsructL() |
54 // CFepLayoutPopupWnd::ConsructL() |
56 // Symbian 2nd phase constructor |
55 // Symbian 2nd phase constructor |
57 // (other items were commented in a header). |
56 // (other items were commented in a header). |
58 // --------------------------------------------------------------------------- |
57 // --------------------------------------------------------------------------- |
59 EXPORT_C void CFepLayoutPopupWnd::ConstructL() |
58 EXPORT_C void CFepLayoutPopupWnd::ConstructL() |
60 { |
59 { |
61 BaseConstructL(); |
60 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 } |
|
70 } |
61 } |
71 |
62 |
72 EXPORT_C void CFepLayoutPopupWnd::ReDrawRect(const TRect& /*aRect*/) |
63 EXPORT_C void CFepLayoutPopupWnd::ReDrawRect(const TRect& /*aRect*/) |
73 { |
64 { |
74 Draw(); |
65 Draw(); |
265 if(iIsShowing) |
256 if(iIsShowing) |
266 return; |
257 return; |
267 RootControl()->SetActiveCtrl(this); |
258 RootControl()->SetActiveCtrl(this); |
268 ReportEvent(EEventCapturePointer); |
259 ReportEvent(EEventCapturePointer); |
269 |
260 |
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 |
|
273 //let pop up window do preparation |
261 //let pop up window do preparation |
274 OnDisplay(); |
262 OnDisplay(); |
275 |
263 |
276 //determine the directoin |
264 //determine the directoin |
277 TRect rtPopup; //final position |
265 TRect rtPopup; //final position |
297 offsetRect.Move( ptLayout ); |
285 offsetRect.Move( ptLayout ); |
298 |
286 |
299 switch( aDisPostion ) |
287 switch( aDisPostion ) |
300 { |
288 { |
301 case EDispBottomRight: |
289 case EDispBottomRight: |
302 rtPopup.SetRect( TPoint( offsetRect.iTl.iX, offsetRect.iBr.iY ), szPopup ); |
290 rtPopup.SetRect( TPoint( offsetRect.iTl.iX, offsetRect.iBr.iY ), szPopup ); |
303 if( rtPopup.iBr.iY > ptScreenSize.iPixelSize.iHeight ) |
291 if( rtPopup.iBr.iY > ptScreenSize.iPixelSize.iHeight ) |
304 { |
292 { |
305 rtPopup.Move( 0, ptScreenSize.iPixelSize.iHeight - rtPopup.iBr.iY ); |
293 //we need move x also |
306 } |
294 rtPopup.Move( aOffsetRect.Width(), |
|
295 ptScreenSize.iPixelSize.iHeight - rtPopup.iBr.iY ); |
|
296 } |
307 if(rtPopup.iBr.iX > ptScreenSize.iPixelSize.iWidth ) |
297 if(rtPopup.iBr.iX > ptScreenSize.iPixelSize.iWidth ) |
308 { |
298 { |
309 rtPopup.Move ( ptScreenSize.iPixelSize.iWidth - rtPopup.iBr.iX, 0 ); |
299 rtPopup.Move ( ptScreenSize.iPixelSize.iWidth - rtPopup.iBr.iX, 0 ); |
310 } |
300 } |
311 break; |
301 break; |
312 case EDispBottomLeft: |
302 case EDispBottomLeft: |
313 rtPopup.SetRect( TPoint( offsetRect.iBr.iX - szPopup.iWidth, offsetRect.iBr.iY), |
303 rtPopup.SetRect( TPoint( offsetRect.iBr.iX - szPopup.iWidth, offsetRect.iBr.iY), |
314 szPopup ); |
304 szPopup ); |
315 if( rtPopup.iBr.iY > ptScreenSize.iPixelSize.iHeight ) |
305 if( rtPopup.iBr.iY > ptScreenSize.iPixelSize.iHeight ) |
316 { |
306 { |
317 //we need move the pop wnd up to ensure it not to be out of screen |
307 //we need move x also |
318 rtPopup.Move( 0, ptScreenSize.iPixelSize.iHeight - rtPopup.iBr.iY ); |
308 rtPopup.Move( aOffsetRect.Width(), |
|
309 ptScreenSize.iPixelSize.iHeight - rtPopup.iBr.iY ); |
319 } |
310 } |
320 if( rtPopup.iTl.iX < 0 ) |
311 if( rtPopup.iTl.iX < 0 ) |
321 { |
312 { |
322 rtPopup.Move ( -rtPopup.iTl.iX, 0 ); |
313 rtPopup.Move ( -rtPopup.iTl.iX, 0 ); |
323 } |
314 } |
324 break; |
315 break; |
325 case EDispTopRight: |
316 case EDispTopRight: |
326 rtPopup.SetRect( TPoint( offsetRect.iTl.iX, offsetRect.iTl.iY - szPopup.iHeight ), |
317 rtPopup.SetRect( TPoint( offsetRect.iTl.iX, offsetRect.iTl.iY - szPopup.iHeight ), |
327 szPopup ); |
318 szPopup ); |
328 if( rtPopup.iTl.iY < 0 ) |
319 if( rtPopup.iTl.iY < 0 ) |
329 { |
320 { |
330 rtPopup.Move ( 0, -rtPopup.iTl.iY ); |
321 rtPopup.Move ( aOffsetRect.Width(), -rtPopup.iTl.iY ); |
331 } |
322 } |
332 if(rtPopup.iBr.iX > ptScreenSize.iPixelSize.iWidth ) |
323 if(rtPopup.iBr.iX > ptScreenSize.iPixelSize.iWidth ) |
333 { |
324 { |
334 rtPopup.Move ( ptScreenSize.iPixelSize.iWidth - rtPopup.iBr.iX, 0 ); |
325 rtPopup.Move ( ptScreenSize.iPixelSize.iWidth - rtPopup.iBr.iX, 0 ); |
335 } |
326 } |
336 |
327 |
339 rtPopup.SetRect( TPoint( offsetRect.iBr.iX - szPopup.iWidth, |
330 rtPopup.SetRect( TPoint( offsetRect.iBr.iX - szPopup.iWidth, |
340 offsetRect.iTl.iY - szPopup.iHeight ), szPopup ); |
331 offsetRect.iTl.iY - szPopup.iHeight ), szPopup ); |
341 |
332 |
342 if( rtPopup.iTl.iY < 0 ) |
333 if( rtPopup.iTl.iY < 0 ) |
343 { |
334 { |
344 rtPopup.Move ( 0, -rtPopup.iTl.iY ); |
335 rtPopup.Move ( -aOffsetRect.Width(), -rtPopup.iTl.iY ); |
345 } |
336 } |
346 |
337 |
347 if( rtPopup.iTl.iX < 0 ) |
338 if( rtPopup.iTl.iX < 0 ) |
348 { |
339 { |
349 rtPopup.Move ( -rtPopup.iTl.iX, 0 ); |
340 rtPopup.Move ( -rtPopup.iTl.iX, 0 ); |
369 layoutOwner->LayoutSizeChanged(rtFinal.Size(), EFalse); |
360 layoutOwner->LayoutSizeChanged(rtFinal.Size(), EFalse); |
370 layoutOwner->SetPosition(rtFinal.iTl); |
361 layoutOwner->SetPosition(rtFinal.iTl); |
371 //RootControl()->Clear(); |
362 //RootControl()->Clear(); |
372 DrawTransparentMaskBackground( TRect( TPoint(), rtFinal.Size() ) ); |
363 DrawTransparentMaskBackground( TRect( TPoint(), rtFinal.Size() ) ); |
373 RootControl()->Move(iLayoutMoveOff); |
364 RootControl()->Move(iLayoutMoveOff); |
374 EnableDrawingInGroup(); |
365 RootControl()->Draw(); |
375 RootControl()->Draw(); |
|
376 DisableDrawingInGroup(); |
|
377 //UpdateArea( TRect( TPoint(), rtFinal.Size()), ETrue); |
366 //UpdateArea( TRect( TPoint(), rtFinal.Size()), ETrue); |
378 } |
367 } |
379 else |
368 else |
380 { |
369 { |
381 iPrevLayoutRect.SetSize(TSize(0,0)); |
370 iPrevLayoutRect.SetSize(TSize(0,0)); |
389 iWndControl->MakeVisible(ETrue); |
378 iWndControl->MakeVisible(ETrue); |
390 } |
379 } |
391 |
380 |
392 //iRect = rtPopup; |
381 //iRect = rtPopup; |
393 Move( rtPopup.iTl - Rect().iTl); |
382 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 |
|
410 UiLayout()->LockArea(iRect,this); |
383 UiLayout()->LockArea(iRect,this); |
411 |
384 Hide(EFalse); |
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); |
|
418 |
385 |
419 iIsShowing = ETrue; |
386 iIsShowing = ETrue; |
420 AfterDisplayed(); |
387 AfterDisplayed(); |
421 |
388 |
422 TRect rectOfPopup =Rect(); //in new layout coord-sys |
389 TRect rectOfPopup =Rect(); //in new layout coord-sys |
468 UiLayout()->SignalOwner(ESignalPopupWndClosed); |
435 UiLayout()->SignalOwner(ESignalPopupWndClosed); |
469 |
436 |
470 iIsShowing = EFalse; |
437 iIsShowing = EFalse; |
471 if(iWndControl) |
438 if(iWndControl) |
472 iWndControl->MakeVisible(EFalse); |
439 iWndControl->MakeVisible(EFalse); |
473 SetReady(EFalse);//disable redraw |
440 Hide(ETrue); |
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); |
|
493 UiLayout()->UnLockArea(iRect,this); |
441 UiLayout()->UnLockArea(iRect,this); |
494 iRect.Move(-iRect.iTl); |
442 iRect.Move(-iRect.iTl); |
495 MLayoutOwner* layoutOwner = UiLayout()->LayoutOwner(); |
443 MLayoutOwner* layoutOwner = UiLayout()->LayoutOwner(); |
496 if(!iPrevLayoutRect.IsEmpty()) |
444 if(!iPrevLayoutRect.IsEmpty()) |
497 { |
445 { |
499 TRect rt; |
447 TRect rt; |
500 rt.SetSize( layoutOwner->LayoutRect().Size() ); |
448 rt.SetSize( layoutOwner->LayoutRect().Size() ); |
501 layoutOwner->SetPosition(iPrevLayoutRect.iTl); |
449 layoutOwner->SetPosition(iPrevLayoutRect.iTl); |
502 layoutOwner->LayoutSizeChanged(iPrevLayoutRect.Size()); |
450 layoutOwner->LayoutSizeChanged(iPrevLayoutRect.Size()); |
503 RootControl()->GraphicDeviceSizeChanged(); |
451 RootControl()->GraphicDeviceSizeChanged(); |
504 bRedraw = ETrue; |
|
505 } |
452 } |
506 |
453 |
507 if (bRedraw) |
454 RootControl()->Draw(); |
508 { |
|
509 RootControl()->Draw(); |
|
510 } |
|
511 |
455 |
512 iIsShowing = EFalse; |
456 iIsShowing = EFalse; |
513 |
457 |
514 //TRect rect(TPoint(0, 0), iPrevLayoutRect.Size()); |
458 TRect rect( TPoint(0,0),iPrevLayoutRect.Size() ); |
515 UpdateArea(popRect, EFalse); |
459 UpdateArea( rect, EFalse ); |
516 } |
460 } |
517 |
461 |
518 // --------------------------------------------------------------------------- |
462 // --------------------------------------------------------------------------- |
519 // CFepLayoutPopupWnd::SetRect |
463 // CFepLayoutPopupWnd::SetRect |
520 // Set the pop up window's rect |
464 // Set the pop up window's rect |
553 // |
497 // |
554 EXPORT_C void CFepLayoutPopupWnd::AfterDisplayed() |
498 EXPORT_C void CFepLayoutPopupWnd::AfterDisplayed() |
555 { |
499 { |
556 //do nothing |
500 //do nothing |
557 } |
501 } |
558 EXPORT_C void CFepLayoutPopupWnd::HandleResourceChange(TInt aType) |
|
559 { |
|
560 if (aType == KPenInputOwnDeviceChange) |
|
561 { |
|
562 if (UiLayout()->NotDrawToLayoutDevice()) |
|
563 { |
|
564 TRAP_IGNORE(iExt->ContructBkDeviceL(Rect().Size(), |
|
565 UiLayout()->LayoutOwner()->BitmapDevice()->DisplayMode())); |
|
566 } |
|
567 } |
|
568 else |
|
569 CControlGroup::HandleResourceChange(aType); |
|
570 } |
|
571 void CFepLayoutPopupWnd::DisableDrawingInGroup() |
|
572 { |
|
573 |
|
574 UiLayout()->DisableLayoutDrawing(ETrue); |
|
575 SetReady(EFalse); |
|
576 for(TInt i = 0; i < NumOfControls(); ++i) |
|
577 { |
|
578 //There is potential defect that if the child control is a group control, its children not set. |
|
579 //This can be solved by locking the area so no one can update until we unlock it in Enalbegroup |
|
580 ControlList()[i]->SetReady(EFalse); |
|
581 } |
|
582 } |
|
583 void CFepLayoutPopupWnd::EnableDrawingInGroup() |
|
584 { |
|
585 SetReady(ETrue); |
|
586 for(TInt i = 0; i < NumOfControls(); ++i) |
|
587 { |
|
588 //There is potential defect that if the child control is a group control, its children not set. |
|
589 //This can be solved by locking the area so no one can update until we unlock it in Enalbegroup |
|
590 ControlList()[i]->SetReady(ETrue); |
|
591 } |
|
592 UiLayout()->DisableLayoutDrawing(EFalse); |
|
593 } |
|
594 |
|
595 |
|
596 |
|
597 CFepLayoutPopupWnd::CPopupWndExt* CFepLayoutPopupWnd::CPopupWndExt::NewL() |
|
598 { |
|
599 CPopupWndExt* self = new (ELeave)CPopupWndExt(); |
|
600 return self; |
|
601 } |
|
602 |
|
603 void CFepLayoutPopupWnd::CPopupWndExt::ContructBkDeviceL(const TSize& aSize,const TDisplayMode& aMode) |
|
604 { |
|
605 TBool bNewBmp = EFalse; |
|
606 if(!iBitmap || iBitmap->DisplayMode() != aMode) |
|
607 { |
|
608 delete iBitmap; |
|
609 iBitmap = 0; |
|
610 iBitmap = new (ELeave) CFbsBitmap; |
|
611 User::LeaveIfError( iBitmap->Create( aSize,aMode)); |
|
612 delete iBitmapDevice; |
|
613 iBitmapDevice = 0; |
|
614 iBitmapDevice = CFbsBitmapDevice::NewL(iBitmap); |
|
615 bNewBmp = ETrue; |
|
616 } |
|
617 if(!iGc) |
|
618 iGc = CFbsBitGc::NewL(); |
|
619 |
|
620 if(!bNewBmp && aSize != iBitmap->SizeInPixels()) |
|
621 { |
|
622 ResizeBackupDeviceL(aSize); |
|
623 } |
|
624 } |
|
625 void CFepLayoutPopupWnd::CPopupWndExt::ResizeBackupDeviceL(const TSize& aSize) |
|
626 { |
|
627 |
|
628 iBitmap->Resize(aSize); |
|
629 iBitmapDevice->Resize( aSize); |
|
630 iGc->Activate(iBitmapDevice); |
|
631 iGc->Resized(); |
|
632 } |
|
633 void CFepLayoutPopupWnd::CPopupWndExt::SetRect(const TRect& aRect) |
|
634 { |
|
635 iRect = aRect; |
|
636 if(iBitmap && iBitmap->SizeInPixels() != aRect.Size()) |
|
637 { |
|
638 TRAP_IGNORE(ResizeBackupDeviceL(aRect.Size())); |
|
639 } |
|
640 } |
|
641 // End of File |
|