textinput/peninputcommonctrlsjp/inc/peninputjapanesepredictivewnd.h
changeset 0 eb1f2e154e89
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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:  Predictive Window
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef C_CPENINPUTJAPANESEPREDICTIVEWND_H
       
    19 #define C_CPENINPUTJAPANESEPREDICTIVEWND_H
       
    20 
       
    21 #include <eiklbo.h>
       
    22 #include <peninputlayoutpopupwnd.h>
       
    23 #include "peninputjapanesepredictivelistboxmodel.h"
       
    24                 // TypeDef:CPredictivePopupLineInfoArray,CPredictivePopupElementArray
       
    25 
       
    26 class CPeninputJapanesePredictiveListBox;
       
    27 class CTextListBoxModel;
       
    28 class CAknFepCtrlEventButton;
       
    29 
       
    30 class CPeninputJapanesePredictiveWnd: public CFepLayoutPopupWnd,
       
    31                      public MEikListBoxObserver,
       
    32                      public MEventObserver
       
    33     {
       
    34     public: // Constructors and destructor
       
    35 
       
    36     enum TPeninputUICtrlScroll
       
    37         {
       
    38         EScrollNone,
       
    39         EScrollLeft,
       
    40         EScrollRight,
       
    41         EScrollUp,
       
    42         EScrollDown
       
    43         };
       
    44         /**
       
    45         * Two-phased constructor.
       
    46         */
       
    47         IMPORT_C static CPeninputJapanesePredictiveWnd* NewL(CFepUiLayout* aUiLayout,
       
    48                                                           TInt aControlId, const CCoeControl* aParent);
       
    49 
       
    50         /**
       
    51         * Destructor.
       
    52         */
       
    53         virtual ~CPeninputJapanesePredictiveWnd();
       
    54 
       
    55         //from base control CFepUiBaseCtrl
       
    56         /**
       
    57          * From CFepUiBaseCtrl
       
    58          * Set control's rectangle
       
    59          *
       
    60          * @since S60 V4.0
       
    61          * @param aRect The new control area
       
    62          */
       
    63         IMPORT_C virtual void SetRect(const TRect& aRect);
       
    64 
       
    65         /**
       
    66          * From CFepUiBaseCtrl
       
    67          * Set control's rectangle
       
    68          *
       
    69          * @since S60 V4.0
       
    70          * @param aFlag ETrue if want to hide the control.
       
    71          */
       
    72          virtual void Hide(TBool aFlag);
       
    73 
       
    74         /**
       
    75         * set scroll up/down button
       
    76         * @since 2.6
       
    77         * @param aScrollUpBtn
       
    78         * @param aScrollDownBtn
       
    79         */
       
    80         void SetButtons(CAknFepCtrlEventButton* aScrollUpBtn, CAknFepCtrlEventButton* aScrollDownBtn);
       
    81 
       
    82         /**
       
    83         * Specify the cursor position of a pop-up list
       
    84         * @since 2.6
       
    85         * @param aItemIndex  The index of the cursor position
       
    86         */
       
    87         void SetCurrentItemIndex(TInt aItemIndex) const;
       
    88 
       
    89         /**
       
    90          * From MEventObserver
       
    91          * Handle control event
       
    92          *
       
    93          * @since S60 v3.2
       
    94          * @param aEventType The event type
       
    95          * @param aCtrl The control who sends the event
       
    96          * @param aEventData The event data
       
    97          * @return None
       
    98          */
       
    99         void HandleControlEvent( TInt aEventType,
       
   100                                      CFepUiBaseCtrl* aCtrl,
       
   101                                      const TDesC& aEventData );
       
   102 
       
   103         /**
       
   104         * From MAknFepUICtrlPredictivePaneInterface
       
   105         * Show candidate list popup window
       
   106         * @since 2.6
       
   107         * @param aItems     array of candidate list
       
   108         * @param aIndex     selecting number when displaying
       
   109         * 
       
   110         */
       
   111         void ShowPopupL(const CDesCArrayFlat* aItems, TInt aIndex);
       
   112 
       
   113         /**
       
   114         * From MAknFepUICtrlPredictivePaneInterface
       
   115         * Hide candidate list popup window
       
   116         * @since 2.6
       
   117         * @param aItems     array of candidate list
       
   118         * 
       
   119         */
       
   120         void HidePopup();
       
   121 
       
   122         /**
       
   123         * Return a selected candidate item number currently
       
   124         * @since 2.6
       
   125         */
       
   126         TInt CurrentItemIndexOfCandidate() const;
       
   127 
       
   128         /**
       
   129         * @param aData Carry information of key pressed
       
   130         * @since 2.6
       
   131         * 
       
   132         */
       
   133         void MoveTo(TPeninputUICtrlScroll aDirection);
       
   134 
       
   135         /**
       
   136         * Update Size
       
   137         * @param aWidth
       
   138         * @param aUnitWidth
       
   139         * @param aUnitHeight
       
   140         */
       
   141         void SizeChanged(TInt aWidth, TInt aUnitWidth, TInt aUnitHeight);
       
   142 
       
   143         /**
       
   144          * Get item whose region contains the point.
       
   145          *
       
   146          * @since S60 V4.0
       
   147          * @param aPoint The point position the layout
       
   148          * @return The index of choice item. -1 if no item contains
       
   149          *         the point
       
   150          */
       
   151          TInt HitTest(const TPoint& aPoint);
       
   152 
       
   153         /**
       
   154          * Handle pointer down event
       
   155          *
       
   156          * @since S60 V4.0
       
   157          * @param aPoint The point position relative the layout
       
   158          * @return The control which handles the event.
       
   159          */
       
   160         virtual CFepUiBaseCtrl* HandlePointerDownEventL(const TPoint& aPoint);
       
   161 
       
   162         /**
       
   163          * Handle pointer move event
       
   164          *
       
   165          * @since S60 V4.0
       
   166          * @param aPoint The point position relative the layout
       
   167          * @return The control which handles the event.
       
   168          */
       
   169         virtual CFepUiBaseCtrl* HandlePointerMoveEventL(const TPoint& aPoint);
       
   170 
       
   171         /**
       
   172          * Handle pointer up event
       
   173          *
       
   174          * @since S60 V4.0
       
   175          * @param aPoint The point position relative the layout
       
   176          * @return The control which handles the event.
       
   177          */
       
   178         virtual CFepUiBaseCtrl* HandlePointerUpEventL(const TPoint& aPoint);
       
   179 
       
   180         // from MEikListBoxObserver 
       
   181         virtual void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
       
   182 
       
   183         /**
       
   184         * Set linecount
       
   185         *
       
   186         */
       
   187         void SetLineCount(TInt aLineCount);
       
   188 
       
   189         /**
       
   190         * called when listbox updated
       
   191         * @param aRect  Rectangle in which the Cone framework believes drawing
       
   192         *               is needed
       
   193         */
       
   194         void ReDraw();
       
   195 
       
   196         /**
       
   197          * Cancel repeat
       
   198          *
       
   199          * @since S60 v3.2
       
   200          * @return None
       
   201          */
       
   202         void CancelRepeat();
       
   203 
       
   204         /**
       
   205         * @return  listbox control
       
   206         * @since 2.6
       
   207         */
       
   208         CPeninputJapanesePredictiveListBox* ListBox() const;
       
   209 
       
   210     /**
       
   211      * From CFepUiBaseCtrl
       
   212      * DeActivate popup window
       
   213      *
       
   214      * @since S60 V4.0
       
   215      */ 
       
   216     void OnDeActivate();
       
   217 
       
   218     protected:
       
   219 
       
   220         /**
       
   221          * Constructor.
       
   222          *
       
   223          * @since S60 V4.0
       
   224          * @param aUiLayout Ui layout who contains this control.Ownership not transferred
       
   225          * @param aControlId control Id
       
   226          */                  
       
   227         CPeninputJapanesePredictiveWnd(CFepUiLayout* aUiLayout,
       
   228                                       TInt aControlId);
       
   229 
       
   230     private:
       
   231         /**
       
   232         * Symbian 2nd phase constructor can leave.
       
   233         */
       
   234         void ConstructL(const CCoeControl* aParent);
       
   235 
       
   236         /**
       
   237         * Setup array with line information in candidate list
       
   238         * @since 2.6
       
   239         * @param aItems                     array with candidate string
       
   240         * @param aMaxDisplayWidthInPixel    maximum width in pixel
       
   241         * @param aFontId                    font id
       
   242         */
       
   243         void CreatePredictivePopupLineInfoArrayL(const CDesCArrayFlat* aItems,
       
   244                                             const TInt aMaxDisplayWidthInPixel,
       
   245                                             const TInt aFontId);
       
   246 
       
   247         /**
       
   248         * Append to array with line information
       
   249         * @since 2.6
       
   250         * @param aLineText      string to show in a line
       
   251         * @param aElementArray  array with element information
       
   252         */
       
   253         void PredictivePopupAppendLineL(const TPtr& aLineText,
       
   254                                    CPredictivePopupElementArray* aElementArray);
       
   255 
       
   256         /**
       
   257         * Create arrary with string to show in a line
       
   258         * @since 2.6
       
   259         * @param aLineArray     arrary with line information
       
   260         * @return   string array
       
   261         */
       
   262         void CreateListTextArrayL(const CPredictivePopupLineInfoArray& aLineArray);
       
   263 
       
   264         /**
       
   265         * Called by the framework to draw the control
       
   266         */
       
   267         void Draw();
       
   268 
       
   269         /**
       
   270         * called when prediction pane is not active
       
   271         */
       
   272         void ClearList();
       
   273 
       
   274         /**
       
   275         * activateButtons or disactivate
       
   276         */
       
   277         void ActivateButtons(TBool aActive) const;
       
   278 
       
   279     private:
       
   280         /**
       
   281         * listbox
       
   282         * Own
       
   283         */    
       
   284         CPeninputJapanesePredictiveListBox* iListBox;
       
   285 
       
   286         /**
       
   287         * LineInfoArray
       
   288         * Own
       
   289         */    
       
   290         CPredictivePopupLineInfoArray* iLineInfoArray;
       
   291 
       
   292         /**
       
   293         * ListTextArray
       
   294         * Own
       
   295         */    
       
   296         CDesCArrayFlat* iListTextArray;
       
   297 
       
   298         /**
       
   299         * scroll up button
       
   300         * Not Own
       
   301         */    
       
   302         CAknFepCtrlEventButton* iScrollUpBtn;
       
   303 
       
   304         /**
       
   305         * scroll down button
       
   306         * Not Own
       
   307         */    
       
   308         CAknFepCtrlEventButton* iScrollDownBtn;
       
   309 
       
   310         /**
       
   311         * The unit width
       
   312         */
       
   313         TInt iUnitWidth;
       
   314 
       
   315         /**
       
   316         * The unit height
       
   317         */
       
   318         TInt iUnitHeight;
       
   319     };
       
   320 
       
   321 #endif //C_CPENINPUTJAPANESEPREDICTIVEWND_H
       
   322 
       
   323 // End Of File