akntabgrp.h

Go to the documentation of this file.
00001 /*
00002 * ============================================================================
00003 *  Name        : akntabgrp.h
00004 *  Part of     : UI Framework Core / AVKON
00005 *  Description : Tab control for the status pane's navigation pane.
00006 *  Version     : %version: tr1s60#26.1.1 %
00007 *
00008 *  Copyright © 2002-2008 Nokia.  All rights reserved.
00009 *  This material, including documentation and any related computer
00010 *  programs, is protected by copyright controlled by Nokia.  All
00011 *  rights are reserved.  Copying, including reproducing, storing,
00012 *  adapting or translating, any or all of this material requires the
00013 *  prior written consent of Nokia.  This material also contains
00014 *  confidential information which may not be disclosed to others
00015 *  without the prior written consent of Nokia.
00016 * ============================================================================
00017 */
00018 
00019 #ifndef AKNTABGRP_H
00020 #define AKNTABGRP_H
00021 
00022 //  INCLUDES
00023 #include <akncontrol.h>
00024 #include <coeccntx.h>
00025 #include <coecobs.h>
00026 #include <aknnavidecoratorobserver.h>
00027 #include "aknconsts.h"
00028 #include "aknutils.h"
00029 
00030 #include <avkon.mbg>
00031 
00032 
00033 // FORWARD DECLARATIONS
00034 
00035 class CEikLabel;
00036 class CEikImage;
00037 class CAknTabGroup;
00038 class CAknTabGroupExtension;
00039 class MAknTabObserver;
00040 class MAknNaviDecoratorObserver;
00041 class TAknWindowLineLayout;
00042 class CAknTabExtension;
00043 
00050 NONSHARABLE_CLASS( CAknTab ) : public CAknControl
00051     {
00052 friend class CAknTabGroup;
00053 
00054 public:
00055 
00059     enum TAknTabDataType
00060         {
00062         EAknTabNone,
00064         EAknTabText,
00066         EAknTabIcon,
00068         EAknTabTextAndIcon
00069         };
00070 
00071 public:
00072 
00076     ~CAknTab();
00077 
00086     static CAknTab* NewL( const CCoeControl& aParent,
00087                           TResourceReader& aReader );
00088 
00097     static CAknTab* NewLC( const CCoeControl& aParent,
00098                            TResourceReader& aReader );
00099 
00109     static CAknTab* NewL( TInt aId,
00110                           const CCoeControl& aParent,
00111                           const TDesC& aTabText );
00112 
00122     static CAknTab* NewLC( TInt aId,
00123                            const CCoeControl& aParent,
00124                            const TDesC& aTabText );
00125 
00137     static CAknTab* NewL( TInt aId,
00138                           const CCoeControl& aParent,
00139                           const TDesC& aTabText,
00140                           const CFbsBitmap* aTabBitmap,
00141                           const CFbsBitmap* aMask = NULL );
00142 
00154     static CAknTab* NewLC( TInt aId,
00155                            const CCoeControl& aParent,
00156                            const TDesC& aTabText,
00157                            const CFbsBitmap* aTabBitmap,
00158                            const CFbsBitmap* aMask = NULL );
00159 
00170     static CAknTab* NewL( TInt aId,
00171                           const CCoeControl& aParent,
00172                           const CFbsBitmap* aTabBitmap,
00173                           const CFbsBitmap* aMask = NULL );
00174 
00185     static CAknTab* NewLC( TInt aId,
00186                            const CCoeControl& aParent,
00187                            const CFbsBitmap* aTabBitmap,
00188                            const CFbsBitmap* aMask = NULL );
00189 
00195     void ReplaceTextL( const TDesC& aTabText );
00196 
00203     void SetActive( TBool aActive, TDrawNow aDrawNow );
00204 
00210     TBool Active() const;
00211 
00217     TInt Id() const;
00218 
00224     enum TAknTabDataType TabType() const;
00225 
00226 
00230     void SetTotalAmountOfTabs( TInt aAmount );
00231 
00237     void SetNarrowTabLayout( TBool aNarrow );
00238     
00250     void SetMultiColorMode( TBool aMultiColor );
00251     
00258     TBool MultiColorMode() const;
00259     
00264     void SetLongTabLayout( TBool aLongTab );
00265 
00266 public: // From base class @c CCoeControl.
00267 
00273     virtual TSize MinimumSize();
00274 
00281     virtual void SetDimmed( TBool aDimmed );
00282 
00290     virtual void GetColorUseListL(
00291         CArrayFix<TCoeColorUse>& aColorUseList ) const;
00292 
00293 protected: // From base class @c CCoeControl.
00294 
00299     virtual void SizeChanged();
00300 
00306     virtual TInt CountComponentControls() const;
00307 
00316     virtual CCoeControl* ComponentControl( TInt aIndex ) const;
00317 
00325     virtual void HandlePointerEventL( const TPointerEvent& aPointerEvent );
00326 
00327 private: // From base class @c CAknControl.
00328 
00329     IMPORT_C void* ExtensionInterface( TUid aInterface );
00330 
00331 private: // From base class @c CCoeControl.
00332 
00333     virtual void Draw( const TRect& aRect ) const;
00334 
00335 private:
00336 
00337     CAknTab( TInt aId );
00338 
00339     void ConstructFromResourceL( TResourceReader& aReader );
00340     
00341     void ConstructL( const TDesC& aTabText );
00342     
00343     void ConstructL( const CFbsBitmap* aTabBitmap,
00344                      const CFbsBitmap* aMask = NULL );
00345 
00346     void LoadColorBitmapL();
00347 
00353     void HandleResourceChange( TInt aType );
00354 
00355     void SizeChangedInNormalLayout();
00356     void SizeChangedInFlatLayout();
00357     void SizeChangedInNarrowLayout();
00358 
00359 private:
00360 
00361     CEikLabel* iLabel;
00362     TInt       iId;
00363     TBool      iActive;
00364 
00365     const CFbsBitmap* iBitmap;
00366     const CFbsBitmap* iBitmapMask;
00367     TAknLayoutRect    iBitmapRect;
00368 
00369     CAknTabExtension* iExtension;
00370     
00371     typedef CArrayPtrFlat<CFbsBitmap> CAknTabColorBitmapArray;
00372     CAknTabColorBitmapArray* iColorBitmaps;
00373     };
00374 
00375 
00382 class CAknTabGroup : public CAknControl,
00383                      public MCoeControlObserver,
00384                      public MCoeControlContext,
00385                      public MAknNaviDecoratorObserver
00386     {
00387 public:
00391     IMPORT_C ~CAknTabGroup();
00392 
00398     IMPORT_C static CAknTabGroup* NewL( const CCoeControl& aParent );
00399 
00405     IMPORT_C static CAknTabGroup* NewLC( const CCoeControl& aParent );
00406 
00407 public:
00408 
00416     IMPORT_C TInt AddTabL( TResourceReader& aReader );
00417 
00424     IMPORT_C void AddTabL( TInt aTabId, const TDesC& aText );
00425 
00434     IMPORT_C void AddTabL( TInt aTabId,
00435                            const TDesC& aText,
00436                            const CFbsBitmap* aTabBitmap,
00437                            const CFbsBitmap* aMask = NULL );
00438 
00446     IMPORT_C void AddTabL( TInt aTabId,
00447                            const CFbsBitmap* aTabBitmap,
00448                            const CFbsBitmap* aMask = NULL );
00455     IMPORT_C void ReplaceTabL( TResourceReader& aReader );
00456 
00463     IMPORT_C void ReplaceTabL( TInt aTabId, const TDesC& aText );
00464 
00473     IMPORT_C void ReplaceTabL( TInt aTabId,
00474                                const TDesC& aText,
00475                                const CFbsBitmap* aTabBitmap,
00476                                const CFbsBitmap* aMask = NULL );
00477 
00485     IMPORT_C void ReplaceTabL( TInt aTabId,
00486                                const CFbsBitmap* aTabBitmap,
00487                                const CFbsBitmap* aMask = NULL );
00488 
00495     IMPORT_C void ReplaceTabTextL( TInt aTabId, const TDesC& aTabText );
00496 
00502     IMPORT_C void DeleteTabL( TInt aTabId );
00503 
00509     IMPORT_C void SetActiveTabById( TInt aTabId );
00510 
00516     IMPORT_C void SetActiveTabByIndex( TInt aTabIndex );
00517 
00523     IMPORT_C TInt ActiveTabId() const;
00524 
00530     IMPORT_C TInt ActiveTabIndex() const;
00531 
00545     IMPORT_C void SetTabFixedWidthL( TInt aWidth );
00546     
00554     IMPORT_C void DimTab( TInt aTabId, TBool aDimmed );
00555     
00563     IMPORT_C virtual TBool IsTabDimmed( TInt aTabId ) const;
00564 
00572     IMPORT_C virtual TInt TabIndexFromId( TInt aTabId ) const;
00573 
00581     IMPORT_C virtual TInt TabIdFromIndex( TInt aTabIndex ) const;
00582 
00588     IMPORT_C virtual TInt TabCount() const;
00589 
00595     IMPORT_C void SetObserver( MAknTabObserver* aObserver );
00596 
00597 public: // From base class @c CCoeControl.
00598 
00604     IMPORT_C virtual TSize MinimumSize();
00605 
00614     IMPORT_C virtual TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
00615                                                   TEventCode aType );
00616 
00624     IMPORT_C virtual void GetColorUseListL(
00625         CArrayFix<TCoeColorUse>& aColorUseList ) const;
00626 
00632     void HandleResourceChange( TInt aType );
00633 
00639     IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent );
00640 
00641 public: // From base class @c MCoeControlObserver.
00642 
00649     IMPORT_C virtual void HandleControlEventL( CCoeControl* aControl,
00650                                                TCoeEvent aEventType );
00651 
00652 public: // From base class @c MCoeControlContext.
00653 
00659     IMPORT_C virtual void PrepareContext( CWindowGc& aGc ) const;
00660 
00661 public: // From base class @c MAknNaviDecoratorObserver.
00662 
00663     /*
00664     * Handles events from navi decorator parent control.
00665     *
00666     * @param  aEventID  ID of event to be handled.
00667     */
00668     IMPORT_C virtual void HandleNaviDecoratorEventL( TInt aEventID );
00669 
00670 protected: // From base class @c CCoeControl.
00671 
00675     IMPORT_C virtual void SizeChanged();
00676 
00682     IMPORT_C virtual TInt CountComponentControls() const;
00683 
00691     IMPORT_C virtual CCoeControl* ComponentControl( TInt aIndex ) const;
00692 
00698     IMPORT_C virtual void FocusChanged( TDrawNow aDrawNow );
00699 
00703     void ReverseTabOrderL();
00704     
00705 private:
00706 
00707     /*
00708     * Reserved
00709     */
00710     IMPORT_C virtual void Reserved1();
00711 
00712     /*
00713     * Reserved
00714     */
00715     IMPORT_C virtual void Reserved2();
00716 
00717     /*
00718     * Reserved
00719     */
00720     IMPORT_C virtual void Reserved3();
00721 
00722 
00723 private:
00724     IMPORT_C CAknTabGroup();
00725 
00739     TInt ConvertTabIndex(TInt aIndex) const;
00740 
00741 private: // From base class @c CCoeControl.
00742 
00743     IMPORT_C virtual void Draw( const TRect& aRect ) const;
00744 
00745 private: // From base class @c CAknControl.
00746 
00747     IMPORT_C void* ExtensionInterface( TUid aInterface );
00748     
00749 public: // New methods
00750 
00765     IMPORT_C void SetTabMultiColorMode( TInt aTabId, TBool aMultiColor );
00766 
00768     enum TDirection
00769         {
00770         ELeft,
00771         ERight
00772         };
00773 
00774 private:
00775     void ConstructL();
00776     void CommonAddTabL(CAknTab* aTab);
00777     void CommonReplaceTabL(CAknTab* aTab);
00778     void HandleTabStateChanged(CCoeControl* aControl);
00779     TInt Index(TInt aTabId) const;
00780     TBool CycleFocus(TDirection aDirection,TDrawNow aDrawNow);
00781     TInt LeftMostTabIndex() const;
00782     TInt RightMostTabIndex() const;
00783     void DrawLowerBorder(TDrawNow aDrawNow) const;
00784     void DoDrawLowerBorder() const;
00785     void ReportNavigationEvent();
00786     void LoadTabBitmapsL(TInt aNumberOfTabsShown, TBool aLongTabs);
00787     TBool TabsVisibleInCurrentLayout() const;
00788     void CurrentLayout( TAknWindowLineLayout& aLayout ) const;
00789     void InitTabGroupGraphicsL();
00790 
00791     void InitTabAnimationEventTimer();
00792     void CancelTabAnimationEventTimer();
00793     static TInt TabAnimationEvent(TAny * aPtr);
00794     void DoTabAnimationEvent();
00795 
00796     TBool NarrowTabLayoutNext();
00797     TBool NarrowTabLayout();
00798 
00799 public:
00800 
00808     void SetDecoratorLayout( TBool aNarrow );
00809 
00810 private:
00811 
00812     void SizeChangedInNormalLayout();
00813     void SizeChangedInFlatLayout();
00814     void SizeChangedInNarrowLayout();
00815     void InitTabAnimationDoubleBufferL( TBool aCreateDoubleBuffer,
00816                                         TBool aForcedDraw );
00817 
00826     static TRect ParentRect( TBool aArrowsUsed );
00827     
00839     void StartCycleAnimationL( TDirection aDirection, TInt aNewTab );
00840     
00845     void SwitchTabLayoutL();
00846 
00847 public:
00848 
00853     void SetNarrowTabLayoutL( TBool aNarrow, TBool aUseAnimation = EFalse );
00854     
00863     void SetNaviArrowsVisible( TBool aVisible );
00864 
00865 private:
00866     CArrayPtr<CAknTab>*     iTabArray;
00867     TInt                    iActiveTab;
00868     TRect                   iSpareRect;
00869 
00870     TInt                    iTabFixedWidth;
00871     TBool                   iLongTabs;
00872     TInt                    iNumberOfTabsShown;
00873     TInt                    iFirstShownTab;
00874 
00875     CFbsBitmap*             iTabBitmaps[KTabNumberOfTabBitmaps];
00876     CFbsBitmap*             iTabMaskBitmaps[KTabNumberOfTabBitmaps];
00877 
00878     TInt                    iBitmapNames[KTabNumberOfTabBitmaps];
00879     TInt                    iBitmapMaskNames[KTabNumberOfTabBitmaps];
00880     CAknTabGroupExtension*  iExtension;
00881 
00882     MAknTabObserver*        iTabObserver;
00883     TBool                   iMirrored;
00884     };
00885 
00886 #endif // AKNTABGRP_H

Copyright © Nokia Corporation 2001-2007
Back to top