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