|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Interface of project pen input plugin utils |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_PENINPUT_PLUGIN_COMMON_H |
|
20 #define C_PENINPUT_PLUGIN_COMMON_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <w32std.h> |
|
24 #include <e32base.h> |
|
25 #include <cenrepnotifyhandler.h> |
|
26 #include <AknsDrawUtils.h> |
|
27 #include <AvkonInternalCRKeys.h> |
|
28 #include <bitmaptransforms.h> // required for enums |
|
29 |
|
30 // FORWARD DECLARATION |
|
31 class CRepository; |
|
32 class MAknFepTimerHandler; |
|
33 |
|
34 // CONSTANTS |
|
35 //const TUid KCRUidAvkon = { 0x101F876E }; |
|
36 //const TUint32 KAknLayoutId = 0x00000001; |
|
37 |
|
38 /** |
|
39 * CAknFepTimer Fep timer class |
|
40 * |
|
41 * This class inherit from CActive to send time event handling |
|
42 * |
|
43 * @lib peninputpluginutils.lib |
|
44 * @since S60 v4.0 |
|
45 */ |
|
46 class CAknFepTimer : public CActive |
|
47 { |
|
48 |
|
49 public: |
|
50 |
|
51 /** |
|
52 * Symbian Constructor |
|
53 * |
|
54 * @since S60 v4.0 |
|
55 * @param aTimerHandler The timer handler |
|
56 * @return Pointer to created CAknFepHwrTimer object |
|
57 */ |
|
58 IMPORT_C static CAknFepTimer* NewL(MAknFepTimerHandler* aTimerHandler); |
|
59 |
|
60 /** |
|
61 * Destructor |
|
62 * |
|
63 * @since S60 v4.0 |
|
64 * @return None |
|
65 */ |
|
66 IMPORT_C ~CAknFepTimer(); |
|
67 |
|
68 /** |
|
69 * Set timer delay. |
|
70 * |
|
71 * @since S60 v4.0 |
|
72 * @param aDelay The timer delay |
|
73 * @return None |
|
74 */ |
|
75 IMPORT_C void SetTimer(const TTimeIntervalMicroSeconds32& aDelay); |
|
76 |
|
77 private: |
|
78 |
|
79 /** |
|
80 * C++ constructor. |
|
81 * |
|
82 * @since S60 v4.0 |
|
83 * @param aTimerHandler The timer handler |
|
84 * @return None |
|
85 */ |
|
86 CAknFepTimer(MAknFepTimerHandler* aTimerHandler); |
|
87 |
|
88 /** |
|
89 * Symbian second-phase constructor |
|
90 * |
|
91 * @since S60 v4.0 |
|
92 * @return None |
|
93 */ |
|
94 void ConstructL(); |
|
95 |
|
96 // From CActive |
|
97 |
|
98 /** |
|
99 * From CActive. |
|
100 * Will be called when timer ends |
|
101 * |
|
102 * @since S60 v4.0 |
|
103 * @return None |
|
104 */ |
|
105 void RunL(); |
|
106 |
|
107 /** |
|
108 * From CActive. |
|
109 * Will be called if RunL leaves |
|
110 * |
|
111 * @since S60 v4.0 |
|
112 * @param aError The leave code reported |
|
113 * @return KErrNone if it handles the leave; otherwise return error code |
|
114 */ |
|
115 TInt RunError(TInt aError); |
|
116 |
|
117 /** |
|
118 * From CActive. |
|
119 * Will be called when timer has been cancelled |
|
120 * |
|
121 * @since S60 v4.0 |
|
122 * @return None |
|
123 */ |
|
124 void DoCancel(); |
|
125 |
|
126 private:// data |
|
127 |
|
128 /** |
|
129 * Timer |
|
130 */ |
|
131 RTimer iTimer; |
|
132 |
|
133 /** |
|
134 * Timer event handler (Not own) |
|
135 */ |
|
136 MAknFepTimerHandler* iTimerHandler; |
|
137 |
|
138 }; |
|
139 |
|
140 /** |
|
141 * Class MAknFepTimerHandler Fep timer handler |
|
142 * |
|
143 * Interface for sending time event handling |
|
144 * |
|
145 * @lib peninputpluginutils.lib |
|
146 * @since S60 v4.0 |
|
147 */ |
|
148 class MAknFepTimerHandler |
|
149 { |
|
150 |
|
151 public: |
|
152 |
|
153 /** |
|
154 * Handling time out event |
|
155 * |
|
156 * @since S60 v4.0 |
|
157 * @param aTimer The timer which sent the request |
|
158 * @return None |
|
159 */ |
|
160 virtual void HandleTimerOut(const CAknFepTimer* aTimer) = 0; |
|
161 |
|
162 }; |
|
163 |
|
164 |
|
165 class CAknFepRepositoryWatcher : public CBase, public MCenRepNotifyHandlerCallback |
|
166 { |
|
167 public: |
|
168 IMPORT_C static CAknFepRepositoryWatcher* NewL( |
|
169 const TUid aUid, |
|
170 const TUint32 aKey, |
|
171 CCenRepNotifyHandler::TCenRepKeyType aKeyType, |
|
172 TCallBack aCallBack, |
|
173 CRepository* aRepository); |
|
174 |
|
175 IMPORT_C static CAknFepRepositoryWatcher* NewL( |
|
176 const TUid aUid, |
|
177 TCallBack aCallBack, |
|
178 CRepository* aRepository); |
|
179 |
|
180 IMPORT_C ~CAknFepRepositoryWatcher(); |
|
181 |
|
182 IMPORT_C TUint32 ChangedKey(); |
|
183 |
|
184 public: // from MCenRepNotifyHandlerCallback |
|
185 IMPORT_C void HandleNotifyInt (TUint32 aKey, TInt aNewValue); |
|
186 IMPORT_C void HandleNotifyError (TUint32 aKey, TInt aError, CCenRepNotifyHandler* aHandler); |
|
187 IMPORT_C void HandleNotifyGeneric(TUint32 aId); |
|
188 |
|
189 private: |
|
190 CAknFepRepositoryWatcher( |
|
191 const TUid aUid, |
|
192 const TUint32 aKey, |
|
193 TCallBack aCallBack, |
|
194 CRepository* aRepository); |
|
195 |
|
196 void ConstructL(CCenRepNotifyHandler::TCenRepKeyType aKeyType); |
|
197 |
|
198 void ConstructL(); |
|
199 |
|
200 private: |
|
201 TUid iUid; |
|
202 TUint32 iKey; |
|
203 TUint32 iChangedKey; |
|
204 TCallBack iCallBack; |
|
205 CRepository* iRepository; |
|
206 CCenRepNotifyHandler* iNotifyHandler; |
|
207 |
|
208 }; |
|
209 |
|
210 /** |
|
211 * Class AknPenInputUtils |
|
212 * |
|
213 * This class provide some utility function for peninput |
|
214 * |
|
215 * @lib peninputpluginutils.lib |
|
216 * @since S60 v4.0 |
|
217 */ |
|
218 class AknPenInputUtils |
|
219 { |
|
220 |
|
221 public: |
|
222 |
|
223 /** |
|
224 * Get ISO code accroding to language ID |
|
225 * |
|
226 * @since S60 v4.0 |
|
227 * @param aLanguage Language ID for looking up |
|
228 * @param aISOCode Pointer to ISO code according to language ID. |
|
229 * @return ETrue if it has iso code; otherwise EFalse |
|
230 */ |
|
231 IMPORT_C static TBool GetISOLanguageCode(const TLanguage aLanguage, TDes& aISOCode); |
|
232 |
|
233 /** |
|
234 * Start application |
|
235 * |
|
236 * @since S60 v4.0 |
|
237 * @param aAppname Application name |
|
238 * @return void |
|
239 */ |
|
240 IMPORT_C static void StartAppL( const TDesC& aAppName ); |
|
241 }; |
|
242 |
|
243 /** |
|
244 * Class AknPenImageUtils |
|
245 * |
|
246 * This class provide some utility function for image |
|
247 * |
|
248 * @lib peninputpluginutils.lib |
|
249 * @since S60 v4.0 |
|
250 */ |
|
251 class AknPenImageUtils |
|
252 { |
|
253 public: |
|
254 /** |
|
255 * Combine two images into 1 image |
|
256 * |
|
257 * @since S60 v4.0 |
|
258 * @param aBmp1 First image used to be combined |
|
259 * @param aBmp2 Second image used to be combined |
|
260 * @param aMode Color depth of new image |
|
261 * @param aHorizontal ETrue means aBmp1 concatenate aBmp2 at horizontal |
|
262 * direction to create new image, otherwise means aBmp1 concatenate aBmp2 |
|
263 * at vertical direction to create new image |
|
264 * @return New image created, its size calculated by size of aBmp1 and aBmp2 |
|
265 */ |
|
266 IMPORT_C static CFbsBitmap* CombineTwoImagesL(const CFbsBitmap* aBmp1, |
|
267 const CFbsBitmap* aBmp2, |
|
268 TDisplayMode aMode, |
|
269 TBool aHorizontal = ETrue); |
|
270 /** |
|
271 * It only used for common button, not so long or so heigh. |
|
272 * |
|
273 * @since S60 v5.0 |
|
274 * @param aBoundRect The rect of the button |
|
275 * @param aGraphicRect The calculated rect for graphics |
|
276 * @return none |
|
277 */ |
|
278 IMPORT_C static void CalculateGraphicRect(const TRect& aBoundRect, TRect& aGraphicRect); |
|
279 |
|
280 /** |
|
281 * Calculate graphics rect for long button |
|
282 * |
|
283 * @since S60 v5.0 |
|
284 * @param aBoundRect The rect of the button |
|
285 * @param aGraphicRect The calculated rect for graphics |
|
286 * @return none |
|
287 */ |
|
288 IMPORT_C static void CalculateLongBtnGraphicRect(const TRect& aBoundRect, TRect& aGraphicRect); |
|
289 }; |
|
290 |
|
291 /** |
|
292 * Class CPenInputColorIcon |
|
293 * |
|
294 * This class provide some encapulation for color icon |
|
295 * Use AKN_FEP_COLOR_ICON_IMAGE resource struct to config color icon |
|
296 * |
|
297 * @lib peninputpluginutils.lib |
|
298 * @since S60 v5.0 |
|
299 */ |
|
300 class CPenInputColorIcon : public CBase |
|
301 { |
|
302 public: |
|
303 virtual ~CPenInputColorIcon(); |
|
304 IMPORT_C static CPenInputColorIcon* NewL( TInt aResID ); |
|
305 IMPORT_C static CPenInputColorIcon* NewLC( TInt aResID ); |
|
306 IMPORT_C virtual void ConstructFromResourceL( TInt aResID ); |
|
307 |
|
308 IMPORT_C virtual void ResizeL( const TSize& aSize ); |
|
309 inline void ReConstructL(); |
|
310 inline void SetDimmed( TBool aIsDimmed ); |
|
311 inline TBool IsDimmed() const; |
|
312 inline CFbsBitmap* Bitmap(); |
|
313 inline CFbsBitmap* BitmapMask(); |
|
314 inline CFbsBitmap* DimmedBitmapMask(); |
|
315 protected: |
|
316 inline CPenInputColorIcon( TInt aResID ); |
|
317 inline void ConstructL(); |
|
318 void CreateDimmedMaskL( CFbsBitmap*& aDimmedMask, |
|
319 const CFbsBitmap* aMask ); |
|
320 void DestroyRes(); |
|
321 private: |
|
322 CFbsBitmap* iBmp; |
|
323 CFbsBitmap* iBmpMask; |
|
324 CFbsBitmap* iDimmedBmp; |
|
325 TBool iIsDimmed; |
|
326 TInt iResID; |
|
327 }; |
|
328 |
|
329 class CPenInput3PiecesColorIcons : public CBase |
|
330 { |
|
331 public: |
|
332 virtual ~CPenInput3PiecesColorIcons(); |
|
333 IMPORT_C static CPenInput3PiecesColorIcons* NewL( |
|
334 TInt aFirstIconResID, |
|
335 TInt aMiddleIconResID, |
|
336 TInt aLastIconResID ); |
|
337 IMPORT_C static CPenInput3PiecesColorIcons* NewLC( |
|
338 TInt aFirstIconResID, |
|
339 TInt aMiddleIconResID, |
|
340 TInt aLastIconResID ); |
|
341 IMPORT_C void SetDimmed( TBool aIsDimmed ); |
|
342 IMPORT_C void ReConstructL(); |
|
343 inline CPenInputColorIcon* FirstIcon(); |
|
344 inline CPenInputColorIcon* MiddleIcon(); |
|
345 inline CPenInputColorIcon* LastIcon(); |
|
346 protected: |
|
347 inline CPenInput3PiecesColorIcons(); |
|
348 void ConstructFromResourceL( TInt aFirstIconResID, |
|
349 TInt aMiddleIconResID, |
|
350 TInt aLastIconResID ); |
|
351 private: |
|
352 CPenInputColorIcon* iFirstIcon; |
|
353 CPenInputColorIcon* iMiddleIcon; |
|
354 CPenInputColorIcon* iLastIcon; |
|
355 }; |
|
356 |
|
357 /** |
|
358 * Class AknPenInputDrawUtils |
|
359 * |
|
360 * This class provide some utility function for draw skin image |
|
361 * |
|
362 * @lib peninputpluginutils.lib |
|
363 * @since S60 v5.0 |
|
364 */ |
|
365 class AknPenInputDrawUtils |
|
366 { |
|
367 public: |
|
368 /** |
|
369 * This method used to draw 3 pieces skined frame |
|
370 * |
|
371 * @since S60 v5.0 |
|
372 * @param aInstance Pointer to the skin instance. If NULL, the method returns immediately |
|
373 * @param aGc Graphics context to be used for drawing |
|
374 * @param aLeftOrTopRect one side rect, maybe left side or top side |
|
375 * @param aCenterRect center rect |
|
376 * @param aRightOrBottomRect one side rect, maybe right side or top side |
|
377 * @param aSideLeftOrTopID skin ID left or top side |
|
378 * @param aCenterID skin ID center |
|
379 * @param aSideRightOrBottomID skin ID right or bottom side |
|
380 * @return none |
|
381 */ |
|
382 IMPORT_C static void Draw3PiecesFrame(MAknsSkinInstance *aInstance, |
|
383 CFbsBitGc& aGc, |
|
384 const TRect& aLeftOrTopRect, |
|
385 const TRect& aCenterRect, |
|
386 const TRect& aRightOrBottomRect, |
|
387 const TAknsItemID& aSideLeftOrTopID, |
|
388 const TAknsItemID& aCenterID, |
|
389 const TAknsItemID& aSideRightOrBottomID); |
|
390 |
|
391 /** |
|
392 * This method used to draw 3 pieces skined frame |
|
393 * |
|
394 * @since S60 v5.0 |
|
395 * @param aInstance Pointer to the skin instance. If NULL, the method returns immediately |
|
396 * @param aGc Graphics context to be used for drawing |
|
397 * @param aOuterRect OutSide rect |
|
398 * @param aInnerRect inside rect |
|
399 * @param aSideLeftOrTopID skin ID left or top side |
|
400 * @param aCenterID skin ID center |
|
401 * @param aSideRightOrBottomID skin ID right or bottom side |
|
402 * @return none |
|
403 */ |
|
404 IMPORT_C static void Draw3PiecesFrame(MAknsSkinInstance *aInstance, |
|
405 CFbsBitGc& aGc, |
|
406 const TRect& aOuterRect, |
|
407 const TRect& aInnerRect, |
|
408 const TAknsItemID& aSideLeftOrTopID, |
|
409 const TAknsItemID& aCenterID, |
|
410 const TAknsItemID& aSideRightOrBottomID); |
|
411 /** |
|
412 * This method used to draw color icon |
|
413 * |
|
414 * @since S60 v5.0 |
|
415 * @param aColorIcon Pointer to the color icon. If NULL, the method returns immediately |
|
416 * @param aGc Graphics context to be used for drawing |
|
417 * @param aRect OutSide rect |
|
418 */ |
|
419 IMPORT_C static void DrawColorIcon( CPenInputColorIcon *aColorIcon, |
|
420 CFbsBitGc& aGc, |
|
421 const TRect& aRect ); |
|
422 |
|
423 /** |
|
424 * This method used to draw 3 pieces color icon |
|
425 * |
|
426 * @since S60 v5.0 |
|
427 * @param aColorIcon Pointer to the color icon. If NULL, the method returns immediately |
|
428 * @param aGc Graphics context to be used for drawing |
|
429 * @param aRect OutSide rect |
|
430 */ |
|
431 IMPORT_C static void Draw3PiecesColorIcon( CPenInput3PiecesColorIcons *aColorIcon, |
|
432 CFbsBitGc& aGc, |
|
433 const TRect& aOuterRect, |
|
434 const TRect& aInnerRect ); |
|
435 |
|
436 }; |
|
437 |
|
438 /** |
|
439 * |
|
440 * The class is from the BitmapTransforms Library bitmap rotation. |
|
441 * @internalTechnology |
|
442 * @Note: This class can be only used for the small graphics' transforms.Please use |
|
443 * CBitmapRotator when you have to handle any big graphics. |
|
444 * |
|
445 */ |
|
446 typedef CBitmapRotator::TRotationAngle TSyncRotationAngle; |
|
447 class CPeninputSyncBitmapRotator : public CBase |
|
448 { |
|
449 public: |
|
450 IMPORT_C static CPeninputSyncBitmapRotator* NewL(); |
|
451 ~CPeninputSyncBitmapRotator(); |
|
452 |
|
453 IMPORT_C TInt Rotate(CFbsBitmap& aSrcBitmap, CFbsBitmap& aTgtBitmap, TSyncRotationAngle aAngle); |
|
454 IMPORT_C TInt Rotate(CFbsBitmap& aBitmap, TSyncRotationAngle aAngle); |
|
455 |
|
456 private: |
|
457 |
|
458 CPeninputSyncBitmapRotator(); |
|
459 void ConstructL(); |
|
460 void Cleanup(); |
|
461 void DoRotate(); |
|
462 void FlipScanLine(TDes8& aDes, TInt aWidth); |
|
463 void PutScanline(TInt aYPos); |
|
464 |
|
465 private: |
|
466 TInt iCurOffset; |
|
467 TInt iRows; |
|
468 TSyncRotationAngle iAngle; |
|
469 TSize iBitmapSize; |
|
470 TDisplayMode iDisplayMode; |
|
471 CFbsBitmap* iTempBitmap; // For the Rotate() with only one bitmap supplied |
|
472 CFbsBitmap* iSrcBitmap; |
|
473 CFbsBitmap* iTgtBitmap; |
|
474 TUint32* iScanlineBuffer; |
|
475 TDisplayMode iScanlineDisplayMode; |
|
476 TInt iPixelSizeInBytes; |
|
477 TPtr8 iScanlineDes; |
|
478 CFbsBitmapDevice* iDevice; |
|
479 CFbsBitGc* iGc; |
|
480 CFbsBitmap* iScanlineBitmap; // Intermediate scanline bitmap |
|
481 #if defined(ROTATION_PROFILING) |
|
482 TUint iStartedAtFc; // Used for profiling |
|
483 #endif |
|
484 }; |
|
485 |
|
486 /** |
|
487 * Class CPenInputTrailColor |
|
488 * |
|
489 * This class provide some encapulation for trail color |
|
490 * |
|
491 * @lib peninputpluginutils.lib |
|
492 * @since S60 v5.0 |
|
493 */ |
|
494 |
|
495 class AknPenInputTrailColorUtils |
|
496 { |
|
497 public: |
|
498 IMPORT_C static TBool CheckColorInColorTable(TInt aColor); |
|
499 //IMPORT_C void SetDefaultColor(TRgb& color); |
|
500 IMPORT_C static TInt ColorCount(); |
|
501 IMPORT_C static TRgb ColorAt(TInt aIndex); |
|
502 IMPORT_C static TInt GetTrailColorByTheme(); |
|
503 }; |
|
504 |
|
505 |
|
506 inline CPenInputColorIcon::CPenInputColorIcon( TInt aResID ) |
|
507 { |
|
508 iResID = aResID; |
|
509 } |
|
510 inline void CPenInputColorIcon::ConstructL() |
|
511 { |
|
512 ConstructFromResourceL( iResID ); |
|
513 } |
|
514 inline void CPenInputColorIcon::SetDimmed( TBool aIsDimmed ) |
|
515 { |
|
516 iIsDimmed = aIsDimmed; |
|
517 } |
|
518 inline TBool CPenInputColorIcon::IsDimmed() const |
|
519 { |
|
520 return iIsDimmed; |
|
521 } |
|
522 inline CFbsBitmap* CPenInputColorIcon::Bitmap() |
|
523 { |
|
524 return iBmp; |
|
525 } |
|
526 inline CFbsBitmap* CPenInputColorIcon::BitmapMask() |
|
527 { |
|
528 return iBmpMask; |
|
529 } |
|
530 inline CFbsBitmap* CPenInputColorIcon::DimmedBitmapMask() |
|
531 { |
|
532 return iDimmedBmp; |
|
533 } |
|
534 |
|
535 inline CPenInput3PiecesColorIcons::CPenInput3PiecesColorIcons() |
|
536 { |
|
537 } |
|
538 inline CPenInputColorIcon* CPenInput3PiecesColorIcons::FirstIcon() |
|
539 { |
|
540 return iFirstIcon; |
|
541 } |
|
542 inline CPenInputColorIcon* CPenInput3PiecesColorIcons::MiddleIcon() |
|
543 { |
|
544 return iMiddleIcon; |
|
545 } |
|
546 inline CPenInputColorIcon* CPenInput3PiecesColorIcons::LastIcon() |
|
547 { |
|
548 return iLastIcon; |
|
549 } |
|
550 inline void CPenInputColorIcon::ReConstructL() |
|
551 { |
|
552 ConstructFromResourceL(iResID); |
|
553 } |
|
554 #endif // C_PENINPUT_PLUGIN_COMMON_H |
|
555 |
|
556 // End Of File |