uifw/AvKon/akncompamode/src/akncompaside.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Control to fill sides of compatibility mode window
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <gulicon.h>
       
    20 #include <aknenv.h>
       
    21 #include <AknsSkinInstance.h>
       
    22 #include <AknsDrawUtils.h>
       
    23 #include <AknsBasicBackgroundControlContext.h>
       
    24 #include <AknUtils.h>
       
    25 
       
    26 #include "akncompaside.h"
       
    27 #include "akncompautils.h"
       
    28 
       
    29 // --------------------------------------------------------------------------
       
    30 //
       
    31 // --------------------------------------------------------------------------
       
    32 CAknCompaSide* CAknCompaSide::NewL()
       
    33     {
       
    34     CAknCompaSide* self = new (ELeave) CAknCompaSide();
       
    35     CleanupStack::PushL(self);
       
    36     self->ConstructL();
       
    37     CleanupStack::Pop(self);
       
    38     return self;
       
    39     }
       
    40 
       
    41 // --------------------------------------------------------------------------
       
    42 //
       
    43 // --------------------------------------------------------------------------
       
    44 CAknCompaSide::~CAknCompaSide()
       
    45     {
       
    46     delete iBgContext;
       
    47     }
       
    48 
       
    49 // --------------------------------------------------------------------------
       
    50 //
       
    51 // --------------------------------------------------------------------------
       
    52 void CAknCompaSide::Draw(const TRect& aRect) const
       
    53     {
       
    54     CWindowGc& gc = SystemGc();
       
    55     
       
    56     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
    57 
       
    58     // If skin background draw fails, flat color will be used
       
    59     if(!AknsDrawUtils::Background(skin, iBgContext, this, gc, aRect))
       
    60         { 
       
    61         TRgb backgroundColor;
       
    62         AknsUtils::GetCachedColor(skin, backgroundColor,
       
    63             KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG20);
       
    64             
       
    65         gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
    66         gc.SetPenColor(backgroundColor);
       
    67         gc.SetBrushColor(backgroundColor);
       
    68         // Draw window rect
       
    69         gc.DrawRect(Rect());
       
    70         }
       
    71     }
       
    72 
       
    73 // --------------------------------------------------------------------------
       
    74 //
       
    75 // --------------------------------------------------------------------------
       
    76 void CAknCompaSide::SetBackground(TPoint aOrigin)
       
    77     {
       
    78     TPoint origo(0, 0);
       
    79     TRect screenRect = AknLayout::screen().Rect();
       
    80     
       
    81     // Skin background context
       
    82     iBgContext->SetParentPos(origo);
       
    83     AknCompaUtils::ScaleRect(screenRect, -aOrigin.iX, 0);
       
    84     iBgContext->SetRect(screenRect);
       
    85     }
       
    86     
       
    87 // --------------------------------------------------------------------------
       
    88 //
       
    89 // --------------------------------------------------------------------------
       
    90 void CAknCompaSide::ConstructL()
       
    91     {
       
    92     CreateWindowL();
       
    93     RWindow& window = Window();
       
    94     // Prevent fading when appication displays a dialog
       
    95     window.SetNonFading(ETrue);
       
    96     // Ordinal priority is not usually set for application windows
       
    97     // (only for window groups). Side control is set to high ordinal
       
    98     // priority. This keeps it always at front and prevents compa
       
    99     // mode application drawing on top of it.
       
   100     const TInt KOrdinalPriority = ECoeWinPriorityAlwaysAtFront + 1;
       
   101     window.SetOrdinalPosition(window.OrdinalPosition(), KOrdinalPriority);
       
   102     iBgContext = CAknsBasicBackgroundControlContext::NewL(
       
   103         KAknsIIDQsnBgScreen, Rect(), ETrue);
       
   104     // Control is left unactivated after construction. ActivateL() should
       
   105     // be called to display it.
       
   106     }