webengine/webkitutils/stmgesturefw/src/utils.cpp
changeset 65 5bfc169077b2
parent 42 d39add9822e2
child 66 cacf6ee57968
equal deleted inserted replaced
42:d39add9822e2 65:5bfc169077b2
     1 /*
       
     2 * Copyright (c) 2008 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 the License "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 #include "utils.h"
       
    19 
       
    20 #include <coemain.h> // for CCoeEnv
       
    21 #include <eikappui.h>  // for CEikAppUi
       
    22 
       
    23 #include "gesturedefs.h"
       
    24 
       
    25 namespace stmUiEventEngine
       
    26 {
       
    27     /** @return the longer edge of the size */
       
    28     inline TInt LongerEdge( const TSize& aSize )
       
    29         {
       
    30         return Max( aSize.iHeight, aSize.iWidth );
       
    31         }
       
    32 
       
    33     // for documentation, see header file
       
    34     TRect ToleranceRect( const TPoint& aCenterPoint )
       
    35         {
       
    36         long toleranceLength = Mm2Pixels(KFingerSize_mm) / 2;
       
    37         TRect toleranceRect( aCenterPoint, TSize() );
       
    38         // grow by the tolerance length, while keeping the center point
       
    39         toleranceRect.Grow( toleranceLength, toleranceLength );
       
    40         return toleranceRect;
       
    41         }
       
    42 
       
    43     long Twips2Pixels(long twips)
       
    44         {
       
    45         CWsScreenDevice* screen = CCoeEnv::Static()->ScreenDevice();
       
    46         TZoomFactor deviceMap(screen);
       
    47         deviceMap.SetZoomFactor(TZoomFactor::EZoomOneToOne);
       
    48         long px = deviceMap.VerticalTwipsToPixels(twips); //assuming that vertical
       
    49         return px;                                        //the same as horizontal
       
    50 
       
    51         }
       
    52 
       
    53     long Mm2Pixels(long mm)
       
    54         {
       
    55         return Twips2Pixels(mm * KTwipsInMm);
       
    56         }
       
    57 
       
    58     long Inches2Pixels(float inches)
       
    59         {
       
    60         return Twips2Pixels(inches * KTwipsInInch);
       
    61         }
       
    62 
       
    63 
       
    64 } // namespace