javamanager/javainstaller/iconsizenotifplugin/inc/iconsizeutils.h
branchRCL_3
changeset 60 6c158198356e
equal deleted inserted replaced
59:e5618cc85d74 60:6c158198356e
       
     1 /*
       
     2 * Copyright (c) 2010 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 #ifndef ICONSIZEUTILS_H
       
    19 #define ICONSIZEUTILS_H
       
    20 
       
    21 #include <aknlayoutscalable_avkon.cdl.h>
       
    22 #include <AknUtils.h>
       
    23 
       
    24 /**
       
    25  * Fallback value of expected size of raster icons in Menu & Home Screen.
       
    26  * Copy of KJavaIconWidth in Menu's mcsmenuiconutility.cpp.
       
    27  */
       
    28 const TInt KIconInMenuFallbackSize = 88;
       
    29 
       
    30 /**
       
    31  * Fallback value of expected size of raster icons in App Mgr.
       
    32  */
       
    33 const TInt KIconInAppMgrFallbackSize = 46;
       
    34 
       
    35 /**
       
    36  * Utility class packing all Java icon sizes needed troughout the system.
       
    37  */
       
    38 class TIconSizes
       
    39 {
       
    40 public:
       
    41     TSize iMenuIconSize;
       
    42     TSize iAppMgrIconSize;
       
    43 };
       
    44 
       
    45 /**
       
    46  * Utility class dealing with Java icon sizes.
       
    47  */
       
    48 class IconSizeUtils
       
    49 {
       
    50 public:
       
    51     /**
       
    52      * Helper for getting the ideal sizes for Java raster icons.
       
    53      * Accesses Akn layouts, therefore a Ui context is required
       
    54      * (CEikonEnv present in the calling thread).
       
    55      * This function has been inlined so that the Java App Mgr plugin
       
    56      * does not have to statically link against the ecom plugin dll.
       
    57      */
       
    58     static TIconSizes GetIconSizes()
       
    59     {
       
    60         TIconSizes res;
       
    61 
       
    62         // Menu & Home Screen icons size.
       
    63         // No api to get it so just use the fallback value for now.
       
    64         res.iMenuIconSize = TSize(KIconInMenuFallbackSize, KIconInMenuFallbackSize);
       
    65 
       
    66         // App manager icon size.
       
    67         // list_double_large_graphic_pane_vc_g1 = the icon of the app mgr list in landscape
       
    68         TAknLayoutRect layoutRect;
       
    69         layoutRect.LayoutRect(TRect(), 
       
    70             AknLayoutScalable_Avkon::list_double_large_graphic_pane_vc_g1(0).LayoutLine());
       
    71         TRect rect(layoutRect.Rect());
       
    72         TInt w(rect.Width());
       
    73         TInt h(rect.Height());
       
    74         if (w < 0 || h < 0)
       
    75         {
       
    76             w = KIconInAppMgrFallbackSize;
       
    77             h = KIconInAppMgrFallbackSize;
       
    78         }
       
    79         res.iAppMgrIconSize = TSize(w, h);
       
    80 
       
    81         return res;
       
    82     }
       
    83 };
       
    84 
       
    85 #endif // ICONSIZEUTILS_H