|
1 /* |
|
2 * Copyright (c) 2004-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 "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: Base class for PolyLine and PolySpline classes. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef AKNSALPOLYBASE_H |
|
20 #define AKNSALPOLYBASE_H |
|
21 |
|
22 #include "AknsAlFixed.h" |
|
23 #include <e32base.h> |
|
24 /** |
|
25 * Base class for PolyLine and PolySpline classes. |
|
26 * |
|
27 * The class is not intended for derivation outside the library. |
|
28 * |
|
29 * @since 3.0 |
|
30 */ |
|
31 class CAknsAlPolyBase : public CBase |
|
32 { |
|
33 public: // Constructors and destructor |
|
34 |
|
35 /** |
|
36 * Default constructor. |
|
37 * |
|
38 * @since 3.0 |
|
39 */ |
|
40 CAknsAlPolyBase(); |
|
41 |
|
42 /** |
|
43 * Destructor |
|
44 * |
|
45 * @since 3.0 |
|
46 */ |
|
47 virtual ~CAknsAlPolyBase(); |
|
48 |
|
49 public: // New functions |
|
50 |
|
51 /** |
|
52 * Internally all positions are scaled to spacing from 0 to 1. |
|
53 * This method sets the area where positions are scaled |
|
54 * before returning. |
|
55 * |
|
56 * @param aAreaSize |
|
57 * |
|
58 * @since 3.0 |
|
59 */ |
|
60 void SetScaledArea( const TSize aAreaSize ); |
|
61 |
|
62 /** |
|
63 * Helper method for scaling point to scaled area. |
|
64 * Possible combinations: |
|
65 * ScaledArea(x,y) -> return TPoint(x*TFixed(x), y*TFixed(y)) |
|
66 * ScaledArea(x,0) -> return TPoint(x*Tfixed(x), TFixed(y)) |
|
67 * ScaledArea(0,y) -> return TPoint(Tfixed(x), y*TFixed(y)) |
|
68 * ScaledArea(0,0) -> return TPoint(Tfixed(x), TFixed(y)) |
|
69 * |
|
70 * @param aPoint input point with (TFixed(x), TFixed(y)) |
|
71 * |
|
72 * @return TPoint scaled to given scaled area |
|
73 * |
|
74 * @since 3.0 |
|
75 */ |
|
76 TPoint CalculateScaledPoint( const TPoint aPoint ); |
|
77 |
|
78 /** |
|
79 * Sets the points for Poly(Line/Spline). |
|
80 * TDesC holds 16-bit integers, which represent values from 0 to 1. |
|
81 * Format of string is: point1_x, point1_y, point2_x, point2_y,... |
|
82 * |
|
83 * @return Leaves with KErrArgument, if the string has odd number of items |
|
84 * or if 2 adjacent points are the same (zero length line/spline segment). |
|
85 * Leaves with KErrNoMemory, if there were not enough memory for new points. |
|
86 * |
|
87 * @since 3.0 |
|
88 */ |
|
89 void SetPolyPointsL( const TDesC16& aPointString ); |
|
90 |
|
91 /** |
|
92 * Sets the points for 1-dimensional Poly(Line/Spline). |
|
93 * TDesC holds 16-bit integers, which represent values from 0 to 1. |
|
94 * Format of string is: point1_x, point1_y, point2_x, point2_y,... |
|
95 * |
|
96 * @return Leaves with KErrArgument, if the string has odd number of items |
|
97 * or if 2 adjacent are in wrong order (points must be in ascending order). |
|
98 * Leaves with KErrNoMemory, if there were not enough memory for new points. |
|
99 * |
|
100 * @since 3.0 |
|
101 */ |
|
102 void SetPolyPoints1DL( const TDesC16& aPointString ); |
|
103 |
|
104 /** |
|
105 * Fast square root for integers. If the input is 16.16 fixed point, |
|
106 * the output is 8.8 fixed point. Use SqrtFixed to get correct output. |
|
107 * |
|
108 * @param aParam |
|
109 * |
|
110 * @return Integer square root. |
|
111 * |
|
112 * @since 3.0 |
|
113 */ |
|
114 TUint Sqrt( TUint aParam ); |
|
115 |
|
116 /** |
|
117 * Returns the point in poly(line/spline) in scaled area. |
|
118 * |
|
119 * @param aPosition 32-bit integer representing the position in poly(line/spline). |
|
120 * If aPosition is 0, starting point is returned and if aPosition is 0xffffffff, |
|
121 * the last point is returned. |
|
122 * |
|
123 * @return Point in poly(line/spline) scaled to the set area or if no |
|
124 * area is set, returned values are in scale from 0 to 1. |
|
125 * |
|
126 * @since 3.0 |
|
127 */ |
|
128 virtual TPoint GetPolyPoint( const TUint32 aPosition ) =0; |
|
129 |
|
130 /** |
|
131 * Calculates and sets the lengths of poly segments. This is automatically |
|
132 * called after the points have been set. |
|
133 * |
|
134 * @return Returns KErrNoMemory if the lengths couldn't be saved. |
|
135 */ |
|
136 virtual void CalculateLengthsL( ) {}; |
|
137 |
|
138 protected: // Data |
|
139 |
|
140 TSize iAreaSize; |
|
141 |
|
142 TInt iPointCount; // number of points |
|
143 |
|
144 struct TPolyPoint |
|
145 { |
|
146 TUint16 iX; |
|
147 TUint16 iY; |
|
148 }; |
|
149 |
|
150 TPolyPoint* iPoints; // poly points |
|
151 |
|
152 // for holding cumulative lengths of poly segments - last length is the |
|
153 // whole poly's length |
|
154 TUint32* iSegmentLengths; |
|
155 }; |
|
156 |
|
157 #endif //AKNSALPOLYBASE_H |
|
158 |
|
159 // End of file |