calendarui/views/inc/calentodocontainer.h
branchRCL_3
changeset 30 bd7edf625bdd
equal deleted inserted replaced
29:12af337248b1 30:bd7edf625bdd
       
     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:  Container for To-Do view's controls.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef TODOCONTAINER_H
       
    20 #define TODOCONTAINER_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <aknlists.h>
       
    24 #include "calencontainer.h"
       
    25 
       
    26 //  CONSTANTS
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class CAgnTodo;
       
    30 class CCalenTodoController;
       
    31 class CEikColumnListBox;
       
    32 class TAknsItemID;
       
    33 class CAknIconArray;
       
    34 class CAknSingleGraphicHeadingStyleListBox;
       
    35 class CCalInstance;
       
    36 
       
    37 // CLASS DECLARATION
       
    38 
       
    39 /**
       
    40 *  Extended class for itemDrawer from CSingleHeadingStyleItemDrawer
       
    41 *  We need this since itemDrawer extends the DrawItem function.
       
    42 *  some extra functinalities are done in this DrawItem.
       
    43 */
       
    44 NONSHARABLE_CLASS( CCalenTodoListBoxItemDrawer ) : public CSingleHeadingStyleItemDrawer
       
    45     {
       
    46     
       
    47     public:
       
    48     CCalenTodoListBoxItemDrawer( MTextListBoxModel* aTextListBoxModel,
       
    49                                      const CFont* aFont,
       
    50                                      CColumnListBoxData* aFormattedCellData,
       
    51                                      CEikListBox* aListBox ,
       
    52                                      const RArray<TInt>& aColorUidArray);
       
    53     
       
    54     ~CCalenTodoListBoxItemDrawer();
       
    55 
       
    56     private: // from CSingleHeadingStyleItemDrawer
       
    57     void DrawItem(TInt aItemIndex, 
       
    58                   TPoint aItemRectPos, 
       
    59                   TBool aItemIsSelected, 
       
    60                   TBool aItemIsCurrent, 
       
    61                   TBool aViewIsEmphasized,
       
    62                   TBool aViewIsDimmed) const;
       
    63     
       
    64     private:
       
    65     CEikListBox* iListBox; //Not owns
       
    66     const RArray<TInt>& iColorUidArray; //Not owns
       
    67     };
       
    68 
       
    69 /**
       
    70 *  Extension class for todo listbox  ( CAknSingleGraphicHeadingStyleListBox )
       
    71 *  Only item drawer , column data and listbox view is created in this class 
       
    72 */
       
    73 NONSHARABLE_CLASS( CCalenTodoListBox ) : public CAknSingleGraphicHeadingStyleListBox
       
    74     {   
       
    75     public:
       
    76         CCalenTodoListBox(const RArray<TInt>& aColorUidArray);
       
    77     
       
    78     private: //from CAknSingleGraphicHeadingStyleListBox
       
    79         CListBoxView* MakeViewClassInstanceL();
       
    80         void CreateItemDrawerL();
       
    81         void SizeChanged();
       
    82         
       
    83     private:
       
    84         void SizeChangedL();
       
    85         
       
    86     private:
       
    87     const RArray<TInt>& iColorUidArray;//Not owns
       
    88     };
       
    89 
       
    90 /**
       
    91 *  Container base class of ToDo application.
       
    92 */
       
    93 NONSHARABLE_CLASS( CCalenTodoContainer ) : public CCalenContainer,
       
    94                                       public MEikListBoxObserver
       
    95     {
       
    96     public:     // New function
       
    97         /**
       
    98         * C++ constructor.
       
    99         */
       
   100         CCalenTodoContainer( CCalenNativeView* aView,
       
   101                              TInt& aHighlightedRowNumber,
       
   102                              TInt& aFirstEntryOnScreenIndex,
       
   103                              MCalenServices& aServices );
       
   104 
       
   105         /**
       
   106         * Destructor.
       
   107         */
       
   108         virtual ~CCalenTodoContainer();
       
   109     public:
       
   110         /**
       
   111          * Handles list box events.
       
   112          * @param aListBox   The originating list box.
       
   113          * @param aEventType A code for the event.
       
   114          */
       
   115         void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
       
   116 
       
   117     public: // New functions
       
   118         /**
       
   119         * Third phase constructor.
       
   120         */
       
   121         void ConstructImplL();
       
   122         
       
   123         /**
       
   124          * Step 1 of construction of view data.
       
   125          */
       
   126         void BeginPopulationWithInstanceViewL();
       
   127 
       
   128         /**
       
   129          * Step 2 of construction of view data.
       
   130          */
       
   131         void CompletePopulationL();
       
   132 
       
   133         /**
       
   134         * Return a focused item index.
       
   135         * @return Item index.       (>= 0)
       
   136         *         Item is empty.    (<  0)
       
   137         */
       
   138         TInt CurrentItemIndex() const;
       
   139 
       
   140         /**
       
   141         * Return pointer of controler for Agenda server.
       
   142         * @return CCalenTodoController pointer
       
   143         */
       
   144         CCalenTodoController* Controller();
       
   145 
       
   146         /**
       
   147         * Set current item index.
       
   148         * @param aIndex Item index
       
   149         */
       
   150         void SetCurrentItemIndex(TInt aIndex);
       
   151 
       
   152         /**
       
   153         * Return list box pointer.
       
   154         * @return List box pointer.
       
   155         */
       
   156         CEikColumnListBox* ListBox() const;
       
   157 
       
   158         /**
       
   159         * Return marked count of list box.
       
   160         * @return Marked count.
       
   161         */
       
   162         TInt MarkedCount();
       
   163 
       
   164         /**
       
   165          * @param aMark Select to mark or unmark.
       
   166          **/
       
   167         void MarkAllL(TBool aMark);
       
   168 
       
   169         /**
       
   170          * @param aMark Select to mark or unmark.
       
   171          **/
       
   172         void MarkCurrentL(TBool aMark);
       
   173 
       
   174         /**
       
   175          * Checks if currently focused item is selected(marked).
       
   176          **/
       
   177         TBool IsCurrentItemSelected(void);
       
   178         
       
   179         /**
       
   180          * Checks if view is empty or not
       
   181          * @return ETrue if view is empty.
       
   182          **/
       
   183         TBool IsEmptyView() const;
       
   184         
       
   185         /**
       
   186         * Get the available preview pane rect for this container
       
   187         */
       
   188         TRect PreviewRectL();
       
   189 
       
   190 
       
   191         /**
       
   192          * From CCalenContainer
       
   193          */
       
   194         void HandleNaviDecoratorEventL(TInt aDirection);
       
   195         
       
   196         void HandleLongTapEventL( const TPoint& aPenEventLocation, 
       
   197                                   const TPoint& aPenEventScreenLocation );
       
   198 
       
   199     private: // New functions
       
   200         /**
       
   201         * Set current item index and draw list.
       
   202         */
       
   203         void SetCurrentItemIndexAndDraw();
       
   204 
       
   205         /**
       
   206         * Prepare setting index of current item.
       
   207         */
       
   208         //void PrepareSetCurrentItemIndexL();
       
   209 
       
   210         /**
       
   211         * Create all item data and draw for list box.
       
   212         */
       
   213         void CreateEntryItertorL();
       
   214 
       
   215         /**
       
   216         * Make a list data of ToDo list.
       
   217         * @param aInstance Agenda instance pointer
       
   218         * @param aPtr List data pointer
       
   219         */
       
   220         void MakeListDataL(CCalInstance* aInstance, TPtr& aPtr);
       
   221 
       
   222         /**
       
   223         * Create skinable icons.
       
   224         * 
       
   225         */
       
   226         void CreateAndAppendIconL( const TAknsItemID& aID,
       
   227                                    const TDesC& aFileName,
       
   228                                    const TInt aBitmapId,
       
   229                                    const TInt aMaskId,
       
   230                                    CAknIconArray* aIconList);
       
   231 
       
   232         /**
       
   233         * Replace a white space character in text buffer
       
   234         * by blank character (" ").
       
   235         * @param aBuf Text buffer
       
   236         */
       
   237         void ReplaceToWhiteSpace(TDes& aBuf);
       
   238 
       
   239         /**
       
   240          * Sets the correct highlight, based on the context.
       
   241          */
       
   242         void SetHighlightingL();
       
   243 
       
   244     private: // Functions from base classes
       
   245         /**
       
   246         * From CCoeControl, child control was resized.
       
   247         */
       
   248         void SizeChanged();
       
   249 
       
   250         /**
       
   251         * From CCoeControl, return child control count.
       
   252         * @return Control count
       
   253         */
       
   254         TInt CountComponentControls() const;
       
   255 
       
   256         /**
       
   257         * From CCoeControl, return child control pointer.
       
   258         * @param aIndex Child control index
       
   259         * @return Child control pointer.
       
   260         */
       
   261         CCoeControl* ComponentControl(TInt aIndex) const;
       
   262 
       
   263         /**
       
   264         * From CCoeControl, process key event.
       
   265         * @param aKeyEvent The key event.
       
   266         * @param aType EEventKey | EEventKeyUp | EEventKeyDown.
       
   267         * @return EKeyWasNotConsumed : Key event was not consumed.
       
   268         */
       
   269         TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,
       
   270                                     TEventCode aType);
       
   271 
       
   272 
       
   273         /**
       
   274          * From CCoeControl, process pointer event.
       
   275          */
       
   276         void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
   277 
       
   278         void Draw(const TRect& /*aRect*/) const;
       
   279 
       
   280         /**
       
   281          * Pass skin information if needed
       
   282          */
       
   283         TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
       
   284 
       
   285 
       
   286 
       
   287         /**
       
   288         * From CCoeControl, Get help context.
       
   289         * @param aContext Help context
       
   290         */
       
   291         void GetHelpContext(TCoeHelpContext& aContext) const;
       
   292 
       
   293         /**
       
   294         * From MActiveStep, reflesh ToDo data.
       
   295         */
       
   296         TInt DoStepL();
       
   297 
       
   298         /**
       
   299          * From CCoeControl Handles a resource relative event
       
   300          * 
       
   301          * @param aType The type of change.
       
   302          */
       
   303         void HandleResourceChange(TInt aType);
       
   304 
       
   305     public: // From CCalenContainer
       
   306         /**
       
   307          * This methods is called after calendar settings have changed.
       
   308          * See day, week and month container for implementation.
       
   309          */
       
   310         void UpdateSize();
       
   311 
       
   312         /**
       
   313          * Handle focus events 
       
   314          */
       
   315         void FocusChanged(TDrawNow aDrawNow);
       
   316 
       
   317         /**
       
   318         * Calling this will force to resource change to happen
       
   319         * We will use the last requested resource change type.
       
   320         */
       
   321         void ForceResourceChange();
       
   322         
       
   323         /**
       
   324          * Create icon index
       
   325          */
       
   326         void CreateIconIndicesL( RArray<MCalenServices::TCalenIcons>& aIndexArray );
       
   327         
       
   328         void CleanupInstances();
       
   329         
       
   330     private:
       
   331         
       
   332         /*
       
   333          * @brief Find calendarinfo object based on calendar name
       
   334          * 
       
   335          * @param aName calendar filename
       
   336          * @param aCalendarInfo referance for calendarinfo
       
   337          * @return TBool find status
       
   338          */
       
   339         static TBool CalendarInfoIdentifierL(const HBufC* aName,
       
   340                 const CCalCalendarInfo& aCalendarInfo);
       
   341 
       
   342     protected:  // Data
       
   343         CCalenTodoController* iController;
       
   344 
       
   345     private:    // Data
       
   346         CAknSingleGraphicHeadingStyleListBox* iListBox;
       
   347         //CCalenTodoListBox* iListBox;
       
   348 //        TInt iForceCurrentIndex;
       
   349         CDesCArrayFlat* iDesArray;
       
   350         
       
   351         RArray<TInt> iColorUidArray;
       
   352 
       
   353         enum TStepPopulate
       
   354             {
       
   355             ENothingDone,
       
   356             EPopulationDone,
       
   357             EDone
       
   358             };
       
   359 
       
   360         TStepPopulate iStepState;
       
   361         //HBufC* iEmptyListText;
       
   362         // view specific data, references to view data
       
   363         TInt& iHighlightedRowNumber;     // The row number highlighted.
       
   364         TInt& iFirstEntryOnScreenIndex;  // The offset of the topmost item on screen to the first entry.
       
   365     };
       
   366 
       
   367 #endif // TODOCONTAINER_H
       
   368 
       
   369 
       
   370 // End of File