|
1 /* |
|
2 * Copyright (c) 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: Active Palette Styler* |
|
15 */ |
|
16 |
|
17 |
|
18 /** |
|
19 * @file ActivePalette2Styler.h |
|
20 * Active Palette Styler |
|
21 */ |
|
22 |
|
23 #ifndef _ACTIVE_PALETTE_2_STYLER_H |
|
24 #define _ACTIVE_PALETTE_2_STYLER_H |
|
25 |
|
26 #include <e32std.h> |
|
27 #include <e32base.h> |
|
28 |
|
29 // Forward declarations |
|
30 class CFbsBitmap; |
|
31 class CFbsBitmapDevice; |
|
32 class CFbsBitGc; |
|
33 class CBitmapContext; |
|
34 class CFont; |
|
35 |
|
36 /** |
|
37 * Used to apply different rendering styles to the 2D Active Palette. |
|
38 * Can not be directly instantiated: used as a base for further sub-classing |
|
39 */ |
|
40 class CActivePalette2Styler : public CBase |
|
41 { |
|
42 public: |
|
43 |
|
44 /** |
|
45 * Draw the entire background for the item, and the supplied item on top |
|
46 * @param aScreenPos The screen index of the item |
|
47 * @param aIcon The item's icon |
|
48 * @param aMask The item's mask |
|
49 * @param aOffsetFrame The offset frame, in case of item-scrolling |
|
50 * @param aOffsetTotal Total number of offset frames, in case of item-scrolling |
|
51 */ |
|
52 virtual void DrawItem(TInt aScreenPos, CFbsBitmap* aIcon, CFbsBitmap* aMask, TInt aOffsetFrame, TInt aOffsetTotal) = 0; |
|
53 |
|
54 /** |
|
55 * Draw the between-item gap following the item at aScreenPos |
|
56 * @param aScreenPos The screen index of the item |
|
57 * @param aOffsetFrame The offset frame, in case of item-scrolling |
|
58 * @param aOffsetTotal Total number of offset frames, in case of item-scrolling |
|
59 */ |
|
60 virtual void DrawGap(TInt aScreenPos, TInt aOffsetFrame, TInt aOffsetTotal) = 0; |
|
61 |
|
62 /** |
|
63 * Update only the area covered by the item graphic with an animation frame |
|
64 * @param aScreenPos The screen index of the item |
|
65 * @param aIcon The item's icon |
|
66 * @param aMask The item's mask |
|
67 */ |
|
68 virtual void AnimItem(TInt aScreenPos, CFbsBitmap* aIcon, CFbsBitmap* aMask) = 0; |
|
69 |
|
70 /** |
|
71 * Draws the top section of the AP, with optional arrow |
|
72 * @param aShowArrow Whether to display the scroll indicator |
|
73 */ |
|
74 virtual void DrawTopScrollArrowSection(TBool aShowArrow) = 0; |
|
75 |
|
76 /** |
|
77 * Draws the bottom section of the AP, with optional arrow |
|
78 * @param aShowArrow Whether to display the scroll indicator |
|
79 */ |
|
80 virtual void DrawBottomScrollArrowSection(TBool aShowArrow) = 0; |
|
81 |
|
82 /** |
|
83 * Draw the focus ring |
|
84 * @param aScreenPos The screen index of the item |
|
85 * @param aOffsetFrame The offset frame, in case of focus-moving |
|
86 * @param aOffsetTotal Total number of offset frames, in case of focus-moving |
|
87 */ |
|
88 void DrawFocusRing(TInt aScreenPos, TInt aOffsetFrame, TInt aOffsetTotal); |
|
89 |
|
90 /** |
|
91 * Render a new tooltip to the buffer |
|
92 * @param aText The tooltip text |
|
93 * @return The total width of the tooltip, in pixels |
|
94 */ |
|
95 virtual TInt DrawTooltip(TDesC* aText); |
|
96 |
|
97 /** |
|
98 * Sets the number of items shown on-screen |
|
99 * @param aItems The new number of items |
|
100 */ |
|
101 void SetNumberOfItemsL(TInt aItems); |
|
102 |
|
103 /** |
|
104 * The current size of the entire active palette |
|
105 * @return Size of the active palette, in pixels |
|
106 */ |
|
107 TSize Size() const; |
|
108 |
|
109 /** |
|
110 * Give the current "dirty" rect, i.e. the minimal rectangle that contains all updated regions |
|
111 * since previous ClearDirtyRect |
|
112 * @return Dirty rect |
|
113 * @see ClearDirtyRect() |
|
114 */ |
|
115 TRect DirtyRect(); |
|
116 |
|
117 /** |
|
118 * Resets the dirty rect |
|
119 * @see DirtyRect() |
|
120 */ |
|
121 void ClearDirtyRect(); |
|
122 |
|
123 /** |
|
124 * Blits the current AP buffer to the supplied context |
|
125 * @param aGc The context to blit to |
|
126 * @param aPos Where to blit to (the top-left corner of the AP) |
|
127 * @param aClippingRect The portion of the AP to blit |
|
128 */ |
|
129 void BlitPalette(CBitmapContext* aGc, TPoint aPos, TRect aClippingRect) const; |
|
130 |
|
131 /** |
|
132 * Blits the current tooltip buffer to the supplied context |
|
133 * @param aGc The context to blit to |
|
134 * @param aPos Where to blit to (the top-left corner of the tooltip) |
|
135 * @param aClippingRect The portion of the tooltip to blit |
|
136 */ |
|
137 virtual void BlitTooltip(CBitmapContext* aGc, const TPoint& aPos, TRect aClippingRect); |
|
138 |
|
139 /** |
|
140 * Blits the current tooltip to the supplied context. |
|
141 * Phase of the tooltip is given and also the total number of phases. |
|
142 * The effect of these depends on the styler, but e.g. the phase could |
|
143 * determine the degree of visibility for the tooltip. |
|
144 * @param aGc The context to blit to |
|
145 * @param aPos Where to blit to (the top-left corner of the tooltip) |
|
146 * @param aCurrentPhase The phase of the tooltip. |
|
147 * @param aTotalPhases The amount of tooltip phases in total. |
|
148 */ |
|
149 virtual void BlitTooltip( CBitmapContext* aGc, const TPoint& aPos, TInt aCurrentPhase, TInt aTotalPhases ); |
|
150 |
|
151 /** |
|
152 * Where the tooltip should appear, relative to the position of the AP |
|
153 * @param aScreenPos The on-screen index of the item the tooltip is for |
|
154 * @return The Y-offset of the tooltip |
|
155 */ |
|
156 TInt TootipYOffset(TInt aScreenPos); |
|
157 |
|
158 /** |
|
159 * The total size of the rendered tooltip |
|
160 * @return The total size of the rendered tooltip |
|
161 */ |
|
162 TSize TooltipSize(); |
|
163 |
|
164 /** |
|
165 * Destructor |
|
166 */ |
|
167 ~CActivePalette2Styler(); |
|
168 |
|
169 protected: |
|
170 |
|
171 /** |
|
172 * Constructor |
|
173 */ |
|
174 CActivePalette2Styler(); |
|
175 |
|
176 /** |
|
177 * Second-phase leaving constructor |
|
178 */ |
|
179 virtual void ConstructL(); |
|
180 |
|
181 /** |
|
182 * Add a rectangle to the current dirty rectangle |
|
183 * @param aNewRect The rect to add |
|
184 */ |
|
185 void AddToDirtyRect(TRect aNewRect); |
|
186 |
|
187 /** |
|
188 * General-purpose graphic-blitting method |
|
189 * @param aPos Where to blit to |
|
190 * @param aGraphicGc The context for the foreground |
|
191 * @param aMaskGc The context for the mask |
|
192 * @param aGraphic The image to blit |
|
193 * @param aGraphicMask The mask for the image |
|
194 * @param aMaskGraphic Whether to mask the image when blitting to aGraphicGc. |
|
195 * @param aMaskMask Whether to mask the mask when blitting to aMaskGc. Mask is applied to itself. |
|
196 */ |
|
197 void BlitGraphic(TPoint aPos, CBitmapContext* aGraphicGc, CBitmapContext* aMaskGc, CFbsBitmap* aGraphic, CFbsBitmap* aGraphicMask, TBool aMaskGraphic, TBool aMaskMask); |
|
198 |
|
199 /** |
|
200 * Blits a graphic to the centre of a given area |
|
201 * @param aArea The area to blit inside |
|
202 * @param aGraphicGc The context for the foreground |
|
203 * @param aMaskGc The context for the mask |
|
204 * @param aGraphic The image to blit |
|
205 * @param aGraphicMask The mask for the image |
|
206 * @param aMaskGraphic Whether to mask the image when blitting to aGraphicGc. |
|
207 * @param aMaskMask Whether to mask the mask when blitting to aMaskGc. Mask is applied to itself. |
|
208 */ |
|
209 void CentreGraphic(TRect aArea, CBitmapContext* aGraphicGc, CBitmapContext* aMaskGc, CFbsBitmap* aGraphic, CFbsBitmap* aGraphicMask, TBool aMaskGraphic, TBool aMaskMask); |
|
210 |
|
211 /** |
|
212 * The mask to use for the tooltip nose |
|
213 * @return The mask to use for the tooltip nose |
|
214 */ |
|
215 virtual TInt TooltipNoseMaskId(); |
|
216 |
|
217 /** |
|
218 * The mask to use for the tooltip body |
|
219 * @return The mask to use for the tooltip body |
|
220 */ |
|
221 virtual TInt TooltipBodyMaskId(); |
|
222 |
|
223 /** |
|
224 * The rectangle of the top section, relative to the top-left of the AP |
|
225 * @return The top section area |
|
226 */ |
|
227 inline TRect TopSectionRect(); |
|
228 |
|
229 /** |
|
230 * The rectangle of the bottom section, relative to the top-left of the AP |
|
231 * @return The bottom section area |
|
232 */ |
|
233 inline TRect BottomSectionRect(); |
|
234 |
|
235 /** |
|
236 * The rectangle of the given item number, relative to the top-left of the AP |
|
237 * @param aScreenPos The screen index of the item |
|
238 * @param aOffsetFrame The offset frame, in case of item-scrolling |
|
239 * @param aOffsetTotal Total number of offset frames, in case of item-scrolling |
|
240 * @return The item area |
|
241 */ |
|
242 inline TRect ItemRect(TInt aScreenPos, TInt aOffsetFrame = 0, TInt aOffsetTotal = 1); |
|
243 |
|
244 /** |
|
245 * The rectangle of the gap following the given item number, relative to the top-left of the AP |
|
246 * @param aScreenPos The screen index of the item |
|
247 * @param aOffsetFrame The offset frame, in case of item-scrolling |
|
248 * @param aOffsetTotal Total number of offset frames, in case of item-scrolling |
|
249 * @return The gap area |
|
250 */ |
|
251 inline TRect GapRect(TInt aScreenPos, TInt aOffsetFrame = 0, TInt aOffsetTotal = 1); |
|
252 |
|
253 /** |
|
254 * Allocate the tooltip draw buffers |
|
255 */ |
|
256 virtual void AllocateTooltipBufL(void); |
|
257 |
|
258 /** |
|
259 * Release the tooltip draw buffers |
|
260 */ |
|
261 virtual void ReleaseTooltipBuf(void); |
|
262 |
|
263 private: |
|
264 |
|
265 /** |
|
266 * Renders the complete tooltip |
|
267 * @param aText The tooltip text |
|
268 */ |
|
269 void RenderTooltip(TDesC* aText); |
|
270 |
|
271 /** |
|
272 * Allocate all the AP draw buffers |
|
273 */ |
|
274 void AllocateDrawBufL(void); |
|
275 |
|
276 /** |
|
277 * Release the AP draw buffers |
|
278 */ |
|
279 void ReleaseDrawBuf(void); |
|
280 |
|
281 protected: |
|
282 |
|
283 /// The draw buffer bitmap. Owned |
|
284 CFbsBitmap* iDrawBufBitmap; |
|
285 /// The draw buffer device. Owned |
|
286 CFbsBitmapDevice* iDrawBufDevice; |
|
287 /// The draw buffer context. Owned |
|
288 CBitmapContext* iDrawBufContext; |
|
289 |
|
290 /// The draw buffer mask bitmap. Owned |
|
291 CFbsBitmap* iDrawBufMaskBitmap; |
|
292 /// The draw buffer mask device. Owned |
|
293 CFbsBitmapDevice* iDrawBufMaskDevice; |
|
294 /// The draw buffer mask context. Owned |
|
295 CBitmapContext* iDrawBufMaskContext; |
|
296 |
|
297 /// Tooltip buffer bitmap. Owned |
|
298 CFbsBitmap* iTooltipBufBitmap; |
|
299 /// Tooltip buffer device. Owned |
|
300 CFbsBitmapDevice* iTooltipBufDevice; |
|
301 /// Tooltip buffer context. Owned |
|
302 CBitmapContext* iTooltipBufContext; |
|
303 |
|
304 /// Tooltip mask buffer bitmap. Owned |
|
305 CFbsBitmap* iTooltipBufMaskBitmap; |
|
306 /// Tooltip mask buffer device. Owned |
|
307 CFbsBitmapDevice* iTooltipBufMaskDevice; |
|
308 /// Tooltip mask buffer context. Owned |
|
309 CBitmapContext* iTooltipBufMaskContext; |
|
310 |
|
311 /// Number of items on-screen |
|
312 TInt iNumItems; |
|
313 /// Number of gaps inbetweeen the items |
|
314 TInt iNumGaps; |
|
315 |
|
316 /// Current dirty rectangle |
|
317 TRect iDirtyRect; |
|
318 /// Whether the dirty rect has yet been written to |
|
319 TBool iDirtyRectExists; |
|
320 |
|
321 /// The font used for the tooltip text. Not owned. |
|
322 const CFont* iFont; |
|
323 |
|
324 /// The width of the tooltip text alone |
|
325 TInt iTextWidth; |
|
326 |
|
327 /// The up-arrow bitmap. Owned |
|
328 CFbsBitmap* iScrollUpIcon; |
|
329 /// The up-arrow bitmap mask. Owned |
|
330 CFbsBitmap* iScrollUpIconMask; |
|
331 |
|
332 /// The down-arrow bitmap. Owned |
|
333 CFbsBitmap* iScrollDownIcon; |
|
334 /// The down-arrow bitmap mask. Owned |
|
335 CFbsBitmap* iScrollDownIconMask; |
|
336 |
|
337 /// The focus-ring bitmap. Owned |
|
338 CFbsBitmap* iFocusRing; |
|
339 /// The focus-ring bitmap mask. Owned |
|
340 CFbsBitmap* iFocusRingMask; |
|
341 |
|
342 /// The tooltip-nose bitmap. Owned |
|
343 CFbsBitmap* iTooltipNose; |
|
344 /// The tooltip-nose bitmap mask. Owned |
|
345 CFbsBitmap* iTooltipNoseMask; |
|
346 /// The tooltip-body bitmap. Owned |
|
347 CFbsBitmap* iTooltipBody; |
|
348 /// The tooltip-body bitmap mask. Owned |
|
349 CFbsBitmap* iTooltipBodyMask; |
|
350 |
|
351 /// The top-section bitmap. Owned |
|
352 CFbsBitmap* iAPTopSection; |
|
353 /// The item background bitmap. Owned |
|
354 CFbsBitmap* iAPItem; |
|
355 /// The gap bitmap. Owned |
|
356 CFbsBitmap* iAPGap; |
|
357 /// The bottom-section bitmap. Owned |
|
358 CFbsBitmap* iAPBottomSection; |
|
359 |
|
360 /// The current rectangle that encompasses only the items |
|
361 TRect iItemsRect; |
|
362 }; |
|
363 |
|
364 #include "ActivePalette2Styler.inl" |
|
365 |
|
366 #endif // #ifdef _ACTIVE_PALETTE_2_STYLER_H |