2 * Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #if !defined(__EIKCTGRP_H__)
20 #define __EIKCTGRP_H__
22 #if !defined(__EIKBCTRL_H__)
28 class TEikGroupControl
33 inline TEikGroupControl();
36 inline TEikGroupControl(CCoeControl* aControl,TInt aId,TInt aLength,TInt aFlags);
38 CCoeControl* iControl;
42 /** IsLengthSet() whether length has been set
44 inline TBool IsLengthSet() const;
45 /** Length() returns value of the length
47 inline TInt Length() const;
48 /** IsStretchable() whether controlgroup is stretchable
50 inline TBool IsStretchable() const;
51 /** SetLength() sets the length
53 inline void SetLength(TInt aLength);
54 /** SetStretchable() sets to be stretchable
56 inline void SetStretchable();
68 class CEikControlGroup : public CEikBorderedControl
70 friend class CTestControlGroup; // test code
72 // CEikCba made a friend to get at Orientation() private method
78 EFromTopLeft=SLafControlGroup::EFromTopLeft,
79 EFromTopRight=SLafControlGroup::EFromTopRight,
80 EFromBottomLeft=SLafControlGroup::EFromBottomLeft,
81 EFromBottomRight=SLafControlGroup::EFromBottomRight
85 ELayHorizontally=SLafControlGroup::ELayHorizontally,
86 ELayVertically =SLafControlGroup::ELayVertically
88 public: // new functions
91 IMPORT_C CEikControlGroup();
94 IMPORT_C ~CEikControlGroup();
95 /** ConstructL() constructs the CEikControlGroup
96 * @param aStart corner to start
97 * @param aOrientation whether controlgroup is vertical or horizontal
99 IMPORT_C void ConstructL(TStartCorner aStart,TOrientation aOrientation);
100 /** AddControlL() adds a new control to the controlgroup
101 * @param aControl control to be added
102 * @param aId id of the control
104 IMPORT_C virtual void AddControlL(CCoeControl* aControl,TInt aId);
105 /** AddControlL() adds new control to the controlgroup
106 * @param aControlGroup a control and it's id packed into TEikGroupControl struct
108 IMPORT_C virtual void AddControlL(TEikGroupControl& aGroupControl);
109 /** InsertControlL() inserts a control to specific position
110 * @param aGroupControl control and its id packed to a struct
111 * @param aIndex index of the array where new control is to be inserted
113 IMPORT_C void InsertControlL(TEikGroupControl& aGroupControl,TInt aIndex);
114 /** DeleteControl() removes control from the group
115 * @param aIndex at which position of the array to delete
116 * @param aCount how many controls to delete
118 IMPORT_C void DeleteControl(TInt aIndex,TInt aCount);
119 /** SetLengthInPixels() sets length of the control group in pixels
120 * @param aLength length of the whole control group in pixels
122 IMPORT_C void SetLengthInPixels(TInt aLength);
123 /** SetBreadthInPixels() sets width of the control group
124 * @param aBreadth width of the control group
126 IMPORT_C void SetBreadthInPixels(TInt aBreadth);
127 /** SetControlSpacing sets horizontal and vertical spacing
128 * @param aHSpacing horizontal spacing between controls
129 * @param aVSpacing vertical spacing between controls
131 IMPORT_C void SetControlSpacing(TInt aHSpacing,TInt aVSpacing);
132 /** SetControlLayout sets control layout parameters
133 * @param aStart start corner
134 * @param aOrientation vertical or horizontal orientation
136 IMPORT_C void SetControlLayout(TStartCorner aStart,TOrientation aOrientation);
137 /** SetNumberOfLines() sets number of lines of the control group
138 * @param aNumLines number of lines
139 * @param aDistributeEvenly whether controls distribute evenly to the group
141 IMPORT_C void SetNumberOfLines(TInt aNumLines,TBool aDistributeEvenly);
142 /** SetControlsAllSameSize() sets all controls to be the same size
144 IMPORT_C void SetControlsAllSameSize();
145 /** LayoutControls layouts the controls
147 IMPORT_C void LayoutControls();
148 /** ControlById() fetches individual controls by id
149 * @param aId id of the control
151 IMPORT_C CCoeControl* ControlById(TInt aId) const;
152 /** IndexById() gets array index from id
153 * @param aId id number of the control
154 * @return index number to the array
156 IMPORT_C TInt IndexById(TInt aId) const;
157 /** Reset() clears the control array
159 IMPORT_C void Reset();
160 /** ControlId() finds id of the control based on CCoeCOntrol pointer
161 * @param aControl control stored in a control group
162 * @return id of the control
164 IMPORT_C TInt ControlId(CCoeControl* aControl) const;
165 /** Control() returns CCoeControl pointer based on array index
166 * @param aIndex index to the internal array
167 * @return control in that position of the array
169 IMPORT_C CCoeControl* Control(TInt aIndex) const; // as requested by Bill
170 /** ControlArray() access to the actual array representation
173 IMPORT_C CArrayFix<TEikGroupControl>* ControlArray() const;
174 /** Orientation orientation of the control group
175 * @return either horizontal or vertical orientation
177 IMPORT_C TOrientation Orientation() const;
178 /** ControlSpacing() gets control's spacing
179 * @aHSpacing modifies variable to get horizontal spacing
180 * @aVSpacing modifies variable to get vertical spacing
182 IMPORT_C void ControlSpacing(TInt& aHSpacing,TInt& aVSpacing) const;
183 public: // from CCoeControl
184 /** MinimumSize() gets minimumsize
186 IMPORT_C TSize MinimumSize();
187 /** CountComponentControls returns component controls count
189 IMPORT_C TInt CountComponentControls() const;
190 /** GetColorUseListL() sets the color use list of the control group
192 IMPORT_C virtual void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const; // not available before Release 005u
193 /** HandleResourceChange() handles resource change event
195 IMPORT_C virtual void HandleResourceChange(TInt aType); // not available before Release 005u
196 /** HandlePointerEventL() handles touch pointer events
198 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
202 EDistributeEvenly =0x40,
204 EDisableMSKDrawing =0x100
206 protected: // from CCoeControl
207 IMPORT_C CCoeControl* ComponentControl(TInt aIndex) const;
208 IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const;
209 // only used from CEikCba
210 void SetMSKVisibility(TBool aEnable);
211 private: // from CCoeControl
212 IMPORT_C void Reserved_2();
217 IMPORT_C void* ExtensionInterface( TUid aInterface );
218 private: // new functions
219 IMPORT_C TInt Adjacent(TInt aRow,TInt aColumn,TInt aCtrlIndex,TInt aTotalRows,TInt aTotalColumns) const;
220 IMPORT_C TStartCorner StartCorner() const;
221 IMPORT_C void DeleteAllComponents();
222 IMPORT_C TSize ControlMinimumSize(TInt aIndex) const;
223 IMPORT_C TInt ControlMinimumLength(TInt aIndex);
224 IMPORT_C TSize LargestControlSize() const;
225 IMPORT_C TBool DistributeEvenly() const;
226 IMPORT_C TBool AllSameSize();
227 private: // from CCoeControl
228 IMPORT_C void SizeChanged();
229 IMPORT_C void Draw(const TRect& aRect) const;
231 CArrayFix<TEikGroupControl>* iControlArray;
239 TSize iLargestControl;
243 inline TEikGroupControl::TEikGroupControl()
244 { iControl=NULL; iId=iFlags=iLength=0; }
245 inline TEikGroupControl::TEikGroupControl(CCoeControl* aControl,TInt aId,TInt aLength,TInt aFlags)
246 : iControl(aControl),iId(aId),iLength(aLength),iFlags(aFlags)
248 inline TBool TEikGroupControl::IsLengthSet() const
249 { return iFlags&ESetLength; }
250 inline TInt TEikGroupControl::Length() const
252 inline TBool TEikGroupControl::IsStretchable() const
253 { return iFlags&EAllowStretch; }
254 inline void TEikGroupControl::SetLength(TInt aLength)
255 { iLength=aLength; iFlags|=ESetLength; }
256 inline void TEikGroupControl::SetStretchable()
257 { iFlags|=EAllowStretch; }