mpxplugins/viewplugins/views/upnpplaybackdialog/src/mpxupnpplaybackdialoglayout.cpp
branchRCL_3
changeset 53 3de6c4cf6b67
equal deleted inserted replaced
52:14979e23cb5e 53:3de6c4cf6b67
       
     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:  Layout and graphic factory for Upnp Playback Dialog
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <AknsUtils.h>
       
    22 #include <AknUtils.h>
       
    23 #include <barsread.h>
       
    24 #include <gulicon.h>
       
    25 #include <aknlayoutscalable_apps.cdl.h>
       
    26 #include <layoutmetadata.cdl.h>
       
    27 #include <data_caging_path_literals.hrh>
       
    28 #include <centralrepository.h>
       
    29 #include <mpxcommonplaybackview.mbg>
       
    30 #include <mpxcommonplaybackview.rsg>
       
    31 #include <mpxupnpplaybackview.rsg>
       
    32 #include <mpxinternalcrkeys.h>
       
    33 #include <mpxlbxextendedfeatures.h>
       
    34 #include <mpxuser.h>
       
    35 
       
    36 #include "mpxupnpplaybackdialoglayout.h"
       
    37 #include "mpxlog.h"
       
    38 
       
    39 using namespace AknLayoutScalable_Apps;
       
    40 
       
    41 
       
    42 // CONSTANTS
       
    43 _LIT(KMPXUpnpPlaybackDialogIconFile, "mpxcommonplaybackview.mbm");
       
    44 
       
    45 
       
    46 // ======== MEMBER FUNCTIONS ========
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // Two-phased constructor.
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 CMPXUPnPPlaybackDialogLayout* CMPXUPnPPlaybackDialogLayout::NewL()
       
    53     {
       
    54     CMPXUPnPPlaybackDialogLayout* self = CMPXUPnPPlaybackDialogLayout::NewLC();
       
    55     CleanupStack::Pop( self );
       
    56     return self;
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // Two-phased constructor.
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CMPXUPnPPlaybackDialogLayout* CMPXUPnPPlaybackDialogLayout::NewLC()
       
    64     {
       
    65     CMPXUPnPPlaybackDialogLayout* self = new ( ELeave ) CMPXUPnPPlaybackDialogLayout();
       
    66     CleanupStack::PushL( self );
       
    67     self->ConstructL();
       
    68     return self;
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // Destructor
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 CMPXUPnPPlaybackDialogLayout::~CMPXUPnPPlaybackDialogLayout()
       
    76     {
       
    77     // Do nothing
       
    78     }
       
    79 
       
    80 // ---------------------------------------------------------------------------
       
    81 // C++ default constructor can NOT contain any code, that
       
    82 // might leave.
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 CMPXUPnPPlaybackDialogLayout::CMPXUPnPPlaybackDialogLayout()
       
    86     {
       
    87     // Do nothing
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // Symbian 2nd phase constructor can leave.
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 void CMPXUPnPPlaybackDialogLayout::ConstructL()
       
    95     {
       
    96     MPX_FUNC( "CMPXUPnPPlaybackDialogLayout::ConstructL" );
       
    97     InitCommonLayoutL();
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // Get layout data for an graphical indicator.
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 TRect CMPXUPnPPlaybackDialogLayout::IndicatorLayout(
       
   105     const TRect& aParentRect,
       
   106     TMPXPbvIndicator aIndicator )
       
   107     {
       
   108     TInt resId(KErrNotFound);
       
   109 
       
   110     // Get Rocker mapping support flag
       
   111     TInt flags( 0 );
       
   112     CRepository* repository( NULL );
       
   113     MPX_TRAPD( err, repository = CRepository::NewL( KCRUidMPXMPFeatures ));
       
   114     if ( KErrNone == err )
       
   115         {
       
   116         repository->Get( KMPXMPLocalVariation, flags );
       
   117         delete repository;
       
   118         repository = NULL;
       
   119         }
       
   120 
       
   121     TBool enableButton( flags & KMPXRockerMappingSupport );
       
   122     const TSize screenSize( CCoeEnv::Static()->ScreenDevice()->SizeInPixels() );
       
   123 
       
   124     if ( screenSize == TSize( 176,208 ))    //lowest portrait
       
   125         {
       
   126         switch ( aIndicator )
       
   127             {
       
   128             case EIconRemotePlayer:
       
   129                 {
       
   130                 if ( enableButton )
       
   131                     {
       
   132                     resId = R_MPX_PBV_REMOTE_INDI_LAYOUT;
       
   133                     }
       
   134                 else
       
   135                     {
       
   136                     resId = R_MPX_PBV_REMOTE_INDI_LAYOUT_WITHOUT_ROCKER;
       
   137                     }
       
   138                 break;
       
   139                 }
       
   140             default:
       
   141                 {
       
   142                 break;
       
   143                 }
       
   144             }
       
   145         }
       
   146     else if ( screenSize == TSize( 352,416 ))
       
   147         {
       
   148         switch ( aIndicator )
       
   149             {
       
   150             case EIconRemotePlayer:
       
   151                 {
       
   152                 resId = R_MPX_PBV_REMOTE_INDI_LAYOUT_DOUBLE_PORTRAIT;
       
   153                 break;
       
   154                 }
       
   155             default:
       
   156                 {
       
   157                 break;
       
   158                 }
       
   159             }
       
   160         }
       
   161     else if ( screenSize == TSize( 240,320 ))
       
   162         {
       
   163         switch ( aIndicator )
       
   164             {
       
   165             case EIconRemotePlayer:
       
   166                 {
       
   167                 if ( enableButton )
       
   168                     {
       
   169                     resId = R_MPX_PBV_REMOTE_INDI_LAYOUT_QVGA_PORTRAIT;
       
   170                     }
       
   171                 else
       
   172                     {
       
   173                     resId = R_MPX_PBV_REMOTE_INDI_LAYOUT_QVGA_PORTRAIT_WITHOUT_ROCKER;
       
   174                     }
       
   175                 break;
       
   176                 }
       
   177             default:
       
   178                 {
       
   179                 break;
       
   180                 }
       
   181             }
       
   182         }
       
   183     else if ( screenSize == TSize( 320,240 )) // QVGA landscape
       
   184         {
       
   185         switch ( aIndicator )
       
   186             {
       
   187             case EIconRemotePlayer:
       
   188                 {
       
   189                 if ( enableButton )
       
   190                     {
       
   191                     resId = R_MPX_PBV_REMOTE_INDI_LAYOUT_QVGA_LANDSCAPE;
       
   192                     }
       
   193                 else
       
   194                     {
       
   195                     resId = R_MPX_PBV_REMOTE_INDI_LAYOUT_QVGA_LANDSCAPE_WITHOUT_ROCKER;
       
   196                     }
       
   197                 break;
       
   198                 }
       
   199             default:
       
   200                 {
       
   201                 break;
       
   202                 }
       
   203             }
       
   204         }
       
   205 
       
   206     TRect rect;
       
   207     if ( resId != KErrNotFound )
       
   208         {
       
   209         TAknLayoutRect res;
       
   210         res.LayoutRect( aParentRect, resId );
       
   211         rect = res.Rect();
       
   212         }
       
   213     else
       
   214         {
       
   215         rect = CMPXCommonPlaybackViewLayout::IndicatorLayout( aParentRect, aIndicator );
       
   216         }
       
   217 
       
   218     return rect;
       
   219     }
       
   220 
       
   221 // ---------------------------------------------------------------------------
       
   222 // Get the bitmap and mask for a given indicator.
       
   223 // ---------------------------------------------------------------------------
       
   224 //
       
   225 CGulIcon* CMPXUPnPPlaybackDialogLayout::GetIndicatorIconMaskL(
       
   226     TMPXPbvIndicator aIndicator )
       
   227     {
       
   228 
       
   229     TParse parse;
       
   230     parse.Set( KMPXUpnpPlaybackDialogIconFile, &KDC_APP_RESOURCE_DIR, NULL );
       
   231     TFileName iconFile( parse.FullName() );
       
   232     User::LeaveIfError( MPXUser::CompleteWithDllPath( iconFile ) );
       
   233 
       
   234     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   235 
       
   236     switch ( aIndicator )
       
   237         {
       
   238         case EIconRemotePlayer:
       
   239             {
       
   240             return CreateColorIconL(
       
   241                 skin,
       
   242                 KAknsIIDQgnIndiMupRandom,
       
   243                 KAknsIIDQsnIconColors,
       
   244                 EAknsCIQsnIconColorsCG26,
       
   245                 iconFile,
       
   246                 EMbmMpxcommonplaybackviewQgn_graf_mup_icon_upnp_remote,
       
   247                 EMbmMpxcommonplaybackviewQgn_graf_mup_icon_upnp_remote_mask );
       
   248             }
       
   249         default:
       
   250             {
       
   251             break;
       
   252             }
       
   253         }
       
   254 
       
   255     return CMPXCommonPlaybackViewLayout::GetIndicatorIconMaskL( aIndicator );
       
   256     }
       
   257 
       
   258 //  End of File