1.1 --- a/epoc32/include/coecontrolarray.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/coecontrolarray.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,183 @@
1.4 -coecontrolarray.h
1.5 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// 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
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +
1.21 +#ifndef __COECONTROLARRAY_H__
1.22 +#define __COECONTROLARRAY_H__
1.23 +
1.24 +#include <e32base.h> // class CBase
1.25 +
1.26 +class CCoeControl;
1.27 +
1.28 +/** Default id for controls that have no associated id. This is equal
1.29 +to KErrNotFound
1.30 +@publishedAll
1.31 +@released
1.32 +*/
1.33 +const TInt KCoeNoControlId = KErrNotFound;
1.34 +
1.35 +/** Class that encapsulates a control and the identifier for that control.
1.36 +
1.37 +Controls in a CCoeControlArray can be associated with an id. This class encapsulates the control and its id.
1.38 +
1.39 +@publishedAll
1.40 +@released */
1.41 +class TCoeControlWithId
1.42 + {
1.43 +public:
1.44 + TCoeControlWithId(TInt aControlId, CCoeControl* aControl = NULL);
1.45 +public:
1.46 + /** The control */
1.47 + CCoeControl* iControl;
1.48 + /** The id of the control */
1.49 + TInt iId;
1.50 + };
1.51 +
1.52 +/** Class that represents an array of controls.
1.53 +
1.54 +The CCoeControlArray class is used to store the child controls of a container control.
1.55 +The method CCoeControl::InitComponentArrayL() must be used to create the array and the method
1.56 +CCoeControlArray& CCoeControl::Components() can be used to get this array.
1.57 +
1.58 +@publishedAll
1.59 +@released */
1.60 +class CCoeControlArray : public CBase
1.61 + {
1.62 +public:
1.63 + /** This class is an iterator for the CCoeControlArray class.
1.64 + @publishedAll
1.65 + @released
1.66 + */
1.67 + class TCursor // robust iterator
1.68 + {
1.69 + public:
1.70 + template<typename T> T* Control();
1.71 + template<typename T> const T* Control() const;
1.72 + IMPORT_C TBool Prev();
1.73 + IMPORT_C TBool Next();
1.74 + IMPORT_C TBool IsValid() const;
1.75 +
1.76 + IMPORT_C TBool operator==(const TCursor& aCursor) const;
1.77 + IMPORT_C TBool operator!=(const TCursor& aCursor) const;
1.78 + public:
1.79 + TCursor(const CCoeControlArray& aArray, TInt aIndex);
1.80 + TInt Index() const;
1.81 + private:
1.82 + IMPORT_C CCoeControl* Ctrl() const;
1.83 + void UpdateMemento() const;
1.84 + void UpdateIndex() const;
1.85 + private:
1.86 + const CCoeControlArray* iArray;
1.87 + mutable TInt iIndex;
1.88 + mutable TCoeControlWithId iMemento;
1.89 + };
1.90 +public:
1.91 + IMPORT_C static CCoeControlArray* NewL(CCoeControl& aOwner);
1.92 + IMPORT_C ~CCoeControlArray();
1.93 + IMPORT_C TInt Count() const;
1.94 + IMPORT_C void Reset();
1.95 + IMPORT_C void ResetAndDestroy();
1.96 + IMPORT_C void SortById();
1.97 +
1.98 + IMPORT_C TBool ControlsOwnedExternally() const;
1.99 + IMPORT_C void SetControlsOwnedExternally(TBool aOwnedExternally);
1.100 +
1.101 + IMPORT_C TBool IsArrayLocked() const;
1.102 + IMPORT_C void SetArrayLocked();
1.103 +
1.104 + template<typename T> T* ControlById(TInt aControlId);
1.105 + template<typename T> const T* ControlById(TInt aControlId) const;
1.106 +
1.107 + IMPORT_C TCursor Begin() const;
1.108 + IMPORT_C TCursor End() const;
1.109 + IMPORT_C TCursor Find(const CCoeControl* aControl) const;
1.110 + IMPORT_C TCursor Find(TInt aControlId) const;
1.111 +
1.112 + IMPORT_C TCursor AppendLC(CCoeControl* aControl, TInt aControlId = KCoeNoControlId);
1.113 + IMPORT_C TCursor InsertAfterLC(TInt aInsertAfterId, CCoeControl* aControl, TInt aControlId = KCoeNoControlId);
1.114 + IMPORT_C TCursor InsertLC(TCursor& aInsertAt, CCoeControl* aControl, TInt aControlId = KCoeNoControlId);
1.115 +
1.116 + IMPORT_C TInt Remove(const CCoeControl* aControl);
1.117 + IMPORT_C CCoeControl* Remove(TCursor aRemoveAt);
1.118 + IMPORT_C CCoeControl* RemoveById(TInt aControlId);
1.119 +public:
1.120 + IMPORT_C TInt Replace(CCoeControl* aOriginalControl, CCoeControl* aNewControl);
1.121 +
1.122 +public: // internal use only
1.123 + IMPORT_C TCoeControlWithId At(TInt aIndex);
1.124 + IMPORT_C const TCoeControlWithId At(TInt aIndex) const;
1.125 + IMPORT_C TInt Id(const CCoeControl& aControl) const;
1.126 + IMPORT_C void Sort(TLinearOrder< TCoeControlWithId > aOrder);
1.127 +public:
1.128 + /** Defines the possible events related to a change to the contents
1.129 + of the array. */
1.130 + enum TEvent
1.131 + {
1.132 + /** A control has been added to the array */
1.133 + EControlAdded,
1.134 + /** A control has been removed from the array */
1.135 + EControlRemoved
1.136 + };
1.137 +
1.138 +private:
1.139 + IMPORT_C CCoeControlArray(CCoeControl& aOwner);
1.140 + TInt IndexById(TInt aControlId) const;
1.141 + IMPORT_C CCoeControl* CtrlById(TInt aControlId) const;
1.142 +
1.143 +private:
1.144 + CCoeControl& iOwner;
1.145 + TInt iFlags;
1.146 + RArray<TCoeControlWithId> iControls;
1.147 + };
1.148 +
1.149 +/** Gets the control.
1.150 +@return The control at the current cursor position.
1.151 +*/
1.152 +template<typename T>
1.153 +T* CCoeControlArray::TCursor::Control()
1.154 + {
1.155 + return static_cast<T*>(Ctrl());
1.156 + }
1.157 +
1.158 +/** Gets the control.
1.159 +@return The control at the current cursor position.
1.160 +*/
1.161 +template<typename T>
1.162 +const T* CCoeControlArray::TCursor::Control() const
1.163 + {
1.164 + return static_cast<T*>(Ctrl());
1.165 + }
1.166 +
1.167 +/** Gets the control with the given id.
1.168 +@param aControlId The id of the desired control.
1.169 +@return The control with the given id.
1.170 +*/
1.171 +template<typename T>
1.172 +T* CCoeControlArray::ControlById(TInt aControlId)
1.173 + {
1.174 + return static_cast<T*>(CtrlById(aControlId));
1.175 + }
1.176 +
1.177 +/** Gets the control with the given id.
1.178 +@param aControlId The id of the desired control.
1.179 +@return The control with the given id.
1.180 +*/
1.181 +template<typename T>
1.182 +const T* CCoeControlArray::ControlById(TInt aControlId) const
1.183 + {
1.184 + return static_cast<T*>(CtrlById(aControlId));
1.185 + }
1.186 +
1.187 +#endif //__COECONTROLARRAY_H__