usbuis/imageprintui/src/emptycontainer.cpp
changeset 93 2dc695882abd
parent 89 3592750162a5
equal deleted inserted replaced
89:3592750162a5 93:2dc695882abd
     1 /*
       
     2 * Copyright (c) 2006 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:  Empty container for UI
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 //INCLUDES
       
    21 #include <AknsDrawUtils.h> 
       
    22 #include <AknsBasicBackgroundControlContext.h>
       
    23 #include <AknsConstants.h>
       
    24 #include <AknUtils.h>
       
    25 #include <eikenv.h>
       
    26 
       
    27 #include "emptycontainer.h"
       
    28 #include "imageprintuidebug.h"
       
    29 
       
    30 
       
    31 // ======== MEMBER FUNCTIONS ========
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // 
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CEmptyContainer::CEmptyContainer()
       
    38     {
       
    39     }
       
    40 
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // 
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 void CEmptyContainer::ConstructL( const TRect& aRect  )
       
    47     {
       
    48     FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::ConstructL"));
       
    49     CreateWindowL();
       
    50 	SetRect( aRect );
       
    51     
       
    52     // Temporary rect is passed. Correct rect is set in SizeChanged.
       
    53     iSkinContext = CAknsBasicBackgroundControlContext::NewL(
       
    54         KAknsIIDQsnBgAreaMain, Rect(), EFalse);
       
    55 
       
    56     ActivateL();
       
    57 
       
    58     FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::ConstructL complete"));
       
    59     }
       
    60 
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // 
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 CEmptyContainer* CEmptyContainer::NewL( 
       
    67     const TRect& aRect )
       
    68     {
       
    69     FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::NewL"));
       
    70     CEmptyContainer* self = CEmptyContainer::NewLC( aRect );
       
    71     CleanupStack::Pop( self );
       
    72     return self;
       
    73     }
       
    74 
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // 
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 CEmptyContainer* CEmptyContainer::NewLC( 
       
    81     const TRect& aRect )
       
    82     {
       
    83     FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::NewLC"));
       
    84     
       
    85     CEmptyContainer* self = new( ELeave ) CEmptyContainer;
       
    86     CleanupStack::PushL( self );
       
    87     self->ConstructL( aRect );
       
    88     return self;
       
    89     }
       
    90 
       
    91 
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // 
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 CEmptyContainer::~CEmptyContainer()
       
    98     {
       
    99     FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::Destructor"));
       
   100     delete iSkinContext; 
       
   101     }
       
   102 
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // 
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 void CEmptyContainer::Draw( const TRect& aRect ) const
       
   109     {
       
   110 
       
   111     FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::Draw"));
       
   112     CWindowGc& gc = SystemGc();
       
   113 
       
   114     // Drawing skin
       
   115     if (iSkinContext)
       
   116         {
       
   117         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   118         AknsDrawUtils::Background( skin, iSkinContext, this, gc, aRect );
       
   119         }
       
   120     else
       
   121         {//  clear the area
       
   122         gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) );
       
   123         gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   124         gc.Clear( aRect );
       
   125         }
       
   126 
       
   127     FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::Draw complete"));
       
   128     }
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // 
       
   132 // ---------------------------------------------------------------------------
       
   133 //
       
   134 void CEmptyContainer::SizeChanged()
       
   135     {
       
   136     FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::SizeChanged()"));
       
   137 
       
   138     TRect parentRect(Rect());
       
   139 	if (iSkinContext)
       
   140         {
       
   141         iSkinContext->SetRect(parentRect);
       
   142         }
       
   143     FLOG(_L("[IMAGEPRINTUI]\t CEmptyContainer::SizeChanged() complete"));
       
   144 	}
       
   145 
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // 
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151  void CEmptyContainer::HandleResourceChange(TInt aType)
       
   152  {
       
   153     if ( aType == KEikDynamicLayoutVariantSwitch )
       
   154         {		
       
   155 		TRect rect;
       
   156 		// ask where container's rectangle should be
       
   157 		// EMainPane equals to area returned by CEikAppUi::ClientRect()
       
   158 		
       
   159  		AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
       
   160         SetRect(rect); 
       
   161 		DrawNow();
       
   162         }
       
   163     else
       
   164         {
       
   165         CCoeControl::HandleResourceChange(aType);
       
   166         }  
       
   167  }
       
   168 
       
   169 //End of File