|
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: |
|
15 * Some utility functions to other classes |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef BUBBLEUTILS_H |
|
21 #define BUBBLEUTILS_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "BMBubbleManager.h" |
|
25 #include <calslbs.h> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CBubbleHeader; |
|
29 class CEikImage; |
|
30 class CEikLabel; |
|
31 class CBubbleImageManager; |
|
32 class TAknLayoutRect; |
|
33 class CBubbleCallObjectImage; |
|
34 class CTelBubbleCustomElement; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 class TBubbleLayoutRect |
|
39 { |
|
40 public: |
|
41 TBubbleLayoutRect(); |
|
42 void SetRect( const TPoint& aPoint, const TSize& aSize ); |
|
43 void SetColor( const TRgb aColor ); |
|
44 TRgb Color() const; |
|
45 TRect Rect() const; |
|
46 private: |
|
47 TRgb iColor; |
|
48 TRect iRect; |
|
49 }; |
|
50 |
|
51 |
|
52 /** |
|
53 * CBubbleUtils class |
|
54 * Some utility functions to other classes |
|
55 * |
|
56 * @lib bubblemanager.lib |
|
57 * @since 1.0 |
|
58 */ |
|
59 class BubbleUtils |
|
60 { |
|
61 public: // Data types |
|
62 |
|
63 // Text place enumeration |
|
64 enum KBubbleUtilsHeaderTextPlace |
|
65 { |
|
66 EBubbleHeaderCLI, |
|
67 EBubbleHeaderLabel, |
|
68 EBubbleHeaderTimerCost, |
|
69 EBubbleHeaderCNAP |
|
70 }; |
|
71 |
|
72 public: // Member functions |
|
73 |
|
74 /** |
|
75 * Sets call type indicators in type pane |
|
76 * @param aHeader Header which contains the information |
|
77 * @param aTypeImage1 The selected (left one) bitmap is attached to |
|
78 * this image |
|
79 * @param aTypeImage2 The selected (right one) bitmap is attached to |
|
80 * this image |
|
81 * @param aBubbleManager Reference to BubbleManager |
|
82 * @return Is at least one image set? |
|
83 */ |
|
84 static TBool SetCallTypePane( const CBubbleHeader& aHeader, |
|
85 CEikImage*& aTypeImage1, |
|
86 CEikImage*& aTypeImage2, |
|
87 CBubbleManager& aBubbleManager ); |
|
88 |
|
89 /** |
|
90 * Sets ciphering off icon to image |
|
91 * @param aHeader Header which contains the information |
|
92 * @param aCypfOffImage The selected bitmap is attached to this image |
|
93 * @param aBubbleManager Reference to BubbleManager |
|
94 * @return Is image set? |
|
95 */ |
|
96 static TBool SetCyphOffImage( const CBubbleHeader& aHeader, |
|
97 CEikImage*& aCypfOffImage, |
|
98 CBubbleManager& aBubbleManager ); |
|
99 |
|
100 |
|
101 /** |
|
102 * Selects text to lines ( for bottom, bottom right and middle bubbles) |
|
103 * @param aHeader Header which contains the information |
|
104 * @param aFirstLineText Text which goes to line 1 in the bubble |
|
105 * @param aSecondLineText Text which goes to line 2 in the bubble |
|
106 * @param aTimerCost Text which goes to timer/cost in the bubble |
|
107 * @param aTextLine1 Component for resource allocation. |
|
108 * @param aTextLine2 Component for resource allocation. |
|
109 * @param aBubbleManager Bubblemanager reference. |
|
110 * @param aFirstLineDir First line text clipping direction |
|
111 * @param aSecondLineDir Second line text clipping direction |
|
112 * @param aTextLineNumber On return contains the text-part line number |
|
113 */ |
|
114 static void ChooseTextsToTwoLines( const CBubbleHeader& aHeader, |
|
115 TPtrC& aFirstLineText, |
|
116 TPtrC& aSecondLineText, |
|
117 CEikLabel*& aTimerCost, |
|
118 CEikLabel*& aTextLine1, |
|
119 CEikLabel*& aTextLine2, |
|
120 CBubbleManager& aBubbleManager, |
|
121 CBubbleManager::TPhoneClippingDirection& aFirstLineDir, |
|
122 CBubbleManager::TPhoneClippingDirection& aSecondLineDir, |
|
123 TUint8& aTextLineNumber ); |
|
124 |
|
125 /** |
|
126 * Selects text to lines ( for bottom, bottom right and middle bubbles) |
|
127 * @param aHeader Header which contains the information |
|
128 * @param aFirstLineText Text which goes to line 1 in the bubble |
|
129 * @param aSecondLineText Text which goes to line 2 in the bubble |
|
130 * @param aThirdLineText Text which goes to line 2 in the bubble |
|
131 * @param aTimerCost Text which goes to timer/cost in the bubble |
|
132 * @param aTextLine1 Component for resource allocation. |
|
133 * @param aTextLine2 Component for resource allocation. |
|
134 * @param aTextLine3 Component for resource allocation. |
|
135 * @param aBubbleManager Bubblemanager reference. |
|
136 * @param aFirstLineDir First line text clipping direction |
|
137 * @param aSecondLineDir Second line text clipping direction |
|
138 * @param aThirdLineDir Third line text clipping direction |
|
139 * @param aTextLineNumber On return contains the text-part line number |
|
140 * @since Series60 2.6 |
|
141 */ |
|
142 static void ChooseTextsToThreeLines( const CBubbleHeader& aHeader, |
|
143 TPtrC& aFirstLineText, |
|
144 TPtrC& aSecondLineText, |
|
145 TPtrC& aThirdLineText, |
|
146 CEikLabel*& aTimerCost, |
|
147 CEikLabel*& aTextLine1, |
|
148 CEikLabel*& aTextLine2, |
|
149 CEikLabel*& aTextLine3, |
|
150 CBubbleManager& aBubbleManager, |
|
151 CBubbleManager::TPhoneClippingDirection& aFirstLineDir, |
|
152 CBubbleManager::TPhoneClippingDirection& aSecondLineDir, |
|
153 CBubbleManager::TPhoneClippingDirection& aThirdLineDir, |
|
154 TUint8& aTextLineNumber ); |
|
155 |
|
156 /** |
|
157 * Selects text to lines |
|
158 * @param aHeader Header which contains the information |
|
159 * @param aFirstLineText Text which goes to line 1 in the bubble |
|
160 * @param aSecondLineText Text which goes to line 2 in the bubble |
|
161 * @param aThirdLineText Text which goes to line 2 in the bubble |
|
162 * @param aTimerCost Text which goes to timer/cost in the bubble |
|
163 * @param aTextLine1 Component for resource allocation. |
|
164 * @param aTextLine2 Component for resource allocation. |
|
165 * @param aTextLine3 Component for resource allocation. |
|
166 * @param aTextLine4 Component for resource allocation. |
|
167 * @param aTextLine5 Component for resource allocation. |
|
168 * @param aBubbleManager Bubblemanager reference. |
|
169 * @param aFirstLineDir First line text clipping direction |
|
170 * @param aSecondLineDir Second line text clipping direction |
|
171 * @param aThirdLineDir Third line text clipping direction |
|
172 * @param aTextLineNumber On return contains the text-part line number |
|
173 * @param aThreeLinesOfText Three lines of call text. |
|
174 * @since Series60 2.6 |
|
175 */ |
|
176 static void ChooseTextsToFiveLines( const CBubbleHeader& aHeader, |
|
177 TPtrC& aFirstLineText, |
|
178 TPtrC& aSecondLineText, |
|
179 TPtrC& aThirdLineText, |
|
180 CEikLabel*& aTextLine1, |
|
181 CEikLabel*& aTextLine2, |
|
182 CEikLabel*& aTextLine3, |
|
183 CEikLabel*& aTextLine4, |
|
184 CEikLabel*& aTextLine5, |
|
185 CBubbleManager& aBubbleManager, |
|
186 CBubbleManager::TPhoneClippingDirection& aFirstLineDir, |
|
187 CBubbleManager::TPhoneClippingDirection& aSecondLineDir, |
|
188 CBubbleManager::TPhoneClippingDirection& aThirdLineDir, |
|
189 TUint8& aTextLineNumber, |
|
190 TBool aThreeLinesOfText ); |
|
191 |
|
192 /** |
|
193 * Selects from longer text (format: "longone\tshort") which one to use |
|
194 * @param aText String containing at least long version of the text |
|
195 * @param aLabel Label which width has been set and the text will be |
|
196 * clipped to. |
|
197 * @param aClipDir Text's clipping direction |
|
198 */ |
|
199 static void SetTextInLabel( |
|
200 const TDesC16& aText, |
|
201 CEikLabel*& aLabel , |
|
202 const CBubbleManager::TPhoneClippingDirection& aClipDir ); |
|
203 |
|
204 /** |
|
205 * Sets given text to label - clips if needed. |
|
206 * @param aText String containing the used text |
|
207 * @param aLabel Label which width has been set and the text will be |
|
208 * clipped to. |
|
209 * @param aClipDir Text's clipping end |
|
210 */ |
|
211 static void ClipToLabel ( |
|
212 const TDesC16& aText, |
|
213 CEikLabel*& aLabel , |
|
214 const CBubbleManager::TPhoneClippingDirection& aClipDir ); |
|
215 |
|
216 |
|
217 /** |
|
218 * Draws image to screen. Pointer check added to previos function. |
|
219 * @param aGc Context to draw to |
|
220 * @param aImage Drawable image - with mask! |
|
221 * @return EFalse if image was not drawn. |
|
222 */ |
|
223 static TBool DrawMaskedImage( CBitmapContext& aGc , CEikImage* aImage ); |
|
224 |
|
225 /** |
|
226 * Tries to set text to label. |
|
227 * @param aLabel Label to set the text to |
|
228 * @param aText The text. |
|
229 */ |
|
230 static void AddTextToEikLabel( |
|
231 CEikLabel*& aLabel , |
|
232 const TDesC& aText); |
|
233 |
|
234 /** |
|
235 * Adds text to call header. Cuts the text if not fit. |
|
236 * @param aHeader The header |
|
237 * @param aTextPlace Enum for text position |
|
238 * @param aTextToSet Original text. |
|
239 * @param aMaxLength Text max length |
|
240 * @param aClipDirection If text is too long, then cnut it. |
|
241 */ |
|
242 static void AddTextToHeader( CBubbleHeader& aHeader, |
|
243 const KBubbleUtilsHeaderTextPlace aTextPlace, |
|
244 const TDesC& aTextToSet, |
|
245 const TInt aMaxLength, |
|
246 const CBubbleManager::TPhoneClippingDirection aClipDirection ); |
|
247 |
|
248 |
|
249 /** |
|
250 * The next three calls AknLayoutUtils's functions after they have |
|
251 * checked the pointer. |
|
252 */ |
|
253 static void LayoutControl( |
|
254 CCoeControl* aControl, |
|
255 const TRect& aControlParent, |
|
256 const TAknWindowLineLayout& aLayout ); |
|
257 |
|
258 static void LayoutBackgroundImage( |
|
259 CEikImage* aImage, |
|
260 const TRect& aParent, |
|
261 const TAknWindowLineLayout& aLayout); |
|
262 |
|
263 static void LayoutImage( |
|
264 CEikImage* aImage, |
|
265 const TRect& aParent, |
|
266 const TAknWindowLineLayout& aLayout); |
|
267 |
|
268 static void LayoutLabel( |
|
269 CEikLabel* aLabel, |
|
270 const TRect& aLabelParent, |
|
271 const TAknTextLineLayout& aLayout ); |
|
272 |
|
273 static void LayoutImage( |
|
274 CEikImage* aImage, |
|
275 const TRect& aParent, |
|
276 const AknLayoutUtils::SAknLayoutControl& aLayout ); |
|
277 |
|
278 static void LayoutCustomElement( |
|
279 CTelBubbleCustomElement* aElement, |
|
280 const TRect& aParent, |
|
281 const TAknWindowLineLayout& aLayout); |
|
282 |
|
283 /** |
|
284 * Converts western number string to Arabic-Indic if needed. |
|
285 * @since 2.0 |
|
286 * @param aResult Result buffer. aResult.MaxLength() must be greater |
|
287 or equal to aSource.Length(). |
|
288 * @param aSource Original string. |
|
289 */ |
|
290 static void ConvertToArabicIndic( |
|
291 TDes& aResult , |
|
292 const TDesC& aSource ); |
|
293 |
|
294 /** |
|
295 * Converts western number string to Arabic-Indic if needed. |
|
296 * @since 2.0 |
|
297 * @param aDes Source and destination |
|
298 */ |
|
299 static void ConvertToArabicIndic( TDes& aDes ); |
|
300 |
|
301 /** |
|
302 * Converts western number string to Arabic-Indic if needed. |
|
303 * @since 2.0 |
|
304 * @param aResult Original string. |
|
305 * @return Result buffer. NULL in OOM case. Ownership transferred. |
|
306 */ |
|
307 static HBufC* ConvertToArabicIndic( const TDesC& aDes ); |
|
308 |
|
309 |
|
310 /** |
|
311 * Set call type pane |
|
312 * @since 2.0 |
|
313 * @param aBubblePlace Bubble place from CBubblePlace. |
|
314 * @param aParent Parent control |
|
315 * @param aTypeIndication1 Left indicator. |
|
316 * @param aTypeIndication2 Rigth indicator. |
|
317 */ |
|
318 static void SetLayoutForCellTypePane( |
|
319 const CBubblePlace::TPhoneBubblePlace& aBubblePlace, |
|
320 const TRect& aParent, |
|
321 CEikImage* aTypeIndication1, |
|
322 CEikImage* aTypeIndication2 ); |
|
323 |
|
324 /** |
|
325 * Set cyphering off icon place |
|
326 * @since 2.0 |
|
327 * @param aHeader Call information. |
|
328 * @param aBubblePlace Bubble place from CBubblePlace. |
|
329 * @param aParent Parent control |
|
330 * @param aCyphOffImage The image. |
|
331 */ |
|
332 static void SetLayoutFofCypheringOffIcon( |
|
333 const CBubbleHeader& aHeader, |
|
334 const CBubblePlace::TPhoneBubblePlace& aBubblePlace, |
|
335 const TRect& aParent, |
|
336 CEikImage* aCyphOffImage ); |
|
337 |
|
338 /** |
|
339 * Places thumbnail image |
|
340 * @param aBubblePlace Bubble place from CBubblePlace |
|
341 * @param aImage The thumbnail image |
|
342 * @param aClippingRect Clipping rectangle. |
|
343 * @param aShadow Thumbnail shadow |
|
344 * @param aParentRect Parent control. |
|
345 */ |
|
346 static void PlaceThumbnail( |
|
347 const CBubblePlace::TPhoneBubblePlace& aBubblePlace, |
|
348 CEikImage* aImage , |
|
349 TBubbleLayoutRect& aShadow, |
|
350 const TRect& aParentRect, |
|
351 CFbsBitmap* aThumbNailBitmap ); |
|
352 |
|
353 |
|
354 /** |
|
355 * |
|
356 * @param aParent Parent control. |
|
357 * @param aWidth Width of the thumbnail image. |
|
358 * @return ETrue if customized image, else EFalse. |
|
359 */ |
|
360 static TBool IsCustomizedImage( const TRect& aParent, const TInt aWidth ); |
|
361 |
|
362 /** |
|
363 * |
|
364 * @param aParent Parent control. |
|
365 * @param aWidth Width of the thumbnail image. |
|
366 * @return TInt Internal type of the image used. |
|
367 */ |
|
368 static TInt GetThumbnailImageType( const TRect& aParent, const TInt aWidth ); |
|
369 /** |
|
370 * @param aLabel Label control to be resized. |
|
371 * @param aParent Parent control. |
|
372 * @param aWidth Width of the thumbnail image. |
|
373 */ |
|
374 static void LabelExtent( CEikLabel* aLabel, |
|
375 const TRect& aParent, |
|
376 const TInt aWidth ); |
|
377 |
|
378 /** |
|
379 * @param aFileName Icon file name. |
|
380 */ |
|
381 static void BubbleIconFileName( TDes& aFileName ); |
|
382 |
|
383 /** |
|
384 * @param aFileName Resource file name. |
|
385 */ |
|
386 static void BubbleResourceFileName( TDes& aFileName ); |
|
387 |
|
388 /** |
|
389 * Selects from longer text (format: "longone\tshort") which one to use |
|
390 * @param aText String containing at least long version of the text |
|
391 * @param aLabel Label which width has been set and the text will be |
|
392 * clipped to. |
|
393 * @param aClipDir Text's clipping direction |
|
394 */ |
|
395 static void SetTextInLabel( |
|
396 const TDesC16& aText, |
|
397 CEikLabel& aLabel , |
|
398 const CBubbleManager::TPhoneClippingDirection& aClipDir ); |
|
399 |
|
400 /** |
|
401 * Sets given text to label - clips if needed. |
|
402 * @param aText String containing the used text |
|
403 * @param aLabel Label which width has been set and the text will be |
|
404 * clipped to. |
|
405 * @param aClipDir Text's clipping end |
|
406 */ |
|
407 static void ClipToLabel ( |
|
408 const TDesC16& aText, |
|
409 CEikLabel& aLabel , |
|
410 const CBubbleManager::TPhoneClippingDirection& aClipDir ); |
|
411 |
|
412 /** |
|
413 * Tries to set text to label. |
|
414 * @param aLabel Label to set the text to |
|
415 * @param aText The text. |
|
416 */ |
|
417 static void AddTextToEikLabel( CEikLabel& aLabel , const TDesC& aText); |
|
418 |
|
419 /** |
|
420 * Creates bubble image from 9-pieceframe. |
|
421 * @since 3.1 |
|
422 * @param aFrameID Skin id for frame. |
|
423 * @param aOuterRect Outer rectangle. |
|
424 * @param aInnerRect Inner rectangle. |
|
425 * @param aBubble Bubble image. |
|
426 */ |
|
427 static void PrepareBubbleImageL( |
|
428 const TAknsItemID& aFrameID, |
|
429 const TRect& aOuterRect, |
|
430 const TRect& aInnerRect, |
|
431 CEikImage*& aBubble ); |
|
432 |
|
433 /** |
|
434 * Makes bubble image transparent based on given |
|
435 * 9-piece mask frame. |
|
436 * @since 3.1 |
|
437 * @param aFrameID Skin id for frame. |
|
438 * @param aOuterRect Outer rectangle. |
|
439 * @param aInnerRect Inner rectangle. |
|
440 * @param aBubble Bubble image. |
|
441 */ |
|
442 static void AddTransparencyToBubbleImageL( |
|
443 const TAknsItemID& aFrameID, |
|
444 const TRect& aOuterRect, |
|
445 const TRect& aInnerRect, |
|
446 CEikImage*& aBubble ); |
|
447 |
|
448 /** |
|
449 * Adds call object image to bubble image. |
|
450 * @since 3.1 |
|
451 * @param aCOImage Image. |
|
452 * @param aCOImageMask Image mask. |
|
453 * @param aCallObjectRect Call object location in bubble. |
|
454 * @param aFrameID Mask frame for image fading. |
|
455 * @param aOuterRect Frame outer rectangle. |
|
456 * @param aInnerRect Frame inner rectangle. |
|
457 * @param aBubble Bubble image. |
|
458 * @param aDimmed ETrue if image is shown dimmed. |
|
459 */ |
|
460 static void PrepareCallObjectToBubbleImageL( |
|
461 const CFbsBitmap* aCOImage, |
|
462 const CFbsBitmap* aCOImageMask, |
|
463 const TRect& aCallObjectRect, |
|
464 const TAknsItemID& aFrameID, |
|
465 const TRect& aOuterRect, |
|
466 const TRect& aInnerRect, |
|
467 CEikImage*& aBubble, |
|
468 TBool aDimmed = EFalse ); |
|
469 |
|
470 /** |
|
471 * Fallback background drawing. This method can be used to draw background, |
|
472 * if skin/bitmap graphichs cannot be used (e.g. due to OOM). |
|
473 * @param aRect Rectangle. |
|
474 */ |
|
475 static void DrawBackgroundRect( CBitmapContext& aGc, |
|
476 const TRect& aRect ); |
|
477 |
|
478 /** |
|
479 * Layouts call type indicators in call type pane. |
|
480 * @since S60 3.2 |
|
481 * @param aParent Parent rectangle. |
|
482 * @param aCallTypePane Call type pane. |
|
483 * @param aTypeIndication1 First indicator. |
|
484 * @param aTypeIndication2 Second indicator. |
|
485 */ |
|
486 static void LayoutCallTypeIndicators( |
|
487 const TRect& aParent, |
|
488 const TAknWindowLineLayout& aCallTypePane, |
|
489 CEikImage* aTypeIndication1, |
|
490 CEikImage* aTypeIndication2 ); |
|
491 |
|
492 |
|
493 /** |
|
494 * Prepares call image attached to call header to be |
|
495 * ready for drawing. |
|
496 * @since S60 3.2 |
|
497 * @param aHeader Call header. |
|
498 * @param aSize Displayable size for call image. |
|
499 */ |
|
500 static void PrepareCallObjectImageL( |
|
501 CBubbleHeader& aHeader, |
|
502 const TSize& aSize ); |
|
503 |
|
504 /** |
|
505 * Combines given masks to new mask bitmap. |
|
506 * @since S60 5.0 |
|
507 * @param aPrimaryMask Mask treated as primary mask. |
|
508 * @param aSecondaryMask Mask treated as secondary mask. |
|
509 * @return The combined mask. |
|
510 */ |
|
511 static CFbsBitmap* CreateCombinedMaskL( |
|
512 const CFbsBitmap* aPrimaryMask, |
|
513 const CFbsBitmap* aSecondaryMask ); |
|
514 |
|
515 private: |
|
516 static void DrawMaskedImage( CBitmapContext& aGc , CEikImage& aImage ); |
|
517 |
|
518 |
|
519 }; |
|
520 |
|
521 #endif //BUBBLEUTILS_H |
|
522 |
|
523 // End of File |