webengine/wmlengine/src/fbox/include/WmlInputElement.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2000 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 the License "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 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CWMLINPUTELEMENT_H
       
    20 #define CWMLINPUTELEMENT_H
       
    21 
       
    22 //  INCLUDES
       
    23 
       
    24 //#include "WmlRenderingElement.h"
       
    25 #include "WmlReSizableEditor.h"
       
    26 #include "WmlFormattedEditor.h"
       
    27 #include <E32DEF.H>
       
    28 #include <coemain.h>
       
    29 #include <eikedwob.h>
       
    30 
       
    31 #include <coeinput.h>
       
    32 #include <frmtview.h>
       
    33 #include <fepbase.h>
       
    34 #include <eikrted.h>
       
    35 
       
    36 // MACROS
       
    37 
       
    38 //#define OOM_TEST_IN_CONSTRUCTL
       
    39 //#define OOM_TEST_IN_HANDLEEDWINEVENTL
       
    40 //#define OOM_TEST_IN_OFFERKEYEVENTL
       
    41 //#define OOM_TEST_IN_HANDLECOMMANDL
       
    42 //#define OOM_TEST_IN_REFRESHL
       
    43 //#define OOM_TEST_IN_INITVALUESL
       
    44 
       
    45 // CONSTANTS
       
    46 
       
    47 const TInt KWmlInputMinimalWidth                = 50;   // minimal width of input's editor
       
    48 
       
    49 // FORWARD DECLARATIONS
       
    50 
       
    51 class CEikRichTextEditor;
       
    52 class CMyFepContainer;
       
    53 class CGraphicsContext;
       
    54 class MGraphicsDeviceMap;
       
    55 class CWmlFormatHandler;
       
    56 class CIdle;
       
    57 class CParaFormatLayer;
       
    58 class CCharFormatLayer;
       
    59 class CRenderingNode;
       
    60 
       
    61 //typedef CWmlFormattedEditor<CWmlReSizableEditor<CEikRichTextEditor> >
       
    62 //CWmlFormattedResizeableEditor;
       
    63 
       
    64 typedef CWmlFormattedEditor CWmlFormattedResizeableEditor;
       
    65 
       
    66 
       
    67 // CLASS DECLARATION
       
    68 
       
    69 /**
       
    70 *  CWmlInputElement implements the functionality
       
    71 *  of the WML input element.
       
    72 */
       
    73 class CWmlInputElement : public MEikEdwinObserver, CBase
       
    74 {
       
    75 protected:      // Constructors and destructor
       
    76 
       
    77     /*
       
    78      * C++ default constructor.
       
    79      * @param aNode The parent node.
       
    80      */
       
    81         CWmlInputElement();
       
    82 
       
    83     /*
       
    84      * Second-phase constructor. Leaves on failure.
       
    85      * @param aParent Parent control.
       
    86      * @param aPopup this control is used as popup or not
       
    87      */
       
    88         void ConstructL(CCoeControl*);
       
    89 
       
    90 public: // Constructors and destructor
       
    91     /*
       
    92      * Two-phased constructor.
       
    93      * It leaves a pointer on the cleanup stack.
       
    94      * @param aNode The parent node.
       
    95      */
       
    96         static CWmlInputElement* NewLC(CCoeControl*);
       
    97         
       
    98     /*
       
    99      * Two-phased constructor.
       
   100      * @param aNode The parent node.
       
   101      */
       
   102         static CWmlInputElement* NewL(CCoeControl*);
       
   103 
       
   104     /*
       
   105      * Destructor.
       
   106      */
       
   107         virtual ~CWmlInputElement();
       
   108 
       
   109 private:        // New functions
       
   110 
       
   111         enum TWmlCursorHandling
       
   112                 {
       
   113                 EWmlMoveCursor,
       
   114                 EWmlScrollDisplay
       
   115                 };
       
   116 
       
   117         /**
       
   118         * Makes the cursor visible by moving it to the last visible position,
       
   119         * or by scrolling the display depending on the aMode parameter.
       
   120         * @param aMode Mode.
       
   121         */
       
   122         void ShowCursorL( TWmlCursorHandling aMode = EWmlMoveCursor );
       
   123 
       
   124         /**
       
   125         * Handles key events in non-editing state.
       
   126         * @param aKeyEvent      Key event.
       
   127         * @param aType          Type.
       
   128         * @return Response.
       
   129         */
       
   130         TKeyResponse NavigateL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   131 
       
   132         /**
       
   133         * Handles key events in editing state
       
   134         * @param aKeyEvent      Key event.
       
   135         * @param aType          Type.
       
   136         * @return Response.
       
   137         */
       
   138         TKeyResponse EditL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   139 
       
   140         /**
       
   141         * This callback stores editor content in browser core.
       
   142         * @param aElement Input element.
       
   143         * @return EFalse
       
   144         */
       
   145         static TInt StoreTextL( TAny* aElement );
       
   146 
       
   147         /**
       
   148         * This callback simulates and invalidates cached key event if any.
       
   149         * @param aElement Input element.
       
   150         * @return EFalse
       
   151         */
       
   152         static TInt SimulateKeyEventL( TAny* aElement );
       
   153 
       
   154 public: // From MEikEdwinObserver
       
   155 
       
   156         /**
       
   157         * Handles edwin events.
       
   158         * @param aEdwin Source of event.
       
   159         * @param aEventType Type of event.
       
   160         */
       
   161         void HandleEdwinEventL( CEikEdwin* aEdwin, TEdwinEvent aEventType );
       
   162 
       
   163 public: // from MFocusable
       
   164 
       
   165         /**
       
   166         * Handles key events.
       
   167         * @param aKeyEvent      Key event.
       
   168         * @param aType          Type.
       
   169         * @return Response.
       
   170         */
       
   171         TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   172         
       
   173         /**
       
   174         * Handles menu events.
       
   175         * @param aCommand       Menu event.
       
   176         */
       
   177         void HandleCommandL( TInt aCommand );
       
   178 
       
   179         /**
       
   180         * At least one line must be visible.
       
   181         * @param aScrollDirection Scrolling direction.
       
   182         * @return Minimum height.
       
   183         */
       
   184         TInt HeightToBeVisible
       
   185                         ( TCursorPosition::TMovementType aScrollDirection ) const;
       
   186 
       
   187         TInt CommandSetResourceIdL();
       
   188 
       
   189         /**
       
   190         * Cancels active element (input element currently)
       
   191         */
       
   192         void DeactivateElement();
       
   193 
       
   194 public: // from CWmlRenderingElement
       
   195         
       
   196         /**
       
   197         * Handles font size settings change.
       
   198         * @return -.
       
   199         */
       
   200         void NotifyVisualChangesL();
       
   201 
       
   202         /**
       
   203         * Querries all of the data from the core.
       
   204         */
       
   205         void RefreshL();
       
   206 
       
   207         /**
       
   208         * Initalize members with default values.
       
   209         */
       
   210         void InitValuesL(CCoeControl*);
       
   211 
       
   212         /**
       
   213         * Draws the inputbox to the given gc
       
   214         * @param aGc            Graphic context.
       
   215         * @param aTopLeft       The topleft point of the drawing rectangle.
       
   216         * @param aClipRect  The clipping rectangle.
       
   217         * @param aMap           The device map (not used).
       
   218         */
       
   219         void DrawInnerRectL( CGraphicsContext& aGc,
       
   220                                                  const TPoint& aTopLeft,
       
   221                                                  const TRect& aClipRect,
       
   222                                                  MGraphicsDeviceMap* aMap ) const;
       
   223         /**
       
   224         * Border is needed?
       
   225         * @return The answer.
       
   226         */
       
   227         virtual TBool BorderIsNeeded() const;
       
   228 
       
   229         /**
       
   230         * Put on, or take off the focus.
       
   231         * @param aItemFocused The direction of the operation. True means putting on.
       
   232         * @return True means that the operation was successful.
       
   233         */
       
   234     virtual TBool SetFocusBeforeDrawBorderL(
       
   235                 TBool aItemFocused,     TCursorPosition::TMovementType aScrollDirection );
       
   236 
       
   237 
       
   238     CCoeControl* ComponentControl( TInt aIndex );
       
   239 
       
   240 
       
   241 // ---------------------------------------------GSZ from RenderingElement    
       
   242 		/*
       
   243 		*Draws the specified parts of the rendering element
       
   244 		*it calls the leaving version ( DrawL() )
       
   245 		*@param aGc the graphics context to draw to
       
   246 		*@param aTopLeft the topleft coordinate of the element on the passed GC
       
   247 		*@param aClipRect is the rectangle to draw
       
   248 		*@param aMap is the device map between the phisical and logical representation of the element
       
   249 		*/
       
   250     void Draw( CGraphicsContext& aGc,
       
   251 				   const TPoint& aTopLeft,
       
   252 				   const TRect& aClipRect,
       
   253 				   MGraphicsDeviceMap* aMap ) const;
       
   254 		
       
   255 		/**
       
   256 		* Leaving version of Draw.
       
   257 		* @see Draw
       
   258 		*/
       
   259 		void DrawL( CGraphicsContext& aGc,
       
   260 				    const TPoint& aTopLeft,
       
   261 				    const TRect& aClipRect,
       
   262 				    MGraphicsDeviceMap* aMap ) const;
       
   263 // ---------------------------------------------GSZ from RenderingElement    
       
   264 
       
   265 private:
       
   266 
       
   267     /**
       
   268     * By default EPOC constructor is private.
       
   269     */
       
   270     void ConstructL();
       
   271 
       
   272         /**
       
   273         * Shows general note. Shows plural text if aDynamic > 1, singular otherwise.
       
   274         */
       
   275         void NoteTooFewCharacterL( TInt aDynamic = 0 );
       
   276 
       
   277         /**
       
   278         * Opens or closes editor.
       
   279         * @param aOn True means enabling.
       
   280         */
       
   281         void AllowEditingL( TBool aOn = ETrue );
       
   282 
       
   283         /**
       
   284         * Updates character counter on navipane.
       
   285         * @param aVisible EFalse hides counter.
       
   286         */
       
   287         void UpdateTextCounterL( TBool aVisible = ETrue );
       
   288 
       
   289         /**
       
   290         * Resizes editor, sets cursor, and relayouts card if necessary.
       
   291         */
       
   292         void HandleTextChangeL();
       
   293 
       
   294 private:        // Data
       
   295         
       
   296         CWmlFormattedResizeableEditor* iEditor;
       
   297         TBool iOpened;
       
   298         TInt iPrevCurPos;
       
   299         TInt iMaxLength;
       
   300         TBool iEmptyOk;
       
   301         CWmlFormatHandler* iHandler;
       
   302         CIdle* iAsyncCallBack;
       
   303         TBool iConfirmed;
       
   304         TKeyEvent iCachedKeyEvent;
       
   305         TBool iCacheIsValid;
       
   306         CParaFormatLayer* iGlobalParaLayer;
       
   307         CCharFormatLayer* iGlobalCharLayer;
       
   308 
       
   309 // ---- GSZ from RenderingElement    
       
   310     		TSize iSizeInTwipsWithoutBorder;
       
   311         TGulBorder iBorder;
       
   312 
       
   313 // ---- GSZ as iNode->ApiProvider().Parent()    
       
   314         CCoeControl* iParent;
       
   315 
       
   316 };
       
   317 #endif
       
   318 
       
   319 // End of File