textinput/peninputarc/inc/pensrvcliinc/penuicandidatewnd.h
branchRCL_3
changeset 56 8152b1f1763a
equal deleted inserted replaced
50:5a1685599b76 56:8152b1f1763a
       
     1 /*
       
     2 * Copyright (c) 2009 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 *
       
    16 */
       
    17 
       
    18 #ifndef PENUICANDIDATEWND_H
       
    19 #define PENUICANDIDATEWND_H
       
    20 
       
    21 #include <coecntrl.h>
       
    22 #include <AknsItemID.h> 
       
    23 #include <AknLayoutDef.h>
       
    24 
       
    25 class MPenUiWndEventObserver;
       
    26 
       
    27 /**
       
    28  *  The constant for max text length of 
       
    29  *  choice list item title.
       
    30  */
       
    31 const TInt KMaxItemTextLength = 100;
       
    32 
       
    33 /**
       
    34  *  CPenUiCandidateWnd
       
    35  *  
       
    36  *  CCoeControl based class used for candidate list
       
    37  * 
       
    38  */
       
    39 class CPenUiCandidateWnd : public CCoeControl
       
    40     {
       
    41 public:
       
    42    /**
       
    43     * Store LAF data for candidate list
       
    44     */
       
    45     class TPenUiCandidateLafData
       
    46         {
       
    47     public:
       
    48         TSize iItemSize;    
       
    49         TInt iHorMargin;
       
    50         TInt iVerMargin;
       
    51         TSize iNaviSize;
       
    52         TSize iNaviInnerSize;
       
    53         TAknTextLineLayout iTextLine;
       
    54         TAknTextLineLayout iPageTextLine;
       
    55         const CFont* iFont;
       
    56         };
       
    57 
       
    58     /**
       
    59      * Choice list item data structure.
       
    60      */
       
    61     class TPenUiCandidateItem
       
    62         {
       
    63     public:
       
    64         /*
       
    65          * Command of choice list item.
       
    66          */
       
    67         TInt iCommand;        
       
    68         /*
       
    69          * Title of choice list item.
       
    70          */
       
    71         TBuf<KMaxItemTextLength> iText;
       
    72         };
       
    73     
       
    74     /**
       
    75      * Two-phased constructor.
       
    76      * 
       
    77      * @since symbian^3
       
    78      * @param aServer the pointer to the owner of the control     
       
    79      * @return Pointer to CPenUiCandidateWnd's instance
       
    80      */
       
    81     static CPenUiCandidateWnd* NewL( MPenUiWndEventObserver* aObserver );
       
    82 
       
    83     /**
       
    84      * Two-phased constructor.
       
    85      * 
       
    86      * @since symbian^3
       
    87      * @param aServer the pointer to the owner of the control     
       
    88      * @return Pointer to CPenUiCandidateWnd's instance
       
    89      */
       
    90     static CPenUiCandidateWnd* NewLC( MPenUiWndEventObserver* aObserver );
       
    91     
       
    92     /**
       
    93      * Destructor
       
    94      */
       
    95     ~CPenUiCandidateWnd();
       
    96     
       
    97     /**
       
    98      * Handle raw events of pen input.
       
    99      *
       
   100      * @since Symbian^3 
       
   101      * @param aEventData The event data.
       
   102      * @return ETrue if layout has processed the event, otherwise EFalse
       
   103      */
       
   104     TBool HandleRawEventL( const TAny* aEventData ); 
       
   105 
       
   106     /**
       
   107      * Set window priority.
       
   108      *
       
   109      * @since Symbian^3     
       
   110      * @param aPriority the priority of candidate
       
   111      * @return None     
       
   112      */
       
   113     inline void SetPriority( TInt aPriority );
       
   114     
       
   115     /**
       
   116      * Set the alienment of text in candidate.
       
   117      *
       
   118      * @since Symbian^3     
       
   119      * @param aAlign The alignment to be used.
       
   120      * @return None
       
   121      */  
       
   122     inline void SetAlign( CGraphicsContext::TTextAlign aAlign );
       
   123     
       
   124     /**
       
   125      * Set the init rect used for the top-left point of candidate.
       
   126      *
       
   127      * @since Symbian^3     
       
   128      * @param aInitRect The initial rect used for the top-left position
       
   129      *                  of candidate.
       
   130      * @return None     
       
   131      */  
       
   132     inline void SetInitRect( const TRect& aInitRect );
       
   133     
       
   134     /**
       
   135      * Enable spell functionality of candidate
       
   136      *
       
   137      * @since Symbian^3     
       
   138      * @param aSpellEnabled ETrue: enable spell;
       
   139      *                      EFalse: disable spell.
       
   140      * @return None     
       
   141      */     
       
   142     inline void EnableSpell( TBool aSpellEnabled );
       
   143 
       
   144     /**
       
   145      * Enable minimal text width when calculates item width.
       
   146      *
       
   147      * @since Symbian^3     
       
   148      * @param aTextWidthEnabled ETrue: enable text line;
       
   149      *                      EFalse: disable text line.
       
   150      * @return None     
       
   151      */     
       
   152     inline void EnableTextWidth( TBool aTextWidthEnabled );
       
   153     
       
   154     /**
       
   155      * Show candidate list
       
   156      * 
       
   157      * @since Symbain^3
       
   158      * @param aItemArray, the contents to be shown
       
   159      * @param aActiveIndex, the default index
       
   160      * @return None
       
   161      */    
       
   162     void ShowCandidateListL( const CDesCArray* aItemArray, TInt aActiveIndex );
       
   163     
       
   164     /**
       
   165      * Hide candidate list
       
   166      * 
       
   167      * @since Symbian^3
       
   168      * @return None
       
   169      */        
       
   170     void HideCandidateList();
       
   171 
       
   172 // From CCoeControl    
       
   173     /**
       
   174      * Handles a change to the control's resources.
       
   175      *  
       
   176      * @since symbian^3
       
   177      * @param aType, a message UID value.
       
   178      * @return None
       
   179      */    
       
   180     void HandleResourceChange( TInt aType );
       
   181     
       
   182 private:
       
   183 
       
   184     /**
       
   185      * C++ Default Constructor 
       
   186      */
       
   187     CPenUiCandidateWnd( MPenUiWndEventObserver* aObserver );
       
   188 
       
   189     /**
       
   190      * 2nd phase constructor. 
       
   191      * 
       
   192      * @since Symbain^3
       
   193      * @return None
       
   194      */
       
   195     void ConstructL();
       
   196     
       
   197     /**
       
   198      * Set all kinds of frame ids 
       
   199      * 
       
   200      * @since Symbain^3
       
   201      * @param aBgFrId, background frame id;
       
   202      * @param aNaviFrId, normal navi button frame id;
       
   203      * @param aNaviActiveFrId, pressed navi button frame id;
       
   204      * @param aNaviDimFrId, dimmed navi button frame id;
       
   205      * @param aItemActiveFrId, heightligh item frame id; 
       
   206      * @return None
       
   207      */
       
   208     void SetImgFrId( TAknsItemID aBgFrId, 
       
   209                      TAknsItemID aNaviFrId,
       
   210                      TAknsItemID aNaviActiveFrId,
       
   211                      TAknsItemID aNaviDimFrId,                     
       
   212                      TAknsItemID aItemActiveFrId );
       
   213     
       
   214     /**
       
   215      * Construct candidate list from resource. 
       
   216      * 
       
   217      * @return None
       
   218      */    
       
   219     void ConstructFromResourceL();
       
   220     
       
   221     /**
       
   222      * Construct up / down arrow buttons from resource. 
       
   223      * 
       
   224      * @since Symbain^3
       
   225      * @param aReader: the resource reader;
       
   226      * @param aUpDown, ETrue, construct up button;
       
   227      *             EFalse, construct down button;  
       
   228      * @return None
       
   229      */  
       
   230     void ConstructPageInfoFromResourceL( TResourceReader& aReader, TBool aUpDown );
       
   231     
       
   232     
       
   233     /**
       
   234      * Read LAF data for candidate list 
       
   235      *  
       
   236      * @since Symbian^3     
       
   237      * @return None
       
   238      */    
       
   239     void ReadLafInfo();
       
   240     
       
   241     /**
       
   242      * Set size for bitmaps
       
   243      * 
       
   244      * @since Symbian^3
       
   245      * @return None
       
   246      */    
       
   247     void SetBitmapSize();
       
   248     
       
   249     /**
       
   250      * Create mask bitmap for dimmed icons 
       
   251      *  
       
   252      * @since Symbian^3
       
   253      * @param aDimmedMask, store the generated mask bitmap for dimmed icons.
       
   254      * @param aMask. the source bitmap
       
   255      * @return None
       
   256      */    
       
   257     void CreateDimmedMaskL( CFbsBitmap*& aDimmedMask,
       
   258                             const CFbsBitmap* aMask ); 
       
   259 
       
   260     /**
       
   261      * Capture all poninters of full screen when candidate list is opened. 
       
   262      * 
       
   263      * @since Symbain^3
       
   264      * @param aFlag, ETrue: capture all pointers of full screen.
       
   265      *               EFalse: don't capture all pointers of full screen.
       
   266      * @return None
       
   267      */       
       
   268     void SetCapturePointer( TBool aFlag );   
       
   269     
       
   270      /**
       
   271       * Get page info and transfer it to descritor.
       
   272       *
       
   273       * @since Symbian^3      
       
   274       * @return None.     
       
   275       */      
       
   276     void GetPageInfoBufL();
       
   277     
       
   278     /**
       
   279      * Set the text item array to candidate list
       
   280      * 
       
   281      * @since Symbian^3
       
   282      * @param aItemArray: The text item array to be shown.
       
   283      * @return None
       
   284      */        
       
   285     void SetItemArrayL( const CDesCArray* aItemArray );
       
   286     
       
   287     /**
       
   288      * Add spell item
       
   289      * 
       
   290      * @since Symbian^3
       
   291      * @return None
       
   292      */        
       
   293     void AddSpellItemL();
       
   294     
       
   295     /**
       
   296      * Calculate the displaying rect of candidate.
       
   297      * 
       
   298      * @since Symbian^3
       
   299      * @return None
       
   300      */         
       
   301     void ReCalcLayout();
       
   302     
       
   303     /**
       
   304      * Return the dynamical width for displaying text.
       
   305      * 
       
   306      * @since Symbian^3
       
   307      * @return The fittable width of candidate.
       
   308      */            
       
   309     TInt WidthToFitText(); 
       
   310     
       
   311     /**
       
   312      * Return the rect to fit the screen size.
       
   313      * 
       
   314      * @since Symbian^3
       
   315      * @param aRect: the source rect to be checked
       
   316      * @return the rect of fittable to screen size
       
   317      */            
       
   318     TRect RectToFitScreen( const TRect& aRect );
       
   319     
       
   320     /**
       
   321      * Draw each item.
       
   322      * 
       
   323      * @since Symbian^3
       
   324      * @param aGc: the pointer of window gc
       
   325      * @param aIndex: the index of the item to be drawn.
       
   326      * @return None
       
   327      */    
       
   328     void DrawItem( CWindowGc* aGc, TInt aIndex ) const;
       
   329     
       
   330     /**
       
   331      * Draw page down / up arrow button.
       
   332      * 
       
   333      * @since Symbian^3
       
   334      * @param aGc: the pointer of window gc
       
   335      * @param aUpDown: ETrue, the up arrow button,
       
   336      *                 EFalse, the down arrow button
       
   337      * @return None
       
   338      */    
       
   339     void DrawPageButton( CWindowGc* aGc, TBool aUpDown ) const;
       
   340     
       
   341     /**
       
   342      * Draw page into text.
       
   343      * 
       
   344      * @since Symbian^3
       
   345      * @param aGc: the pointer of window gc
       
   346      * @return None
       
   347      */
       
   348     void DrawPageInfo( CWindowGc* aGc ) const;
       
   349   
       
   350     /**
       
   351      * Handle pointer down event
       
   352      *
       
   353      * @since Symbian^3 
       
   354      * @param aPoint The point position relative the layout
       
   355      * @return None.
       
   356      */                                        
       
   357      void HandlePointerDownEvent(const TPoint& aPoint);
       
   358     
       
   359     /**
       
   360      * Handle pointer move event
       
   361      *
       
   362      * @since Symbian^3
       
   363      * @param aPoint The point position relative the layout
       
   364      * @return None.       
       
   365      */                  
       
   366      void HandlePointerMoveEvent(const TPoint& aPoint);
       
   367     
       
   368     /**
       
   369      * Handle pointer up event
       
   370      *
       
   371      * @since Symbian^3
       
   372      * @return None.      
       
   373      */                  
       
   374      void HandlePointerUpEventL();  
       
   375      
       
   376      /**
       
   377       * Check pointer area of pointer event 
       
   378       *
       
   379       * @param aPoint The point position relative the layout
       
   380       * @return None.     
       
   381       */                  
       
   382      void CheckPointerEvent(const TPoint& aPoint);
       
   383       
       
   384      /**
       
   385       * Return the index of pointed text item.
       
   386       *  
       
   387       * @since symbian^3
       
   388       * @param aPoint, the position of pointer down.
       
   389       * @return the index of the pointed text item.
       
   390       */    
       
   391      TInt ItemIndexByPoint( const TPoint& aPoint );
       
   392      
       
   393      /**
       
   394       * Report item selected event to ui layout
       
   395       *
       
   396       * @since Symbian^3
       
   397       * @return None.     
       
   398       */
       
   399      void ReportItemSelectedEventL();
       
   400      
       
   401      /**
       
   402       * Delete all bitmaps.
       
   403       *
       
   404       * @since Symbian^3
       
   405       * @return None.     
       
   406       */ 
       
   407      void DeleteAllBitmaps();
       
   408      
       
   409      /**
       
   410       * Handle skin change.
       
   411       *
       
   412       * @since Symbian^3
       
   413       * @return None.     
       
   414       */ 
       
   415      void HandleSkinChangeL(); 
       
   416      
       
   417  // From CCoeControl
       
   418      /**
       
   419       * Responds to changes to the size and position of the contents of this control.
       
   420       * 
       
   421       * @since Symbian^3
       
   422       * @return None
       
   423       */         
       
   424      void SizeChanged();
       
   425      
       
   426      /**
       
   427       * Draw candidate control.
       
   428       * 
       
   429       * @since Symbian^3
       
   430       * @param aRect: the rect to be drawn.
       
   431       * @return None
       
   432       */    
       
   433      void Draw( const TRect& aRect ) const;       
       
   434      
       
   435 private:
       
   436     /**
       
   437      * The alignment of text in candidate list
       
   438      *      
       
   439      */
       
   440     CGraphicsContext::TTextAlign iAlign;
       
   441     
       
   442     /**
       
   443      * The initial rect for the top-left point
       
   444      *      
       
   445      */
       
   446     TRect iInitRect;
       
   447     
       
   448     /**
       
   449      * If enabling the spell functionality
       
   450      *      
       
   451      */
       
   452     TBool iSpellEnabled;
       
   453     
       
   454     /**
       
   455      * If enabling text width
       
   456      *      
       
   457      */
       
   458     TBool iTextWidthEnabled;
       
   459 
       
   460     /**
       
   461      * Store Laf Data.
       
   462      *      
       
   463      */
       
   464     CPenUiCandidateWnd::TPenUiCandidateLafData iLafData;
       
   465     
       
   466     /**
       
   467      * Store the item list.
       
   468      *      
       
   469      */
       
   470     RPointerArray<CPenUiCandidateWnd::TPenUiCandidateItem> iItemList;
       
   471     
       
   472     /**
       
   473      * Background frame id.
       
   474      *
       
   475      */
       
   476     TAknsItemID iBgFrId;    
       
   477 
       
   478     /**
       
   479      * Hilight frame id.
       
   480      *
       
   481      */
       
   482     TAknsItemID iItemActiveFrId;
       
   483     
       
   484     /**
       
   485      * Navi buttons normal frame id.
       
   486      *
       
   487      */    
       
   488     TAknsItemID iNaviFrId;
       
   489 
       
   490     /**
       
   491      * Navi buttons pressed frame id.
       
   492      *
       
   493      */
       
   494     TAknsItemID iNaviActiveFrId;
       
   495     
       
   496     /**
       
   497      * Navi buttons dim frame id.
       
   498      *
       
   499      */    
       
   500     TAknsItemID iNaviDimFrId;
       
   501     
       
   502     /**
       
   503      * The width of text area
       
   504      *
       
   505      */
       
   506     TInt iItemWidth;
       
   507     
       
   508     /**
       
   509      * The rect of list pane
       
   510      *
       
   511      */
       
   512     TRect iListRect;
       
   513     
       
   514     /**
       
   515      * The rect of scroll pane
       
   516      *
       
   517      */
       
   518     TRect iScrollRect;
       
   519 
       
   520     /**
       
   521      * The rect of up arrow button
       
   522      *
       
   523      */
       
   524     TRect iPageUpRect;
       
   525 
       
   526     /**
       
   527      * The rect of down arrow button
       
   528      *
       
   529      */    
       
   530     TRect iPageDownRect;
       
   531     
       
   532     /**
       
   533      * The rect of each item.
       
   534      *
       
   535      */
       
   536     RArray<TRect> iItemRects;
       
   537     
       
   538     /**
       
   539      * The size of separator line.
       
   540      *
       
   541      */    
       
   542     TSize iSeparatorSize;
       
   543     
       
   544     /**
       
   545      * The index of current page.
       
   546      *
       
   547      */
       
   548     TInt iCurrentPage;
       
   549     
       
   550     /**
       
   551      * The number of total page.
       
   552      *
       
   553      */    
       
   554     TInt iTotalPages;
       
   555 
       
   556     /**
       
   557      * The index of focused item.
       
   558      *
       
   559      */ 
       
   560     TInt iFocusItem;
       
   561     
       
   562     /**
       
   563      * The text of page info
       
   564      *
       
   565      * Owned
       
   566      */     
       
   567     HBufC* iPageInfo; 
       
   568     
       
   569     /**
       
   570      * The area type of pointer 
       
   571      *
       
   572      */    
       
   573     TInt iPointerArea;
       
   574     
       
   575     /**
       
   576      * If navi buttons need to be shown
       
   577      *
       
   578      */
       
   579     TBool iNaviBtnShown;
       
   580 
       
   581     /**
       
   582      * The bitmap of page up button.
       
   583      *
       
   584      * Owned.
       
   585      */
       
   586     CFbsBitmap* iPageUpBmp;
       
   587     
       
   588     /**
       
   589      * The mask bitmap of page up button.
       
   590      *
       
   591      * Owned.
       
   592      */
       
   593     CFbsBitmap* iPageUpBmpMask;
       
   594 
       
   595     /**
       
   596      * The mask bitmap of dimmed page up button.
       
   597      *
       
   598      * Owned.
       
   599      */
       
   600     CFbsBitmap* iPageUpDimBmpMask;
       
   601     
       
   602     /**
       
   603      * The mask bitmap of dimmed page down button.
       
   604      *
       
   605      * Owned.
       
   606      */
       
   607     CFbsBitmap* iPageDownBmp;
       
   608 
       
   609     /**
       
   610      * The bitmap of page down button.
       
   611      *
       
   612      * Owned.
       
   613      */
       
   614     CFbsBitmap* iPageDownBmpMask;
       
   615     
       
   616     /**
       
   617      * The mask bitmap of page down button.
       
   618      *
       
   619      * Owned.
       
   620      */
       
   621     CFbsBitmap* iPageDownDimBmpMask;
       
   622     
       
   623     /**
       
   624      * The bitmap of separator.
       
   625      *
       
   626      * Owned.
       
   627      */
       
   628     CFbsBitmap* iSeperationBmp;
       
   629 
       
   630     /**
       
   631      * The mask bitmap of separator.
       
   632      *
       
   633      * Owned.
       
   634      */    
       
   635     CFbsBitmap* iSeperationMaskBmp;
       
   636     
       
   637     /**
       
   638      * The observer of the control
       
   639      * 
       
   640      * Now own
       
   641      */
       
   642     MPenUiWndEventObserver* iObserver;    
       
   643     };
       
   644 
       
   645 
       
   646 /**
       
   647 * Set window priority.
       
   648 */
       
   649 inline void CPenUiCandidateWnd::SetPriority( TInt aPriority )
       
   650     {
       
   651     Window().SetOrdinalPosition( 0, aPriority );    
       
   652     }
       
   653 
       
   654 /**
       
   655 * Set the alienment of text in candidate.
       
   656 */ 
       
   657 inline void CPenUiCandidateWnd::SetAlign(CGraphicsContext::TTextAlign aAlign)
       
   658     {
       
   659     iAlign = aAlign;
       
   660     }
       
   661 
       
   662 /**
       
   663 * Set the init rect used for the top-left point of candidate.
       
   664 */ 
       
   665 inline void CPenUiCandidateWnd::SetInitRect( const TRect& aInitRect )
       
   666     {
       
   667     iInitRect = aInitRect;
       
   668     }
       
   669     
       
   670 /**
       
   671 * Enable spell functionality of candidate
       
   672 */ 
       
   673 inline void CPenUiCandidateWnd::EnableSpell( TBool aSpellEnabled )
       
   674     {
       
   675     iSpellEnabled = aSpellEnabled;
       
   676     }
       
   677 
       
   678 /**
       
   679 * Enable minimal text width when calculates item width.
       
   680 */ 
       
   681 inline void CPenUiCandidateWnd::EnableTextWidth( TBool aTextWidthEnabled )
       
   682     {
       
   683     iTextWidthEnabled = aTextWidthEnabled;
       
   684     }
       
   685 
       
   686 #endif //R_RPENINPUTANIM_H
       
   687 
       
   688 // End of File