26
|
1 |
/*******************************************************************************
|
|
2 |
* Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved. This program and the accompanying materials
|
|
4 |
* are made available under the terms of the Eclipse Public License v1.0
|
|
5 |
* which accompanies this distribution, and is available at
|
|
6 |
* http://www.eclipse.org/legal/epl-v10.html
|
|
7 |
*
|
|
8 |
* Contributors:
|
|
9 |
* Nokia Corporation - S60 implementation
|
|
10 |
*******************************************************************************/
|
|
11 |
|
|
12 |
|
|
13 |
#ifndef SWTMENUARRANGER_H
|
|
14 |
#define SWTMENUARRANGER_H
|
|
15 |
|
|
16 |
|
|
17 |
#include "eswtwidgetscore.h"
|
|
18 |
|
|
19 |
|
|
20 |
class CSwtMenuBar;
|
|
21 |
#ifdef RD_SCALABLE_UI_V2
|
|
22 |
class CAknStylusPopUpMenu;
|
|
23 |
#endif //RD_SCALABLE_UI_V2
|
|
24 |
|
|
25 |
/**
|
|
26 |
* CSwtMenuArranger
|
|
27 |
* @lib eswt
|
|
28 |
*
|
|
29 |
* Context menus contain:
|
|
30 |
* # Prior to 9.2:
|
|
31 |
* - Specific control menu of focused control (Mark, Unmark, etc.).
|
|
32 |
* - OK & SELECT commands of focused control.
|
|
33 |
* - OK & SELECT commands of all parents of focused control.
|
|
34 |
* # Since 9.2:
|
|
35 |
* - No context menus in 9.2.
|
|
36 |
*
|
|
37 |
* Stylus popup menus contain:
|
|
38 |
* # Prior to 9.2:
|
|
39 |
* - Specific control menu of long tapped control (Mark, Unmark, etc.).
|
|
40 |
* - OK & SELECT commands of long tapped control.
|
|
41 |
* - OK & SELECT commands of all parents of long tapped control.
|
|
42 |
* if the control is also the focused control.
|
|
43 |
* - Popup menu of long tapped control (Control.setMenu()).
|
|
44 |
* # Since 9.2:
|
|
45 |
* - Specific control menu of long tapped control (Mark, Unmark, etc.).
|
|
46 |
* - All commands of long tapped control.
|
|
47 |
* - Popup menu of long tapped control (Control.setMenu()).
|
|
48 |
*
|
|
49 |
* Options menus contain:
|
|
50 |
* # Prior to 9.2:
|
|
51 |
* - Menu bar of active shell.
|
|
52 |
* - Specific control menu of focused control (Mark, Unmark, etc.).
|
|
53 |
* - All commands of all parents of focused control.
|
|
54 |
* - All commands of focused control.
|
|
55 |
* - Popup menu of focused control (Control.setMenu()).
|
|
56 |
* # Since 9.2:
|
|
57 |
* - Menu bar of active shell.
|
|
58 |
* - All commands of active shell.
|
|
59 |
*/
|
|
60 |
NONSHARABLE_CLASS(CSwtMenuArranger)
|
|
61 |
: public CBase
|
|
62 |
, public MEikMenuObserver
|
|
63 |
, public MSwtMenuArranger
|
|
64 |
{
|
|
65 |
public:
|
|
66 |
/**
|
|
67 |
* Two phase constructor.
|
|
68 |
* @param aDisplay Current display.
|
|
69 |
* @return Object pointer.
|
|
70 |
*/
|
|
71 |
static CSwtMenuArranger* NewL(MSwtDisplay& aDisplay);
|
|
72 |
|
|
73 |
/**
|
|
74 |
* Destructor
|
|
75 |
*/
|
|
76 |
~CSwtMenuArranger();
|
|
77 |
|
|
78 |
private:
|
|
79 |
/**
|
|
80 |
* First phase constructor.
|
|
81 |
* @param aDisplay Current display.
|
|
82 |
*/
|
|
83 |
inline CSwtMenuArranger(MSwtDisplay& aDisplay);
|
|
84 |
|
|
85 |
/**
|
|
86 |
* Second phase constructor.
|
|
87 |
*/
|
|
88 |
void ConstructL();
|
|
89 |
|
|
90 |
/**
|
|
91 |
* Compute menu bar.
|
|
92 |
*/
|
|
93 |
void ComputeCurrentMenuBar();
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Popup menu getter.
|
|
97 |
* @return MSwtMenu*
|
|
98 |
*/
|
|
99 |
const MSwtMenu* GetCurrentPopupMenu() const;
|
|
100 |
|
|
101 |
/**
|
|
102 |
* Control menu getter.
|
|
103 |
* @return MSwtMenu*
|
|
104 |
*/
|
|
105 |
const MSwtMenu* GetCurrentControlMenu() const;
|
|
106 |
|
|
107 |
/**
|
|
108 |
* Active menu bar getter.
|
|
109 |
* @return MSwtMenu*
|
|
110 |
*/
|
|
111 |
const MSwtMenu* GetActiveMenuBar() const;
|
|
112 |
|
|
113 |
/**
|
|
114 |
* Cascade menu getter.
|
|
115 |
* @param aItemData
|
|
116 |
* @return MSwtMenu*
|
|
117 |
*/
|
|
118 |
const MSwtMenu* GetCascadeMenu(const CEikMenuPaneItem::SData& aItemData) const;
|
|
119 |
|
|
120 |
/**
|
|
121 |
* Focused control getter.
|
|
122 |
* @return MSwtControl*
|
|
123 |
*/
|
|
124 |
const MSwtControl* GetFocusedControl() const;
|
|
125 |
|
|
126 |
/**
|
|
127 |
* Check if opened menu has radio group.
|
|
128 |
* @return true if radio group
|
|
129 |
*/
|
|
130 |
TBool OpenedMenusHaveRadioGroup() const;
|
|
131 |
|
|
132 |
/**
|
|
133 |
* Refresh CBA.
|
|
134 |
* @param aItemData aCommandArrangerRefreshRequired
|
|
135 |
*/
|
|
136 |
void RefreshCba(TBool aCommandArrangerRefreshRequired = ETrue,
|
|
137 |
TBool aFocusedControlOnly = EFalse);
|
|
138 |
|
|
139 |
/**
|
|
140 |
* Helper for handling menu pane visibility changes.
|
|
141 |
* The status of the new visibility must be known and passed as parameter.
|
|
142 |
* @param aStatus is the real visibility status.
|
|
143 |
*/
|
|
144 |
void HandlePaneVisibilityChangeL(CEikMenuPane* aPane, TBool aStatus);
|
|
145 |
|
|
146 |
/**
|
|
147 |
* Resets the list of opened menus, menu panes, etc.
|
|
148 |
*/
|
|
149 |
void ResetOpenedLists();
|
|
150 |
|
|
151 |
/**
|
|
152 |
* Updates the images size after resolution change
|
|
153 |
*/
|
|
154 |
void UpdateImageSize();
|
|
155 |
|
|
156 |
// From MSwtMenuArranger
|
|
157 |
public:
|
|
158 |
void ControlFocusLost();
|
|
159 |
void ControlFocusGained(const MSwtControl& aControl);
|
|
160 |
void ActiveShellLost();
|
|
161 |
void ActiveShellGained(const MSwtShell& aShell);
|
|
162 |
void MenuBarSetOnDecorations();
|
|
163 |
void SetCommandMenu(const MSwtMenu* aCommandMenu);
|
|
164 |
void SetContextMenu(const MSwtMenu* aCommandMenuOk);
|
|
165 |
void HandleMenuChangedL(const MSwtMenu& aMenu, TSwtMenuEvent aType);
|
|
166 |
CEikMenuBar* EikMenuBar() const;
|
|
167 |
void AddOptionsCommandL();
|
|
168 |
void RemoveOptionsCommand();
|
|
169 |
void UpdateOptionsCommandL();
|
|
170 |
TBool IsOptionsCommandAdded();
|
|
171 |
void TryDisplayMenuBarL(TBool aDisplayContextMenu);
|
|
172 |
void TryDisplayPopupMenuL(const MSwtMenu& aMenu);
|
|
173 |
void StopDisplayingPopupMenuL(const MSwtMenu& aMenu);
|
|
174 |
void StopDisplayingMenuBar();
|
|
175 |
TBool HasMenuItems() const;
|
|
176 |
void HandleResolutionChangeL();
|
|
177 |
void HandleWindowVisibilityChangeL(CCoeControl* aDestination);
|
|
178 |
TSize ImageSize() const;
|
|
179 |
CEikMenuPane* ParentPane(CEikMenuPane& aPane) const;
|
|
180 |
|
|
181 |
#ifdef RD_SCALABLE_UI_V2
|
|
182 |
void OpenStylusPopupMenuL(const MSwtControl& aControl, const TPoint& aPoint,
|
|
183 |
MSwtPopupMenuCallBack* aCallBack = NULL);
|
|
184 |
void OpenStylusPopupMenuL(const MSwtMenu& aMenu, const TPoint& aPoint);
|
|
185 |
void CloseStylusPopupMenuL();
|
|
186 |
#endif //RD_SCALABLE_UI_V2
|
|
187 |
|
|
188 |
// From MEikMenuObserver
|
|
189 |
public:
|
|
190 |
/**
|
|
191 |
* Dynamically initialises a menu pane. The framework calls this function
|
|
192 |
* immediately before the menu pane is activated. Typically should inquire
|
|
193 |
* the value of application data, and initialise menu items accordingly.
|
|
194 |
* This includes dimming menu items, changing their text, setting the state
|
|
195 |
* of checked items and radio buttons and dynamically adding items to a menu.
|
|
196 |
*/
|
|
197 |
void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
|
|
198 |
|
|
199 |
/**
|
|
200 |
* Called by the Uikon framework to handle the emphasising or de-emphasising
|
|
201 |
* of a menu window. CEikMenuBar objects call this on their observer to
|
|
202 |
* emphasise themselves when they are displayed, and de-emphasise themselves
|
|
203 |
* when they stop displaying.
|
|
204 |
*/
|
|
205 |
void SetEmphasis(CCoeControl* aMenuControl, TBool aEmphasis);
|
|
206 |
|
|
207 |
// From MEikCommandObserver
|
|
208 |
public:
|
|
209 |
void ProcessCommandL(TInt aCommandId);
|
|
210 |
|
|
211 |
// Data
|
|
212 |
private:
|
|
213 |
/**
|
|
214 |
* Related display.
|
|
215 |
*/
|
|
216 |
MSwtDisplay& iDisplay;
|
|
217 |
|
|
218 |
/**
|
|
219 |
* Current command menu, not owned, may be null.
|
|
220 |
*/
|
|
221 |
const MSwtMenu* iCommandMenu;
|
|
222 |
|
|
223 |
/**
|
|
224 |
* Current context menu, not owned, may be null
|
|
225 |
*/
|
|
226 |
const MSwtMenu* iCommandMenuOk;
|
|
227 |
|
|
228 |
/**
|
|
229 |
* Current menubar (default menubar or menubar of focused decorations)
|
|
230 |
*/
|
|
231 |
const MSwtMenu* iCurrentMenuBar;
|
|
232 |
|
|
233 |
/**
|
|
234 |
* Current menubar when focused decorations has no menubar, owned
|
|
235 |
*/
|
|
236 |
MSwtMenu* iDefaultMenuBar;
|
|
237 |
|
|
238 |
/**
|
|
239 |
* Control used to display menubar, owned
|
|
240 |
*/
|
|
241 |
CSwtMenuBar* iMenuBar;
|
|
242 |
|
|
243 |
/**
|
|
244 |
* Previous menubar control, not owned, may be null
|
|
245 |
*/
|
|
246 |
CEikMenuBar* iOldEikMenuBar;
|
|
247 |
|
|
248 |
/**
|
|
249 |
* Array of opened menus
|
|
250 |
*/
|
|
251 |
RPointerArray<MSwtMenu> iOpenedMenus;
|
|
252 |
|
|
253 |
/**
|
|
254 |
* Array of opened menu panes
|
|
255 |
*/
|
|
256 |
RPointerArray<CEikMenuPane> iOpenedMenuPanes;
|
|
257 |
|
|
258 |
/**
|
|
259 |
* Keeps track of the visibility of the panes.
|
|
260 |
* Needed to avoid a resolution change glitch.
|
|
261 |
*/
|
|
262 |
RArray<TBool> iOpenedMenuPanesVisibility;
|
|
263 |
|
|
264 |
/**
|
|
265 |
* The string for menu Options in right soft key
|
|
266 |
*/
|
|
267 |
HBufC* iOptionsString;
|
|
268 |
|
|
269 |
/**
|
|
270 |
* Flag for indicating if the "Options" command has been added in CBA
|
|
271 |
*/
|
|
272 |
TBool iOptionsCommandAdded;
|
|
273 |
|
|
274 |
/**
|
|
275 |
* Indicates if the menu bar is closing
|
|
276 |
*/
|
|
277 |
TBool iMenuBarIsClosing;
|
|
278 |
|
|
279 |
#ifdef RD_SCALABLE_UI_V2
|
|
280 |
/**
|
|
281 |
* Stylus popup menu
|
|
282 |
*/
|
|
283 |
CAknStylusPopUpMenu* iStylusPopup;
|
|
284 |
|
|
285 |
/**
|
|
286 |
* Indicates if the stylus popup menu is currently shown
|
|
287 |
*/
|
|
288 |
TBool iShowingStylusPopup;
|
|
289 |
#endif //RD_SCALABLE_UI_V2
|
|
290 |
|
|
291 |
/**
|
|
292 |
* Cached image size for the panes
|
|
293 |
*/
|
|
294 |
TSize iImageSize;
|
|
295 |
|
|
296 |
MSwtPopupMenuCallBack* iPopupMenuCallback;
|
|
297 |
};
|
|
298 |
|
|
299 |
|
|
300 |
#endif // SWTMENUARRANGER_H
|