textinput/peninputarc/inc/peninputlayoutcontrolinc/peninputlayoutinsertionpoint.h
changeset 0 eb1f2e154e89
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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 layout interface
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CINSERTIONPOINT_H
       
    20 #define C_CINSERTIONPOINT_H
       
    21 
       
    22 #include <w32std.h>
       
    23 #include <peninputlayoutminterface.h>
       
    24 
       
    25 class CFepUiBaseCtrl;
       
    26 class CLayoutTimer;
       
    27 
       
    28 #ifndef __CURSOR_CONST__
       
    29 #define __CURSOR_CONST__
       
    30 /** Cursor blink timer interval */
       
    31 const TInt KCursorBlinkPerioid = 500000;
       
    32 /** Stop Cursor blink timer */
       
    33 /** Cursor width*/
       
    34 const TInt KCursorWidth = 3;
       
    35 /** Cursor position offset */
       
    36 const TInt KCursorPosCorrectionX = -1;
       
    37 /** Cursor position offset */
       
    38 const TInt KCursorPosCorrectionY = 0;
       
    39 #endif //__CURSOR_CONST__
       
    40 
       
    41 /**
       
    42  * Class CInsertionPoint
       
    43  *
       
    44  * Insertion point i.e. the cursor for edit area of the vkb-control.
       
    45  * 
       
    46  * @lib feplayouteng.lib
       
    47  * @since S60 v4.0
       
    48  */
       
    49 NONSHARABLE_CLASS(CInsertionPoint) : public CBase, MTimerHandler
       
    50     {
       
    51 public:
       
    52     // Constructors and destructor
       
    53     /**
       
    54      * Static constructor.
       
    55      *
       
    56      * @since S60 v4.0
       
    57      * @param aOwner The layout owner
       
    58      * @param aHeight A height of the cursor
       
    59      * @param aBitmapDevice The bitmap device.
       
    60      * @param aGc The graphic context.
       
    61      */
       
    62     IMPORT_C static CInsertionPoint* NewL(CFepUiBaseCtrl* aOwner, 
       
    63                                  CFbsBitmapDevice* aBitmapDevice, 
       
    64                                  CBitmapContext* aGc,
       
    65                                  TInt aHeight);
       
    66     
       
    67     /**
       
    68      * Destructor.
       
    69      *
       
    70      * @since S60 v4.0
       
    71      */
       
    72     virtual ~CInsertionPoint();
       
    73 
       
    74     /**
       
    75      * Sets the new position for cursor.
       
    76      *
       
    77      * @since S60 v4.0
       
    78      * @param aPosition New position
       
    79      */
       
    80      IMPORT_C void SetPosition(const TPoint& aPosition);
       
    81     
       
    82     /**
       
    83      * get the cursor position.
       
    84      *
       
    85      * @since S60 v4.0
       
    86      * @return The cursor position
       
    87      */
       
    88     TPoint Position();    
       
    89 
       
    90     /**
       
    91      * Turns the cursor on and off
       
    92      *
       
    93      * @since S60 v4.0
       
    94      * @param aOn ETrue -> cursor on, EFalse -> cursor off
       
    95      */
       
    96     IMPORT_C void SetOn(TBool aOn);
       
    97 
       
    98     /**
       
    99      * Sets caret height.
       
   100      *
       
   101      * @since S60 v4.0
       
   102      * @param aHeight new caret height in pixels
       
   103      */
       
   104     IMPORT_C void SetHeight(TInt aHeight);
       
   105     
       
   106     /**
       
   107      * Draw the cursor 
       
   108      * Draw the cursor by inverting colors in the cursor rectangle
       
   109      *
       
   110      * @since S60 v4.0
       
   111      * @param aGc Window graphics context to draw the cursor into
       
   112      * @param aReset ETrue to set the initial cusor state to invisiable, 
       
   113      *        which is used in case editor clear itself before redraw.
       
   114      */
       
   115      IMPORT_C void Draw(CBitmapContext* aGc, TBool aReset = EFalse);        
       
   116     
       
   117      inline TBool IsOn();
       
   118      
       
   119      inline TBool IsVisible();
       
   120 
       
   121     /**
       
   122      * Turns the cursor shown and off
       
   123      *
       
   124      * @since S60 v4.0
       
   125      * @param aOn ETrue -> cursor shown, EFalse -> cursor hide
       
   126      */
       
   127     inline void SetVisible(TBool aVisible);
       
   128     
       
   129     /**
       
   130      * Get the height of caret
       
   131      *
       
   132      * @since S60 v4.0
       
   133      * @return Height of caret
       
   134      */
       
   135     inline TInt Height();
       
   136 
       
   137     IMPORT_C void DelayCursorWhileDraging();
       
   138 private: //Methods
       
   139     /**
       
   140     * C++ default constructor.
       
   141     * 
       
   142     * @since S60 v4.0
       
   143     * @param aOwner The editor, who is the owner of insertion pointer
       
   144     * @param aHeight height of insertionpoint
       
   145      * @param aBitmapDevice The bitmap device.
       
   146      * @param aGc The graphic context.
       
   147      */
       
   148     CInsertionPoint(CFepUiBaseCtrl* aOwner,
       
   149                     CFbsBitmapDevice* aBitmapDevice,
       
   150                     CBitmapContext* aGc,
       
   151                     TInt aHeight);
       
   152 
       
   153     /**
       
   154      * 2nd phase constructor.
       
   155      * 
       
   156      * @since S60 v4.0
       
   157      */
       
   158     void ConstructL();
       
   159                 
       
   160     /**
       
   161      * Invalidates InsertionPoint's rect
       
   162      * 
       
   163      * @since S60 v4.0
       
   164      */
       
   165     void InvalidateInsertionPoint();
       
   166     
       
   167     /**
       
   168      * Timer's callBack function that handles cursor blinking
       
   169      * 
       
   170      * @since S60 v4.0
       
   171      */
       
   172     static TInt CursorBlinkCallBack(TAny *aPtr);
       
   173    
       
   174     //from base class MTimerHandler
       
   175     /**
       
   176      * HandleTimerOut. Handling time out event
       
   177      * @since S60 v4.0
       
   178      * @param aTimeType The timer type
       
   179      */                
       
   180     void HandleTimerOut(TInt /*aTimeType*/);
       
   181 private:    // Data
       
   182 
       
   183     /** 
       
   184      * Position of the cursor 
       
   185      */
       
   186     TPoint iPosition;
       
   187 
       
   188     /**
       
   189      * Height of the cursor
       
   190      */
       
   191     TInt iHeight;
       
   192 
       
   193     /**
       
   194      * Boolean value telling is the cursor on
       
   195      */
       
   196     TBool iIsOn;     
       
   197     
       
   198     /**
       
   199      * Boolean value telling is the cursor currently visible 
       
   200      */
       
   201     TBool iIsVisible;         
       
   202     
       
   203     /**
       
   204      * Active object which uses a timer to handle cursor blinking 
       
   205      */
       
   206     CPeriodic* iCursorBlinkingTimer;  
       
   207     
       
   208     /**
       
   209      * Cursor rect
       
   210      */
       
   211     TRect iCursorRect;            
       
   212 
       
   213     /** 
       
   214      * owner of this insertion point
       
   215      * Not own
       
   216      */
       
   217     CFepUiBaseCtrl* iEditor;
       
   218 
       
   219     /** 
       
   220      * bitmap device for drawing
       
   221      * Not own
       
   222      */    
       
   223     CFbsBitmapDevice* iBitmapDevice;
       
   224     
       
   225     /** 
       
   226      * graphic context
       
   227      * Not own
       
   228      */    
       
   229     CBitmapContext* iGc;
       
   230     
       
   231     /**
       
   232      * The timer to restore the cursor while pen is dragging.
       
   233      */
       
   234     CLayoutTimer* iRestoreCursorTimer;
       
   235     
       
   236     //flag tells whether the cursor is temprary disabled
       
   237     TBool iCursorTempDisabled;
       
   238     };
       
   239 
       
   240 inline TBool CInsertionPoint::IsOn()
       
   241     {
       
   242     return iIsOn;
       
   243     }
       
   244     
       
   245 inline TBool CInsertionPoint::IsVisible()
       
   246     {
       
   247     return iIsVisible;
       
   248     }
       
   249 
       
   250 inline void CInsertionPoint::SetVisible(TBool aVisible)
       
   251     {
       
   252     iIsVisible = aVisible;
       
   253     }
       
   254 
       
   255 inline TInt CInsertionPoint::Height()
       
   256     {
       
   257     return iHeight;
       
   258     }
       
   259 
       
   260 #endif //C_CINSERTIONPOINT_H
       
   261