|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Converts logical coordinate value to physical coordinate value. |
|
15 // Then adjusts the value, assuming that it must be within the drawing rectangle. |
|
16 // The first, "<0" check is arguable - should it be there or not!? |
|
17 // Because it HIDES negative values of "x" coordinate, so possible programmer's errors! |
|
18 // But with used logical to physical transformation it is possible that some logical |
|
19 // coordinate value might be transformed to negative physical coordinate value and |
|
20 // then it has to be checked and set to 0. |
|
21 // |
|
22 // |
|
23 |
|
24 inline TInt Log2Phys(TInt aCoordVal, TInt aScalingOrigin, TInt aScalingFactor, TInt aSize) |
|
25 { |
|
26 aCoordVal = aScalingOrigin + aCoordVal * aScalingFactor; |
|
27 return aCoordVal < 0 ? 0 : aCoordVal >= aSize ? (aSize - 1) : aCoordVal; |
|
28 } |
|
29 |
|
30 //Converts logical coordinate value to physical coordinate value. |
|
31 //Then adjusts the value, assuming that it represents right-bottom coordinate of the logical |
|
32 //rectangle. The first, "<0" check is arguable - should it be there or not!? |
|
33 //Because it HIDES negative values of "x" coordinate, so possible programmer's errors! |
|
34 //But with used logical to physical transformation it is possible that some logical |
|
35 //coordinate value is transformed to negative physical coordinate value and then it has to |
|
36 //be checked and set to 0. |
|
37 inline TInt RBtmLog2Phys(TInt aCoordVal, TInt aScalingOrigin, TInt aScalingFactor, TInt aSize) |
|
38 { |
|
39 aCoordVal = aScalingOrigin + aCoordVal * aScalingFactor; |
|
40 return aCoordVal < 0 ? 0 : aCoordVal > aSize ? aSize : aCoordVal; |
|
41 } |
|
42 |