lafagnosticuifoundation/cone/src/COEPRIV.CPP
changeset 0 2f259fa3e83a
child 18 fcdfafb36fe7
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 1997-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 //
       
    15 
       
    16 #include "coepriv.h"
       
    17 #include "coepanic.h"
       
    18 #include <coecntrl.h>	// class CCoeControl
       
    19 
       
    20 
       
    21 LOCAL_C TBool IsHandleValid(TUint aHandle)
       
    22 	{
       
    23 	return (aHandle&3)==0;
       
    24 	}
       
    25 
       
    26 //
       
    27 // CCoeView class
       
    28 //
       
    29 
       
    30 CCoeView* CCoeView::NewLC(MCoeView& aView)
       
    31 	{
       
    32 	CCoeView* self=new(ELeave) CCoeView(aView);
       
    33 	CleanupStack::PushL(self);
       
    34 	return self;
       
    35 	}
       
    36 
       
    37 CCoeView::CCoeView(MCoeView& aView) : iView(aView)
       
    38 	{
       
    39 	}
       
    40 
       
    41 
       
    42 
       
    43 //
       
    44 // class CCoeRedrawer
       
    45 //
       
    46 
       
    47 CCoeRedrawer::CCoeRedrawer(RWsSession& aWsSession)
       
    48 	:CActive(EActivePriorityRedrawEvents),
       
    49 	 iWsSession(aWsSession),
       
    50 	 iFirstRunL(ETrue)
       
    51 	{
       
    52 	CActiveScheduler::Add(this);
       
    53 	Queue();
       
    54 	}
       
    55 
       
    56 CCoeRedrawer::~CCoeRedrawer()
       
    57 	{
       
    58 	Cancel();
       
    59 	}
       
    60 
       
    61 void CCoeRedrawer::Queue()
       
    62 	{
       
    63 	iWsSession.RedrawReady(&iStatus);
       
    64 	SetActive();
       
    65 	}
       
    66 
       
    67 void CCoeRedrawer::RunL()
       
    68 	{
       
    69 	TWsRedrawEvent redraw;
       
    70 	iWsSession.GetRedraw(redraw);
       
    71 	const TUint handle = redraw.Handle();
       
    72 	__ASSERT_ALWAYS(IsHandleValid(handle), Panic(ECoePanicInvalidHandle)); 
       
    73 	CCoeControl* window=REINTERPRET_CAST(CCoeControl*,handle);
       
    74 	Queue();
       
    75 #if defined(_DEBUG)
       
    76 	if (window)
       
    77 		{
       
    78 		TRAPD(err, window->HandleRedrawEvent(redraw.Rect()));
       
    79 		__ASSERT_ALWAYS(err==KErrNone,Panic(ECoePanicLeaveWithoutTrapDuringRedraw));
       
    80 		}
       
    81 #else
       
    82 	if (window)
       
    83 		window->HandleRedrawEvent(redraw.Rect());
       
    84 #endif
       
    85 	iWsSession.Flush();	//flush the window-server client-side buffer *after* HandleRedrawEvent has done any drawing
       
    86 
       
    87 #if defined(USE_IH_RAISE_EVENT)
       
    88 	const TInt appStartupInstrumentationEventIdBase=CCoeEnv::Static()->AppStartupInstrumentationEventIdBase();
       
    89 	if (appStartupInstrumentationEventIdBase!=0)
       
    90 		{
       
    91 		IH_DECLARE( lInstrumentationHandler );
       
    92 		IH_CREATE( lInstrumentationHandler );
       
    93 		IH_RAISE_EVENT( lInstrumentationHandler, appStartupInstrumentationEventIdBase+MTestInstrumentation::TIDOffsetEndApplicationFirstRedraw );
       
    94 		IH_DELETE( lInstrumentationHandler );
       
    95 		}
       
    96 #endif
       
    97 	if (iFirstRunL)
       
    98 		{
       
    99 		iFirstRunL=EFalse;
       
   100 		}
       
   101 	}
       
   102 
       
   103 void CCoeRedrawer::DoCancel()
       
   104 	{
       
   105 	iWsSession.RedrawReadyCancel();
       
   106 	}