idlehomescreen/widgetmanager/inc/wmlistbox.h
branchRCL_3
changeset 83 5456b4e8b3a8
equal deleted inserted replaced
82:5f0182e07bfb 83:5456b4e8b3a8
       
     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 widget listbox for WidgetManager
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef ___WMLISTBOX_H__
       
    20 #define ___WMLISTBOX_H__
       
    21 
       
    22 // INCLUDES
       
    23 #include <eiklbi.h>
       
    24 #include <eiktxlbx.h>
       
    25 #include <eiktxlbm.h>
       
    26 #include <eikfrlb.h>
       
    27 #include <eiktxlbm.h>
       
    28 #include <aknlists.h>
       
    29 
       
    30 #include <touchfeedback.h>
       
    31 #include <touchlogicalfeedback.h>
       
    32 #include <aknlongtapdetector.h> 
       
    33 #include "wmwidgetdataobserver.h"
       
    34 #include "wmwidgetdata.h"
       
    35 #include "wmwidgetorderdata.h"
       
    36 
       
    37 // FORWARD DECLARATIONS
       
    38 class CWmListBox;
       
    39 class CWmPlugin;
       
    40 class CListBoxView;
       
    41 class CFormattedCellListBoxData;
       
    42 class CAknLongTapDetector;
       
    43 class CWmListModel;
       
    44 class CWmWidgetData;
       
    45 class CAknStylusPopUpMenu;
       
    46 class MEikMenuObserver;
       
    47 class CWmListItemDrawer;
       
    48 
       
    49 // CLASS DECLARATIONS
       
    50 
       
    51 /**
       
    52  * CWmListItemDrawer
       
    53  */
       
    54 NONSHARABLE_CLASS( CWmListItemDrawer ): public CFormattedCellListBoxItemDrawer
       
    55     {
       
    56 public:
       
    57     /** Two-phased constructor. */
       
    58     static CWmListItemDrawer* NewL(
       
    59                 CWmPlugin& aWmPlugin,
       
    60                 MTextListBoxModel* aTextListBoxModel,
       
    61                 const CFont* aFont,
       
    62                 CFormattedCellListBoxData* aFormattedCellData,
       
    63                 CWmListBox* aListBox  );
       
    64 
       
    65     /** Destructor. */
       
    66     ~CWmListItemDrawer();
       
    67     
       
    68     /** Default logo image. */
       
    69     const CFbsBitmap* DefaultLogoImage();
       
    70     /** Default logo mask. */
       
    71     const CFbsBitmap* DefaultLogoMask();
       
    72 
       
    73     /**
       
    74      * sets item height according to layout 
       
    75      */
       
    76     void UpdateItemHeight();
       
    77 
       
    78 public:
       
    79     /**
       
    80      * from CFormattedCellListBoxItemDrawer:
       
    81      * draws a single list box item
       
    82      */
       
    83     void DrawItem(
       
    84                 TInt aItemIndex, TPoint aItemRectPos, 
       
    85                 TBool aItemIsSelected, TBool aItemIsCurrent, 
       
    86                 TBool aViewIsEmphasized, TBool aViewIsDimmed ) const;
       
    87     
       
    88 private:
       
    89     /** Constructor for performing 1st stage construction */
       
    90     CWmListItemDrawer( 
       
    91                 CWmPlugin& aWmPlugin,
       
    92                 MTextListBoxModel* aTextListBoxModel,  
       
    93                 const CFont* aFont,  
       
    94                 CFormattedCellListBoxData* aFormattedCellData,
       
    95                 CWmListBox* aListBox );
       
    96 
       
    97     /** 2nd phase constructor */
       
    98     void ConstructL();
       
    99     
       
   100 private: // data members
       
   101     /** 
       
   102      * the plugin root (not owned) 
       
   103      */
       
   104     CWmPlugin& iWmPlugin;
       
   105 
       
   106     /** 
       
   107      * pointer to the list box data (not owned) 
       
   108      */
       
   109     CFormattedCellListBoxData* iCellData;
       
   110 
       
   111     /** 
       
   112      * pointer to the listbox (not owned) 
       
   113      */
       
   114     CWmListBox* iListBox;
       
   115     
       
   116     /** 
       
   117      * default logo (when widget does not have one) bitmap 
       
   118      */
       
   119     CFbsBitmap*         iDefaultLogoImage;
       
   120     
       
   121     /** 
       
   122      * default logo (when widget does not have one) mask 
       
   123      */
       
   124     CFbsBitmap*         iDefaultLogoImageMask;
       
   125     
       
   126     };
       
   127 
       
   128 
       
   129 // CLASS DECLARATIONS
       
   130 /**
       
   131  * CWmListBox
       
   132  */
       
   133 NONSHARABLE_CLASS( CWmListBox ): public CEikFormattedCellListBox,
       
   134                       public MWmWidgetDataObserver
       
   135     {
       
   136 public:
       
   137     
       
   138     /**
       
   139      * Two-phased constructor.
       
   140      */
       
   141     static CWmListBox* NewL(
       
   142             CWmPlugin& aWmPlugin,
       
   143             const TRect& aRect,
       
   144             const CCoeControl* aParent,  
       
   145             TInt aFlags = 0 );
       
   146 
       
   147     /** Destructor. */
       
   148     ~CWmListBox();
       
   149 
       
   150 public: // API for manipulating list content
       
   151     
       
   152     /** Default Logo. */
       
   153     const CFbsBitmap* DefaultLogo();
       
   154     /** Default Logo mask. */
       
   155     const CFbsBitmap* DefaultMask();
       
   156 
       
   157     /** 
       
   158      * Findbox visibility
       
   159      * 
       
   160      * @param aVisibility sets find pane visibility
       
   161      */
       
   162     inline void SetFindPaneIsVisible( TBool aVisibility );
       
   163     
       
   164     /** 
       
   165      * Currently selected item index 
       
   166      * 
       
   167      * @return return currently selected item 
       
   168      */
       
   169     TInt CurrentListBoxItemIndex();
       
   170     
       
   171     /** 
       
   172      * real index for listbox item if findbox is active 
       
   173      * 
       
   174      * @return return index from original list for currently selected item
       
   175      */
       
   176     TInt RealIndex( TInt aIndex, TBool aIgnoreSearchIndex = EFalse );
       
   177     
       
   178     /** 
       
   179      * number of items in the widget data array (also items on the list) 
       
   180      * 
       
   181      * @return count of widget data array
       
   182      */
       
   183     inline TInt WidgetDataCount();
       
   184     
       
   185     /** 
       
   186      * currently selected item
       
   187      * @return the selected item, or NULL if nothing selected
       
   188      */
       
   189     CWmWidgetData* WidgetData();
       
   190     
       
   191     /** 
       
   192      * gets an item by index 
       
   193      * 
       
   194      * @param aItemIndex index for item to return
       
   195      * @param aIgnoreSearchIndex if true will get widget from full list
       
   196      * even when search is open
       
   197      */
       
   198     CWmWidgetData& WidgetData( TInt aItemIndex, 
       
   199             TBool aIgnoreSearchIndex = EFalse );
       
   200 
       
   201     /**
       
   202      * gets the constant widget data array
       
   203      */
       
   204     inline const RWidgetDataValues& WidgetDataArray();
       
   205 
       
   206     /** 
       
   207      * inserts widget data to the model. Takes ownership of the object.
       
   208      * The widget data will appear to correct location in natural order:
       
   209      * - in previously saved position, if it has been viewed before
       
   210      *   (widget data must have a pointer to persistent widget order)
       
   211      * - in case this is a new widget, it will appear topmost
       
   212      * - in case there is no persistent widgets order or it is empty,
       
   213      *   the widget is added in alphabetical order
       
   214      * 
       
   215      * NOTE: caller must call HandleItemAdditionL() for the listbox after
       
   216      * adding all widget datas to update the listbox correctly!
       
   217      * 
       
   218      * @param aWidget Data data to add
       
   219      * @param aRedraw listbox update flag 
       
   220      */
       
   221     void AddWidgetDataL( CWmWidgetData* aWidgetData, TBool aRedraw = ETrue );
       
   222     
       
   223     /** 
       
   224      * removes widget data from given index in the model
       
   225      * The method reorganises the list model and size.
       
   226      * Drawing is still needed to update the appearance.
       
   227      * 
       
   228      * @param aItemIndex index to remove
       
   229      * */
       
   230     void RemoveWidgetData( TInt aItemIndex, TBool aIgnoreSearchIndex = EFalse );
       
   231     
       
   232     /** 
       
   233      * requests to redraw item in given index position 
       
   234      * 
       
   235      * @param aItemIndex index to redraw
       
   236      */
       
   237     void RedrawItem( TInt aItemIndex );
       
   238 
       
   239     /** sort order of widgets in the list */
       
   240     enum TSortOrder
       
   241         {
       
   242         /** sort list as it was on last run */
       
   243         EStoredOrder,
       
   244         /** sort alphabetically */
       
   245         EAlphabetical,
       
   246         /** show latest installed first */
       
   247         ELatestFirst
       
   248         };
       
   249 
       
   250     /** 
       
   251      * Sorts the listbox's visible array 
       
   252      * 
       
   253      * @param aOrder sort order
       
   254      */
       
   255     void DoSortToVisibleArray( TSortOrder aOrder );
       
   256     
       
   257     /**
       
   258      * Responds to layout switched.
       
   259      */
       
   260     void HandleLayoutChanged();
       
   261 
       
   262     /**
       
   263      * Returns size of logo 
       
   264      * 
       
   265      * @return Size of logo rect
       
   266      */
       
   267     TSize LogoSize();
       
   268 
       
   269     /**
       
   270      * gets the constant widget order data array
       
   271      */
       
   272     inline const ROrderArray& OrderDataArray();
       
   273     
       
   274     /** 
       
   275      * Sorts the order array
       
   276      * 
       
   277      * @param aOrder sort order
       
   278      */
       
   279     void DoSortToOrderData( TSortOrder aOrder );
       
   280     
       
   281     /**
       
   282      * Adds order data to array
       
   283      */
       
   284     void AddOrderDataL( CWmWidgetOrderData* aOrderData );
       
   285     
       
   286     /**
       
   287      * Returns orderdata object by index
       
   288      */
       
   289     CWmWidgetOrderData* OrderData( TInt aItemIndex );
       
   290     
       
   291     /**
       
   292      * Returns true if findpane is in use
       
   293      */
       
   294     TBool IsFindPaneIsVisible();
       
   295     
       
   296 private: // from CEikTextListBox
       
   297     /**
       
   298      * Creates the item drawer.
       
   299      * 
       
   300      * @see CEikTextListBox::CreateItemDrawerL
       
   301      */
       
   302     void CreateItemDrawerL();
       
   303 
       
   304 protected: // from base class CCoeControl
       
   305     
       
   306     /**
       
   307      * Sets the control's extent, specifying a rectangle.
       
   308      * 
       
   309      * @see CCoeControl::SizeChanged
       
   310      */
       
   311     void SizeChanged();
       
   312 
       
   313 private: // from base class CCoeControl
       
   314 
       
   315     /*
       
   316      * Draws the control.
       
   317      * 
       
   318      * @see CCoeControl::Draw
       
   319      */
       
   320     void Draw( const TRect& aRect ) const;
       
   321     
       
   322 private:
       
   323     /** Constructor for performing 1st stage construction */
       
   324     CWmListBox( CWmPlugin& aWmPlugin );
       
   325 
       
   326     /** 2nd phase constructor */
       
   327     void ConstructL(
       
   328             const TRect& aRect,
       
   329             const CCoeControl* aParent,
       
   330             TInt aFlags );
       
   331     
       
   332 private:
       
   333     /** 
       
   334      * linear order for sorting, depending on the sort type being used 
       
   335      */
       
   336     TLinearOrder<CWmWidgetData> SortOrder( TSortOrder aOrder );
       
   337     
       
   338     /** 
       
   339      * linear order for sorting, depending on the sort type being used 
       
   340      */
       
   341     TLinearOrder<CWmWidgetOrderData> SortOrderToOrderData( TSortOrder aOrder );
       
   342     
       
   343 protected: // from MWmWidgetDataObserver
       
   344 
       
   345     /** 
       
   346      * widget needs redrawing 
       
   347      * 
       
   348      * @param aWidgetData item to redraw
       
   349      */
       
   350     void HandleWidgetDataChanged( CWmWidgetData* aWidgetData );
       
   351 
       
   352 private:
       
   353 
       
   354     /** 
       
   355      * the plugin root (not owned) 
       
   356      */
       
   357     CWmPlugin&          iWmPlugin;
       
   358 
       
   359     /** 
       
   360      * array of widget data objects (the list model) 
       
   361      */
       
   362     RWidgetDataValues   iVisibleWidgetArray;
       
   363 
       
   364     /** 
       
   365      * the currently active item ADD button's rectangle, for push recognition 
       
   366      */
       
   367     TRect               iButtonRect;
       
   368 
       
   369     /** 
       
   370      * state of list box find pane 
       
   371      */
       
   372     TBool               iFindPaneIsVisible;
       
   373     
       
   374     /** size of logo rect in list item */
       
   375     TSize               iLogoSize;
       
   376     
       
   377     /** 
       
   378      * array of widget order objects
       
   379      */
       
   380     ROrderArray         iOrderDataArray;
       
   381     };
       
   382 #include "wmlistbox.inl"
       
   383 
       
   384 #endif ___WMLISTBOX_H__
       
   385 
       
   386 // End of File