00001 // EIKCBA.H 00002 // 00003 // Copyright (c) 1998 Symbian Ltd. All rights reserved. 00004 // 00005 00006 #if !defined(__EIKCBA_H__) 00007 #define __EIKCBA_H__ 00008 00009 #if !defined(__EIKCTGRP_H__) 00010 #include <eikctgrp.h> 00011 #endif 00012 00013 #if !defined(__BADESCA_H__) 00014 #include <badesca.h> 00015 #endif 00016 00017 #if !defined(__EIKBRGRP_H__) 00018 #include <eikbtgrp.h> 00019 #endif 00020 00021 #if !defined(__EIKSBOBS_H__) 00022 #include <eiksbobs.h> 00023 #endif 00024 00025 #if !defined(__EIKSBFRM_H__) 00026 #include <eiksbfrm.h> 00027 #endif 00028 00029 #include <eikimage.h> 00030 #include <akncontrol.h> 00031 00032 #start_since SINCE_3_1_SDK 00033 #include <AknsItemData.h> //TAknsItemID 00034 #include <babitflags.h> //TBitFlags 00035 #end_since SINCE_3_1_SDK 00036 00037 class CEikLabel; 00038 class CEikCbaButton; 00039 class CCoeBrushAndPenContext; 00040 class MEikCommandObserver; 00041 class TCoeColorUse; 00042 00043 class CAknScrollBar; 00044 class TEikScrollBarModel; 00045 00046 class CEikEnhancedCbaButton; 00047 class CEikCommandTable; 00048 00049 #start_since SINCE_3_1_SDK 00050 class CAknsBasicBackgroundControlContext; 00051 class CAknsLayeredBackgroundControlContext; 00052 #end_since SINCE_3_1_SDK 00053 00054 const TInt KMaxCbaLabelLength = 32; 00055 const TInt KMaxButtonsInCommandTable = 4; 00056 00062 NONSHARABLE_CLASS(CEikCba) : public CEikControlGroup, public MEikEnhancedButtonGroup, public MEikScrollBarObserver 00063 // NONSHARABLE_CLASS(CEikCba) : public CEikControlGroup, public MEikButtonGroup, public MEikScrollBarObserver 00064 { 00065 public: 00066 DECLARE_TYPE_ID(0x101F4105) 00067 00068 // Construction/Destruction 00069 static CEikCba* NewL(const CEikCba* aPrevious,MEikCommandObserver* aCommandObserver,RWindowGroup* aParentWg); 00070 static CEikCba* NewL(TInt aResourceId,const CEikCba* aPrevious,MEikCommandObserver* aCommandObserver,RWindowGroup* aParentWg); 00071 static CEikCba* NewLC(const CEikCba* aPrevious,MEikCommandObserver* aCommandObserver,RWindowGroup* aParentWg); 00072 static CEikCba* NewLC(TInt aResourceId,const CEikCba* aPrevious,MEikCommandObserver* aCommandObserver,RWindowGroup* aParentWg); 00073 ~CEikCba(); 00074 00075 public: // new methods 00076 TInt MaxCommands() const; 00077 void UpdateCbaLabels(TBool aScrollerOn); 00078 #start_since SINCE_3_1_SDK 00082 TInt MSKEnabledInPlatform() const; 00083 #end_since SINCE_3_1_SDK 00084 00085 // Scrollbar handling methods 00086 void SetSBFrameObserver(MEikScrollBarObserver* aObserver); 00087 void SetScrollBarModelL(TEikScrollBarModel* aModel); 00088 const CEikCbaScrollBarFrame* ScrollBarFrame() const; 00089 CAknScrollBar* VScrollBarAsControl(); 00090 void CreateArrowHeadScrollBarL(); // 00091 00092 public: // from CEikControlGroup 00093 void InsertControlL(TEikGroupControl& aGroupControl,TInt aIndex); // Overridden to prevent setting container window 00094 00095 public: // from MEikButtonGroup 00096 void SetCommandL(TInt aPosition,TInt aCommandId,const TDesC* aText,const CFbsBitmap* aBitmap,const CFbsBitmap* aMask); 00097 void SetCommandL(TInt aPosition,TInt aResourceId); 00098 void SetCommandSetL(TInt aResourceId); 00099 void AddCommandL(TInt aPosition,TInt aCommandId,const TDesC* aText,const CFbsBitmap* aBitmap,const CFbsBitmap* aMask); 00100 void AddCommandToStackL(TInt aPosition,TInt aCommandId,const TDesC* aText,const CFbsBitmap* aBitmap,const CFbsBitmap* aMask); 00101 void AddCommandToStackL(TInt aPosition,TInt aResourceId); 00102 void AddCommandSetToStackL(TInt aResourceId); 00103 void SetDefaultCommand(TInt aCommandId); 00104 TSize CalcMinimumSizeL(TInt aResourceId); 00105 void RemoveCommandFromStack(TInt aPosition,TInt aCommandId); 00106 TInt CommandPos(TInt aCommandId) const; 00107 00108 void DimCommand(TInt aCommandId,TBool aDimmed); 00109 TBool IsCommandDimmed(TInt aCommandId) const; 00110 void MakeCommandVisible(TInt aCommandId,TBool aVisible); 00111 TBool IsCommandVisible(TInt aCommandId) const; 00112 void AnimateCommand(TInt aCommandId); 00113 00114 00115 CCoeControl* AsControl(); 00116 const CCoeControl* AsControl() const; 00117 void SetBoundingRect(const TRect& aBoundingRect); 00118 void ReduceRect(TRect& aBoundingRect) const; 00119 CCoeControl* GroupControlById(TInt aCommandId); 00120 CCoeControl* GroupControlById(TInt aCommandId) const; 00121 TInt CommandId(TInt aCommandPos) const; 00122 TInt ButtonCount() const; 00123 void RemovePreviousCommand(TInt aPosition); 00124 00125 // Added during integration for Rel18 by Tim. 00126 CEikCommandButton* GroupControlAsButton(TInt aCommandId) const ; 00127 TUint ButtonGroupFlags() const ; 00128 IMPORT_C void SetButtonGroupFlags(TInt aFlags); 00129 00142 IMPORT_C void SetSkinBackgroundId(const TAknsItemID& aIID); 00143 00144 #start_since SINCE_3_1_SDK 00149 void SetMSKIconL(); 00150 #end_since SINCE_3_1_SDK 00151 00152 00153 public: // formerly from MTopSetMember<CEikCba>, now reserved 00154 virtual void Reserved_MtsmPosition(); 00155 virtual void Reserved_MtsmObject(); 00156 00157 public: // from CCoeControl 00158 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); 00159 TSize MinimumSize(); 00160 void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const; 00161 void HandleResourceChange(TInt aType); 00162 #start_since SINCE_3_1_SDK 00166 void MakeVisible(TBool aVisible); 00167 #end_since SINCE_3_1_SDK 00168 00174 void HandlePointerEventL(const TPointerEvent& aPointerEvent); 00175 00176 public: //from MEikEnhancedButtonGroup 00177 IMPORT_C void OfferCommandListL(const RArray<TInt>& aCommandList); 00178 IMPORT_C void OfferCommandListL(const TInt aResourceId); 00179 IMPORT_C TBool IsCommandInGroup(const TInt aCommandId) const; 00180 IMPORT_C void ReplaceCommand(const TInt aCommandId, const TInt aResourceId); 00181 00182 private: 00186 IMPORT_C void* ExtensionInterface( TUid aInterface ); 00187 00188 00189 protected: // from MEikScrollBarObserver 00190 virtual void HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType); 00191 00192 protected: // from CCoeControl 00193 TTypeUid::Ptr MopSupplyObject(TTypeUid aId); 00194 void Draw(const TRect& aRect) const; 00195 00196 private: // new methods 00197 CEikCba(const CEikCba* aPrevious,MEikCommandObserver* aCommandObserver,RWindowGroup* aParentWg); 00198 void BaseConstructL(); 00199 void ConstructL(TInt aResourceId); 00200 void ConstructFromResourceL(TResourceReader& aReader); 00201 CEikCbaButton* ButtonById(TInt aCommandId) const; 00202 void CreateScrollBarFrameL(); 00203 void InsertScrollBarL(); 00204 TEikGroupControl VScrollBarAsGroupControl(); 00205 void CheckSkinAndUpdateContext(); 00206 00207 TInt AknLayoutFlags() const; 00208 void SizeChangedInControlPane(); 00209 void SizeChangedInStaconPane(); 00210 void UpdateFonts(); 00211 00212 void DoSkinChange(); 00213 void DoColorChange(); 00214 void DoLayoutChange(); 00215 00222 void LayoutControl( CCoeControl* aControl, const TRect& aRect ); 00223 00228 void DoStopEffectL(); 00229 00233 void StartEffectL(); 00234 00240 static TInt StopEffectL( TAny* aThis ); 00241 00242 private: // from CCoeControl 00243 void SizeChanged(); 00244 00245 00246 private: 00247 TUint iCbaFlags; 00248 const CEikCba* iLink; // used to maintain the original settings if a client needs to temporarily change its cba 00249 CCoeBrushAndPenContext* iBrushAndPenContext; 00250 MEikCommandObserver* iCommandObserver; 00251 CEikCbaScrollBarFrame* iSBFrame; 00252 RWindowGroup* iParentWg; 00253 00254 // new member variable that stores commands in correct order 00255 CEikCommandTable* iCommandTable; 00256 00257 // for MSK 00258 TBool iMSKset; 00259 TBool iMSKEnabledInPlatform; // caches CenRep value 00260 // additional observer for MSK. This is called first and default observer after that. 00261 MEikCommandObserver* iMSKCommandObserver; 00262 00263 // from extension 00264 const CFont* iLabelFont; 00265 const CFont* iStaconLabelFont; 00266 TBool iPopupVisible; 00267 TBitFlags iFlags; 00268 CAknsBasicBackgroundControlContext* iBgContext; 00269 TAknsItemID iBgIID; 00270 CAknsLayeredBackgroundControlContext* iStaconBgContext; 00271 00272 /* Timer for feedback effect */ 00273 CPeriodic* iTimer; 00274 }; 00275 00276 00277 class CEikCbaButton : public CAknControl 00278 { 00279 public: 00280 struct SButtonOptions 00281 { 00282 TInt iCommandId; 00283 TBool iDimmed; 00284 }; 00285 public: 00286 ~CEikCbaButton(); 00287 void ConstructL(TGulAlignmentValue aAlignment); 00288 public: 00289 void AddCommandL(const TDesC& aText); 00290 void PushCommandL(TInt aCommandId,const TDesC& aText); 00291 TInt PopCommand(); 00292 void RemoveCommand(TInt aCommandId); 00293 void RemovePreviousCommand(); 00294 // AKNLAF start 00295 void SwitchToShortTextL(TBool aShortText); 00296 void SetLabelFont(const CFont* aLabelFont); 00297 void TruncateLabelText(); 00298 // AKNLAF end 00299 public: // from CCoeControl 00300 void SetContainerWindowL(const CCoeControl& aContainer); 00301 void ConstructFromResourceL(TResourceReader& aReader, TGulAlignmentValue anAlignment); 00302 TSize MinimumSize(); 00303 void SetDimmed(TBool aDimmed); 00304 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); 00305 public: 00306 void SetImage(CEikImage &aImage); 00307 void ReplaceImageByLabel(); 00308 inline TBool IsImageOn() const {return iDoImage;}; 00309 #start_since SINCE_3_1_SDK 00310 00314 void ConstructEmptyButtonL(); 00315 #end_since SINCE_3_1_SDK 00316 //private: 00317 protected: 00318 // void UpdateLabelReserveLengthL(const TDesC& aText); 00319 TInt IndexFromCommandId(TInt aCommandId); 00320 void UpdateLabelText(TPtrC aLabelText); 00321 private: // from CCoeControl 00322 TInt CountComponentControls() const; 00323 CCoeControl* ComponentControl(TInt aIndex) const; 00324 void SizeChanged(); 00325 private: 00329 IMPORT_C void* ExtensionInterface( TUid aInterface ); 00330 00331 public: // new functions 00332 00333 00334 private: 00335 void PrepareImageL(); 00336 00337 protected: 00338 TBuf<KMaxCbaLabelLength> iFullLabelText; 00339 TPtrC iLongLabelText; 00340 TPtrC iShortLabelText; 00341 CEikLabel* iLabel; 00342 CDesCArray* iText; 00343 CArrayFix<SButtonOptions>* iButtonOptions; 00344 CEikImage* iImage; 00345 }; 00346 00351 class CEikEnhancedCbaButton : public CEikCbaButton 00352 { 00353 public: 00357 CEikEnhancedCbaButton(); 00358 00362 ~CEikEnhancedCbaButton(); 00363 00368 TInt CommandType() const; 00369 00374 void SetCommandType(const TInt aCommandType); 00375 00380 TInt CommandId() const; 00381 00386 void ConstructFromResourceL(TResourceReader& aReader); 00387 00391 void ConstructEmptyButtonL(); 00392 00397 TPtrC* LabelText(); 00398 00399 00400 private: // member variables 00401 TInt iCommandType; 00402 TInt iCommandId; 00403 }; 00404 00412 NONSHARABLE_CLASS(CEikCommandTable) : public CBase 00413 { 00414 public: 00418 static CEikCommandTable* NewL(); 00419 static CEikCommandTable* NewLC(); 00420 ~CEikCommandTable(); 00421 00427 TInt AddCommandL(CEikEnhancedCbaButton* aButton); 00428 00434 TBool IsCommandPlaced(const TInt aCommandId) const; 00435 00441 void ReplaceCommandL(const TInt aCommandId, const TInt aResourceId); 00442 00448 CEikEnhancedCbaButton* Command(const TInt aCommandIndex); 00449 00453 void Reset(); 00454 00455 private: // member functions 00459 CEikCommandTable(); 00460 00464 void ConstructL(); 00465 00466 private: // member variables 00467 TFixedArray<CEikEnhancedCbaButton*, KMaxButtonsInCommandTable> iCommandButtons; // displayed commands 00468 00469 // priority order for each button 00470 RArray< RArray<TInt> > iPriorities; 00471 }; 00472 00473 #endif