textinput/peninputhwrtrui/inc/truishortcutscontainer.h
changeset 40 2cb9bae34d17
parent 31 f1bdd6b078d1
child 49 37f5d84451bd
equal deleted inserted replaced
31:f1bdd6b078d1 40:2cb9bae34d17
     1 /*
       
     2 * Copyright (c) 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:  CTruiShortcutsContainer class of TrainingUI
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_TRUISHORTCUTSCONTAINER_H
       
    20 #define C_TRUISHORTCUTSCONTAINER_H
       
    21 
       
    22 #include <eiklbo.h>
       
    23 #include <AknPreviewPopUpObserver.h>
       
    24 #include "truicontainerbase.h"
       
    25 
       
    26 class CEikButtonGroupContainer;
       
    27 class CAknSingleGraphicStyleListBox;
       
    28 class CTruiHwrBox;
       
    29 class CAknPreviewPopUpController;
       
    30 
       
    31 /**
       
    32  *  CTruiShortcutsContainer container control
       
    33  *  Used as the component to shortcut main view
       
    34  *
       
    35  *  @code
       
    36  *      iContainer = CTruiShortcutsContainer::NewL( ClientRect() );
       
    37  *      iContainer->SetMopParent( this );
       
    38  *      AppUi()->AddToStackL( *this, iContainer );
       
    39  *  @endcode
       
    40  *
       
    41  */
       
    42 class CTruiShortcutsContainer : public CTruiContainerBase,
       
    43                                 public MEikListBoxObserver,
       
    44                                 public MAknPreviewPopUpObserver
       
    45     {
       
    46 public:
       
    47 
       
    48     /**
       
    49      * Two-phased constructor.
       
    50      * @param aRect The rectangle that defines the control's extent. 
       
    51      *              The rectangle's origin is relative to the origin of its associated window.
       
    52      * @return Pointer to the component control
       
    53      */
       
    54     static CTruiShortcutsContainer* NewL( const TRect& aRect );
       
    55     
       
    56     /**
       
    57      * Two-phased constructor.
       
    58      * @param aRect The rectangle that defines the control's extent. 
       
    59      *              The rectangle's origin is relative to the origin of its associated window.
       
    60      * @return Pointer to the component control
       
    61      */
       
    62     static CTruiShortcutsContainer* NewLC( const TRect& aRect );
       
    63 
       
    64     /**
       
    65      * Destructor.
       
    66      */
       
    67     virtual ~CTruiShortcutsContainer();
       
    68 
       
    69     /**
       
    70      * Popup the TextSettingPage and added the new shortcut to ListBox.    
       
    71      */    
       
    72     void AddShortcutL();
       
    73     
       
    74     /**
       
    75      * Delete shortcut.    
       
    76      */
       
    77     void DeleteShortcutL();
       
    78     
       
    79     /**
       
    80      * Mark shortcut.    
       
    81      */
       
    82     void MarkShortcutL();
       
    83     
       
    84     /**
       
    85      * Unmark shortcut.    
       
    86      */
       
    87     void UnmarkShortcutL();
       
    88     
       
    89     /**
       
    90      * Return currently selected item's index.
       
    91      *
       
    92      * @return Currently selected item's index. 
       
    93      */
       
    94     TInt CurrentItemIndex();
       
    95 
       
    96     /**
       
    97      * Test if the currently selected index is marked.
       
    98      *
       
    99      * @param aSelectedIndex: Current selected item's index
       
   100      * @return ETrue if the item is marked. EFalse if it is not marked. 
       
   101      */    
       
   102     TBool IsMarked( TInt aSelectedIndex );
       
   103      
       
   104     /**
       
   105      * Return the count of being marked currently.
       
   106      *     
       
   107      * @return The count of being marked. 
       
   108      */    
       
   109     TInt MarkCount();
       
   110     
       
   111     /**
       
   112      * Edit shortcut
       
   113      * @param aOnlyEditText ETrue : Only edit shortcut text.
       
   114      *                      EFalse : Only edit shortcut model.
       
   115      */
       
   116     void EditShortcutL( TBool aOnlyEditText = EFalse );
       
   117         
       
   118     
       
   119     /**
       
   120      * Check if reset introduction
       
   121      * 
       
   122      * @return ETrue: Reset introcudtion
       
   123      *         EFalse: Do not.
       
   124      */
       
   125     TBool IsResetIntroduction();
       
   126 
       
   127     /**
       
   128      * Reset introduction
       
   129      * 
       
   130      */
       
   131     void ResetIntroductionL();
       
   132     
       
   133     /**
       
   134      * Set flag to indicate popup window being displayed.
       
   135      *
       
   136      * @param aDisplayPopupWindow ETrue : Displaying.
       
   137      *                            EFalse : Not displaying.
       
   138      */
       
   139     inline void SetDisplayPopupWindow( TBool aDisplayPopupWindow )
       
   140         {
       
   141         iDisplayPopupWindow = aDisplayPopupWindow;
       
   142         };
       
   143 
       
   144 // from MEikListBoxObserver
       
   145     /**
       
   146      * Observer callback from the listbox
       
   147      * @param aListBox  ptr to listbox that is calling the method  
       
   148      * @param aEventType  type of event; defined by MEikListBoxObserver 
       
   149      */
       
   150     void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType );
       
   151 
       
   152 // from CCoeControl
       
   153     /**
       
   154      * Handles key event.
       
   155      *
       
   156      * @param aKeyEvent The key event.
       
   157      * @param aType The type of key event: EEventKey, EEventKeyUp or EEventKeyDown. 
       
   158      *
       
   159      * @return Indicates whether or not the key event was used by this control.
       
   160      */    
       
   161     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   162                                  TEventCode aType );    
       
   163 
       
   164     /**
       
   165      *  GetHelpContext()
       
   166      *  Identify the help context so that the framework can look up
       
   167      *  the corresponding help topic
       
   168      *  @param aContext Returns the help context
       
   169      */    
       
   170     void GetHelpContext( TCoeHelpContext& aContext ) const;
       
   171            
       
   172 private:
       
   173     
       
   174    /**
       
   175     * Constructor.
       
   176     */
       
   177     CTruiShortcutsContainer();
       
   178 
       
   179    /**
       
   180     * Perform the second phase construction of a CTruiMainViewContainer object.
       
   181     *
       
   182     * @param aRect: The rectangle that defines the control's extent. 
       
   183     */
       
   184     void ConstructL( const TRect& aRect );
       
   185     
       
   186     /**
       
   187      * Create controls to be displayed in this container.
       
   188      */    
       
   189     void InitializeControlsL();       
       
   190     
       
   191     /**
       
   192      * Delete shortcut from ListBox.     
       
   193      */    
       
   194     void DeleteItemsL();
       
   195     
       
   196     /**
       
   197      * Create preview popup controller to show popup hwrbox.       
       
   198      */ 
       
   199     CAknPreviewPopUpController* CreatePopupHwrBoxL();
       
   200     
       
   201     /**
       
   202      * Popup HWR box
       
   203      * @param aPosition The position to display HWR box
       
   204      * @param aShowDelay The delay time interval before being shown.
       
   205      * @param aHideDelay The delay time interval after which to hide tooltip.     
       
   206      */ 
       
   207     void PopupHwrBoxL( const TPoint& aPosition, 
       
   208                        const TTimeIntervalMicroSeconds32& aShowDelay,
       
   209                        const TTimeIntervalMicroSeconds32& aHideDelay );        
       
   210     /**
       
   211      * Preview shortcut model in popup hwrbox.
       
   212      * @param aShortcutText The shortcut to be previewed
       
   213      */ 
       
   214     void PreviewShortcutModelL( const TDesC& aShortcutText, TInt aIndex );
       
   215                           
       
   216    /**
       
   217     * Check if need to preview shortcut and perform previewing necessarily.
       
   218     *
       
   219     * @param aIndex To stand for which item of the listbox
       
   220     * @return ETrue : Preview shortcut model. EFalse : Don't preview it.
       
   221     */    
       
   222     TBool CheckAndPreviewShortcutModelL( TInt aIndex );
       
   223     
       
   224    /**
       
   225     * Update buttons' status in toolbar.
       
   226     *
       
   227     * @param aIndex To stand for which item of the listbox.
       
   228     */
       
   229     void UpdateToolbarButtonStatus( TInt aIndex );
       
   230 
       
   231     /**
       
   232      * Create ListBox
       
   233      */
       
   234     void CreateListBoxL();
       
   235     
       
   236     /**
       
   237      * Setup text data for listbox
       
   238      */    
       
   239     void LoadTextArrayL( const CDesCArray* aTextArray );
       
   240     
       
   241     /**
       
   242      * Handle event when listbox change to another focused item.
       
   243      */
       
   244     void HandleListBoxFocusChangedL( TInt aIndex );    
       
   245 
       
   246     /**
       
   247      * Popup context menu.
       
   248      * @param aResourceId The resource Id of the context menu.
       
   249      */
       
   250     void PopupContextMenuL( TInt aResourceId );
       
   251     
       
   252     /**
       
   253      * Get position relative to screen origin for popup window.
       
   254      * @param aIndex The index of item from which pop up.
       
   255      */
       
   256     TPoint PopupWindowPosition( TInt aIndex );
       
   257        
       
   258 // from MAknPreviewPopUpObserver
       
   259     /**    
       
   260     * Called by the preview popup when an appropriate event takes place. 
       
   261     * @param aController Pointer to the sender of the event.
       
   262     * @param aEvent Event type.
       
   263     */
       
   264     void HandlePreviewPopUpEventL(
       
   265           CAknPreviewPopUpController* aController, TPreviewPopUpEvent aEvent );
       
   266 
       
   267 // from CoeControl.   
       
   268     /**     
       
   269      * Responds to changes to the size and position of the contents of this control.
       
   270      */
       
   271     void SizeChanged();
       
   272     
       
   273     /**     
       
   274      * Responds to a change in focus.
       
   275      * @param aDrawNow Contains the value that was passed to it by SetFocus().
       
   276      */
       
   277     void FocusChanged( TDrawNow aDrawNow );
       
   278     
       
   279     /**     
       
   280      * Handles pointer events.
       
   281      * @param aPointerEvent The pointer event.
       
   282      */
       
   283     void HandlePointerEventL( const TPointerEvent& aPointerEvent );
       
   284        
       
   285 private: // data
       
   286         
       
   287     /**
       
   288      * list box to display all shortcut
       
   289      * Not own
       
   290      */
       
   291     CAknSingleGraphicStyleListBox* iListBox;
       
   292     
       
   293     /**
       
   294      * Pointer to HWR box displayed in popup controller
       
   295      * Own
       
   296      */
       
   297     CTruiHwrBox* iHwrBox;
       
   298 
       
   299     /**
       
   300      * Pointer to preview popup used to show tooltip
       
   301      * Own
       
   302      */
       
   303     CAknPreviewPopUpController* iPopupController;
       
   304 
       
   305     /**
       
   306      * Check if popup preview when focus changed
       
   307      */
       
   308     TBool iDisplayPopupWindow;
       
   309     
       
   310     TUint iShortcutUnicode;
       
   311     
       
   312     /**
       
   313      * Point of pen down on item.
       
   314      */
       
   315     TPoint iPenDownPoint;
       
   316     };
       
   317 
       
   318 #endif // C_TRUISHORTCUTSCONTAINER_H
       
   319