|
1 /* |
|
2 * Copyright (c) 2002-2006 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: Utility methods for call object handling. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef BUBBLECALLOBJECTTUTILS_H |
|
21 #define BUBBLECALLOBJECTTUTILS_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <gdi.h> |
|
25 #include "BMBubbleManager.h" |
|
26 #include <avkon.hrh> |
|
27 |
|
28 // CONSTANTS |
|
29 |
|
30 // DATA TYPES |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CBubbleCallObjectImage; |
|
34 class CBubbleImageReader; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * Utility methods for call object handling. |
|
40 * |
|
41 * @lib BubbleManager |
|
42 * @since Series 60 3.1 |
|
43 */ |
|
44 class BubbleCallObjectUtils |
|
45 { |
|
46 public: |
|
47 // Tiling mode |
|
48 enum TTileMode |
|
49 { |
|
50 ETileTopLeft, // Tiling begin from top left corner |
|
51 ETileTopRight, // Tiling begin from top right corner |
|
52 ETileCenterLeft, // Tiling begin from left, vertically centered |
|
53 ETileCenterRight // Tiling begin from right, vertically centered |
|
54 }; |
|
55 |
|
56 // Scale mode. Aspect ratio is always preserved. |
|
57 enum TScaleMode |
|
58 { |
|
59 EFillTarget, |
|
60 EMaximumFit |
|
61 }; |
|
62 |
|
63 public: // New functions |
|
64 /////////////////////////////////////////////////////////////////////// |
|
65 // |
|
66 // Construction and manipulation of CFbsBitmap objects. |
|
67 // |
|
68 /////////////////////////////////////////////////////////////////////// |
|
69 |
|
70 /** |
|
71 * Creates a new bitmap from the given bitmap by scaling it to the |
|
72 * given size. Proportions of the source bitmap are maintained so |
|
73 * cropping may be applied. If the given bitmap is very small it |
|
74 * is duplicated, not scaled, to fill the created bitmap. |
|
75 * @param aBitmap Source bitmap |
|
76 * @param aTargetSize Size of bitmap to be created. |
|
77 * @param aDisplayMode Display mode for bitmap created. |
|
78 * @param aTileMode Tiling mode. |
|
79 * @return New bitmap instance. |
|
80 */ |
|
81 static CFbsBitmap* CreateBitmapL( |
|
82 const CFbsBitmap* aBitmap, |
|
83 const TSize& aTargetSize, |
|
84 TDisplayMode aDisplayMode, |
|
85 TTileMode aTileMode = ETileTopLeft ); |
|
86 |
|
87 /** |
|
88 * Creates a new bitmap by cropping given bitmap to given size. |
|
89 * @param aBitmap Bitmap to be cropped. |
|
90 * @param aTargetSize Target size. |
|
91 * @param aDisplayMode Display mode for bitmap created. |
|
92 * @return New bitmap instance. |
|
93 */ |
|
94 static CFbsBitmap* CreateCroppedBitmapL( |
|
95 const CFbsBitmap* aBitmap, |
|
96 const TSize& aTargetSize, |
|
97 TDisplayMode aDisplayMode ); |
|
98 |
|
99 /** |
|
100 * Creates a new bitmap by tiling given bitmap to given size. |
|
101 * @param aBitmap Bitmap to be tiled. |
|
102 * @param aTargetSize Target size. |
|
103 * @param aDisplayMode Display mode for bitmap created. |
|
104 * @param aTileMode Tiling mode. |
|
105 * @return New bitmap instance. |
|
106 */ |
|
107 static CFbsBitmap* CreateTiledBitmapL( |
|
108 const CFbsBitmap* aBitmap, |
|
109 const TSize& aTargetSize, |
|
110 TDisplayMode aDisplayMode, |
|
111 TTileMode aTileMode ); |
|
112 |
|
113 /** |
|
114 * Creates a new bitmap and renders given text given on it. |
|
115 * Text is rendered according to call2_cli_visual_text_pane |
|
116 * layout. Creates also mask bitmap. |
|
117 * @param aText Text to be rendered. |
|
118 * @param aMainPaneRect Main pane rectangle. |
|
119 * @param aSize Size for created bitmap. |
|
120 * @param aTextColor Text color. |
|
121 * @param aAlpha Transparency of text: 0-255. |
|
122 * @param aDisplayMode Display mode for bitmap created. |
|
123 * @param aBitmap Created bitmap on return. |
|
124 * @param aMask Created mask on return. |
|
125 */ |
|
126 static void CreateImageBitmapsFromTextLC( |
|
127 const TDesC& aText, |
|
128 const TRect& aMainPaneRect, |
|
129 const TSize& aSize, |
|
130 const TRgb& aTextColor, |
|
131 TUint aAlpha, |
|
132 TDisplayMode aDisplayMode, |
|
133 CFbsBitmap*& aBitmap, |
|
134 CFbsBitmap*& aMask ); |
|
135 |
|
136 /** |
|
137 * Calculates scaling factor for source size to fill target size. |
|
138 * @param aSourceSize Source size. |
|
139 * @param aTargetSize Target size. |
|
140 * @param aScaleMode Scaling mode. |
|
141 * @return Scaling factor. |
|
142 */ |
|
143 static TReal ScalingFactor( |
|
144 const TSize& aSourceSize, |
|
145 const TSize& aTargetSize, |
|
146 TScaleMode aScaleMode ); |
|
147 |
|
148 /** |
|
149 * Calculates scale factor and clipping rectangle based on |
|
150 * source and target size. Clip rect is relative to source. |
|
151 * @param aSourceSize Source size. |
|
152 * @param aTargetSize Target size. |
|
153 * @param aScaleMode Scaling mode. |
|
154 * @param aScaleFactor Target size. |
|
155 * @param aClipRect Target size. |
|
156 * @return ETrue if source is tiny image i.e. not possible |
|
157 * to scale it to fill target. |
|
158 */ |
|
159 static TBool GetScaleFactorAndClipRect( |
|
160 const TSize& aSourceSize, |
|
161 const TSize& aTargetSize, |
|
162 TScaleMode aScaleMode, |
|
163 TReal& aScaleFactor, |
|
164 TRect& aClipRect ); |
|
165 }; |
|
166 |
|
167 #endif // BUBBLECALLOBJECTTUTILS_H |
|
168 |
|
169 // End of File |