mpxplugins/viewplugins/views/upnpplaybackdialog/src/mpxupnpplaybackdialoglayout.cpp
changeset 0 ff3acec5bc43
child 21 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 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     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // Get layout data for an graphical indicator.
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 TRect CMPXUPnPPlaybackDialogLayout::IndicatorLayout(
       
   104     const TRect& aParentRect,
       
   105     TMPXPbvIndicator aIndicator )
       
   106     {
       
   107     TInt resId(KErrNotFound);
       
   108 
       
   109     // Get Rocker mapping support flag
       
   110     TInt flags( 0 );
       
   111     CRepository* repository( NULL );
       
   112     MPX_TRAPD( err, repository = CRepository::NewL( KCRUidMPXMPFeatures ));
       
   113     if ( KErrNone == err )
       
   114         {
       
   115         repository->Get( KMPXMPLocalVariation, flags );
       
   116         delete repository;
       
   117         repository = NULL;
       
   118         }
       
   119 
       
   120     TBool enableButton( flags & KMPXRockerMappingSupport );
       
   121     const TSize screenSize( CCoeEnv::Static()->ScreenDevice()->SizeInPixels() );
       
   122 
       
   123     if ( screenSize == TSize( 176,208 ))    //lowest portrait
       
   124         {
       
   125         switch ( aIndicator )
       
   126             {
       
   127             case EIconRemotePlayer:
       
   128                 {
       
   129                 if ( enableButton )
       
   130                     {
       
   131                     resId = R_MPX_PBV_REMOTE_INDI_LAYOUT;
       
   132                     }
       
   133                 else
       
   134                     {
       
   135                     resId = R_MPX_PBV_REMOTE_INDI_LAYOUT_WITHOUT_ROCKER;
       
   136                     }
       
   137                 break;
       
   138                 }
       
   139             default:
       
   140                 {
       
   141                 break;
       
   142                 }
       
   143             }
       
   144         }
       
   145     else if ( screenSize == TSize( 352,416 ))
       
   146         {
       
   147         switch ( aIndicator )
       
   148             {
       
   149             case EIconRemotePlayer:
       
   150                 {
       
   151                 resId = R_MPX_PBV_REMOTE_INDI_LAYOUT_DOUBLE_PORTRAIT;
       
   152                 break;
       
   153                 }
       
   154             default:
       
   155                 {
       
   156                 break;
       
   157                 }
       
   158             }
       
   159         }
       
   160     else if ( screenSize == TSize( 240,320 ))
       
   161         {
       
   162         switch ( aIndicator )
       
   163             {
       
   164             case EIconRemotePlayer:
       
   165                 {
       
   166                 if ( enableButton )
       
   167                     {
       
   168                     resId = R_MPX_PBV_REMOTE_INDI_LAYOUT_QVGA_PORTRAIT;
       
   169                     }
       
   170                 else
       
   171                     {
       
   172                     resId = R_MPX_PBV_REMOTE_INDI_LAYOUT_QVGA_PORTRAIT_WITHOUT_ROCKER;
       
   173                     }
       
   174                 break;
       
   175                 }
       
   176             default:
       
   177                 {
       
   178                 break;
       
   179                 }
       
   180             }
       
   181         }
       
   182     else if ( screenSize == TSize( 320,240 )) // QVGA landscape
       
   183         {
       
   184         switch ( aIndicator )
       
   185             {
       
   186             case EIconRemotePlayer:
       
   187                 {
       
   188                 if ( enableButton )
       
   189                     {
       
   190                     resId = R_MPX_PBV_REMOTE_INDI_LAYOUT_QVGA_LANDSCAPE;
       
   191                     }
       
   192                 else
       
   193                     {
       
   194                     resId = R_MPX_PBV_REMOTE_INDI_LAYOUT_QVGA_LANDSCAPE_WITHOUT_ROCKER;
       
   195                     }
       
   196                 break;
       
   197                 }
       
   198             default:
       
   199                 {
       
   200                 break;
       
   201                 }
       
   202             }
       
   203         }
       
   204 
       
   205     TRect rect;
       
   206     if ( resId != KErrNotFound )
       
   207         {
       
   208         TAknLayoutRect res;
       
   209         res.LayoutRect( aParentRect, resId );
       
   210         rect = res.Rect();
       
   211         }
       
   212     else
       
   213         {
       
   214         rect = CMPXCommonPlaybackViewLayout::IndicatorLayout( aParentRect, aIndicator );
       
   215         }
       
   216 
       
   217     return rect;
       
   218     }
       
   219 
       
   220 // ---------------------------------------------------------------------------
       
   221 // Get the bitmap and mask for a given indicator.
       
   222 // ---------------------------------------------------------------------------
       
   223 //
       
   224 CGulIcon* CMPXUPnPPlaybackDialogLayout::GetIndicatorIconMaskL(
       
   225     TMPXPbvIndicator aIndicator )
       
   226     {
       
   227 
       
   228     TParse parse;
       
   229     parse.Set( KMPXUpnpPlaybackDialogIconFile, &KDC_APP_RESOURCE_DIR, NULL );
       
   230     TFileName iconFile( parse.FullName() );
       
   231     User::LeaveIfError( MPXUser::CompleteWithDllPath( iconFile ) );
       
   232 
       
   233     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   234 
       
   235     switch ( aIndicator )
       
   236         {
       
   237         case EIconRemotePlayer:
       
   238             {
       
   239             return CreateColorIconL(
       
   240                 skin,
       
   241                 KAknsIIDQgnIndiMupRandom,
       
   242                 KAknsIIDQsnIconColors,
       
   243                 EAknsCIQsnIconColorsCG26,
       
   244                 iconFile,
       
   245                 EMbmMpxcommonplaybackviewQgn_graf_mup_icon_upnp_remote,
       
   246                 EMbmMpxcommonplaybackviewQgn_graf_mup_icon_upnp_remote_mask );
       
   247             }
       
   248         default:
       
   249             {
       
   250             break;
       
   251             }
       
   252         }
       
   253 
       
   254     return CMPXCommonPlaybackViewLayout::GetIndicatorIconMaskL( aIndicator );
       
   255     }
       
   256 
       
   257 //  End of File