uigraphics/AknIcon/srvsrc/AknIconSrvIconItem.cpp
changeset 0 05e9090e2422
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2002 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:   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include <e32std.h>
       
    23 #include <fbs.h>
       
    24 #include "AknIconSrvIconItem.h"
       
    25 #include "AknIconSrv.h"
       
    26 #include "AknIconPanic.h"
       
    27 #include "AknIconSrvDef.h"
       
    28 #include "AknIconFileNameCache.h"
       
    29 
       
    30 // CONSTANTS
       
    31 
       
    32 // ================= MEMBER FUNCTIONS ==========================================
       
    33 
       
    34 CAknIconSrvIconItem::CAknIconSrvIconItem()
       
    35     {
       
    36     }
       
    37 
       
    38 CAknIconSrvIconItem::CAknIconSrvIconItem( const TAknIconParams& aParams )
       
    39     {
       
    40     // This constructor is used when the object is instantiated in stack,
       
    41     // so CBase's zero initialization is not done.
       
    42     Mem::FillZ( this, sizeof( CAknIconSrvIconItem ) );
       
    43     iFileNameRef = &aParams.iFileName;
       
    44     iBitmapId = (TInt16)aParams.iBitmapId;
       
    45     iMaskId = (TInt16)aParams.iMaskId;
       
    46     iSize = aParams.iSize;
       
    47     iModeAndFlags = aParams.iMode;
       
    48     iRotationAngle = aParams.iRotationAngle;
       
    49     iColor = aParams.iColor;
       
    50     iAppIcon = aParams.iAppIcon;
       
    51     if (aParams.IsCompressionDisabled())
       
    52         {
       
    53         DisableCompression();
       
    54         }
       
    55     iPrecacheItem = EFalse;
       
    56     }
       
    57 
       
    58 CAknIconSrvIconItem::~CAknIconSrvIconItem()
       
    59     {   
       
    60     delete iBitmap;
       
    61     delete iMask;
       
    62     }
       
    63 
       
    64 CAknIconSrvIconItem* CAknIconSrvIconItem::NewL(
       
    65     const TAknIconParams& aParams,
       
    66     CFbsBitmap* aBitmap,
       
    67     CFbsBitmap* aMask,
       
    68     const TAknContentDimensions& aDimensions,
       
    69     CAknIconFileNameCache& aFileNameCache )
       
    70     {
       
    71     CAknIconSrvIconItem* item = new( ELeave ) CAknIconSrvIconItem;
       
    72     CleanupStack::PushL( item );
       
    73     item->ConstructL( aParams, aBitmap, aMask, aDimensions, aFileNameCache );
       
    74     CleanupStack::Pop();
       
    75     return item;
       
    76     }
       
    77 
       
    78 void CAknIconSrvIconItem::ConstructL(
       
    79     const TAknIconParams& aParams,
       
    80     CFbsBitmap* aBitmap,
       
    81     CFbsBitmap* aMask,
       
    82     const TAknContentDimensions& aDimensions,
       
    83     CAknIconFileNameCache& aFileNameCache )
       
    84     {
       
    85     // cache icon file name        
       
    86     iFileName = aFileNameCache.CacheIconFileNameL(aParams.iFileName); 
       
    87 
       
    88     iBitmapId = (TInt16)aParams.iBitmapId;
       
    89     iMaskId = (TInt16)aParams.iMaskId;
       
    90     iSize = aParams.iSize;
       
    91     iModeAndFlags = aParams.iMode;
       
    92     iRotationAngle = aParams.iRotationAngle;
       
    93 
       
    94     iBitmap = aBitmap;
       
    95     iMask = aMask;
       
    96 
       
    97     iUserCount = ( iMaskId >= 0 ? 2 : 1 );
       
    98     iColor = KColorNotDefined;
       
    99     // Dimensions are stored here so that there is no need to query them from
       
   100     // rasterizer any more, which is potentially slow.
       
   101     iDimensions = aDimensions;
       
   102     iAppIcon = aParams.iAppIcon;
       
   103     if (aParams.IsCompressionDisabled())
       
   104         {
       
   105         DisableCompression();
       
   106         }
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CAknIconSrvIconItem::LinearOrder
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 #ifdef __WINSCW__            
       
   114 #pragma warning (disable:4706) // assignment within conditional expression
       
   115 #else
       
   116 #pragma diag_suppress 1293
       
   117 #pragma warning (disable:1293)
       
   118 #endif
       
   119 TInt CAknIconSrvIconItem::LinearOrder(
       
   120     const CAknIconSrvIconItem& aFirst,
       
   121     const CAknIconSrvIconItem& aSecond )
       
   122     {
       
   123     TInt result;
       
   124 
       
   125     if ( !(result = aFirst.iBitmapId - aSecond.iBitmapId) &&
       
   126          !(result = aFirst.iMaskId - aSecond.iMaskId) &&
       
   127          !(result = aFirst.iSize.iWidth - aSecond.iSize.iWidth) &&
       
   128          !(result = aFirst.iSize.iHeight - aSecond.iSize.iHeight) )
       
   129         {
       
   130         TInt firstMode = aFirst.iModeAndFlags & 0xffff;
       
   131         TInt secondMode = aSecond.iModeAndFlags & 0xffff;
       
   132 
       
   133         if ( !(result = firstMode - secondMode) )
       
   134             {
       
   135             const TDesC* firstFileName = aFirst.iFileNameRef ?
       
   136                 aFirst.iFileNameRef : aFirst.iFileName;
       
   137 
       
   138             const TDesC* secondFileName = aSecond.iFileNameRef ?
       
   139                 aSecond.iFileNameRef : aSecond.iFileName;
       
   140 
       
   141             if ( !(result = firstFileName->CompareF( *secondFileName )) )
       
   142                 {
       
   143                 if ( !(result = aFirst.iRotationAngle - aSecond.iRotationAngle) )
       
   144                     {          
       
   145                         if ( !(result = aFirst.iColor.Internal() - aSecond.iColor.Internal()) )                        
       
   146                         {
       
   147                         result = (aFirst.iModeAndFlags & EFlagDisableCompression) -
       
   148                                  (aSecond.iModeAndFlags & EFlagDisableCompression);
       
   149                         // checking if its application icon          
       
   150                         if ( !result )         
       
   151                             {
       
   152                             result = aFirst.iAppIcon ^ aSecond.iAppIcon;
       
   153                             }
       
   154                         }                             
       
   155                     }
       
   156                 }
       
   157             }
       
   158         }
       
   159 
       
   160     return result;
       
   161     }
       
   162 
       
   163 #pragma warning (default:4706)
       
   164 
       
   165 // -----------------------------------------------------------------------------
       
   166 // CAknIconSrvIconItem::GetInfo
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 void CAknIconSrvIconItem::GetInfo( TAknIconParams& aParams ) const
       
   170     {
       
   171     // Icon item got the file name as a reference
       
   172     if ( iFileNameRef )
       
   173         {
       
   174         aParams.iFileName = *iFileNameRef;
       
   175         }
       
   176     // Icon item owns the file name
       
   177     else
       
   178         {
       
   179         aParams.iFileName = *iFileName;
       
   180         }
       
   181 
       
   182     aParams.iBitmapId = iBitmapId;
       
   183     aParams.iMaskId = iMaskId;
       
   184     aParams.iSize = iSize;
       
   185     aParams.iMode = iModeAndFlags & 0xffff;
       
   186     aParams.iRotationAngle = iRotationAngle;
       
   187     aParams.iColor = iColor;
       
   188     if (IsCompressionDisabled())
       
   189         {
       
   190         aParams.DisableCompression();
       
   191         }
       
   192     aParams.iAppIcon = iAppIcon;    
       
   193     }
       
   194 
       
   195 //  End of File