void CEdgedWin::Redraw(const TRect& aRect)
	{
	iWsGc.Activate(*iWindow);
	iWsGc.Reset();
	iWsGc.SetPenStyle(iPenStyle);
	iWsGc.SetBrushStyle(iBrushStyle);
	TBool redraw = EFalse;
	//redraw outer rectangle if in rect
	if (aRect.iTl.iX < iOpaqueRect.iTl.iX ||
	    aRect.iTl.iY < iOpaqueRect.iTl.iY ||
	    aRect.iBr.iX > iOpaqueRect.iBr.iX ||
	    aRect.iBr.iY > iOpaqueRect.iBr.iY)
	    {
	    redraw = ETrue;
	    iRedrawWindow->BeginRedraw();
		iWsGc.SetPenColor(iTransFgColor);
		iWsGc.SetBrushColor(iTransBgColor);
		iWsGc.DrawRect(TRect(TPoint(0,0), iSize));
	//	iRedrawWindow->EndRedraw() will be taken care of below
	    }
	//redraw inner rectangle
	if (redraw || aRect.Intersects(iOpaqueRect))
		{
		if (!redraw)
			{
			iRedrawWindow->BeginRedraw(iOpaqueRect);//iOpaqueRect);
			}
		iWsGc.SetPenColor(iFgColor);
		iWsGc.SetBrushColor(iBgColor);
		iWsGc.DrawRect(iOpaqueRect);
		iRedrawWindow->EndRedraw();
		}
	iWsGc.Deactivate();
	}
void CCameraEngine::StartDirectViewFinderL(RWsSession& aSession,
                            CWsScreenDevice& aScreenDevice,
                            RWindowBase& aWindow,
                            TRect& aScreenRect,
                            TRect& aClipRect)
{
    if (iEngineState < EEngineIdle)
        User::Leave(KErrNotReady);

    if (0 == (iCameraInfo.iOptionsSupported & TCameraInfo::EViewFinderDirectSupported))
        User::Leave(KErrNotSupported);

    if (!iCamera->ViewFinderActive()) {
        // Viewfinder extent needs to be clipped according to the clip rect.
        // This is because the native camera framework does not support
        // clipping and starting viewfinder with bigger than the display(S60
        // 5.0 and older)/window(Symbian^3 and later) would cause viewfinder
        // starting to fail entirely. This causes shrinking effect in some
        // cases, but is better than not having the viewfinder at all.
        if (aScreenRect.Intersects(aClipRect))
            aScreenRect.Intersection(aClipRect);

        if (iCameraIndex != 0)
            iCamera->SetViewFinderMirrorL(true);
        if (aScreenRect.Width() > 0 && aScreenRect.Height() > 0) {
            iCamera->StartViewFinderDirectL(aSession, aScreenDevice, aWindow, aScreenRect);
        } else {
            if (iObserver)
                iObserver->MceoHandleError(EErrViewFinderReady, KErrArgument);
        }
    }
}
Exemple #3
0
void CGdiBlitMasked::BaseTest(const TRect &aRect, TInt)
	{
// needs re-writing to emulate tiling of the source rect
	if (!aRect.Intersects(TRect(BaseWin->Size())))
		return;
	TSize size(aRect.Size());
	TSize bitSize=iBitmap->SizeInPixels();
	if (size.iWidth>bitSize.iWidth)
		size.iWidth=bitSize.iWidth;
	if (size.iHeight>bitSize.iHeight)
		size.iHeight=bitSize.iHeight;
//
// Set up the scratch mask as a black and white bitmap containing the mask to blit
// The mask pattern is replicated all over the scratchmask bitmap
//
	iScratchMaskGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
	iScratchMaskGc->SetPenStyle(CGraphicsContext::ENullPen);
	iScratchMaskGc->SetBrushColor(TRgb(0,0,0));
	iScratchMaskGc->DrawRect(TRect(iScratchMask->SizeInPixels()));
	iScratchMaskGc->SetPenColor(TRgb(255,255,255));
	iScratchMaskGc->SetPenStyle(CGraphicsContext::ESolidPen);
	TSize maskSize(iCurrMask->SizeInPixels());
	TPoint pos;
	TRgb *rgbBuf=(TRgb *)User::AllocL(maskSize.iWidth*sizeof(TRgb));		//Doesn't do any harm if it leaves
	for(pos.iY=0;pos.iY<maskSize.iHeight;pos.iY++)
		{
		TPtr8 ptr((TUint8 *)rgbBuf,maskSize.iWidth*sizeof(TRgb));
		iCurrMask->GetScanLine(ptr, pos, maskSize.iWidth, ERgb);
		for(TInt index=0;index<maskSize.iWidth;index++)
			{
			iScratchMaskGc->SetPenColor(rgbBuf[index]);
//			if ((isLow && !iLowCutOff) || (!isLow && iLowCutOff))
				iScratchMaskGc->Plot(TPoint(index,pos.iY));
			}
		}
	User::Free(rgbBuf);

	for(pos.iY=0;pos.iY<size.iHeight;pos.iY+=maskSize.iHeight)
		for(pos.iX=0;pos.iX<size.iWidth;pos.iX+=maskSize.iWidth)
			iScratchMaskGc->CopyRect(pos, TRect(maskSize));
//
// Blit this to the screen in ANDNOT mode to clear all the pixels we want the mask blit to draw to
//
	iGdi->SetDrawMode(CGraphicsContext::EDrawModeANDNOT);
	iGdi->BitBlt(aRect.iTl, iScratchMask, TRect(size));
//
// Copy the test bitmap to the scratch bitmap then use the scratch mask to clear all the bits
// that should masked out of the draw to the screen
//
	iScratchGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
	iScratchGc->BitBlt(TPoint(0,0), iBitmap);
	iScratchGc->SetDrawMode(CGraphicsContext::EDrawModeAND);
	iScratchGc->BitBlt(TPoint(0,0), iScratchMask);
//
// Now copy the scratch bitmap to the screen in OR mode to get the final result
//
	iGdi->SetDrawMode(CGraphicsContext::EDrawModeOR);
	iGdi->BitBlt(aRect.iTl, iScratch, TRect(size));
	}
void CImage::Draw(const TRect& aRect) const
{
   // Draw the parent control
   //CEikBorderedControl::Draw(aRect);
   // Get the standard graphics context 
   CWindowGc& gc = SystemGc();
   // Gets the control's extent - Don't encroach on the border
   TRect rect = Rect();//Border().InnerRect(Rect());
   // set the clipping region
   gc.SetClippingRect(rect);   
   if(iMask == NULL && iBitmap != NULL && rect.Intersects(aRect)){
      gc.BitBlt(rect.iTl, iBitmap);
   } else if(iMask != NULL && iBitmap != NULL && rect.Intersects(aRect)){
      TRect pictRect(TPoint(0,0), iBitmap->SizeInPixels());
      gc.BitBltMasked(rect.iTl, iBitmap, pictRect, iMask, EFalse);
   }
}
// ---------------------------------------------------------------------------
// Sets visible area.
// ---------------------------------------------------------------------------
//
void CAlfSrvDisplaySubSession::SetVisibleAreaL( const RMessage2& aMessage, TBool aForce )
    {
    // Parse parameters

    // 1: area rect (in)
    TRect rect;
    TPckg<TRect> rectPckg(rect); 
    aMessage.Read(1,rectPckg);
	        
		CAlfAppSrvSession& session = static_cast<CAlfAppSrvSession&>(Session());	        
	           
    // Set clipping rect for display visible area to e.g. avoid unnecesssary 
    // drawing under Avkon status/control pane areas. TV out does not show
    // those so no clipping in that case.
    if (UseVisualAreaClipping())
       {
       iRect = rect;
		
			if ( session.IsFocused() )
        		{
    	      TRect clipped = Session().AlfAppUi()->Container()->Rect();
#ifndef SYMBIAN_BUILD_GCE
		       	if (clipped.Intersects(rect))
		           {
		           clipped.Intersection(rect);        
		           }
#endif           
		       	iDisplay->SetVisibleAreaClippingRect(clipped);        
		       	iDisplay->SetDirty();
	        	}
	       }           
	           
    // Set visible area        
			if ( session.IsFocused() || aForce )
        		{
    		    static_cast<CAlfAppSrvSession&>(Session()).SetClientDrawingArea( rect );
        		}
    // Complete
    aMessage.Complete( KErrNone );
    }
// ---------------------------------------------------------------------------
// CFepUiLayoutRootCtrl::IsValidDestination
// Test whether the rect conflicts with other controls
// (other items were commented in a header).
// ---------------------------------------------------------------------------
//    
TBool CFepUiLayoutRootCtrl::IsValidDestination(const TRect& aRect,
                                               CDragBar* aDragBar,
                                               TBool& aVInfo,
                                               TBool& aHInfo)
    {    
    aVInfo = EFalse;
    aHInfo = EFalse;
    if(!Rect().Contains(aRect.iTl) || !Rect().Contains(aRect.iBr)) //outside of the ui layout
        return EFalse;   
     
    CFepUiBaseCtrl* ctrl;

    for(TInt i = iCtrlList.Count()-1; i >= 0;i--)
        {
        ctrl = iCtrlList[i];            
        TBool bIsDragingComponent = EFalse;
        if(aDragBar)
            {
            if(aDragBar->IsDraggingComponent(ctrl))
                bIsDragingComponent = ETrue;
            }
  
        
        if(!bIsDragingComponent && aRect.Intersects(ctrl->Rect()))   //conflicts with others
            {
            //is the control one of the dragbar component.
           
            if(!ctrl->AllowOverlap()) 
                {                    
                //if the control not allow overlapping, then it's invalid pos
                return EFalse;
                }
                
            }
        }
    
    return ETrue;
}    
// ---------------------------------------------------------------------------
// 2nd phasse constructor
// ---------------------------------------------------------------------------
//
void CAlfSrvDisplaySubSession::ConstructL()
    {
    CAlfSrvSubSessionBase::ConstructL();
    
    // With one display, use the existing one or create one if there aren't any.
    const TRect& rect = CHuiStatic::ScreenDevice()->SizeInPixels();
    
    // when running oldstyle, we may have rect different from whole screen
    if (Session().AlfAppUi()->Container())
        {
        const TRect& rect = Session().AlfAppUi()->Container()->Rect();
        }
    
    // Shared normal screen 0
    if ((iDisplayType == CHuiDisplay::EDisplayLcd0) || 
       ((iDisplayType == CHuiDisplay::EDisplayNormal) && (iScreenBufferUid == KHuiUidBackBufferScreen0)))
        {            
        iDisplay = 
            Session().SharedHuiEnv()->DisplayCount() ? 
                &Session().SharedHuiEnv()->PrimaryDisplay() : 
                &Session().SharedHuiEnv()->NewDisplayL( rect, Session().AlfAppUi()->Container(), 0,
                	NULL,  CHuiDisplay::EDisplayNormal, iScreenBufferUid );
                
        Session().AlfAppUi()->AppendDisplayOnSharedWindowL(*iDisplay);
        
        #ifdef TFXSERVER_API_V2
		// Register to Tfx Server
        MTransitionServer2* tfxServer = Session().AlfServer()->TfxServer();
        if (tfxServer)
        	{
        	// Note: if this returns KErrNotFound, it is also send to Tfx server
        	TInt wgId = Session().ClientWindowGroup();
       		// Just ignore returned error code. Can this cause trouble? 
       		tfxServer->RegisterApp(MTransitionServer2::ETypeAlf, wgId, KNullUid, KNullUid);
        	}
   		#endif
        }
        
    // Off screen buffer    
    else if (iDisplayType == CHuiDisplay::EDisplayOffScreenBuffer)
        {            
        iDisplay = &Session().SharedHuiEnv()->NewDisplayL( rect, Session().AlfAppUi()->Container(), 0, NULL, iDisplayType, iScreenBufferUid );

        TRect clipped = rect;
        if (clipped.Intersects(iRect))
            {
            clipped.Intersection(iRect);        
            }

        iDisplay->SetVisibleArea(clipped);        
        }
        
    // Shared TV-out display    
    else if (IsTvOut())
        {
        if (Session().SharedHuiEnv()->DisplayCount() == 0)
            {
            // Primary lcd must exist before tv out is created            
            User::Leave(KErrNotFound);                    
            }                
        else
            {                
            iDisplay = &Session().SharedHuiEnv()->NewDisplayL( iRect,
                 Session().AlfAppUi()->Container(),
                 0, 
                 &Session().SharedHuiEnv()->PrimaryDisplay(), 
                 CHuiDisplay::EDisplayNormal, 
                 KHuiUidBackBufferTvOutNormal
                 );                  
            }
        }  
     else
     	{
     	User::Leave(KErrNotFound); 
     	} 
     
    // If we have screen buffer observers for the new display, add Alf server as an observer 	
    TAlfScreenBufferEvent event = {iScreenBufferUid, MHuiScreenBufferObserver::ECreated, TRect(), TRect()};
    if (Session().AlfServer()->ScreenBufferManager().TriggerScreenBufferEvent(event))
    	{
    	iDisplay->AddScreenBufferObserverL(&Session().AlfServer()->ScreenBufferManager());
    	}
	
    }
void CAlfSrvDisplaySubSession::SetSessionFocused(TBool aFocused)
    {
    if ( iDisplay )
        {
        if (aFocused)
            {
            // Set clipping rect for display visible area to e.g. avoid unnecesssary 
            // drawing under Avkon status/control pane areas. TV out does not show
            // those so no clipping in that case.
            if (UseVisualAreaClipping())
                {
                TRect clipped = Session().AlfAppUi()->Container()->Rect();
                if (clipped.Intersects(iRect))
                    {
                    clipped.Intersection(iRect);        
                    }
                iDisplay->SetVisibleAreaClippingRect(clipped);        
                iDisplay->SetDirty();
                }

            // If background items are used
            if (iBackgroundItems.Count() != 0)
                {
                TRAP_IGNORE(iDisplay->SetBackgroundItemsL(iBackgroundItems))                        
                }
            else
                {
                TRAP_IGNORE(iDisplay->SetClearBackgroundL(
                        CHuiDisplay::TClearMode(iDisplayClearBackground)))                                        
                }    

            if ( KAlfSrvClientQualitySupport )
                {
                iDisplay->SetQuality(THuiQuality(iDisplayRenderingQuality));
                }
            iDisplay->SetUseDepth(iDisplayUseDepthTest);
            
            UpdateAutomaticFading(); // update non-fading to app ui container
            }
        else
            {
            // Disable clipping rect 
            if (UseVisualAreaClipping())
                {
                iDisplay->SetVisibleAreaClippingRect(TRect(0,0,0,0));        
                iDisplay->SetDirty();
                }                
            }    
        
        if (IsTvOut())
            {
            if (aFocused)
                {
                TRAP_IGNORE(
                    {
                    iDisplay->RestoreL();
                    Session().AlfAppUi()->AppendTvDisplayOnSharedWindowL(*iDisplay);
                    })
                }
            else
                {
                Session().AlfAppUi()->RemoveTvDisplayOnSharedWindow(*iDisplay);
                iDisplay->Release();    
                }                
            }