fep/aknfep/UiPlugins/AknFepUiInterface/AvkonImpl/inc/insertionpoint.h
changeset 36 a7632c26d895
parent 35 0f326f2e628e
child 42 b3eaa440ab06
equal deleted inserted replaced
35:0f326f2e628e 36:a7632c26d895
     1 /*
       
     2 * Copyright (c) 2008-2008 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 *       Provides the CInsertionPoint definition.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 #ifndef INSERTIONPOINT_H
       
    30 #define INSERTIONPOINT_H
       
    31 
       
    32 #include <e32base.h>	// For CActive, link against: euser.lib
       
    33 #include <e32std.h>		// For RTimer, link against: euser.lib
       
    34 #include <w32std.h>
       
    35 #include "aknfepuilayoutdatamgr.h"
       
    36 
       
    37 /**
       
    38  * The cursor observer interface.
       
    39  * 
       
    40  * @lib aknfepuiavkonplugin.dll
       
    41  * @since S60 v5.0
       
    42  */
       
    43 class MRefreshObserver
       
    44     {
       
    45 public:
       
    46     /**
       
    47      * When the cursor state is changed,it will notify its observer through this function.
       
    48      * 
       
    49      * @since S60 v5.0
       
    50      * @param None.
       
    51      * @return None.
       
    52      */
       
    53     virtual void Refresh( ) = 0;
       
    54     };
       
    55 
       
    56 /**
       
    57  * The cursor class.
       
    58  * 
       
    59  * @lib aknfepuiavkonplugin.dll
       
    60  * @since S60 v5.0
       
    61  */
       
    62 
       
    63 class CInsertionPoint : public CActive
       
    64     {
       
    65 public:
       
    66     enum TInsertionPointState
       
    67         {
       
    68         EUninitialized,
       
    69         EInitialized,
       
    70         EError
       
    71         };
       
    72 
       
    73     /**
       
    74      * Cancel and destroy.
       
    75      * 
       
    76      * @since S60 v5.0.
       
    77      * @return none.
       
    78      */
       
    79     virtual ~CInsertionPoint( );
       
    80 
       
    81     /**
       
    82      * NewL function.
       
    83      * 
       
    84      * @since S60 v5.0.
       
    85      * @return none.
       
    86      */
       
    87      static CInsertionPoint* NewL( CAknFepUiLayoutDataMgr* aLafDataMgr );
       
    88 
       
    89     /**
       
    90      * NewLC funciton. 
       
    91      * 
       
    92      * @since S60 v5.0.
       
    93      * @return none. 
       
    94      */
       
    95      static CInsertionPoint* NewLC( CAknFepUiLayoutDataMgr* aLafDataMgr );
       
    96 
       
    97     /**
       
    98      * Set iRefreshObserver member.
       
    99      * 
       
   100      * @since S60 v5.0
       
   101      * @param aObserver. The observer you want to set.
       
   102      * @return none.
       
   103      */
       
   104      void SetRefreshObserver( MRefreshObserver* aObserver );
       
   105 
       
   106     /**
       
   107      * Set the position of cursor.
       
   108      * The max position of cursor is larger than length of visual text 
       
   109      * by 1 stride.
       
   110      * 
       
   111      * @since S60 5.0
       
   112      * @param aOffset. The cursor position which based on 0 index.
       
   113      * @return None.
       
   114      */
       
   115      void SetPosition( TInt aOffSet );
       
   116 
       
   117     /**
       
   118      * Set the rect where visual text will be displayed.
       
   119      * 
       
   120      * @since S60 v5.0
       
   121      * @param aRect. The rect you want to display the visual text in.
       
   122      * @return None.
       
   123      */
       
   124      void SetTextRect( TRect aRect );
       
   125 
       
   126     /**
       
   127      * Set the height of cursor.
       
   128      * 
       
   129      * @since S60 v5.0
       
   130      * @param aHeight. The cursor height you want to set.
       
   131      * @return.
       
   132      */
       
   133      void SetHeight();
       
   134 
       
   135     /**
       
   136      * Draw the cursor on the screen.
       
   137      * 
       
   138      * @since S60 v5.0
       
   139      * @param aGc. the gc you used to draw the cursor.
       
   140      * @return.
       
   141      */
       
   142      void Draw( CWindowGc& aGc );
       
   143 
       
   144     /**
       
   145      * Active the cursor into active state.
       
   146      * 
       
   147      * @since S60 v5.0
       
   148      * @param None.
       
   149      * @return None.
       
   150      */
       
   151      void Active();
       
   152 
       
   153     /**
       
   154      * Deactive the cursor into deactive state.
       
   155      * 
       
   156      * @since S60 v5.0
       
   157      * @param None.
       
   158      * return None.
       
   159      */
       
   160      void Deactive();
       
   161 
       
   162 private:
       
   163 
       
   164     /**
       
   165      * Insertion Point.
       
   166      * 
       
   167      * @since S60 v5.0
       
   168      * @param None.
       
   169      */
       
   170     CInsertionPoint( CAknFepUiLayoutDataMgr* aLafDataMgr );
       
   171 
       
   172     /**
       
   173      * Two-phrase constructor.
       
   174      * 
       
   175      * @since S60 v5.0
       
   176      * @param None.
       
   177      * @return None.
       
   178      */
       
   179     void ConstructL();
       
   180 
       
   181     /**
       
   182      * From CActive.
       
   183      * The callback function used by CActiveScheduler.
       
   184      * 
       
   185      * @since S60 v5.0
       
   186      * @param None.
       
   187      * @return None.
       
   188      */
       
   189     void RunL();
       
   190 
       
   191     /**
       
   192      * From CActive.
       
   193      * How to cancel me.
       
   194      * 
       
   195      * @since S60 v5.0
       
   196      * @param None.
       
   197      * @return None.
       
   198      */
       
   199     void DoCancel();
       
   200 
       
   201     /**
       
   202      * From CActive.
       
   203      * Handle leaves from RunL().
       
   204      * 
       
   205      * @since S60 v5.0
       
   206      * @param None.
       
   207      * @return None.
       
   208      */
       
   209     TInt RunError( TInt aError );
       
   210 
       
   211     /**
       
   212      * Start the cursor with glint if actived or with gray color if deactived.
       
   213      * 
       
   214      * @since S60 v5.0
       
   215      * @param aDelay. After this time, the RunL should be called.
       
   216      * @return None.
       
   217      */
       
   218     void StartL( TTimeIntervalMicroSeconds32 aDelay );
       
   219 
       
   220 private:
       
   221     // Data.
       
   222     /**
       
   223      * The state of CInsertionPoint object.
       
   224      */
       
   225     TInt iState;
       
   226     /**
       
   227      * The timer for changing the visibility of this cursor.
       
   228      */
       
   229     RTimer iTimer;
       
   230     /**
       
   231      * The rect that visual text must be displayed on.
       
   232      */
       
   233     TRect iTextRect;
       
   234     /**
       
   235      * the cursor rect which will be drawn onto the screen.
       
   236      */
       
   237     TRect iCursorRect;
       
   238     /**
       
   239      * Whether this cursor should be displayed.
       
   240      */
       
   241     TBool isVisible;
       
   242     /**
       
   243      * the length from the beginning of visual text to the cursor position.
       
   244      */
       
   245     TInt iOffSet;
       
   246     /**
       
   247      * the height of cursor.
       
   248      */
       
   249     TInt iHeight;
       
   250     /**
       
   251      * the BrushColor of active cursor.
       
   252      */
       
   253     TRgb iActiveBrushColor;
       
   254     /**
       
   255      * the PenColor of active cursor.
       
   256      */
       
   257     TRgb iActivePenColor;
       
   258     /**
       
   259      * the BrushColor of active cursor.
       
   260      */
       
   261     TRgb iInactiveBrushColor;
       
   262     /**
       
   263      * the PenColor of active cursor.
       
   264      */
       
   265     TRgb iInactivePenColor;
       
   266     /**
       
   267      * the width of cursor.
       
   268      */
       
   269     TInt iWidth;
       
   270     /**
       
   271      * Whether this cursor is actived.
       
   272      */
       
   273     TBool isActive;
       
   274     /**
       
   275      * The observer for caring of the cursor's change.
       
   276      * Not own.
       
   277      */
       
   278     MRefreshObserver* iRefreshObserver;
       
   279 	CAknFepUiLayoutDataMgr* iLafDataMgr;
       
   280     };
       
   281 
       
   282 #endif /* INSERTIONPOINT_H */