34
|
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: menu item presentation model
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef HNMENUITEMMODEL_H_
|
|
20 |
#define HNMENUITEMMODEL_H_
|
|
21 |
|
|
22 |
#include <e32base.h>
|
|
23 |
|
|
24 |
class CHnMenuItemModel;
|
|
25 |
|
|
26 |
/**
|
|
27 |
* Menu item model iterator.
|
|
28 |
*
|
|
29 |
* Used to iterate on menu items structure. Provides basic
|
|
30 |
* iterator interface.
|
|
31 |
*
|
|
32 |
* @lib hnpresentationmodel
|
|
33 |
* @since S60 5.0
|
|
34 |
* @ingroup group_hnpresentationmodel
|
|
35 |
*/
|
|
36 |
class MHnMenuItemModelIterator
|
|
37 |
{
|
|
38 |
public:
|
|
39 |
|
|
40 |
/**
|
|
41 |
* Checks whether there is at least one more element.
|
|
42 |
*
|
|
43 |
* @since S60 5.0
|
|
44 |
* @return ETrue if there is a next item, otherwise EFalse.
|
|
45 |
*/
|
|
46 |
virtual TBool HasNext() = 0;
|
|
47 |
|
|
48 |
/**
|
|
49 |
* Gets the next item and move the cursor to the next item.
|
|
50 |
*
|
|
51 |
* @since S60 5.0
|
|
52 |
* @return A pointer to the element or NULL if there are no more elements.
|
|
53 |
*/
|
|
54 |
virtual CHnMenuItemModel* GetNext() = 0;
|
|
55 |
|
|
56 |
/**
|
|
57 |
* Checks whether there is at least one more element (item specific).
|
|
58 |
*
|
|
59 |
* @since S60 5.0
|
|
60 |
* @return ETrue if there is a next item, otherwise EFalse.
|
|
61 |
*/
|
|
62 |
virtual TBool HasNextSpecific() = 0;
|
|
63 |
|
|
64 |
/**
|
|
65 |
* Gets the next menu item ( specific for the item
|
|
66 |
* - e.g. Applications folder item )
|
|
67 |
* and move the cursor to the next menu item.
|
|
68 |
*
|
|
69 |
* @since S60 5.0
|
|
70 |
* @return A pointer to the element or NULL if there are no more elements.
|
|
71 |
*/
|
|
72 |
virtual CHnMenuItemModel* GetNextSpecific() = 0;
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Resets the iterator.
|
|
76 |
*
|
|
77 |
* @since S60 5.0
|
|
78 |
*/
|
|
79 |
virtual void Reset() = 0;
|
|
80 |
|
|
81 |
};
|
|
82 |
|
|
83 |
/**
|
|
84 |
* Menu item model class.
|
|
85 |
*
|
|
86 |
* Represents menu item. Contains all data needed to display and
|
|
87 |
* use menu item properly. Implemented as tree structure.
|
|
88 |
*
|
|
89 |
* @lib hnpresentationmodel
|
|
90 |
* @since S60 5.0
|
|
91 |
* @ingroup group_hnpresentationmodel
|
|
92 |
*/
|
|
93 |
NONSHARABLE_CLASS( CHnMenuItemModel ):
|
|
94 |
public CBase,
|
|
95 |
public MHnMenuItemModelIterator
|
|
96 |
{
|
|
97 |
public:
|
|
98 |
enum THnMenuItemType {
|
|
99 |
EItemApplication, //in options with & without focus
|
|
100 |
EItemAction, //in options with focus
|
|
101 |
EItemSpecific //in options with focus & in stylus popup
|
|
102 |
};
|
|
103 |
|
|
104 |
public:
|
|
105 |
|
|
106 |
/**
|
|
107 |
* Two-phased constructor.
|
|
108 |
*
|
|
109 |
* @since S60 5.0
|
|
110 |
* @param aName Name for menu item
|
|
111 |
*/
|
|
112 |
IMPORT_C static CHnMenuItemModel* NewL( const TDesC& aName );
|
|
113 |
|
|
114 |
/**
|
|
115 |
* Virtual Destructor.
|
|
116 |
*
|
|
117 |
* @since S60 5.0
|
|
118 |
*/
|
|
119 |
~CHnMenuItemModel();
|
|
120 |
|
|
121 |
/**
|
|
122 |
* Gets menu item model.
|
|
123 |
*
|
|
124 |
* @since S60 5.0
|
|
125 |
* @return Menu item structure
|
|
126 |
*/
|
|
127 |
IMPORT_C MHnMenuItemModelIterator* GetMenuStructure();
|
|
128 |
|
|
129 |
/**
|
|
130 |
* @see MHnMenuItemModelIterator.
|
|
131 |
*/
|
|
132 |
IMPORT_C virtual TBool HasNext();
|
|
133 |
|
|
134 |
/**
|
|
135 |
* @see MHnMenuItemModelIterator.
|
|
136 |
*/
|
|
137 |
IMPORT_C virtual CHnMenuItemModel* GetNext();
|
|
138 |
|
|
139 |
/**
|
|
140 |
* @see MHnMenuItemModelIterator.
|
|
141 |
*/
|
|
142 |
IMPORT_C virtual TBool HasNextSpecific();
|
|
143 |
|
|
144 |
/**
|
|
145 |
* @see MHnMenuItemModelIterator.
|
|
146 |
*/
|
|
147 |
IMPORT_C virtual CHnMenuItemModel* GetNextSpecific();
|
|
148 |
|
|
149 |
/**
|
|
150 |
* @see MHnMenuItemModelIterator.
|
|
151 |
*/
|
|
152 |
IMPORT_C virtual void Reset();
|
|
153 |
|
|
154 |
/**
|
|
155 |
* Gets name.
|
|
156 |
*
|
|
157 |
* @since S60 5.0
|
|
158 |
* @return Name of the menu.
|
|
159 |
*/
|
|
160 |
IMPORT_C const TDesC& NameL();
|
|
161 |
|
|
162 |
/**
|
|
163 |
* Gets command id.
|
|
164 |
*
|
|
165 |
* @since S60 5.0
|
|
166 |
* @return Command id.
|
|
167 |
*/
|
|
168 |
IMPORT_C TInt Command();
|
|
169 |
|
|
170 |
/**
|
|
171 |
* Sets command id.
|
|
172 |
*
|
|
173 |
* @since S60 5.0
|
|
174 |
* @param aCommandId Command id from data model.
|
|
175 |
*/
|
|
176 |
IMPORT_C void SetCommand( TInt aCommandId );
|
|
177 |
|
|
178 |
/**
|
|
179 |
* Gets menu item position.
|
|
180 |
*
|
|
181 |
* @since S60 5.0
|
|
182 |
* @return Position of item in menu.
|
|
183 |
*/
|
|
184 |
IMPORT_C TInt Position();
|
|
185 |
|
|
186 |
/**
|
|
187 |
* Sets menu item position.
|
|
188 |
*
|
|
189 |
* @since S60 5.0
|
|
190 |
* @param aPosition Position of item in menu.
|
|
191 |
*/
|
|
192 |
IMPORT_C void SetPosition( TInt aPosition );
|
|
193 |
|
|
194 |
/**
|
|
195 |
* Sets menu item type.
|
|
196 |
*
|
|
197 |
* @since S60 5.0
|
|
198 |
* @param aMenuItemType type of menu element.
|
|
199 |
*/
|
|
200 |
IMPORT_C void SetMenuItemType( THnMenuItemType aMenuItemType );
|
|
201 |
|
|
202 |
/**
|
|
203 |
* Appends child item.
|
|
204 |
*
|
|
205 |
* @since S60 5.0
|
|
206 |
* @param aMenuModel Menu item model.
|
|
207 |
*/
|
|
208 |
IMPORT_C void AppendChildMenuL( CHnMenuItemModel* aMenuModel );
|
|
209 |
|
|
210 |
/**
|
|
211 |
* Returns menu item type.
|
|
212 |
*
|
|
213 |
* @since S60 5.0
|
|
214 |
* @return menu item type.
|
|
215 |
*/
|
|
216 |
IMPORT_C THnMenuItemType MenuItemType();
|
|
217 |
|
|
218 |
private:
|
|
219 |
|
|
220 |
/**
|
|
221 |
* Default constructor.
|
|
222 |
*
|
|
223 |
* @since S60 5.0
|
|
224 |
*/
|
|
225 |
CHnMenuItemModel();
|
|
226 |
|
|
227 |
/**
|
|
228 |
* Second phase constructor.
|
|
229 |
*
|
|
230 |
* @since S60 5.0
|
|
231 |
* @param aName Name for menu item
|
|
232 |
*/
|
|
233 |
void ConstructL( const TDesC& aName );
|
|
234 |
|
|
235 |
private: // data
|
|
236 |
|
|
237 |
/**
|
|
238 |
* Name value cache.
|
|
239 |
*/
|
|
240 |
RBuf iName;
|
|
241 |
|
|
242 |
/**
|
|
243 |
* Command Id.
|
|
244 |
*/
|
|
245 |
TInt iCommand;
|
|
246 |
|
|
247 |
/**
|
|
248 |
* Position.
|
|
249 |
*/
|
|
250 |
TInt iPosition;
|
|
251 |
|
|
252 |
/**
|
|
253 |
* Next child.
|
|
254 |
*/
|
|
255 |
TInt iNextMenu;
|
|
256 |
|
|
257 |
/**
|
|
258 |
* Children pointer array.
|
|
259 |
*/
|
|
260 |
RPointerArray< CHnMenuItemModel > iChildren;
|
|
261 |
|
|
262 |
/**
|
|
263 |
* Type of menu item.
|
|
264 |
*/
|
|
265 |
THnMenuItemType iMenuItemType;
|
|
266 |
};
|
|
267 |
|
|
268 |
#endif // HNMENUITEMMODEL_H_
|