williamr@2: /* williamr@2: * Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members williamr@2: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #if !defined(__EIKCTGRP_H__) williamr@2: #define __EIKCTGRP_H__ williamr@2: williamr@2: #if !defined(__EIKBCTRL_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #include williamr@2: williamr@2: class TEikGroupControl williamr@2: { williamr@2: public: williamr@2: /** Constructor williamr@2: */ williamr@2: inline TEikGroupControl(); williamr@2: /** Constructor williamr@2: */ williamr@2: inline TEikGroupControl(CCoeControl* aControl,TInt aId,TInt aLength,TInt aFlags); williamr@2: public: williamr@2: CCoeControl* iControl; williamr@2: TInt iId; williamr@2: TInt iLongId; williamr@2: public: williamr@2: /** IsLengthSet() whether length has been set williamr@2: */ williamr@2: inline TBool IsLengthSet() const; williamr@2: /** Length() returns value of the length williamr@2: */ williamr@2: inline TInt Length() const; williamr@2: /** IsStretchable() whether controlgroup is stretchable williamr@2: */ williamr@2: inline TBool IsStretchable() const; williamr@2: /** SetLength() sets the length williamr@2: */ williamr@2: inline void SetLength(TInt aLength); williamr@2: /** SetStretchable() sets to be stretchable williamr@2: */ williamr@2: inline void SetStretchable(); williamr@2: public: williamr@2: enum TControlFlags williamr@2: { williamr@2: ESetLength =0x01, williamr@2: EAllowStretch =0x02 williamr@2: }; williamr@2: private: williamr@2: TInt iLength; williamr@2: TInt iFlags; williamr@2: }; williamr@2: williamr@2: class CEikControlGroup : public CEikBorderedControl williamr@2: { williamr@2: friend class CTestControlGroup; // test code williamr@2: williamr@2: // CEikCba made a friend to get at Orientation() private method williamr@2: friend class CEikCba; williamr@2: // -> williamr@2: public: williamr@2: enum TStartCorner williamr@2: { williamr@2: EFromTopLeft=SLafControlGroup::EFromTopLeft, williamr@2: EFromTopRight=SLafControlGroup::EFromTopRight, williamr@2: EFromBottomLeft=SLafControlGroup::EFromBottomLeft, williamr@2: EFromBottomRight=SLafControlGroup::EFromBottomRight williamr@2: }; williamr@2: enum TOrientation williamr@2: { williamr@2: ELayHorizontally=SLafControlGroup::ELayHorizontally, williamr@2: ELayVertically =SLafControlGroup::ELayVertically williamr@2: }; williamr@2: public: // new functions williamr@2: /** Constructor williamr@2: */ williamr@2: IMPORT_C CEikControlGroup(); williamr@2: /** Destructor williamr@2: */ williamr@2: IMPORT_C ~CEikControlGroup(); williamr@2: /** ConstructL() constructs the CEikControlGroup williamr@2: * @param aStart corner to start williamr@2: * @param aOrientation whether controlgroup is vertical or horizontal williamr@2: */ williamr@2: IMPORT_C void ConstructL(TStartCorner aStart,TOrientation aOrientation); williamr@2: /** AddControlL() adds a new control to the controlgroup williamr@2: * @param aControl control to be added williamr@2: * @param aId id of the control williamr@2: */ williamr@2: IMPORT_C virtual void AddControlL(CCoeControl* aControl,TInt aId); williamr@2: /** AddControlL() adds new control to the controlgroup williamr@2: * @param aControlGroup a control and it's id packed into TEikGroupControl struct williamr@2: */ williamr@2: IMPORT_C virtual void AddControlL(TEikGroupControl& aGroupControl); williamr@2: /** InsertControlL() inserts a control to specific position williamr@2: * @param aGroupControl control and its id packed to a struct williamr@2: * @param aIndex index of the array where new control is to be inserted williamr@2: */ williamr@2: IMPORT_C void InsertControlL(TEikGroupControl& aGroupControl,TInt aIndex); williamr@2: /** DeleteControl() removes control from the group williamr@2: * @param aIndex at which position of the array to delete williamr@2: * @param aCount how many controls to delete williamr@2: */ williamr@2: IMPORT_C void DeleteControl(TInt aIndex,TInt aCount); williamr@2: /** SetLengthInPixels() sets length of the control group in pixels williamr@2: * @param aLength length of the whole control group in pixels williamr@2: */ williamr@2: IMPORT_C void SetLengthInPixels(TInt aLength); williamr@2: /** SetBreadthInPixels() sets width of the control group williamr@2: * @param aBreadth width of the control group williamr@2: */ williamr@2: IMPORT_C void SetBreadthInPixels(TInt aBreadth); williamr@2: /** SetControlSpacing sets horizontal and vertical spacing williamr@2: * @param aHSpacing horizontal spacing between controls williamr@2: * @param aVSpacing vertical spacing between controls williamr@2: */ williamr@2: IMPORT_C void SetControlSpacing(TInt aHSpacing,TInt aVSpacing); williamr@2: /** SetControlLayout sets control layout parameters williamr@2: * @param aStart start corner williamr@2: * @param aOrientation vertical or horizontal orientation williamr@2: */ williamr@2: IMPORT_C void SetControlLayout(TStartCorner aStart,TOrientation aOrientation); williamr@2: /** SetNumberOfLines() sets number of lines of the control group williamr@2: * @param aNumLines number of lines williamr@2: * @param aDistributeEvenly whether controls distribute evenly to the group williamr@2: */ williamr@2: IMPORT_C void SetNumberOfLines(TInt aNumLines,TBool aDistributeEvenly); williamr@2: /** SetControlsAllSameSize() sets all controls to be the same size williamr@2: */ williamr@2: IMPORT_C void SetControlsAllSameSize(); williamr@2: /** LayoutControls layouts the controls williamr@2: */ williamr@2: IMPORT_C void LayoutControls(); williamr@2: /** ControlById() fetches individual controls by id williamr@2: * @param aId id of the control williamr@2: */ williamr@2: IMPORT_C CCoeControl* ControlById(TInt aId) const; williamr@2: /** IndexById() gets array index from id williamr@2: * @param aId id number of the control williamr@2: * @return index number to the array williamr@2: */ williamr@2: IMPORT_C TInt IndexById(TInt aId) const; williamr@2: /** Reset() clears the control array williamr@2: */ williamr@2: IMPORT_C void Reset(); williamr@2: /** ControlId() finds id of the control based on CCoeCOntrol pointer williamr@2: * @param aControl control stored in a control group williamr@2: * @return id of the control williamr@2: */ williamr@2: IMPORT_C TInt ControlId(CCoeControl* aControl) const; williamr@2: /** Control() returns CCoeControl pointer based on array index williamr@2: * @param aIndex index to the internal array williamr@2: * @return control in that position of the array williamr@2: */ williamr@2: IMPORT_C CCoeControl* Control(TInt aIndex) const; // as requested by Bill williamr@2: /** ControlArray() access to the actual array representation williamr@2: * @return array williamr@2: */ williamr@2: IMPORT_C CArrayFix* ControlArray() const; williamr@2: /** Orientation orientation of the control group williamr@2: * @return either horizontal or vertical orientation williamr@2: */ williamr@2: IMPORT_C TOrientation Orientation() const; williamr@2: /** ControlSpacing() gets control's spacing williamr@2: * @aHSpacing modifies variable to get horizontal spacing williamr@2: * @aVSpacing modifies variable to get vertical spacing williamr@2: */ williamr@2: IMPORT_C void ControlSpacing(TInt& aHSpacing,TInt& aVSpacing) const; williamr@2: public: // from CCoeControl williamr@2: /** MinimumSize() gets minimumsize williamr@2: */ williamr@2: IMPORT_C TSize MinimumSize(); williamr@2: /** CountComponentControls returns component controls count williamr@2: */ williamr@2: IMPORT_C TInt CountComponentControls() const; williamr@2: /** GetColorUseListL() sets the color use list of the control group williamr@2: */ williamr@2: IMPORT_C virtual void GetColorUseListL(CArrayFix& aColorUseList) const; // not available before Release 005u williamr@2: /** HandleResourceChange() handles resource change event williamr@2: */ williamr@2: IMPORT_C virtual void HandleResourceChange(TInt aType); // not available before Release 005u williamr@2: /** HandlePointerEventL() handles touch pointer events williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: protected: williamr@2: enum williamr@2: { williamr@2: EDistributeEvenly =0x40, williamr@2: EAllSameSize =0x80, williamr@2: EDisableMSKDrawing =0x100 williamr@2: }; williamr@2: protected: // from CCoeControl williamr@2: IMPORT_C CCoeControl* ComponentControl(TInt aIndex) const; williamr@2: IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const; williamr@2: // only used from CEikCba williamr@2: void SetMSKVisibility(TBool aEnable); williamr@2: private: // from CCoeControl williamr@2: IMPORT_C void Reserved_2(); williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: private: // new functions williamr@2: IMPORT_C TInt Adjacent(TInt aRow,TInt aColumn,TInt aCtrlIndex,TInt aTotalRows,TInt aTotalColumns) const; williamr@2: IMPORT_C TStartCorner StartCorner() const; williamr@2: IMPORT_C void DeleteAllComponents(); williamr@2: IMPORT_C TSize ControlMinimumSize(TInt aIndex) const; williamr@2: IMPORT_C TInt ControlMinimumLength(TInt aIndex); williamr@2: IMPORT_C TSize LargestControlSize() const; williamr@2: IMPORT_C TBool DistributeEvenly() const; williamr@2: IMPORT_C TBool AllSameSize(); williamr@2: private: // from CCoeControl williamr@2: IMPORT_C void SizeChanged(); williamr@2: IMPORT_C void Draw(const TRect& aRect) const; williamr@2: protected: williamr@2: CArrayFix* iControlArray; williamr@2: private: williamr@2: TInt iLayout; williamr@2: TInt iLines; williamr@2: TInt iHSpacing; williamr@2: TInt iVSpacing; williamr@2: TInt iBreadth; williamr@2: TInt iLength; williamr@2: TSize iLargestControl; williamr@2: }; williamr@2: williamr@2: williamr@2: inline TEikGroupControl::TEikGroupControl() williamr@2: { iControl=NULL; iId=iFlags=iLength=0; } williamr@2: inline TEikGroupControl::TEikGroupControl(CCoeControl* aControl,TInt aId,TInt aLength,TInt aFlags) williamr@2: : iControl(aControl),iId(aId),iLength(aLength),iFlags(aFlags) williamr@2: {} williamr@2: inline TBool TEikGroupControl::IsLengthSet() const williamr@2: { return iFlags&ESetLength; } williamr@2: inline TInt TEikGroupControl::Length() const williamr@2: { return iLength; } williamr@2: inline TBool TEikGroupControl::IsStretchable() const williamr@2: { return iFlags&EAllowStretch; } williamr@2: inline void TEikGroupControl::SetLength(TInt aLength) williamr@2: { iLength=aLength; iFlags|=ESetLength; } williamr@2: inline void TEikGroupControl::SetStretchable() williamr@2: { iFlags|=EAllowStretch; } williamr@2: williamr@2: #endif