textinput/peninputsplitqwerty/inc/peninputsplitqwertywindow.h
changeset 0 eb1f2e154e89
child 5 a47de9135b21
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     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:  peninput generic vkb window layout class
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef C_PENINPUTSPLITQWERTYWINDOW_H
       
    19 #define C_PENINPUTSPLITQWERTYWINDOW_H
       
    20 
       
    21 // System includes
       
    22 #include <peninputlayoutwindowext.h>
       
    23 #include <peninputuistatemgrinterface.h>
       
    24 #include <AknLayoutDef.h>
       
    25 
       
    26 // Forward declarations
       
    27 class CAknFepCtrlEventButton;
       
    28 class CAknFepCtrlDragButton;
       
    29 class CAknFepCtrlRepeatButton;
       
    30 class CAknFepCtrlCommonButton;
       
    31 class CPeninputCommonChoiceList;
       
    32 class CPeninputSplitQwertyLafMgr;
       
    33 class CPeninputSyncBitmapRotator;
       
    34 class CRepository;
       
    35 class CFepLayoutScrollableList;
       
    36 
       
    37 // Constants
       
    38 const TInt KMaxFileLength = 80;
       
    39 const TInt KMaxRangeLabelLength = 32;
       
    40 
       
    41 /**
       
    42  * class TAllRangeLabels
       
    43  */
       
    44 class TAllRangeLabels
       
    45     {
       
    46 public:
       
    47     TBuf<KMaxRangeLabelLength> iLabelNativeChar;
       
    48     TBuf<KMaxRangeLabelLength> iLabelNativeNumber;
       
    49     TBuf<KMaxRangeLabelLength> iLabelLatinChar;
       
    50     TBuf<KMaxRangeLabelLength> iLabelLatinNumber;
       
    51     TBuf<KMaxRangeLabelLength> iLabelSymbol;
       
    52     TBuf<KMaxRangeLabelLength> iLabelAccent;
       
    53     };
       
    54 
       
    55 /**
       
    56  * class CPeninputSplitQwertyWindow
       
    57  * Main window of IME Split-Qwerty 
       
    58  *
       
    59  *  @lib peninputsplitqwerty.lib
       
    60  *  @since S60 v5.0
       
    61  */
       
    62 class CPeninputSplitQwertyWindow : public CPeninputLayoutWindowExt
       
    63     {
       
    64 public:
       
    65     /**
       
    66      * Symbian constructor
       
    67      *
       
    68      * @since S60 v5.0
       
    69      * @param aUiLayout The plugin ui layout
       
    70      * @param aLayoutContext The vkb layout context
       
    71      * @return The pointer to CPeninputSplitQwertyWindow object
       
    72      */
       
    73     static CPeninputSplitQwertyWindow* NewL( CFepUiLayout* aUiLayout,
       
    74                                              MPeninputLayoutContext* aLayoutContext,
       
    75                                              MPeninputUiStateMgr* aUiStateMgr );
       
    76 
       
    77     /**
       
    78      * C++ destructor
       
    79      *
       
    80      * @since S60 v5.0
       
    81      * @return None
       
    82      */
       
    83     virtual ~CPeninputSplitQwertyWindow();
       
    84 
       
    85 public: //from base class CPeninputLayoutWindowExt
       
    86     /**
       
    87      * From CPeninputLayoutWindowExt
       
    88      * Get id of window config resource
       
    89      *
       
    90      * @since S60 v5.0
       
    91      * @return The id of window config resource
       
    92      */
       
    93     TInt GetWindowConfigResId();
       
    94 
       
    95     /**
       
    96      * From CPeninputLayoutWindowExt
       
    97      * Get id of window resource
       
    98      *
       
    99      * @since S60 v5.0
       
   100      * @return The id of window resource
       
   101      */
       
   102     TInt GetWindowResId();
       
   103 
       
   104     /**
       
   105      * From CPeninputLayoutWindowExt
       
   106      * Get resource id of numeric keymapping
       
   107      *
       
   108      * @since S60 v5.0
       
   109      * @return The id of window resource
       
   110      */
       
   111     TInt GetNumKeymappingResId();
       
   112 
       
   113     /**
       
   114      * From CPeninputLayoutWindowExt
       
   115      * Get file name of window config resource
       
   116      *
       
   117      * @since S60 v5.0
       
   118      * @param aLangID The id of language
       
   119      * @return The file name of window config resource
       
   120      */
       
   121     const TDesC& GetWindowConfigResFileName( TInt aLangID );
       
   122 
       
   123     /**
       
   124      * From CPeninputLayoutWindow
       
   125      * Get file name of window resource
       
   126      *
       
   127      * @since S60 v5.0
       
   128      * @return The file name of window resource
       
   129      */
       
   130     const TDesC& GetWindowResFileName();
       
   131 
       
   132     /**
       
   133      * From CPeninputLayoutWindowExt
       
   134      * Change unit size
       
   135      *
       
   136      * @since S60 v5.0
       
   137      * @return The window rect
       
   138      */
       
   139     const TRect ChangeUnitSize();
       
   140 
       
   141     /**
       
   142      * From CPeninputLayoutWindowExt
       
   143      * Change size of client area
       
   144      *
       
   145      * @since S60 v5.0
       
   146      * @return None
       
   147      */
       
   148     void ChangeClientSize();
       
   149 
       
   150     /**
       
   151      * From CPeninputLayoutWindowExt
       
   152      * Construct all controls specified in resource
       
   153      *
       
   154      * @since S60 v5.0
       
   155      * @return None
       
   156      */
       
   157     void CreateAllControlsL();
       
   158 
       
   159     /**
       
   160      * From CPeninputLayoutWindowExt
       
   161      * Set control fonts. Fonts info comes from resource
       
   162      *
       
   163      * @since S60 v5.0
       
   164      * @return None
       
   165      */
       
   166     void SetControlsFont();
       
   167 
       
   168     /**
       
   169      * From CPeninputLayoutWindowExt
       
   170      * Pop up choice list
       
   171      *
       
   172      * @since S60 v5.0
       
   173      * @return None
       
   174      */
       
   175     void PopupChoiceList();
       
   176 
       
   177     /**
       
   178      * From CPeninputLayoutWindowExt
       
   179      * Re-organize all controls in the assigned client area layout
       
   180      *
       
   181      * @since S60 v5.0
       
   182      * @param aClientLayoutId The id of client area layout
       
   183      * @return None
       
   184      */
       
   185     void ReorganizeControls( TInt aClientLayoutId, TBool aNeedReset );
       
   186 
       
   187     /**
       
   188      * From CPeninputLayoutWindowExt
       
   189      * Do when case changed
       
   190      *
       
   191      * @since S60 v5.0
       
   192      * @param aNewCase The new case
       
   193      * @return None
       
   194      */
       
   195     void DoCaseChange( TInt aNewCase );
       
   196 
       
   197 public:
       
   198     /**
       
   199      * From CPeninputLayoutWindowExt
       
   200      * Handle control event 
       
   201      *
       
   202      * @since S60 v5.0
       
   203      * @param aEventType The event type
       
   204      * @param aCtrl The control who sends the event
       
   205      * @param aEventData The event data
       
   206      * @return None
       
   207      */
       
   208     void HandleControlEvent( TInt aEventType, CFepUiBaseCtrl* aCtrl,
       
   209                              const TDesC& aEventData );
       
   210 
       
   211 public:
       
   212     /**
       
   213      * ConstructFromResourceL load settings from resource.
       
   214      * Before calling this function, the resource id should be set
       
   215      *
       
   216      * @since S60 v5.0
       
   217      * @return None
       
   218      */
       
   219     void ConstructFromResourceL();
       
   220 
       
   221     /**
       
   222      * Callback function to do background construction
       
   223      * 
       
   224      *
       
   225      * @since S60 v5.0
       
   226      * @return None
       
   227      */
       
   228     static TInt BackgroundTaskL( TAny* aPtr );
       
   229 
       
   230     /**
       
   231      * Set current language
       
   232      *
       
   233      * @since S60 v5.0
       
   234      * @param aLang Current language
       
   235      * @return None
       
   236      */
       
   237     void SetSwitchlistLanguage( TInt aLang );
       
   238 
       
   239     /**
       
   240      * Set current editor is secret
       
   241      *
       
   242      * @since S60 v5.0
       
   243      * @param aSecret Editor is secret
       
   244      * @return None
       
   245      */
       
   246     void SetSwitchlistSecretFlag( TBool aSecret );
       
   247 
       
   248     /**
       
   249      * Dim the arrow keys on qwerty when the editor is findpane or secret editor
       
   250      * 
       
   251      * @since S60 v5.0
       
   252      * @param aSecret Editor is secret
       
   253      * @return None
       
   254      */
       
   255     void DimArrowKeys( TBool aDimArrow );
       
   256 
       
   257     /**
       
   258      * Handle accented char event
       
   259      *
       
   260      * @since S60 v5.0
       
   261      * @param aEventType The event type
       
   262      * @param aEventData The event data
       
   263      * @param aDeadKey The DeadKey char buffer
       
   264      * @param anewCharBuf The new Accented buffer
       
   265      * @return None
       
   266      */
       
   267     TBool HandleAccentCharEvent( TInt aEventType, const TDesC& aEventData,
       
   268                                  const TDesC& aDeadKey, HBufC* anewCharBuf );
       
   269 
       
   270     /**
       
   271      * Handle virtual key latched event
       
   272      *
       
   273      * @since S60 v5.0
       
   274      * @param aEventType The event type
       
   275      * @param aCtrl The controler
       
   276      * @param aEventData Event data
       
   277      * @return None
       
   278      */
       
   279     void HandleVirtualKeyLatchedEvent( TInt aEventType, CFepUiBaseCtrl* aCtrl, 
       
   280                                        const TDesC& aEventData );
       
   281 
       
   282     /**
       
   283      * Handle virtual key up event
       
   284      *
       
   285      * @since S60 v5.0
       
   286      * @param aEventType The event type
       
   287      * @param aCtrl The controler
       
   288      * @param aEventData Event data
       
   289      * @return None
       
   290      */
       
   291     TBool HandleVirtualKeyUpEvent( TInt aEventType, CFepUiBaseCtrl* aCtrl,
       
   292                                    const TDesC& aEventData );
       
   293 
       
   294     /*
       
   295      * Set dead key
       
   296      *
       
   297      * @since S60 v5.0
       
   298      * @return None
       
   299      */
       
   300     void SetDeadKey();
       
   301 
       
   302     /**
       
   303      * Unlatch a DeadKey by the key buffer
       
   304      *
       
   305      * @since S60 v5.0
       
   306      * @param abuf The key buffer which will be unlatched
       
   307      * @return None
       
   308      */
       
   309     void UnLatchDeadKey( const TDesC& abuf = KNullDesC );
       
   310 
       
   311     /**
       
   312      * Update laf data
       
   313      * 
       
   314      * @since S60 v5.0
       
   315      * @return None
       
   316      */
       
   317     void UpdateLafData();
       
   318 
       
   319     /*
       
   320      * Load accent labels for range list
       
   321      *
       
   322      * @since S60 v5.0
       
   323      * @param aLang current language id
       
   324      * @return None
       
   325      */
       
   326     void ConstructAccentListL( TInt aLangId );
       
   327 
       
   328     /*
       
   329      * Load range labels for range list
       
   330      *
       
   331      * @since S60 v5.0
       
   332      * @param aLangId current language id
       
   333      * @return None
       
   334      */
       
   335     void ConstructRangeLabelListL( TInt aLangId );
       
   336 
       
   337     /**
       
   338      * Show or hide preview bubble
       
   339      * 
       
   340      * @since S60 v5.0
       
   341      * @param aShow ETrue if preview bubble is going to be Shown
       
   342      * @return None
       
   343      */    
       
   344     void ShowBubble( TInt aShow );
       
   345 
       
   346     /**
       
   347      * Update state of range button
       
   348      * 
       
   349      * @since S60 v5.0
       
   350      * @return None
       
   351      */
       
   352     void UpdateRangeCtrlsL();
       
   353 
       
   354     /**
       
   355      * Update layout position and size
       
   356      * 
       
   357      * @since S60 v5.0
       
   358      * @return None
       
   359      */
       
   360     void UpdateLayoutPosAndSize();
       
   361 
       
   362 
       
   363 protected: //from base class CPeninputLayoutWindowExt
       
   364     /**
       
   365      * Set laf layout type
       
   366      * 
       
   367      * @since S60 v5.0
       
   368      * @param aRows row count 
       
   369      * @param aColumns column count
       
   370      * @return None
       
   371      */
       
   372     virtual void SetLafLayOut( TInt aRows, TInt aColumns );
       
   373 
       
   374     /**
       
   375      * Create custom control
       
   376      * 
       
   377      * @since S60 v5.0
       
   378      * @return ETrue if success
       
   379      */
       
   380     virtual TBool CreateCustomControlL( TInt16 aControlId, TInt32 aImageId );
       
   381 
       
   382     /**
       
   383      * Add custom control to this group
       
   384      * 
       
   385      * @since S60 v5.0
       
   386      * @param aCtrl a control
       
   387      * @return None
       
   388      */
       
   389     virtual void AddCustomControlGroupL( CFepUiBaseCtrl* aCtrl );
       
   390 
       
   391     /**
       
   392      * Set layout size
       
   393      * 
       
   394      * @since S60 v5.0
       
   395      * @return None
       
   396      */
       
   397     void SetVkbLayoutSize();
       
   398 
       
   399 private:
       
   400     /**
       
   401      * C++ constructor
       
   402      *
       
   403      * @since S60 v5.0
       
   404      * @param aUiLayout The plugin ui layout
       
   405      * @param aLayoutContext The vkb layout context
       
   406      * @return None
       
   407      */
       
   408     CPeninputSplitQwertyWindow( CFepUiLayout* aUiLayout,
       
   409                                 MPeninputLayoutContext* aLayoutContext,
       
   410                                 MPeninputUiStateMgr* aUiStateMgr );
       
   411 
       
   412     /**
       
   413      * Symbian constructor
       
   414      * 
       
   415      * @since S60 v5.0
       
   416      * @return None
       
   417      */
       
   418     void ConstructL();
       
   419     
       
   420 private:
       
   421     /**
       
   422      * Add range bar into client area
       
   423      *
       
   424      * @since S60 v5.0
       
   425      * @return None
       
   426      */
       
   427     void AddRangeBarL();
       
   428 
       
   429     /**
       
   430      * Add button to client area
       
   431      *
       
   432      * @since S60 v5.0
       
   433      * @param aControlId The control id
       
   434      * @param aEventId The control's event id
       
   435      * @param aResId The control's resource id
       
   436      * @param aUnicode The control's unicode
       
   437      * @param aIsRepeat The TBool indicating whether the 
       
   438      *        control is repeated or not
       
   439      * @return The pointer to CAknFepCtrlEventButton object
       
   440      */
       
   441     CAknFepCtrlEventButton* AddButtonL( const TInt aControlId,
       
   442                                         const TInt aEventId, 
       
   443                                         const TInt aResId, 
       
   444                                         const TInt aUnicode = 0,
       
   445                                         const TBool aIsRepeat = EFalse );
       
   446 
       
   447     /**
       
   448      * Add popup window to display accented char list
       
   449      *
       
   450      * @since S60 v5.0
       
   451      * @return None
       
   452      */
       
   453     void AddPopupWindowL();
       
   454 
       
   455     /**
       
   456      * Reorgnize position and size of function buttons
       
   457      *
       
   458      * @since S60 v5.0
       
   459      * @return None
       
   460      */
       
   461     void ReorgnizeTitleBar();
       
   462 
       
   463     /**
       
   464      * Show range list
       
   465      *
       
   466      * @since S60 v5.0
       
   467      * @return None
       
   468      */
       
   469     void PopupRangeListL();
       
   470 
       
   471     /**
       
   472      * Get resource info of accented chars popup window
       
   473      *
       
   474      * @since S60 v5.0
       
   475      * @return None
       
   476      */
       
   477     void GetPopupWndInfoFromResL( TResourceReader reader, const TRect& aRect );
       
   478 
       
   479     /**
       
   480      * Background constructor
       
   481      *
       
   482      * @since S60 v5.0
       
   483      * @return None
       
   484      */
       
   485     void DoIdleConstructL();
       
   486 
       
   487     /**
       
   488      * Simulate raw event
       
   489      *
       
   490      * @since S60 v5.0
       
   491      * @param aScanCode scan code of key
       
   492      * @param aType event type
       
   493      * @return None
       
   494      */
       
   495     void SimulateRawEvent( TInt aScanCode, TRawEvent::TType aType );
       
   496 
       
   497     inline TBool IsRtoLLanguage( TInt aLanguage );
       
   498     inline TBool IsValidLanguage( TInt aLanguage );
       
   499 
       
   500     inline CAknFepCtrlEventButton* EventButtonCtrl( TInt aCtrlId );
       
   501     inline CAknFepCtrlCommonButton* CommonButtonCtrl( TInt aCtrlId );
       
   502     TInt IntContext( TPeninputDataType aDataIndex );
       
   503 
       
   504     /**
       
   505      * Handle size changed for range list
       
   506      *
       
   507      * @since S60 v5.0
       
   508      * @return None
       
   509      */
       
   510     void HandlePopupSizeChange();
       
   511 
       
   512     /**
       
   513      * Handle dead key event
       
   514      *
       
   515      * @since S60 v5.0
       
   516      * @param aEventType event type
       
   517      * @param aEventData event data
       
   518      * @return ETrue if event is handled
       
   519      */
       
   520     TBool HandleDeadKeyL( TInt aEventType, const TDesC& aEventData );
       
   521 
       
   522     /**
       
   523      * Handle resource of button(base on language direction)
       
   524      *
       
   525      * @since S60 v5.0
       
   526      * @param aControlId id of button control
       
   527      * @return None
       
   528      */
       
   529     void HandleButtonResOnLangDirChange( TInt aControlId );
       
   530     void HandleButtonResOnLangDirChangeL( TInt aControlId );
       
   531 
       
   532     /**
       
   533      * Handle range list event
       
   534      *
       
   535      * @since S60 v5.0
       
   536      * @return None
       
   537      */
       
   538     void HandleRangeListSelectedL( CFepUiBaseCtrl* aCtrl, const TDesC& aData );
       
   539 
       
   540 private: // Data
       
   541 
       
   542     /**
       
   543      * The vkb extenting control for vkb area
       
   544      * Not own
       
   545      */
       
   546     CPeninputVkbCtrlExt* iVkbCtrl;
       
   547 
       
   548     /**
       
   549      * button ctrl: left arrow
       
   550      * Not own
       
   551      */
       
   552     CAknFepCtrlRepeatButton* iArrowLeftButton;
       
   553 
       
   554     /**
       
   555      * button ctrl: right arrow
       
   556      * Not own
       
   557      */
       
   558     CAknFepCtrlRepeatButton* iArrowRightButton;
       
   559 
       
   560     /**
       
   561      * button ctrl: range
       
   562      * Not own
       
   563      */
       
   564     CAknFepCtrlCommonButton* iRangeButton;
       
   565 
       
   566     /**
       
   567      * Range list
       
   568      * Not own
       
   569      */
       
   570     CPeninputCommonChoiceList* iPopupWnd;
       
   571 
       
   572     /**
       
   573      * The resource file name
       
   574      */
       
   575     TBuf<KMaxFileLength> iResourceFilename;
       
   576 
       
   577     /**
       
   578      * The background bitmap of popup window
       
   579      * Not own
       
   580      */
       
   581     CFbsBitmap* iPopupWndBgImg;
       
   582 
       
   583     /**
       
   584      * The focus bitmap of popup window
       
   585      * Not own
       
   586      */
       
   587     CFbsBitmap* iPopupWndFocusImg;
       
   588 
       
   589     /**
       
   590      * The UI state manager
       
   591      * Not own
       
   592      */
       
   593     MPeninputUiStateMgr* iUiStateMgr;
       
   594 
       
   595     /**
       
   596      * Application window rect
       
   597      */
       
   598     TRect iAppWndRect;
       
   599 
       
   600     /**
       
   601      * AO for background task
       
   602      * Own
       
   603      */
       
   604     CIdle* iIdle;
       
   605 
       
   606     /**
       
   607      * Whether popup window has been initied
       
   608      */
       
   609     TBool iPopupInited;
       
   610 
       
   611     /**
       
   612      * Popup window item rect
       
   613      */
       
   614     TRect iPopupItemRect;
       
   615 
       
   616     /**
       
   617      * Choice text layout
       
   618      */
       
   619     TAknTextLineLayout iChoiceTextLayout;
       
   620 
       
   621     /**
       
   622      * Whether popup window text property has been set
       
   623      */
       
   624     TBool iPopupSet;
       
   625 
       
   626     /**
       
   627      * Array of unit size
       
   628      * Own
       
   629      */
       
   630     RArray<TSize> iUnits;
       
   631 
       
   632     /**
       
   633      * Laf data manager
       
   634      * Own
       
   635      */
       
   636     CPeninputSplitQwertyLafMgr* iLafMgr;
       
   637 
       
   638     /**
       
   639      * The new DeadKey buffer
       
   640      */
       
   641     TBuf<16> iNewDeadKeyBuf;
       
   642 
       
   643     /**
       
   644      * The old DeadKey buffer
       
   645      */
       
   646     TBuf<16> iOldDeadKeyBuf;
       
   647 
       
   648     /**
       
   649      * Window layout of preview bubble 
       
   650      */
       
   651     TAknWindowLineLayout iBubbleSize;
       
   652     
       
   653     /**
       
   654      * Text layout of preview bubble 
       
   655      */
       
   656     TAknTextLineLayout iBubbleTextLayout;
       
   657     
       
   658     /**
       
   659      * Flag for first construction
       
   660      */
       
   661     TBool iFirstConstruct;
       
   662 
       
   663     /**
       
   664      * Writing language
       
   665      */
       
   666     TInt iLanguage;
       
   667 
       
   668     /**
       
   669      * Bitmap rotator
       
   670      * Own
       
   671      */
       
   672     CPeninputSyncBitmapRotator* iBmpRotator;
       
   673 
       
   674     /**
       
   675      * Accent commonds for range list
       
   676      * Own
       
   677      */
       
   678     RArray<CFepLayoutChoiceList::SItem> iAccentCmdList;
       
   679 
       
   680     /**
       
   681      * Range labels for range list
       
   682      */
       
   683     TAllRangeLabels iRangeLabels;
       
   684 
       
   685     };
       
   686 
       
   687 inline TBool CPeninputSplitQwertyWindow::IsRtoLLanguage( TInt aLanguage )
       
   688     {
       
   689     return ( aLanguage == ELangArabic || aLanguage == ELangHebrew
       
   690             || aLanguage == ELangFarsi || aLanguage == ELangUrdu );
       
   691     }
       
   692 
       
   693 inline TBool CPeninputSplitQwertyWindow::IsValidLanguage( TInt aLanguage )
       
   694     {
       
   695     return ( aLanguage != ELangTest && aLanguage != ELangNone );
       
   696     }
       
   697 
       
   698 inline CAknFepCtrlEventButton* CPeninputSplitQwertyWindow::EventButtonCtrl(
       
   699                                                                 TInt aCtrlId )
       
   700     {
       
   701     return static_cast<CAknFepCtrlEventButton*> ( Control( aCtrlId ) );
       
   702     }
       
   703 
       
   704 inline CAknFepCtrlCommonButton* CPeninputSplitQwertyWindow::CommonButtonCtrl(
       
   705                                                                 TInt aCtrlId )
       
   706     {
       
   707     return static_cast<CAknFepCtrlCommonButton*> ( Control( aCtrlId ) );
       
   708     }
       
   709 
       
   710 #endif // C_PENINPUTSPLITQWERTYWINDOW_H