|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Definition of menu item attribute |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __MENUITEMATTR_H__ |
|
20 #define __MENUITEMATTR_H__ |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 class RWriteStream; |
|
25 class RReadStream; |
|
26 |
|
27 /** |
|
28 * Menu item attribute. |
|
29 * @lib mcsmenu.lib |
|
30 * @since S60 v5.0 |
|
31 */ |
|
32 NONSHARABLE_CLASS( CMenuItemAttr ): public CBase |
|
33 { |
|
34 |
|
35 public: |
|
36 |
|
37 /** |
|
38 * Destructor. |
|
39 */ |
|
40 virtual ~CMenuItemAttr(); |
|
41 |
|
42 /** |
|
43 * Two-phased constructor. |
|
44 * @param aName Attribute name. |
|
45 * @return The created object. |
|
46 */ |
|
47 static CMenuItemAttr* NewL( const TDesC& aName ); |
|
48 |
|
49 /** |
|
50 * Two-phased constructor. |
|
51 * @param aName Attribute name. |
|
52 * @return The created object. |
|
53 */ |
|
54 static CMenuItemAttr* NewLC( const TDesC& aName ); |
|
55 |
|
56 /** |
|
57 * Two-phased constructor (create and internalize). |
|
58 * @aStream Stream. |
|
59 * @return The created object. |
|
60 */ |
|
61 static CMenuItemAttr* NewLC( RReadStream& aStream ); |
|
62 |
|
63 /** |
|
64 * Get name. |
|
65 * @return Name. |
|
66 */ |
|
67 TPtrC Name() const { return iName; } |
|
68 |
|
69 /** |
|
70 * Get value. |
|
71 * @return Value, or NULL if attribute is not set. |
|
72 */ |
|
73 HBufC* Value() const { return iValue; } |
|
74 |
|
75 /** |
|
76 * Set value. Sets changed status as appropriate. |
|
77 * @param aValue Value, or NULL if attribute is not set (==remove attr). |
|
78 * Ownership taken. |
|
79 */ |
|
80 void SetValue( HBufC* aValue ); |
|
81 |
|
82 /** |
|
83 * Get changed status. |
|
84 * @return ETrue if changed. |
|
85 */ |
|
86 TBool Changed() const { return iChanged; } |
|
87 |
|
88 /** |
|
89 * Set changed status. |
|
90 * @param Changed status. |
|
91 */ |
|
92 void SetChanged( TBool aChanged ) { iChanged = aChanged; } |
|
93 |
|
94 /** |
|
95 * Externalize to stream. |
|
96 * @param aStream Stream to externalize to. |
|
97 */ |
|
98 void ExternalizeL( RWriteStream& aStream ) const; |
|
99 |
|
100 /** |
|
101 * Internalize from stream. |
|
102 * @param aStream Stream to externalize from. |
|
103 */ |
|
104 void InternalizeL( RReadStream& aStream ); |
|
105 |
|
106 protected: |
|
107 |
|
108 /** |
|
109 * Second phased constructor. |
|
110 * @param aName Attribute name. |
|
111 */ |
|
112 void ConstructL( const TDesC& aName ); |
|
113 |
|
114 private: // data |
|
115 |
|
116 RBuf iName; ///< Name. Own. |
|
117 HBufC* iValue; ///< Value (or NULL). Own. |
|
118 TBool iChanged; ///< ETrue if changed. |
|
119 |
|
120 }; |
|
121 |
|
122 /** |
|
123 * Attribute array. |
|
124 * @lib mcsmenu.lib |
|
125 * @since S60 v5.0 |
|
126 */ |
|
127 NONSHARABLE_CLASS( RMenuItemAttrArray ) : public RPointerArray<CMenuItemAttr> |
|
128 { |
|
129 |
|
130 public: |
|
131 |
|
132 /** |
|
133 * Find attribute by name. |
|
134 * @param aName Name. |
|
135 * @return Index of attribute, or KErrNotFound. |
|
136 */ |
|
137 TInt Find( const TDesC& aName ) const; |
|
138 |
|
139 /** |
|
140 * Count changed attributes. |
|
141 * @return Number of changed attributes. |
|
142 */ |
|
143 TInt CountChanged() const; |
|
144 |
|
145 /** |
|
146 * Clear changed status for all attributes. |
|
147 */ |
|
148 void ClearChanged(); |
|
149 |
|
150 /** |
|
151 * Externalize changed items to stream. |
|
152 * @param aStream Stream to externalize to. |
|
153 */ |
|
154 void ExternalizeChangesL( RWriteStream& aStream ) const; |
|
155 |
|
156 /** |
|
157 * Externalize all items to stream. |
|
158 * @param aStream Stream to externalize to. |
|
159 */ |
|
160 void ExternalizeL( RWriteStream& aStream ) const; |
|
161 |
|
162 /** |
|
163 * Internalize from stream. |
|
164 * @param aStream Stream to externalize from. |
|
165 */ |
|
166 void InternalizeL( RReadStream& aStream ); |
|
167 |
|
168 }; |
|
169 |
|
170 /** |
|
171 * Push a ResetAndDestroy() on the cleanup stack. |
|
172 * @param aArray Array. |
|
173 */ |
|
174 void CleanupResetAndDestroyPushL( RMenuItemAttrArray& aArray ); |
|
175 |
|
176 #endif // __MENUITEMATTR_H__ |