|
1 /* |
|
2 * Copyright (c) 2006-2007 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: Defines a CHuiFrameBrush class - a brush that draws a frame element |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __HUIFRAMEBRUSH_H__ |
|
21 #define __HUIFRAMEBRUSH_H__ |
|
22 |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <AknsItemID.h> |
|
26 #include <uiacceltk/HuiBrush.h> |
|
27 #include <uiacceltk/HuiSkin.h> |
|
28 #include <uiacceltk/HuiGc.h> |
|
29 #include <uiacceltk/HuiImage.h> |
|
30 #include <uiacceltk/HuiTimedPoint.h> |
|
31 #include <uiacceltk/HuiEnv.h> |
|
32 #include <uiacceltk/huimetric.h> |
|
33 |
|
34 class CHuiImageLoaderUtil; |
|
35 |
|
36 /** |
|
37 * Frame brush |
|
38 * |
|
39 * @lib hitchcock.lib |
|
40 * @since S60 v5.0 |
|
41 */ |
|
42 NONSHARABLE_CLASS(CHuiFrameBrush): public CHuiBrush, public MHuiActionObserver |
|
43 { |
|
44 public: |
|
45 |
|
46 enum TFrameParts |
|
47 { |
|
48 EFramePartCornerTl = 0, |
|
49 EFramePartCornerTr, |
|
50 EFramePartCornerBl, |
|
51 EFramePartCornerBr, |
|
52 EFramePartSideT, |
|
53 EFramePartSideB, |
|
54 EFramePartSideL, |
|
55 EFramePartSideR, |
|
56 EFramePartCenter |
|
57 }; |
|
58 |
|
59 /** |
|
60 * NewL. Creates new instance of CHuiFrameBrush. |
|
61 * |
|
62 * @param aImage Image for the frame. Image will be used as such, |
|
63 * framerects (if set) are ignored. |
|
64 * @param aEdgeOffset Coordinates of the offset in metric units. |
|
65 * @return New instance. Onwership tranferred to the caller. |
|
66 */ |
|
67 IMPORT_C static CHuiFrameBrush* NewL( |
|
68 const THuiImage& aImage, |
|
69 const THuiXYMetric& aEdgeOffset); |
|
70 |
|
71 /** |
|
72 * NewLC. Creates new instance of CHuiFrameBrush and leaves |
|
73 * it onto the cleanup stack. |
|
74 * |
|
75 * @param aImage Image for the frame. Image will be used as such, |
|
76 * framerects (if set) are ignored. |
|
77 * @param aEdgeOffset Coordinates of the offset in metric units. |
|
78 * @return New instance. Onwership tranferred to the caller. |
|
79 */ |
|
80 IMPORT_C static CHuiFrameBrush* NewLC( |
|
81 const THuiImage& aImage, |
|
82 const THuiXYMetric& aEdgeOffset); |
|
83 |
|
84 |
|
85 /** |
|
86 * NewL. Creates new instance of CHuiFrameBrush. |
|
87 * |
|
88 * @param aIID Skin ID for the frame. |
|
89 * @param aEdgeOffset Coordinates of the offset in metric units. |
|
90 * @return New instance. Onwership tranferred to the caller. |
|
91 */ |
|
92 IMPORT_C static CHuiFrameBrush* NewL( |
|
93 const TAknsItemID& aIID, |
|
94 const THuiXYMetric& aEdgeOffset); |
|
95 |
|
96 /** |
|
97 * NewLC. Creates new instance of CHuiFrameBrush and leaves |
|
98 * it onto the cleanup stack. |
|
99 * |
|
100 * @param aIID Skin ID for the frame. |
|
101 * @param aEdgeOffset Coordinates of the offset in metric units. |
|
102 * @return New instance. Onwership tranferred to the caller. |
|
103 */ |
|
104 IMPORT_C static CHuiFrameBrush* NewLC( |
|
105 const TAknsItemID& aIID, |
|
106 const THuiXYMetric& aEdgeOffset); |
|
107 |
|
108 /** |
|
109 * NewL. Creates new instance of CHuiFrameBrush. |
|
110 * |
|
111 * @deprecated |
|
112 * @param aIID Skin ID for the frame. |
|
113 * @param aEdgeOffsetX X coordinate of the offset in pixels. |
|
114 * @param aEdgeOffsetY Y coordinate of the offset in pixels. |
|
115 * @return New instance. Onwership tranferred to the caller. |
|
116 */ |
|
117 IMPORT_C static CHuiFrameBrush* NewL( |
|
118 const TAknsItemID& aIID, |
|
119 TInt aEdgeOffsetX = 0, |
|
120 TInt aEdgeOffsetY = 0 ); |
|
121 |
|
122 /** |
|
123 * NewLC. Creates new instance of CHuiFrameBrush and leaves |
|
124 * it onto the cleanup stack. |
|
125 * |
|
126 * @deprecated |
|
127 * @param aIID Skin ID for the frame. |
|
128 * @param aEdgeOffsetX X coordinate of the offset in pixels. |
|
129 * @param aEdgeOffsetY Y coordinate of the offset in pixels. |
|
130 * @return New instance. Onwership tranferred to the caller. |
|
131 */ |
|
132 IMPORT_C static CHuiFrameBrush* NewLC( |
|
133 const TAknsItemID& aIID, |
|
134 TInt aEdgeOffsetX = 0, |
|
135 TInt aEdgeOffsetY = 0); |
|
136 |
|
137 /** |
|
138 * Destructor |
|
139 */ |
|
140 ~CHuiFrameBrush(); |
|
141 |
|
142 |
|
143 /** |
|
144 * Sets the frame rectangles which define the nine frame areas. |
|
145 * |
|
146 * @param aInnerRect Inner rect (pixels) in where the EFramePartCenter is drawn. |
|
147 * @param aOuterRect Outter rect (pixels). |
|
148 */ |
|
149 IMPORT_C void SetFrameRectsL(const TRect& aInnerRect, const TRect& aOuterRect); |
|
150 |
|
151 /** |
|
152 * Sets edge offset. |
|
153 * @param aEdgeOffset Coordinates of the offset in metric units. |
|
154 */ |
|
155 IMPORT_C void SetEdgeOffset(const THuiXYMetric& aEdgeOffset); |
|
156 |
|
157 /** |
|
158 * Sets frame image. Whole frame will be constrcuted from this image. |
|
159 * @param aImage Image for the frame. |
|
160 */ |
|
161 IMPORT_C void SetImage(const THuiImage& aImage); |
|
162 |
|
163 /** |
|
164 * Sets framepart image. Whole frame will be constrcuted from 9 parts, each part has |
|
165 * to be set separately using this method. Genrally using 9-piece frame is not as |
|
166 * efficient as 1-pice frame, so this method should be used only when really needed. |
|
167 * @param aFramePart Frame part to which the image is intended. |
|
168 * @param aImage Image for the frame part. |
|
169 */ |
|
170 IMPORT_C void SetImage(TFrameParts aFramePart, const THuiImage& aImage); |
|
171 |
|
172 /** |
|
173 * From CHuiBrush. |
|
174 * @see CHuiBrush::ExpandVisualRect(TRect& aRect) |
|
175 */ |
|
176 void ExpandVisualRect(TRect& aRect) const; |
|
177 |
|
178 /** |
|
179 * From CHuiBrush. |
|
180 * @see CHuiBrush::Changed() const |
|
181 */ |
|
182 TBool Changed() const; |
|
183 |
|
184 /** |
|
185 * From CHuiBrush. |
|
186 * @see CHuiBrush::ClearChanged() |
|
187 */ |
|
188 void ClearChanged(); |
|
189 |
|
190 /** |
|
191 * From CHuiBrush. |
|
192 * @see CHuiBrush::Draw(CHuiGc& aGc, const MHuiBrushGuide& aGuide) const; |
|
193 */ |
|
194 void Draw(CHuiGc& aGc, const MHuiBrushGuide& aGuide) const; |
|
195 |
|
196 protected: |
|
197 |
|
198 CHuiFrameBrush(const THuiImage& aImage, const THuiXYMetric& aEdgeOffset); |
|
199 CHuiFrameBrush(const TAknsItemID& aIID, const THuiXYMetric& aEdgeOffset); |
|
200 CHuiFrameBrush(const TAknsItemID& aIID, TInt aEdgeOffsetX, TInt aEdgeOffsetY); |
|
201 CHuiFrameBrush(); |
|
202 |
|
203 // from MHuiActionObserver |
|
204 void HandleActionL(const THuiActionCommand& aActionCommand); |
|
205 |
|
206 private: |
|
207 TSize GetFramePartSize(const TFrameParts aFramePart) const; |
|
208 void ConstructFrameL(); |
|
209 static void ResetAndDestroyImageArray( TAny* aAny ); |
|
210 THuiRealPoint PointInPixels(const CHuiVisual* aVisual, const THuiTimedPoint& aPoint, const THuiXYMetric& aMetric) const; |
|
211 void InitImagesL(TInt aNumberOfImages); |
|
212 void ConstructL(const THuiImage& aImage); |
|
213 TRect AdjustedOuterRect(const TSize& aFullFrameSize) const; |
|
214 TRect AdjustedInnerRect(const TSize& aFullFrameSize) const; |
|
215 private: |
|
216 TAknsItemID iFrameIID; |
|
217 TRect iInnerRect; |
|
218 TRect iOuterRect; |
|
219 |
|
220 NONSHARABLE_CLASS(CHuiImageWithID): public CBase |
|
221 { |
|
222 public: |
|
223 CHuiImageWithID(THuiImage aImage, TInt aId):iImage(aImage),iId(aId){} |
|
224 ~CHuiImageWithID(); |
|
225 const MHuiSegmentedTexture& Texture(); |
|
226 THuiImage& Image(); |
|
227 void SetImage(const THuiImage& aImage); |
|
228 private: |
|
229 THuiImage iImage; |
|
230 TInt iId; |
|
231 }; |
|
232 |
|
233 RPointerArray<CHuiImageWithID> iImages; |
|
234 CHuiImageLoaderUtil* iImageloader; |
|
235 |
|
236 public: |
|
237 THuiTimedPoint iEdgeOffset; |
|
238 private: |
|
239 THuiXYMetric iEdgeOffsetMetric; |
|
240 TBool iEnvReleased; |
|
241 TBool iSkinChanged; |
|
242 }; |
|
243 |
|
244 #endif |