mmsharing/mmshui/src/musuibackgroundviewcontainer.cpp
changeset 15 ccd8e69b5392
parent 2 b31261fd4e04
child 20 e8be2c2e049d
child 22 496ad160a278
equal deleted inserted replaced
2:b31261fd4e04 15:ccd8e69b5392
     1 /*
       
     2 * Copyright (c) 2005 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:  The MUS application's UI class.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "musuibackgroundviewcontainer.h"
       
    19 #include "musuiappui.h"
       
    20 #include "muslogger.h" // debug logging
       
    21 
       
    22 #include <AknsControlContext.h>
       
    23 #include <AknsBasicBackgroundControlContext.h>
       
    24 #include <AknsDrawUtils.h>
       
    25 #include <StringLoader.h>                // StringLoader
       
    26 #include <aknnotewrappers.h>
       
    27 #include <AknWaitDialog.h>
       
    28 #include <AknGlobalNote.h>
       
    29 #include <AknDef.h>
       
    30 
       
    31 
       
    32 // Hidden window group. magic number 32 hiddens window
       
    33 _LIT( KMusUiBackgroundWindowGroupName,"32MusUiBackground" );
       
    34 
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CMusUiBackgroundViewContainer* CMusUiBackgroundViewContainer::NewL( 
       
    41     const TRect& aRect, 
       
    42     TInt aOrdinalPosition )
       
    43     {
       
    44     CMusUiBackgroundViewContainer* self =
       
    45         new( ELeave )CMusUiBackgroundViewContainer( aOrdinalPosition );
       
    46     CleanupStack::PushL( self );
       
    47     self->ConstructL( aRect );
       
    48     CleanupStack::Pop( self );
       
    49     return self;
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 CMusUiBackgroundViewContainer::CMusUiBackgroundViewContainer( 
       
    57     TInt aOrdinalPosition ) : iOrdinalPosition( aOrdinalPosition )
       
    58     {
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 void CMusUiBackgroundViewContainer::ConstructL( const TRect& aRect )
       
    66     {
       
    67     MUS_LOG( "mus: [MUSUI ]  -> CMusUiBackgroundViewContainer::ConstructL()" );
       
    68     
       
    69     RWindowGroup iMyWindowGroup = RWindowGroup( iCoeEnv->WsSession() );
       
    70     User::LeaveIfError( iMyWindowGroup.Construct( ( TUint32 )&iMyWindowGroup) );
       
    71 
       
    72     iMyWindowGroup.SetName( KMusUiBackgroundWindowGroupName );
       
    73     iMyWindowGroup.SetOrdinalPosition( iOrdinalPosition, ECoeWinPriorityNormal );
       
    74     iMyWindowGroup.EnableReceiptOfFocus( EFalse );
       
    75 
       
    76     CreateWindowL(&iMyWindowGroup);
       
    77 
       
    78     iGroupIdentifier = iMyWindowGroup.Identifier();
       
    79 
       
    80     iBackGround = CAknsBasicBackgroundControlContext::NewL(
       
    81         KAknsIIDQsnBgAreaMain,
       
    82         aRect,
       
    83         EFalse );
       
    84 
       
    85     SetRect( aRect );
       
    86 
       
    87     ActivateL();
       
    88 
       
    89     MUS_LOG( "mus: [MUSUI ]  <- CMusUiBackgroundViewContainer::ConstructL()" );
       
    90     }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 CMusUiBackgroundViewContainer::~CMusUiBackgroundViewContainer()
       
    97     {
       
    98     MUS_LOG( "mus: [MUSUI ]  -> CMusUiBackgroundViewContainer::~CMusUiBackgroundViewContainer()" );
       
    99     delete iBackGround;
       
   100     MUS_LOG( "mus: [MUSUI ]  <- CMusUiBackgroundViewContainer::~CMusUiBackgroundViewContainer()" );
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 void CMusUiBackgroundViewContainer::RefreshView()
       
   108     {
       
   109     MUS_LOG( "mus: [MUSUI ]  -> CMusUiBackgroundViewContainer::RefreshView()" );
       
   110 
       
   111     DrawNow();
       
   112 
       
   113     MUS_LOG( "mus: [MUSUI ]  <- CMusUiBackgroundViewContainer::RefreshView()" );
       
   114     }
       
   115 
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // Set's this group right ordinal position
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 void CMusUiBackgroundViewContainer::SetOrdinalPosition()
       
   122     {
       
   123     MUS_LOG1( "mus: [MUSUI ]  -> CMusUiBackgroundViewContainer::SetOrdinalPosition(): %d",
       
   124                 iOrdinalPosition );
       
   125     MakeVisible( ETrue );
       
   126 
       
   127     iCoeEnv->WsSession().SetWindowGroupOrdinalPosition( iGroupIdentifier,
       
   128                                                         iOrdinalPosition );
       
   129 
       
   130     DrawNow();
       
   131     MUS_LOG( "mus: [MUSUI ]  <- CMusUiBackgroundViewContainer::SetOrdinalPosition()" );
       
   132     }
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // Set's this group right ordinal position
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 void CMusUiBackgroundViewContainer::SetOrdinalPosition( TInt aOrdianlPosition)
       
   139     {
       
   140     MUS_LOG1( "mus: [MUSUI ]  -> CMusUiBackgroundViewContainer::SetOrdinalPosition(): %d",
       
   141             aOrdianlPosition );
       
   142     MakeVisible( ETrue );
       
   143 
       
   144     iCoeEnv->WsSession().SetWindowGroupOrdinalPosition( iGroupIdentifier,
       
   145                                                         aOrdianlPosition );
       
   146 
       
   147     DrawNow();
       
   148     MUS_LOG( "mus: [MUSUI ]  <- CMusUiBackgroundViewContainer::SetOrdinalPosition()" );
       
   149     }
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 void CMusUiBackgroundViewContainer::UpdateOrdinalPositionValue( TBool aUp )
       
   156     {
       
   157     MUS_LOG1( "mus: [MUSUI ]  -> CMusUiBackgroundViewContainer::UpdateOrdinalPositionValue(): %d",
       
   158                 aUp );
       
   159     if ( aUp )
       
   160         {
       
   161         ++iOrdinalPosition;
       
   162         }
       
   163     else
       
   164         {
       
   165         --iOrdinalPosition;
       
   166         }
       
   167     SetOrdinalPosition();
       
   168     MUS_LOG( "mus: [MUSUI ]  <- CMusUiBackgroundViewContainer::UpdateOrdinalPositionValue()" );
       
   169     }
       
   170 
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // Called by framework when the view size is changed
       
   174 // -----------------------------------------------------------------------------
       
   175 //
       
   176 void CMusUiBackgroundViewContainer::SizeChanged()
       
   177     {
       
   178     MUS_LOG( "mus: [MUSUI ]  -> CMusUiBackgroundViewContainer::SizeChanged()" );
       
   179     TRect parentRect(Rect());
       
   180     if (iBackGround)
       
   181         {
       
   182         (static_cast<CAknsBasicBackgroundControlContext*>(iBackGround))->SetRect(parentRect);
       
   183         }
       
   184 
       
   185     SetOrdinalPosition();
       
   186     //MakeVisible( EFalse );
       
   187     MUS_LOG( "mus: [MUSUI ]  <- CMusUiBackgroundViewContainer::SizeChanged()" );
       
   188     }
       
   189 
       
   190 
       
   191 // -----------------------------------------------------------------------------
       
   192 // Called by framework when to retrieve the no. of controls.
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 TInt CMusUiBackgroundViewContainer::CountComponentControls() const
       
   196     {
       
   197     return 0; // return nbr of controls inside this container
       
   198     }
       
   199 
       
   200 
       
   201 // -----------------------------------------------------------------------------
       
   202 // Called by framework to retrieve the control specified by index.
       
   203 // -----------------------------------------------------------------------------
       
   204 //
       
   205 CCoeControl* CMusUiBackgroundViewContainer::ComponentControl( TInt /*aIndex*/ ) const
       
   206     {
       
   207     return NULL;
       
   208     }
       
   209 
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // Called by framework to redraw the screen area.
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 void CMusUiBackgroundViewContainer::Draw( const TRect& aRect ) const
       
   216     {
       
   217     MUS_LOG( "mus: [MUSUI ]  -> CMusUiBackgroundViewContainer::Draw()" );
       
   218 
       
   219     CWindowGc& gc = SystemGc();
       
   220 
       
   221     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   222     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
   223     if(!AknsDrawUtils::Background( skin, cc,this,gc,aRect,KAknsDrawParamDefault ))
       
   224         {
       
   225         MUS_LOG( "mus: [MUSUI ]     Skin not valid or not found" );
       
   226         gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) );
       
   227         gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   228         gc.Clear( aRect );
       
   229         }
       
   230 
       
   231     MUS_LOG( "mus: [MUSUI ]  <- CMusUiBackgroundViewContainer::Draw()" );
       
   232     }
       
   233 
       
   234 // -----------------------------------------------------------------------------
       
   235 //
       
   236 // -----------------------------------------------------------------------------
       
   237 //
       
   238 void CMusUiBackgroundViewContainer::HandleControlEventL(
       
   239     CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
       
   240     {
       
   241     // TODO: Add your control event handler code here
       
   242     }
       
   243 
       
   244 
       
   245 // -----------------------------------------------------------------------------
       
   246 // Called by framework to act on key events if required.
       
   247 // -----------------------------------------------------------------------------
       
   248 //
       
   249 TKeyResponse CMusUiBackgroundViewContainer::OfferKeyEventL(
       
   250                         const TKeyEvent& /*aKeyEvent*/,
       
   251                         TEventCode /*aType*/ )
       
   252     {
       
   253     return EKeyWasNotConsumed;
       
   254     }
       
   255 
       
   256 
       
   257 // -----------------------------------------------------------------------------
       
   258 // Supply the Mob Object for background skin drawing
       
   259 // -----------------------------------------------------------------------------
       
   260 //
       
   261 TTypeUid::Ptr CMusUiBackgroundViewContainer::MopSupplyObject( TTypeUid aId )
       
   262     {
       
   263     if (aId.iUid == MAknsControlContext::ETypeId && iBackGround )
       
   264         {
       
   265         return MAknsControlContext::SupplyMopObject( aId, iBackGround );
       
   266         }
       
   267     return CCoeControl::MopSupplyObject( aId );
       
   268     }
       
   269 
       
   270 
       
   271 
       
   272 // end of file