|         |      1 /* | 
|         |      2 * Copyright (c) 2007-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:  header file of virtual keyboard key information and control | 
|         |     15 * | 
|         |     16 */ | 
|         |     17  | 
|         |     18  | 
|         |     19 #ifndef C_CVIRTUALKEYBOARD_KEY_CTRL_H | 
|         |     20 #define C_CVIRTUALKEYBOARD_KEY_CTRL_H | 
|         |     21 #include "peninputlayoutvkb.h" | 
|         |     22 #include "peninputlayoutbasecontrol.h" | 
|         |     23 class CVirtualKeyboard; | 
|         |     24 class CVirtualKey; | 
|         |     25  | 
|         |     26 //class CVirtualKeyCtrl | 
|         |     27 //Internal used by virtual keyboard | 
|         |     28 NONSHARABLE_CLASS(CVirtualKeyCtrl) : public CFepUiBaseCtrl | 
|         |     29     { | 
|         |     30 protected: | 
|         |     31     //internal event type | 
|         |     32     enum TVirtualKeyEventType | 
|         |     33         { | 
|         |     34         EVirtualKeyControlUp,	 //key up event on virtual key | 
|         |     35         EVirtualKeyControlDown,  //key down event on virtual key | 
|         |     36         }; | 
|         |     37 public: | 
|         |     38     /** | 
|         |     39      * Factory function.         | 
|         |     40      * | 
|         |     41      * @since S60 V5.0         | 
|         |     42      * @param aKeyboard The keyboard contains the key | 
|         |     43      * @param aKeyInfo The virtual key information data | 
|         |     44      * @return An instance of CVirtualKeyCtrl class         | 
|         |     45      */  | 
|         |     46     static CVirtualKeyCtrl* NewL(CVirtualKeyboard* aKeyboard,CVirtualKey* aKeyInfo);     | 
|         |     47         | 
|         |     48     /** | 
|         |     49      * Destructor | 
|         |     50      * | 
|         |     51      * @since S60 V5.0 | 
|         |     52      */        | 
|         |     53     ~CVirtualKeyCtrl(); | 
|         |     54      | 
|         |     55     //from base class CFepUiBaseCtrl | 
|         |     56     /** | 
|         |     57      * From CFepUiBaseCtrl | 
|         |     58      * Draw control | 
|         |     59      * | 
|         |     60      * @since S60 V5.0 | 
|         |     61      */                                | 
|         |     62     virtual void Draw();     | 
|         |     63  | 
|         |     64     /** | 
|         |     65      * From CFepUiBaseCtrl | 
|         |     66      * Handle pointer levae event.  | 
|         |     67      * This will be called only when it's got pointer down event before and  | 
|         |     68      * now pointer leaves without pointer up event | 
|         |     69      * | 
|         |     70      * @since S60 V5.0 | 
|         |     71      * @param aPoint current pointer position | 
|         |     72      */ | 
|         |     73     virtual void HandlePointerLeave(const TPoint& aPoint); | 
|         |     74      | 
|         |     75     /** | 
|         |     76      * From CFepUiBaseCtrl | 
|         |     77      * Handle pointer enter event.  | 
|         |     78      * This will be called only when it's got pointer down event previously then  | 
|         |     79      * pointer leaves but now comes back without pointer up event. | 
|         |     80      * | 
|         |     81      * @since S60 V5.0 | 
|         |     82      * @param aPoint current pointer position      | 
|         |     83      */ | 
|         |     84     virtual void HandlePointerEnter(const TPoint& aPoint);             | 
|         |     85  | 
|         |     86     /** | 
|         |     87      * From CFepUiBaseCtrl | 
|         |     88      * Handle pointer down event | 
|         |     89      * | 
|         |     90      * @since S60 V4.0 | 
|         |     91      * @param aPoint The point position relative the layout | 
|         |     92      * @return The control which handles the event.      | 
|         |     93      */                                         | 
|         |     94     virtual CFepUiBaseCtrl* HandlePointerDownEventL(const TPoint& aPoint);     | 
|         |     95     | 
|         |     96     /** | 
|         |     97      * From CFepUiBaseCtrl | 
|         |     98      * Handle pointer up event | 
|         |     99      * | 
|         |    100      * @since S60 V4.0 | 
|         |    101      * @param aPoint The point position relative the layout | 
|         |    102  	 * @return The control which handles the event | 
|         |    103      */                   | 
|         |    104     virtual CFepUiBaseCtrl* HandlePointerUpEventL(const TPoint& aPoint); | 
|         |    105      | 
|         |    106     /** | 
|         |    107      * From CFepUiBaseCtrl | 
|         |    108      * Cancel pointer down event. | 
|         |    109      * This will be called when a control has pointer down but pointer up  | 
|         |    110      * event happens in other ways. | 
|         |    111      * | 
|         |    112      * @since S60 V4.0 | 
|         |    113      * @param aFocusedFlag ETrue if got focused, otherwise EFalse | 
|         |    114      */           | 
|         |    115     virtual void CancelPointerDownL();     | 
|         |    116  | 
|         |    117     inline CVirtualKeyboard* Keyboard(); | 
|         |    118      | 
|         |    119     inline CVirtualKey* VirtualKey(); | 
|         |    120  | 
|         |    121     TBool Contains(const TPoint& aPt); | 
|         |    122      | 
|         |    123     void SetVirtualKeyImgID(TVirtualKeyDrawInfo aVirtualKeyDrawInfo); | 
|         |    124      | 
|         |    125 protected: | 
|         |    126     /** | 
|         |    127      * 2nd phase constructor | 
|         |    128      * | 
|         |    129      * @since S60 V5.0 | 
|         |    130      */     | 
|         |    131     void ConstructL(); | 
|         |    132  | 
|         |    133     /** | 
|         |    134      * Report key event to outside | 
|         |    135      * | 
|         |    136      * @since S60 V5.0 | 
|         |    137      * @param aEventType The event type for current key event | 
|         |    138      */                      | 
|         |    139     void ReportKeyEvent(TControlEvent aEventType);     | 
|         |    140      | 
|         |    141     /** | 
|         |    142      * Constructor | 
|         |    143      * | 
|         |    144      * @since S60 V5.0 | 
|         |    145      * @param aKeyboard The key board contains the key | 
|         |    146      * @param aKeyInfo The virtual key information | 
|         |    147      */                          | 
|         |    148     CVirtualKeyCtrl(CVirtualKeyboard* aKeyboard,CVirtualKey *aKeyInfo); | 
|         |    149         | 
|         |    150 private: | 
|         |    151     /** | 
|         |    152      * Draw dimmed key | 
|         |    153      * | 
|         |    154      * @since S60 V5.0      | 
|         |    155      */         | 
|         |    156     void DrawDimKey(); | 
|         |    157      | 
|         |    158     /** | 
|         |    159      * Draw highlighed key | 
|         |    160      * | 
|         |    161      * @since S60 V5.0      | 
|         |    162      */             | 
|         |    163     void DrawHighlightKey(); | 
|         |    164      | 
|         |    165     /** | 
|         |    166      * Draw key in normal state (non-highlight/non-dimmed) | 
|         |    167      * | 
|         |    168      * @since S60 V5.0      | 
|         |    169      */             | 
|         |    170     void DrawNormalStateKey();             | 
|         |    171      | 
|         |    172     /** | 
|         |    173      * Draw key text | 
|         |    174      * | 
|         |    175      * @since S60 V5.0      | 
|         |    176      */             | 
|         |    177     void DrawKeyText(); | 
|         |    178      | 
|         |    179     /** | 
|         |    180      * Redraw and update the key | 
|         |    181      * | 
|         |    182      * @since S60 V5.0      | 
|         |    183      */             | 
|         |    184     void ReDraw(); | 
|         |    185      | 
|         |    186     /** | 
|         |    187      * Draw a key area with the given bitmap | 
|         |    188      * | 
|         |    189      * @since S60 V5.0      | 
|         |    190      * @param aDestRect The rect to be drawn | 
|         |    191      * @param aSourceRect The source area in the bitmap | 
|         |    192      * @param aBmp The bitmap used | 
|         |    193      * @param aMask The mask bitmap | 
|         |    194      * @param aInvertFlag The flag controls the mask effect. See DrawBitmapMasked. | 
|         |    195      */                 | 
|         |    196     void DrawBmp(const TRect& aDestRect,const TRect& aSourceRect, | 
|         |    197                     const CFbsBitmap* aBmp,CFbsBitmap* aMask, | 
|         |    198                     TBool aInvertFlag = EFalse); | 
|         |    199  | 
|         |    200     /** | 
|         |    201      * Get the control event for given internal event type | 
|         |    202      * | 
|         |    203      * @since S60 V5.0      | 
|         |    204      * @param aEvent Internal event type | 
|         |    205      * @return The event type after conversion. | 
|         |    206     */                                 | 
|         |    207     virtual TControlEvent GetKeyEventType(TVirtualKeyEventType aEvent); | 
|         |    208      | 
|         |    209     TBool MaskBmpContains(const TPoint& aPt); | 
|         |    210     CFbsBitmap* MaskBmp(); | 
|         |    211      | 
|         |    212     void DrawIrregularKey(TVirtualKeyIrregularKeyState aKeyState,  | 
|         |    213                           TVirtualKeyIrregularKeyState aKeyStateMask); | 
|         |    214      | 
|         |    215 private: | 
|         |    216     /**  | 
|         |    217      * virtual key information | 
|         |    218      * Not own | 
|         |    219      */     | 
|         |    220     CVirtualKey* iKeyInfo; | 
|         |    221      | 
|         |    222     /**  | 
|         |    223      * virtual keyboard | 
|         |    224      * Not own | 
|         |    225      */     | 
|         |    226     CVirtualKeyboard* iKeyboard;     | 
|         |    227     /** | 
|         |    228      * scan code. This is used to when searching key by scancode. | 
|         |    229      */     | 
|         |    230     TInt iScanCode;        | 
|         |    231      | 
|         |    232     TVirtualKeyDrawInfo iVirtualKeyDrawInfo;      | 
|         |    233      | 
|         |    234 friend class CVirtualKeyboard;     | 
|         |    235     }; | 
|         |    236      | 
|         |    237 inline CVirtualKeyboard* CVirtualKeyCtrl::Keyboard() | 
|         |    238     { | 
|         |    239     return iKeyboard; | 
|         |    240     } | 
|         |    241  | 
|         |    242 inline CVirtualKey* CVirtualKeyCtrl::VirtualKey() | 
|         |    243 	{ | 
|         |    244 	return iKeyInfo; | 
|         |    245 	} | 
|         |    246      | 
|         |    247 //class CVirtualRawKeyCtrl | 
|         |    248 /* | 
|         |    249 CVirtualRawKeyCtrl differes with CVirtualKeyCtrl in that when pressed, it generates | 
|         |    250 raw key event ( by simulating) which works just like a hardware key | 
|         |    251 */ | 
|         |    252 NONSHARABLE_CLASS(CVirtualRawKeyCtrl) : public CVirtualKeyCtrl     | 
|         |    253     { | 
|         |    254 public:     | 
|         |    255     /** | 
|         |    256      * Factory function.         | 
|         |    257      * | 
|         |    258      * @since S60 V5.0         | 
|         |    259      * @param aKeyboard The keyboard contains the key | 
|         |    260      * @param aKeyInfo The virtual key information data | 
|         |    261      * @return An instance of CVirtualKeyCtrl class         | 
|         |    262      */  | 
|         |    263     static CVirtualRawKeyCtrl* NewL(CVirtualKeyboard* aKeyboard,CVirtualKey* aKeyInfo); | 
|         |    264      | 
|         |    265     /** | 
|         |    266      * Cancel pointer down event. | 
|         |    267      * This will be called when a control has pointer down but pointer up  | 
|         |    268      * event happens in other ways. If overrided, this base implementation  | 
|         |    269      * must be called in order to report the event. | 
|         |    270      * | 
|         |    271      * @since S60 V4.0 | 
|         |    272      * @param aFocusedFlag ETrue if got focused, otherwise EFalse | 
|         |    273      */                                 | 
|         |    274     virtual void CancelPointerDownL(); | 
|         |    275  | 
|         |    276     /** | 
|         |    277      * From CFepUiBaseCtrl | 
|         |    278      * Handle pointer levae event.  | 
|         |    279      * This will be called only when it's got pointer down event before and  | 
|         |    280      * now pointer leaves without pointer up event | 
|         |    281      * | 
|         |    282      * @since S60 V5.0 | 
|         |    283      * @param aPoint current pointer position | 
|         |    284      */ | 
|         |    285     virtual void HandlePointerLeave(const TPoint& aPoint); | 
|         |    286 private: | 
|         |    287     /** | 
|         |    288      * Constructor | 
|         |    289      * | 
|         |    290      * @since S60 V5.0         | 
|         |    291      * @param aKeyboard The keyboard contains the key | 
|         |    292      * @param aKeyInfo The virtual key information data | 
|         |    293      */  | 
|         |    294     CVirtualRawKeyCtrl(CVirtualKeyboard* aKeyboard,CVirtualKey* aKeyInfo); | 
|         |    295      | 
|         |    296     //from base CVirtualKeyCtrl | 
|         |    297     /** | 
|         |    298      * Get the control event for given internal event type | 
|         |    299      * | 
|         |    300      * @since S60 V5.0      | 
|         |    301      * @param aEvent Internal event type | 
|         |    302      * @return The event type after conversion. | 
|         |    303     */                                         | 
|         |    304     virtual TControlEvent GetKeyEventType(TVirtualKeyEventType aEvent); | 
|         |    305     };   | 
|         |    306      | 
|         |    307 #endif //C_CVIRTUALKEYBOARD_KEY_CTRL_H | 
|         |    308  | 
|         |    309 //end of file |