taskswitcher/taskswitcherui/taskswitcherapp/inc/tsappview.h
changeset 4 4d54b72983ae
child 9 f966699dea19
equal deleted inserted replaced
3:fb3763350a08 4:4d54b72983ae
       
     1 /*
       
     2 * Copyright (c) 2008 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:  appui
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef TSAPPVIEW_H
       
    20 #define TSAPPVIEW_H
       
    21 
       
    22 #include <e32base.h> 
       
    23 #include <coecntrl.h>
       
    24 #include <AknPopupFader.h>
       
    25 #include "tsdevicestate.h"
       
    26 #include "tsdatachangeobserver.h"
       
    27 #include "tseventcontrolerobserver.h"
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CAknsFrameBackgroundControlContext;
       
    31 class CTsFastSwapArea;
       
    32 class CAknPopupHeadingPane;
       
    33 class CTsEventControler;
       
    34 
       
    35 /**
       
    36  * Taskswitcher applicatio view class.
       
    37  */
       
    38 class CTsAppView : public CCoeControl, public MCoeControlObserver,
       
    39         public MTsDeviceStateObserver,
       
    40         public MAknFadedComponent,
       
    41         public MTsDataChangeObserver,
       
    42         public MTsEventControlerObserver
       
    43     {
       
    44 public:
       
    45 
       
    46     /**
       
    47      * Two-phase constructor.
       
    48      * 
       
    49      * @param aRect Area where view should draw itself.
       
    50      */
       
    51     static CTsAppView* NewL(const TRect& aRect,
       
    52             CTsDeviceState& aDeviceState);
       
    53 
       
    54     /**
       
    55      * @copydoc NewL
       
    56      */
       
    57     static CTsAppView* NewLC(const TRect& aRect,
       
    58             CTsDeviceState& aDeviceState);
       
    59 
       
    60     /**
       
    61      * Destructor.
       
    62      */
       
    63     ~CTsAppView();
       
    64 
       
    65     /**
       
    66      * Called from appui if the app came to foreground.
       
    67      */
       
    68     void HandleSwitchToForegroundEvent();
       
    69     
       
    70     /**
       
    71      * Called from appui if the app went to background.
       
    72      */
       
    73     void HandleSwitchToBackgroundEvent();
       
    74 
       
    75     /**
       
    76      * From CCoeControl      Method handling the pointer events while the fsw is used.
       
    77      *
       
    78      * @param aPointerEvent  Information about the event.
       
    79      */
       
    80     void HandlePointerEventL( const TPointerEvent &aPointerEvent );
       
    81 
       
    82 public:
       
    83     // from CCoeControl
       
    84     void Draw( const TRect& aRect ) const;
       
    85     TTypeUid::Ptr MopSupplyObject( TTypeUid aId );
       
    86     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
    87     TInt CountComponentControls() const;
       
    88     CCoeControl* ComponentControl(TInt aIndex) const;
       
    89     void SizeChanged();
       
    90     
       
    91     //Own
       
    92     /*
       
    93      * Forward app key handling to fasswaparea control.
       
    94      */
       
    95     void HandleAppKey(TInt aType);
       
    96 
       
    97 protected:
       
    98     // from MCoeControlObserver
       
    99     void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType );
       
   100 
       
   101     // from MTsDeviceStateObserver
       
   102     void HandleDeviceStateChanged( TChangeType aChangeType );
       
   103 
       
   104 protected: // from MAknFadedComponent
       
   105     TInt CountFadedComponents();
       
   106     CCoeControl* FadedComponent( TInt aIndex );
       
   107 
       
   108 protected: // from MTsCenrepChangeObserver
       
   109     void CenrepChanged( TUint32 aKey, TInt aNewValue );
       
   110 
       
   111 protected: // from MTsDataChangeObserver
       
   112     void DataChanged( CCoeControl* aWhere, TInt aNewCount );
       
   113 
       
   114 private:
       
   115 
       
   116     /**
       
   117      * @copydoc NewL
       
   118      */
       
   119     void ConstructL( const TRect& aRect );
       
   120 
       
   121     /**
       
   122      * C++ constructor.
       
   123      */
       
   124     CTsAppView( CTsDeviceState& aDeviceState );
       
   125 
       
   126     /**
       
   127      * Updates the internal state for currently focused control.
       
   128      * @param   aNewFocusedControl  ptr to new focused control, ownership not taken
       
   129      */    
       
   130     void ChangeFocus( CCoeControl* aNewFocusedControl );
       
   131     
       
   132     /**
       
   133      * Creates components.
       
   134      */
       
   135     void CreateControlsL();
       
   136     
       
   137     /**
       
   138      * Appends component rects to the given array.
       
   139      * @param   aRects  array
       
   140      */
       
   141     void GetRects( RArray<TRect>& aRects );
       
   142     
       
   143     /**
       
   144      * Handles key event according to the portrait-style (vertical) layout.
       
   145      */
       
   146     TKeyResponse OfferKeyEventPortraitStyleL( const TKeyEvent& aKeyEvent, TEventCode aType);
       
   147 
       
   148     /**
       
   149      * Calculates and returns the following:
       
   150      *   - the rectangle for main_tport_pane
       
   151      *   - the outer rectangle for the frame
       
   152      *   - the inner rectangle for the frame
       
   153      */
       
   154     void UpdatePopupRects(  );
       
   155 
       
   156     /**
       
   157      * Updates the text in the applications and suggestions heading panes.
       
   158      */
       
   159     void UpdateHeadingsL();
       
   160     
       
   161     /**
       
   162      * Disables transition animations for taskswitcher app.
       
   163      * (the automatic effects that are applied when coming/leaving foreground)
       
   164      */
       
   165     void DisableAppSwitchEffects();
       
   166     
       
   167     
       
   168 public://From MTsEventControlerObserver
       
   169     /**
       
   170      * Declare drag gesture handling.
       
   171      * @param aOffset - drag distance
       
   172      */
       
   173     virtual void MoveOffset(const TPoint& aOffset);
       
   174     
       
   175     /**
       
   176      * Declare tap gesture handling.
       
   177      * @param aPoint - tap position
       
   178      */
       
   179     virtual void TapL(const TPoint& aPoint);
       
   180     
       
   181     /**
       
   182      * Declare long tap gesture handling.
       
   183      * @param aPoint - tap position
       
   184      */
       
   185     virtual void LongTapL(const TPoint& aPoint);
       
   186     
       
   187     /**
       
   188      * 
       
   189      */
       
   190     virtual void Drag(
       
   191         const AknTouchGestureFw::MAknTouchGestureFwDragEvent& aEvent);
       
   192     
       
   193     /**
       
   194      * Declare animation stop handling
       
   195      */
       
   196     virtual void Stop();
       
   197     
       
   198     /**
       
   199      * Declare getter for view position
       
   200      */
       
   201     virtual TPoint ViewPos() const;
       
   202         
       
   203 private: // Data
       
   204 
       
   205     // Ref to container for commonly used instances
       
   206     CTsDeviceState& iDeviceState;
       
   207 
       
   208     // Background context, owned
       
   209     CAknsFrameBackgroundControlContext* iBgContext;
       
   210     
       
   211     // Fast Swap area, owned
       
   212     CTsFastSwapArea* iFastSwapArea;
       
   213 
       
   214     /**
       
   215      * Heading pane, own
       
   216      */
       
   217     CAknPopupHeadingPane* iAppsHeading;
       
   218 
       
   219     /**
       
   220      * Currently focused control, not own
       
   221      */
       
   222     CCoeControl* iFocused;
       
   223     
       
   224     /**
       
   225      * Rectangle of the control.
       
   226      */
       
   227     TRect iViewRect;
       
   228     
       
   229     /**
       
   230      * Popup fader instance.
       
   231      */
       
   232     TAknPopupFader iPopupFader;
       
   233     
       
   234     /**
       
   235      * Pointer for background image, owned
       
   236      */
       
   237     TRect iBgContextOuterRect;
       
   238     TRect iBgContextInnerRect;
       
   239     CTsEventControler* iEvtHandler; //own
       
   240     };
       
   241 
       
   242 #endif // TSAPPVIEW_H