widgetmanager/inc/wmmaincontainer.h
changeset 0 f72a12da539e
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     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 * Declares main container control for Widget Manager application.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef WMMAINCONTAINER_H
       
    20 #define WMMAINCONTAINER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <e32cmn.h>
       
    24 #include <f32file.h>
       
    25 #include <coecobs.h>
       
    26 #include <coecntrl.h>
       
    27 #include <AknsUtils.h>
       
    28 #include <gulicon.h>
       
    29 #include <eiklbo.h>  // MEikListBoxObserver
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CWmPlugin;
       
    33 class CWmListBox;
       
    34 class CAknsBasicBackgroundControlContext;
       
    35 class CAknViewAppUi;
       
    36 class CAknSearchField;
       
    37 class CAknButton;
       
    38 class CCoeControl;
       
    39 class CAknSearchField;
       
    40 class CWmWidgetLoaderAo;
       
    41 
       
    42 /**
       
    43  * Container class for WmMainContainer
       
    44  * 
       
    45  * @class	CWmMainContainer WmMainContainer.h
       
    46  */
       
    47 NONSHARABLE_CLASS( CWmMainContainer ) : public CCoeControl,
       
    48                                         public MEikListBoxObserver,
       
    49                                         public MCoeControlObserver
       
    50 	{
       
    51 public: // constructors and destructor
       
    52 	
       
    53     /*
       
    54      * Two-phased constructor.
       
    55      * 
       
    56      * @param aRect container rect
       
    57      * @param aParent control base class 
       
    58      * @param aCommandObserver observers respond to user commands
       
    59      * @param aWmPlugin wm plugin
       
    60      */
       
    61 	static CWmMainContainer* NewL( 
       
    62 		const TRect& aRect, 
       
    63 		const CCoeControl* aParent,
       
    64 		MEikCommandObserver* aCommandObserver,
       
    65 		CWmPlugin& aWmPlugin );
       
    66 
       
    67     /*
       
    68      * Two-phased constructor.
       
    69      * 
       
    70      * @param aRect container rect
       
    71      * @param aParent control base class 
       
    72      * @param aCommandObserver observers respond to user commands
       
    73      * @param aWmPlugin wm plugin
       
    74      */
       
    75 	static CWmMainContainer* NewLC( 
       
    76 		const TRect& aRect, 
       
    77 		const CCoeControl* aParent, 
       
    78 		MEikCommandObserver* aCommandObserver,
       
    79 		CWmPlugin& aWmPlugin );	
       
    80 
       
    81 	 /** Destructor */
       
    82 	virtual ~CWmMainContainer();
       
    83 	
       
    84 private:
       
    85 	CWmMainContainer( CWmPlugin& aWmPlugin );
       
    86     
       
    87     void ConstructL( 
       
    88             const TRect& aRect, 
       
    89             const CCoeControl* aParent, 
       
    90             MEikCommandObserver* aCommandObserver );
       
    91 
       
    92 public: // new functions	
       
    93 
       
    94     /** 
       
    95      * @return true, if portal button is currently selected 
       
    96      */
       
    97     TBool PortalSelected();
       
    98     
       
    99     /** 
       
   100      * @return true, if a widget in list is currently selected 
       
   101      */
       
   102     TBool WidgetSelected();
       
   103     
       
   104     /** 
       
   105      * @return true, ADD command is possible
       
   106      */
       
   107     TBool CanDoAdd(); 
       
   108     
       
   109     /** 
       
   110      * @return true, if UNINSTALL command is possible
       
   111      */
       
   112     TBool CanDoUninstall();
       
   113     
       
   114     /** 
       
   115      * @return true, if LAUNCH command is possible
       
   116      */
       
   117     TBool CanDoLaunch();
       
   118 
       
   119     /**
       
   120      * @return true, if FIND command is possible
       
   121      */
       
   122     TBool CanDoFind();
       
   123     
       
   124     /**
       
   125      * @return true, if SORT command is possible
       
   126      */
       
   127     TBool CanDoSort();
       
   128     
       
   129     /**
       
   130      * @return true, if DETAILS command is possible
       
   131      */
       
   132     TBool CanDoDetails();
       
   133     
       
   134     /**
       
   135      * @return true, if HELP command is possible
       
   136      */
       
   137     TBool CanDoHelp();
       
   138     
       
   139     /** 
       
   140      * executes widget details dialog launch 
       
   141      */
       
   142     void LaunchDetailsDialogL();
       
   143 
       
   144     /** 
       
   145 	 * executes widget addition to home screen 
       
   146 	 */
       
   147 	void AddWidgetToHomeScreenL();
       
   148 	
       
   149 	/** 
       
   150 	 * executes widget launch 
       
   151 	 */
       
   152 	void LaunchWidgetL();
       
   153 	
       
   154 	/** 
       
   155 	 * executes findbox activation 
       
   156 	 */
       
   157 	void ActivateFindPaneL();
       
   158 
       
   159     /** 
       
   160 	 * executes findbox deactivation 
       
   161 	 */
       
   162     void DeactivateFindPaneL();
       
   163 	
       
   164     /** 
       
   165      * sorts the widget list in alphabetical order
       
   166      */
       
   167     void SortListAlphabeticallyL();
       
   168 
       
   169 	/** 
       
   170 	 * executes widget uninstall 
       
   171 	 */
       
   172 	void UninstallWidgetL();
       
   173 
       
   174     /**
       
   175      * opens OVI portal
       
   176      */
       
   177     void OpenOviPortalL();
       
   178 
       
   179     /**
       
   180      * Selection key (middle soft key)
       
   181      */
       
   182     void SelectL();
       
   183     
       
   184     /**
       
   185      * Show widget manager help
       
   186      */
       
   187     void ShowHelpL();
       
   188 
       
   189     /** 
       
   190      * handles situation when widget list has changed.
       
   191      * in practice reloads the widget list from the widgets API
       
   192      * and redraws the screen.
       
   193      */
       
   194 	void HandleWidgetListChanged();
       
   195 
       
   196 public:
       
   197 
       
   198     /**
       
   199      * Handles key events.
       
   200      * 
       
   201      * @see CCoeControl::OfferKeyEventL
       
   202      */
       
   203 	TKeyResponse OfferKeyEventL( 
       
   204 			const TKeyEvent& aKeyEvent, 
       
   205 			TEventCode aType );
       
   206 	
       
   207 	/**
       
   208 	 * Handles a change to the control's resources
       
   209 	 * 
       
   210 	 * @see CCoeControl::HandleResourceChange
       
   211 	 */
       
   212 	void HandleResourceChange( TInt aType );
       
   213 	
       
   214 	/**
       
   215 	 * Handles pointer events.
       
   216 	 * 
       
   217 	 * @see CCoeControl::HandlePointerEventL
       
   218 	 */
       
   219 	void HandlePointerEventL( const TPointerEvent& aPointerEvent );
       
   220 	
       
   221 	/**
       
   222 	 * returns whether adding of widget was sucessful or not 
       
   223 	 */
       
   224 	TInt ExitStatus();
       
   225    
       
   226 	/**
       
   227      * Sets the exit status to denote the failure or sucess of adding
       
   228      * widget to homescreen
       
   229      */
       
   230 	void SetExitStatus( TInt aExitStatus );
       
   231 
       
   232 	/**
       
   233 	 * Moves focus to the OVI button
       
   234 	 */
       
   235     void SetFocusToOviButton();
       
   236 
       
   237     /**
       
   238      * Moves focus to the widgets list, alternatively also setting the currently
       
   239      * selected item.
       
   240      * @param aIndex the item in widgets list to highlight during setting focus.
       
   241      *        By default the previously selected item will be highlighted.
       
   242      */
       
   243     void SetFocusToWidgetList( TInt aIndex = KErrUnknown );
       
   244 
       
   245     /*
       
   246      * Tells if user inputs should be handeled or not. If ret is EFalse wm 
       
   247      * can ignore user inputs. This is becouse closing view is async and user
       
   248      * might give some inputs before view is closed. 
       
   249      */
       
   250     TBool ClosingDown();
       
   251         
       
   252     /*
       
   253      * To set iClosingDown. See above.
       
   254      */
       
   255     void SetClosingDown( TBool aClosingDown );
       
   256     
       
   257 protected: // from base class CCoeControl
       
   258     
       
   259     /**
       
   260      * Sets the control's extent, specifying a rectangle.
       
   261      * 
       
   262      * @see CCoeControl::SizeChanged
       
   263      */
       
   264     void SizeChanged();
       
   265 
       
   266 private: // from base class CCoeControl
       
   267 
       
   268     /*
       
   269      * Draws the control.
       
   270      * 
       
   271      * @see CCoeControl::Draw
       
   272      */
       
   273     void Draw( const TRect& aRect ) const;
       
   274     
       
   275     /**
       
   276     * Suppy Mop object for control context
       
   277     * @param TTypeUid aId
       
   278     */
       
   279     TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
       
   280 
       
   281 private: // from MEikListBoxObserver
       
   282 
       
   283     /**
       
   284      * List box observer interface.
       
   285      * 
       
   286      * @see MEikListBoxObserver::HandleListBoxEventL
       
   287      */
       
   288     void HandleListBoxEventL(
       
   289                         CEikListBox* aListBox,
       
   290                         TListBoxEvent aEventType);
       
   291 
       
   292 private: // from MCoeControlObserver
       
   293 
       
   294     /**
       
   295      * Control observer interface
       
   296      * 
       
   297      * @see MCoeControlObserver::HandleControlEventL
       
   298      */
       
   299     void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
       
   300 
       
   301 private: // New functions
       
   302     
       
   303     void AddControlL( CCoeControl* aControl, TInt aControlId );
       
   304     void InitializeControlsL( const TRect& aRect );
       
   305     void LayoutControlsL();
       
   306     void StartLoadingWidgetsL();
       
   307     void RemoveCtrlsFromStack();
       
   308     TKeyResponse MoveFocusByKeys(
       
   309             const TKeyEvent& aKeyEvent, 
       
   310             TEventCode aType );
       
   311     void UpdateFocusMode();
       
   312     CCoeControl* FindChildControlByPoint( const TPoint& aPoint );
       
   313     void HandleFindSizeChanged();
       
   314 
       
   315 private:
       
   316 
       
   317     /**
       
   318      * the plugin root
       
   319      */
       
   320     CWmPlugin&              iWmPlugin;
       
   321 
       
   322     /**
       
   323      * parent control
       
   324      */
       
   325     const CCoeControl*      iParent;    
       
   326 
       
   327     /**
       
   328      * the widgets list
       
   329      */
       
   330     CWmListBox*             iWidgetsList;
       
   331 
       
   332     /**
       
   333 	 * search filed
       
   334 	 */
       
   335     CAknSearchField* 		iFindbox;
       
   336     
       
   337     /**
       
   338 	 * search filed visibility switch
       
   339 	 */
       
   340     TBool            		iFindPaneIsVisible;
       
   341     
       
   342     /**
       
   343      * background
       
   344      */
       
   345     CAknsBasicBackgroundControlContext* iBgContext;
       
   346     
       
   347     /**
       
   348      * Ovi portal
       
   349      */
       
   350     CAknButton*             iOviPortal;
       
   351 
       
   352     /** GUI layout modes */
       
   353     enum TWmLayout
       
   354         {
       
   355         EPortrait,
       
   356         ELandscape,
       
   357         ELandscapeMirrored
       
   358         };
       
   359 
       
   360     /**
       
   361      * current widget manager container layout
       
   362      */
       
   363     TWmLayout               iLayout;
       
   364 
       
   365     /** focus modes */
       
   366     enum TWmFocusMode
       
   367         {
       
   368         ENowhere,
       
   369         EOvi,
       
   370         EList,
       
   371         EFind
       
   372         };
       
   373 
       
   374     /**
       
   375      * current widget manager focus mode
       
   376      */
       
   377     TWmFocusMode            iFocusMode;
       
   378     
       
   379 	/**
       
   380      * exit variable to denote sucess or failure of adding widget to hs
       
   381      */
       
   382     TInt                    iExitStatus;
       
   383 
       
   384     /**
       
   385      * AO for loading widgets into the list UI
       
   386      */
       
   387     CWmWidgetLoaderAo*      iWidgetLoader;
       
   388     
       
   389     /**
       
   390      * If this is set to ETrue it means wmview is closing and all user inputs
       
   391      * should be ignored.
       
   392      */
       
   393     TBool                   iClosingDown;
       
   394     };
       
   395 
       
   396 #endif // WMMAINCONTAINER_H
       
   397 
       
   398 // End of File