00001 /* 00002 * ============================================================================== 00003 * Name : akntabgrp.h 00004 * Part of : AVKON 00005 * Interface : ?Interface_category, ?Interface_name 00006 * Description : Implements tab control to the status 00007 pane's navigation pane. 00008 * Version : ?Version 00009 * 00010 * Copyright © 2002-2004 Nokia. All rights reserved. 00011 * This material, including documentation and any related 00012 * computer programs, is protected by copyright controlled by 00013 * Nokia. All rights are reserved. Copying, including 00014 * reproducing, storing, adapting or translating, any 00015 * or all of this material requires the prior written consent of 00016 * Nokia. This material also contains confidential 00017 * information which may not be disclosed to others without the 00018 * prior written consent of Nokia. 00019 * ============================================================================== 00020 */ 00021 00022 00023 #ifndef AKNTABGRP_H 00024 #define AKNTABGRP_H 00025 00026 // INCLUDES 00027 #include <AknControl.h> 00028 #include <coeccntx.h> 00029 #include <coecobs.h> 00030 #include <aknnavidecoratorobserver.h> 00031 #include "aknconsts.h" 00032 #include "aknutils.h" 00033 00034 #include <avkon.mbg> 00035 00036 00037 // FORWARD DECLARATIONS 00038 00039 class CEikLabel; 00040 class CEikImage; 00041 class CAknTabGroup; 00042 class CAknTabGroupExtension; 00043 class MAknTabObserver; 00044 class MAknNaviDecoratorObserver; 00045 class TAknWindowLineLayout; 00046 class CAknTabExtension; 00052 NONSHARABLE_CLASS(CAknTab) : public CAknControl 00053 { 00054 friend class CAknTabGroup; 00055 00056 public: 00060 enum TAknTabDataType 00061 { 00063 EAknTabNone, 00065 EAknTabText, 00067 EAknTabIcon, 00069 EAknTabTextAndIcon 00070 }; 00071 00072 public: 00076 ~CAknTab(); 00077 00084 static CAknTab* NewL(const CCoeControl& aParent,TResourceReader& aReader); 00085 00092 static CAknTab* NewLC(const CCoeControl& aParent,TResourceReader& aReader); 00093 00101 static CAknTab* NewL(TInt aId,const CCoeControl& aParent,const TDesC& aTabText); 00102 00110 static CAknTab* NewLC(TInt aId,const CCoeControl& aParent,const TDesC& aTabText); 00111 00121 static CAknTab* NewL(TInt aId,const CCoeControl& aParent,const TDesC& aTabText, 00122 const CFbsBitmap* aTabBitmap,const CFbsBitmap* aMask = NULL); 00123 00133 static CAknTab* NewLC(TInt aId,const CCoeControl& aParent,const TDesC& aTabText, 00134 const CFbsBitmap* aTabBitmap,const CFbsBitmap* aMask = NULL); 00135 00144 static CAknTab* NewL(TInt aId,const CCoeControl& aParent,const CFbsBitmap* aTabBitmap, 00145 const CFbsBitmap* aMask = NULL); 00146 00155 static CAknTab* NewLC(TInt aId,const CCoeControl& aParent,const CFbsBitmap* aTabBitmap, 00156 const CFbsBitmap* aMask = NULL); 00157 00162 void ReplaceTextL(const TDesC& aTabText); 00163 00169 void SetActive(TBool aActive,TDrawNow aDrawNow); 00170 00175 TBool Active() const; 00176 00181 TInt Id() const; 00182 00187 enum TAknTabDataType TabType() const; 00188 00189 00193 void SetTotalAmountOfTabs(TInt aAmount); 00194 00200 void SetNarrowTabLayout(TBool aNarrow); 00201 00202 public: // from CCoeControl 00203 00208 virtual TSize MinimumSize(); 00209 00215 virtual void SetDimmed(TBool aDimmed); 00216 00223 virtual void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const; 00224 00225 protected: // from CCoeControl 00226 00231 virtual void SizeChanged(); 00232 00237 virtual TInt CountComponentControls() const; 00238 00245 virtual CCoeControl* ComponentControl(TInt aIndex) const; 00246 00252 virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent); 00253 00254 private: 00258 IMPORT_C void* ExtensionInterface( TUid aInterface ); 00259 00260 private: 00261 virtual void Draw(const TRect& aRect) const; 00262 00263 private: 00264 CAknTab(TInt aId); 00265 00266 void ConstructFromResourceL(TResourceReader& aReader); 00267 void ConstructL(const TDesC& aTabText); 00268 void ConstructL(const CFbsBitmap* aTabBitmap,const CFbsBitmap* aMask = NULL); 00269 00270 void LoadColorBitmapL(); 00271 00277 void HandleResourceChange( TInt aType ); 00278 00279 void SizeChangedInNormalLayout(); 00280 void SizeChangedInFlatLayout(); 00281 void SizeChangedInNarrowLayout(); 00282 00283 private: 00284 CEikLabel* iLabel; 00285 TInt iId; 00286 TBool iActive; 00287 00288 const CFbsBitmap* iBitmap; 00289 const CFbsBitmap* iBitmapMask; 00290 TAknLayoutRect iBitmapRect; 00291 00292 CAknTabExtension* iExtension; 00293 typedef CArrayPtrFlat<CFbsBitmap> CAknTabColorBitmapArray; 00294 CAknTabColorBitmapArray* iColorBitmaps; 00295 }; 00296 00297 00301 class CAknTabGroup : public CAknControl, public MCoeControlObserver, public MCoeControlContext, public MAknNaviDecoratorObserver 00302 { 00303 public: 00307 IMPORT_C ~CAknTabGroup(); 00308 00314 IMPORT_C static CAknTabGroup* NewL(const CCoeControl& aParent); 00315 00321 IMPORT_C static CAknTabGroup* NewLC(const CCoeControl& aParent); 00322 00323 public: 00330 IMPORT_C TInt AddTabL(TResourceReader& aReader); 00331 00338 IMPORT_C void AddTabL(TInt aTabId, const TDesC& aText); 00339 00348 IMPORT_C void AddTabL(TInt aTabId, const TDesC& aText, const CFbsBitmap* aTabBitmap, 00349 const CFbsBitmap* aMask = NULL); 00350 00358 IMPORT_C void AddTabL(TInt aTabId, const CFbsBitmap* aTabBitmap, 00359 const CFbsBitmap* aMask = NULL); 00365 IMPORT_C void ReplaceTabL(TResourceReader& aReader); 00366 00373 IMPORT_C void ReplaceTabL(TInt aTabId, const TDesC& aText); 00374 00383 IMPORT_C void ReplaceTabL(TInt aTabId, const TDesC& aText, const CFbsBitmap* aTabBitmap, 00384 const CFbsBitmap* aMask = NULL); 00385 00393 IMPORT_C void ReplaceTabL(TInt aTabId, const CFbsBitmap* aTabBitmap, 00394 const CFbsBitmap* aMask = NULL); 00395 00402 IMPORT_C void ReplaceTabTextL(TInt aTabId, const TDesC& aTabText); 00403 00409 IMPORT_C void DeleteTabL(TInt aTabId); 00410 00416 IMPORT_C void SetActiveTabById(TInt aTabId); 00417 00423 IMPORT_C void SetActiveTabByIndex(TInt aTabIndex); 00424 00430 IMPORT_C TInt ActiveTabId() const; 00431 00437 IMPORT_C TInt ActiveTabIndex() const; 00438 00447 IMPORT_C void SetTabFixedWidthL(TInt aWidth); 00448 00449 IMPORT_C void DimTab(TInt aTabId,TBool aDimmed); 00450 00451 IMPORT_C virtual TBool IsTabDimmed(TInt aTabId) const; 00452 00459 IMPORT_C virtual TInt TabIndexFromId(TInt aTabId) const; 00460 00467 IMPORT_C virtual TInt TabIdFromIndex(TInt aTabIndex) const; 00468 00474 IMPORT_C virtual TInt TabCount() const; 00475 00481 IMPORT_C void SetObserver(MAknTabObserver* aObserver); 00482 00483 public: // from CCoeControl 00484 00490 IMPORT_C virtual TSize MinimumSize(); 00491 00498 IMPORT_C virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); 00499 00504 IMPORT_C virtual void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const; 00505 00509 void HandleResourceChange(TInt aType); 00510 00516 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); 00517 00518 public: // from MCoeControlObserver 00519 00525 IMPORT_C virtual void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType); 00526 00527 public: // from MCoeControlContext 00528 00534 IMPORT_C virtual void PrepareContext(CWindowGc& aGc) const; 00535 00536 public: 00537 /* 00538 * From MAknNaviDecoratorObserver 00539 * Handles events from NaviDecorator 00540 * @param aEventID ID of event to be handled 00541 */ 00542 IMPORT_C virtual void HandleNaviDecoratorEventL( TInt aEventID ); 00543 00544 protected: // from CCoeControl 00545 00549 IMPORT_C virtual void SizeChanged(); 00550 00555 IMPORT_C virtual TInt CountComponentControls() const; 00556 00562 IMPORT_C virtual CCoeControl* ComponentControl(TInt aIndex) const; 00563 00567 IMPORT_C virtual void FocusChanged(TDrawNow aDrawNow); 00568 00572 void ReverseTabOrderL(); 00573 private: 00574 /* 00575 * Reserved 00576 */ 00577 IMPORT_C virtual void Reserved1(); 00578 00579 /* 00580 * Reserved 00581 */ 00582 IMPORT_C virtual void Reserved2(); 00583 00584 /* 00585 * Reserved 00586 */ 00587 IMPORT_C virtual void Reserved3(); 00588 00589 00590 private: 00591 IMPORT_C CAknTabGroup(); 00592 00606 TInt ConvertTabIndex(TInt aIndex) const; 00607 00608 private: 00609 IMPORT_C virtual void Draw(const TRect& aRect) const; 00610 00611 private: 00615 IMPORT_C void* ExtensionInterface( TUid aInterface ); 00616 00617 private: 00618 enum TDirection 00619 { 00620 ELeft, 00621 ERight 00622 }; 00623 00624 private: 00625 void ConstructL(); 00626 void CommonAddTabL(CAknTab* aTab); 00627 void CommonReplaceTabL(CAknTab* aTab); 00628 void HandleTabStateChangedL(CCoeControl* aControl); 00629 TInt Index(TInt aTabId) const; 00630 TBool CycleFocus(TDirection aDirection,TDrawNow aDrawNow); 00631 TInt LeftMostTabIndex() const; 00632 TInt RightMostTabIndex() const; 00633 void DrawLowerBorder(TDrawNow aDrawNow) const; 00634 void DoDrawLowerBorder() const; 00635 void ReportNavigationEvent(); 00636 void LoadTabBitmapsL(TInt aNumberOfTabsShown, TBool aLongTabs); 00637 TBool TabsVisibleInCurrentLayout() const; 00638 void CurrentLayout( TAknWindowLineLayout& aLayout ) const; 00639 void LoadStaconTabBitmapsL(); 00640 void InitTabGroupGraphicsL(); 00641 00642 void InitTabAnimationEventTimerL(); 00643 void CancelTabAnimationEventTimer(); 00644 static TInt TabAnimationEvent(TAny * aPtr); 00645 void DoTabAnimationEvent(); 00646 00647 TBool NarrowTabLayoutNext(); 00648 TBool NarrowTabLayout(); 00649 void SetDecoratorLayout(TBool aNarrow); 00650 00651 void SizeChangedInNormalLayout(); 00652 void SizeChangedInFlatLayout(); 00653 void SizeChangedInNarrowLayout(); 00654 void InitTabAnimationDoubleBufferL(TBool aCreateDoubleBuffer, TBool aForcedDraw); 00655 void InitTabAnimationDoubleBufferL(TBool aCreateDoubleBuffer); 00656 public: 00657 00658 /* 00659 * Used by the UI framework. Applications can set the narrow 00660 * layout using CAknNaviDecorator class. 00661 * 00662 */ 00663 void SetNarrowTabLayout(TBool aNarrow); 00664 00665 00666 private: 00667 CArrayPtr<CAknTab>* iTabArray; 00668 TInt iActiveTab; 00669 TRect iSpareRect; 00670 00671 TInt iTabFixedWidth; 00672 TBool iLongTabs; 00673 TInt iNumberOfTabsShown; 00674 TInt iFirstShownTab; 00675 00676 CFbsBitmap* iTabBitmaps[KTabNumberOfTabBitmaps]; 00677 CFbsBitmap* iTabMaskBitmaps[KTabNumberOfTabBitmaps]; 00678 00679 TInt iBitmapNames[KTabNumberOfTabBitmaps]; 00680 TInt iBitmapMaskNames[KTabNumberOfTabBitmaps]; 00681 CAknTabGroupExtension* iExtension; 00682 00683 MAknTabObserver* iTabObserver; 00684 TBool iMirrored; 00685 }; 00686 00687 00688 // AKNTABGRP_H 00689 #endif