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