idlehomescreen/xmluirendering/uiengine/src/xnviewcontroladapter.cpp
branchRCL_3
changeset 12 9674c1a575e9
child 18 d05a55b217df
equal deleted inserted replaced
11:ff572dfe6d86 12:9674c1a575e9
       
     1 /*
       
     2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation for wrapper for a box
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <gfxtranseffect/gfxtranseffect.h>
       
    20 #include <akntransitionutils.h>
       
    21 
       
    22 // User includes
       
    23 #include "xnappuiadapter.h"
       
    24 #include "xnuiengine.h"
       
    25 #include "xnnode.h"
       
    26 #include "xndomnode.h"
       
    27 #include "xnnodepluginif.h"
       
    28 #include "xnproperty.h"
       
    29 #include "xnviewadapter.h"
       
    30 #include "xnbackgroundmanager.h"
       
    31 #include "xnviewdata.h"
       
    32 #include "xnviewmanager.h"
       
    33 #include "xnviewcontroladapter.h"
       
    34 
       
    35 // Constants
       
    36     
       
    37 // ============================ MEMBER FUNCTIONS ===============================
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CXnViewControlAdapter::NewL
       
    41 // Symbian static 1st phase constructor
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 CXnViewControlAdapter* CXnViewControlAdapter::NewL( CXnNodePluginIf& aNode )
       
    45     {
       
    46 	CXnViewControlAdapter* self = new( ELeave ) CXnViewControlAdapter( aNode );
       
    47 
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL( aNode );
       
    50     CleanupStack::Pop( self );
       
    51 
       
    52     return self;	
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CXnViewControlAdapter::ConstructL
       
    57 // Symbian 2nd phase constructor can leave.
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 void CXnViewControlAdapter::ConstructL( CXnNodePluginIf& aNode )
       
    61     {
       
    62     CXnControlAdapter::ConstructL( aNode );
       
    63             
       
    64     CreateWindowL();
       
    65 
       
    66     if( Window().SetTransparencyAlphaChannel() == KErrNone )      
       
    67         {       
       
    68         Window().SetBackgroundColor( ~0 );       
       
    69         }   
       
    70    
       
    71     Window().SetPointerGrab( EFalse );
       
    72     
       
    73     EnableDragEvents();
       
    74            
       
    75     ActivateL();
       
    76   
       
    77     SetComponentsToInheritVisibility( ETrue );
       
    78         
       
    79     iAppUi.UiStateListener().AddObserver( *this );
       
    80     }
       
    81     
       
    82 // -----------------------------------------------------------------------------
       
    83 // CXnViewControlAdapter::CXnViewControlAdapter
       
    84 // C++ default constructor
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 CXnViewControlAdapter::CXnViewControlAdapter( CXnNodePluginIf& aNode ) 
       
    88     : iNode( aNode ), iAppUi( static_cast< CXnAppUiAdapter& >( *iAvkonAppUi ) ),
       
    89     iHitpoint( TPoint( -1,-1 ) )
       
    90     {    
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CXnViewControlAdapter::~CXnViewControlAdapter
       
    95 // C++ destructor
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 CXnViewControlAdapter::~CXnViewControlAdapter()
       
    99     {
       
   100     iAppUi.UiStateListener().RemoveObserver( *this );      
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CXnViewControlAdapter::MakeVisible
       
   105 //
       
   106 // -----------------------------------------------------------------------------
       
   107 // 
       
   108 void CXnViewControlAdapter::MakeVisible( TBool aVisible )
       
   109     {
       
   110     if ( aVisible == IsVisible() )
       
   111         {
       
   112         return;
       
   113         }
       
   114     
       
   115     if ( aVisible )
       
   116         {
       
   117         if ( !iAppUi.UiEngine().IsEditMode() )
       
   118             {
       
   119             Window().SetPointerGrab( ETrue );
       
   120             }
       
   121         }
       
   122     else
       
   123         {
       
   124         Window().SetPointerGrab( EFalse );
       
   125         
       
   126         ResetGrabbing();
       
   127         }
       
   128         
       
   129     CCoeControl::MakeVisible( aVisible );    
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CXnViewControlAdapter::Draw
       
   134 //
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 void CXnViewControlAdapter::Draw( const TRect& aRect ) const
       
   138     {    
       
   139     SystemGc().Clear( aRect );        
       
   140     }
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // CXnViewControlAdapter::HandlePointerEventL
       
   144 //
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 void CXnViewControlAdapter::HandlePointerEventL( 
       
   148     const TPointerEvent& aPointerEvent )
       
   149     {
       
   150     if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
   151         {
       
   152         iHitpoint = aPointerEvent.iPosition;
       
   153         }
       
   154     
       
   155     iAppUi.UiEngine().DisableRenderUiLC();
       
   156             
       
   157     CXnControlAdapter::HandlePointerEventL( aPointerEvent );
       
   158     
       
   159     iAppUi.UiEngine().RenderUIL();
       
   160     
       
   161     CleanupStack::PopAndDestroy();    
       
   162     }
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // CXnViewControlAdapter::ResetGrabbing()
       
   166 // 
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 void CXnViewControlAdapter::ResetGrabbing()
       
   170     {
       
   171     TPointerEvent event;
       
   172     event.iType = TPointerEvent::EButton1Up;
       
   173     
       
   174     TRAP_IGNORE( RemoveGrabbingControL( this, event ) );
       
   175     
       
   176     iHitpoint.SetXY( -1, -1 );
       
   177     }
       
   178 
       
   179 // -----------------------------------------------------------------------------
       
   180 // CXnViewControlAdapter::RemoveGrabbingControL()
       
   181 // Removes recursively grabbing controls
       
   182 // -----------------------------------------------------------------------------
       
   183 //
       
   184 void CXnViewControlAdapter::RemoveGrabbingControL( const CCoeControl* aControl,
       
   185     const TPointerEvent& aEvent ) const
       
   186     {
       
   187     TInt count( aControl->CountComponentControls() );
       
   188     
       
   189     for( TInt i = 0; i < count; i++ )
       
   190         {
       
   191         CCoeControl* child( aControl->ComponentControl( i ) );
       
   192         
       
   193         if( child && child->Rect().Contains( iHitpoint ) )
       
   194             {
       
   195             child->CCoeControl::HandlePointerEventL( aEvent ); 
       
   196             RemoveGrabbingControL( child, aEvent );
       
   197             }
       
   198         }
       
   199     }
       
   200 
       
   201 // -----------------------------------------------------------------------------
       
   202 // CXnViewControlAdapter::NotifyForegroundChanged()
       
   203 // 
       
   204 // -----------------------------------------------------------------------------
       
   205 //
       
   206 void CXnViewControlAdapter::NotifyForegroundChanged( TForegroundStatus aStatus )
       
   207     {
       
   208     if ( aStatus == EBackground || aStatus == EPartialForeground )
       
   209         {
       
   210         ResetGrabbing();
       
   211         }
       
   212     }
       
   213 
       
   214 // -----------------------------------------------------------------------------
       
   215 // CXnViewControlAdapter::NotifyLightStatusChanged()
       
   216 //  
       
   217 // -----------------------------------------------------------------------------
       
   218 //
       
   219 void CXnViewControlAdapter::NotifyLightStatusChanged( TBool /*aLightsOn*/ )
       
   220     {    
       
   221     }
       
   222 
       
   223 // -----------------------------------------------------------------------------
       
   224 // CXnViewControlAdapter::NotifyInCallStateChaged()
       
   225 // 
       
   226 // -----------------------------------------------------------------------------
       
   227 //
       
   228 void CXnViewControlAdapter::NotifyInCallStateChaged( TBool /*aInCall*/ )
       
   229     {    
       
   230     }
       
   231 
       
   232 // End of file