|
1 /* |
|
2 * Copyright (c) 2009 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: Item action menu register. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_AKNITEMACTIONMENUREGISTER_H |
|
19 #define C_AKNITEMACTIONMENUREGISTER_H |
|
20 |
|
21 #include <coemain.h> |
|
22 |
|
23 class MAknCollection; |
|
24 class MAknCollectionObserver; |
|
25 class CAknItemActionMenuRegisterArray; |
|
26 class CAknItemActionMenu; |
|
27 class MObjectProvider; |
|
28 |
|
29 /** |
|
30 * Item action menu register. |
|
31 * |
|
32 * @lib eikcoctl |
|
33 * @since S60 v5.2 |
|
34 */ |
|
35 NONSHARABLE_CLASS( AknItemActionMenuRegister ) : public CCoeStatic |
|
36 { |
|
37 |
|
38 public: |
|
39 |
|
40 /** |
|
41 * Sets constructing menu bar owner. This method should be called |
|
42 * from constructing components that have menu bar (e.g. CAknView, |
|
43 * CAknDialog). This way the item action menu can be linked |
|
44 * to correct menu bar. |
|
45 * |
|
46 * @internal |
|
47 * @param aMenuBarOwner Pointer to constructing menu bar owner. |
|
48 */ |
|
49 IMPORT_C static void SetConstructingMenuBarOwnerL( |
|
50 MObjectProvider* aMenuBarOwner ); |
|
51 |
|
52 /** |
|
53 * Sets a menu bar owner that overrides all other possible menubar |
|
54 * providers. This menu bar owner is meant to be temporary and should be |
|
55 * set by components that: |
|
56 * -May contain a listbox. |
|
57 * -Have their own menubar. |
|
58 * |
|
59 * When such a component is destroyed it must call this method again with |
|
60 * NULL paramater to unregister the overriding menu bar owner. |
|
61 * |
|
62 * @internal |
|
63 * @param aMenuBarOwner Pointer to overriding menu bar owner. |
|
64 * @param aFlags Flags, not currently used. |
|
65 */ |
|
66 IMPORT_C static void SetOverridingMenuBarOwnerL( |
|
67 MObjectProvider* aMenuBarOwner, TUint aFlags = 0 ); |
|
68 |
|
69 /** |
|
70 * Registers a collection. |
|
71 * |
|
72 * @internal |
|
73 * @param aCollection Collection to be registered. |
|
74 * @return Item action menu the collection was registered to. |
|
75 */ |
|
76 static CAknItemActionMenu* RegisterCollectionL( |
|
77 MAknCollection& aCollection ); |
|
78 |
|
79 /** |
|
80 * Registers item action menu to aMenuBar. |
|
81 * |
|
82 * @internal |
|
83 * @param aMenuBar Calling menu bar. |
|
84 */ |
|
85 static void RegisterMenuBarL( CEikMenuBar& aMenuBar ); |
|
86 |
|
87 /** |
|
88 * Unregisters menu bar. |
|
89 * |
|
90 * @internal |
|
91 * @param aMenuBar Calling menu bar. |
|
92 */ |
|
93 static void UnregisterMenuBar( CEikMenuBar& aMenuBar ); |
|
94 |
|
95 /** |
|
96 * Registers aItemActionMenu to menu bar. |
|
97 * |
|
98 * @internal |
|
99 * @param aItemActionMenu Calling item action menu. |
|
100 */ |
|
101 static void RegisterItemActionMenuL( CAknItemActionMenu& aItemActionMenu ); |
|
102 |
|
103 /** |
|
104 * Unregisters item action menu. |
|
105 * |
|
106 * @internal |
|
107 * @param aItemActionMenu Calling item action menu. |
|
108 */ |
|
109 static void UnregisterItemActionMenu( |
|
110 CAknItemActionMenu& aItemActionMenu ); |
|
111 |
|
112 /** |
|
113 * Registers collection observer. |
|
114 * |
|
115 * @internal |
|
116 * @param aObserver Collection observer. |
|
117 */ |
|
118 static void RegisterCollectionObserverL( |
|
119 MAknCollectionObserver& aObserver ); |
|
120 |
|
121 /** |
|
122 * Unregisters collection observer. |
|
123 * |
|
124 * @internal |
|
125 * @param aObserver Collection observer. |
|
126 */ |
|
127 static void UnregisterCollectionObserver( |
|
128 MAknCollectionObserver& aObserver ); |
|
129 |
|
130 /** |
|
131 * Destructor. |
|
132 */ |
|
133 virtual ~AknItemActionMenuRegister(); |
|
134 |
|
135 private: |
|
136 |
|
137 /** |
|
138 * C++ constructor. |
|
139 */ |
|
140 AknItemActionMenuRegister(); |
|
141 |
|
142 /** |
|
143 * Symbian second-phase constructor. |
|
144 */ |
|
145 void ConstructL(); |
|
146 |
|
147 /** |
|
148 * Returns ETrue if application is single click compatible. |
|
149 * |
|
150 * @return ETrue if application is single click compatible. |
|
151 */ |
|
152 static TBool AppUiSingleClickCompatible(); |
|
153 |
|
154 /** |
|
155 * Provides register instance. |
|
156 * |
|
157 * @return Item action menu register instance. |
|
158 */ |
|
159 static AknItemActionMenuRegister* Instance(); |
|
160 |
|
161 /** |
|
162 * Registers collection. |
|
163 * |
|
164 * @param aCollection State to be registered. |
|
165 * @return Item action menu the collection was registered to. |
|
166 */ |
|
167 CAknItemActionMenu* DoRegisterCollectionL( |
|
168 MAknCollection& aCollection ); |
|
169 |
|
170 /** |
|
171 * Registers item action menu to aMenuBar. |
|
172 * |
|
173 * @param aMenuBar Calling menu bar. |
|
174 */ |
|
175 void DoRegisterMenuBarL( CEikMenuBar& aMenuBar ); |
|
176 |
|
177 /** |
|
178 * Unregisters menu bar. |
|
179 * |
|
180 * @param aMenuBar Calling menu bar. |
|
181 */ |
|
182 void DoUnregisterMenuBar( CEikMenuBar& aMenuBar ); |
|
183 |
|
184 /** |
|
185 * Registers aItemActionMenu to menu bar. |
|
186 * |
|
187 * @param aItemActionMenu Calling item action menu. |
|
188 */ |
|
189 void DoRegisterItemActionMenuL( CAknItemActionMenu& aItemActionMenu ); |
|
190 |
|
191 /** |
|
192 * Unregisters item action menu. |
|
193 * |
|
194 * @param aItemActionMenu Calling item action menu. |
|
195 */ |
|
196 void DoUnregisterItemActionMenu( CAknItemActionMenu& aItemActionMenu ); |
|
197 |
|
198 /** |
|
199 * Registers collection observer. |
|
200 * |
|
201 * @param aObserver Collection observer. |
|
202 */ |
|
203 void DoRegisterCollectionObserverL( |
|
204 MAknCollectionObserver& aObserver ); |
|
205 |
|
206 /** |
|
207 * Unregisters collection observer. |
|
208 * |
|
209 * @param aObserver Collection observer. |
|
210 */ |
|
211 void DoUnregisterCollectionObserver( MAknCollectionObserver& aObserver ); |
|
212 |
|
213 /** |
|
214 * Returns the pointer to visible dialog menu bar. |
|
215 * |
|
216 * @param aAppUi AppUi. |
|
217 * @return Visible dialog menu bar. |
|
218 */ |
|
219 CEikMenuBar* DialogMenuBar( CAknAppUi* aAppUi ); |
|
220 |
|
221 /** |
|
222 * Returns the pointer to active view menu bar. |
|
223 * |
|
224 * @param aAppUi AppUi. |
|
225 * @return Active view menu bar. |
|
226 */ |
|
227 CEikMenuBar* ViewMenuBar( CAknAppUi* aAppUi ); |
|
228 |
|
229 /** |
|
230 * Returns the pointer to constructing object menu bar. |
|
231 * |
|
232 * @return Constructing object menu bar. |
|
233 */ |
|
234 CEikMenuBar* ConstructingObjectMenuBar(); |
|
235 |
|
236 /** |
|
237 * Returns the pointer to overriding object menu bar. |
|
238 * |
|
239 * @return Overriding object menu bar. |
|
240 */ |
|
241 CEikMenuBar* OverridingObjectMenuBar(); |
|
242 |
|
243 /** |
|
244 * Registers collection to item action menu. |
|
245 * Creates and sets item action menu to menu bar |
|
246 * if one is not found. If menu bar is not found, item action menu |
|
247 * is stored to iUnregisteredMenus for later usage. |
|
248 * |
|
249 * @param aMenuBar Menu bar |
|
250 * @param aCollection Collection to be registered. |
|
251 * @return Pointer to item action menu collection was registered to. |
|
252 */ |
|
253 CAknItemActionMenu* RegisterStateToItemActionMenuL( |
|
254 CEikMenuBar* aMenuBar, |
|
255 MAknCollection& aCollection ); |
|
256 |
|
257 /** |
|
258 * Provides pointer to the current menu bar. |
|
259 * |
|
260 * @internal |
|
261 * @return Pointer to menu bar. |
|
262 */ |
|
263 CEikMenuBar* FindCurrentMenuBarL(); |
|
264 |
|
265 /** |
|
266 * Adds register entry. |
|
267 * |
|
268 * @param aMenuBar Menu bar. |
|
269 * @param aItemActionMenu Item action menu. |
|
270 */ |
|
271 void AddRegisterEntryL( |
|
272 CEikMenuBar& aMenuBar, CAknItemActionMenu& aItemActionMenu ); |
|
273 |
|
274 /** |
|
275 * Adds observers with aMenuBar to item action menu. |
|
276 * |
|
277 * @param aMenuBar Menu bar. |
|
278 * @param aItemActionMenu Item action menu. |
|
279 */ |
|
280 void AddObserversToItemActionMenuL( |
|
281 CEikMenuBar* aMenuBar, CAknItemActionMenu& aItemActionMenu ); |
|
282 |
|
283 /** |
|
284 * Creates register instance. |
|
285 * |
|
286 * @return Item action menu register instance. |
|
287 */ |
|
288 static AknItemActionMenuRegister* CreateInstanceL(); |
|
289 private: // data |
|
290 |
|
291 /** |
|
292 * Data class for unregistered menus. |
|
293 * |
|
294 * @lib eikcoctl |
|
295 * @since S60 v5.2 |
|
296 */ |
|
297 class TAknUnregisteredMenuData |
|
298 { |
|
299 public: |
|
300 /** |
|
301 * Pointer to unregistered menu owner. |
|
302 */ |
|
303 MObjectProvider* iOwner; |
|
304 |
|
305 /** |
|
306 * Pointer to unregistered menu. |
|
307 */ |
|
308 CAknItemActionMenu* iMenu; |
|
309 }; |
|
310 |
|
311 /** |
|
312 * Data class for unregistered observers. |
|
313 */ |
|
314 class TAknUnregisteredObserverData |
|
315 { |
|
316 |
|
317 public: |
|
318 /** |
|
319 * C++ constructor. |
|
320 */ |
|
321 TAknUnregisteredObserverData( |
|
322 CEikMenuBar* aMenuBar, |
|
323 MAknCollectionObserver& aObserver ); |
|
324 |
|
325 public: |
|
326 /** |
|
327 * Reference to menu bar. |
|
328 */ |
|
329 CEikMenuBar* iMenuBar; |
|
330 |
|
331 /** |
|
332 * Observer. |
|
333 */ |
|
334 MAknCollectionObserver& iObserver; |
|
335 }; |
|
336 |
|
337 /** |
|
338 * Menu bar owner that is currently being constructed. |
|
339 * Not own. |
|
340 */ |
|
341 MObjectProvider* iMenuBarOwner; |
|
342 |
|
343 /** |
|
344 * Unregistered menu data. |
|
345 */ |
|
346 RArray<TAknUnregisteredMenuData> iUnregisteredMenus; |
|
347 |
|
348 /** |
|
349 * Unregistered menu observers. |
|
350 */ |
|
351 RArray<TAknUnregisteredObserverData> iUnregisteredObservers; |
|
352 |
|
353 /** |
|
354 * Register array. |
|
355 * Own. |
|
356 */ |
|
357 CAknItemActionMenuRegisterArray* iRegisterArray; |
|
358 |
|
359 /** |
|
360 * Menu bar owner used to override all other menubar providers. |
|
361 * Not own. |
|
362 */ |
|
363 MObjectProvider* iOverridingMenuBarOwner; |
|
364 }; |
|
365 |
|
366 #endif // C_AKNITEMACTIONMENUREGISTER_H |
|
367 |