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: |
|
15 * Provides the FEP's Avkon UI access methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 #include "AknFepUiAvkonMenus.h" |
|
31 #include <eikmenub.h> |
|
32 #include <eikmenup.h> |
|
33 #include <eikappui.h> |
|
34 |
|
35 CAknFepUIAvkonMenuPaneImpl::CAknFepUIAvkonMenuPaneImpl() |
|
36 { |
|
37 } |
|
38 |
|
39 void CAknFepUIAvkonMenuPaneImpl::ConstructMenuSctRowFromDialogL( TInt aCharCase, TDes& aSpecialChars, TInt aResourceId ) |
|
40 { |
|
41 if (iMenuPane) |
|
42 iMenuPane->ConstructMenuSctRowFromDialogL(aCharCase, aSpecialChars, aResourceId); |
|
43 } |
|
44 |
|
45 void CAknFepUIAvkonMenuPaneImpl::ConstructMenuSctRowL( TDes& aSpecialChars, TInt aResourceId ) |
|
46 { |
|
47 if (iMenuPane) |
|
48 iMenuPane->ConstructMenuSctRowL(aSpecialChars, aResourceId); |
|
49 } |
|
50 |
|
51 void CAknFepUIAvkonMenuPaneImpl::DeleteMenuItem(TInt aCommandId) |
|
52 { |
|
53 if (iMenuPane) |
|
54 iMenuPane->DeleteMenuItem(aCommandId); |
|
55 } |
|
56 |
|
57 void CAknFepUIAvkonMenuPaneImpl::InsertMenuItemL(const SItemData& aMenuItem, TInt aPosition) |
|
58 { |
|
59 if (iMenuPane) |
|
60 iMenuPane->InsertMenuItemL(*reinterpret_cast<const CEikMenuPaneItem::SData*>(&aMenuItem), aPosition); |
|
61 } |
|
62 |
|
63 TBool CAknFepUIAvkonMenuPaneImpl::MenuItemExists(TInt aCommandId, TInt& aPosition) |
|
64 { |
|
65 if (iMenuPane) |
|
66 return iMenuPane->MenuItemExists(aCommandId, aPosition); |
|
67 return EFalse; |
|
68 } |
|
69 |
|
70 TInt CAknFepUIAvkonMenuPaneImpl::NumberOfItemsInPane() const |
|
71 { |
|
72 if (iMenuPane) |
|
73 return iMenuPane->NumberOfItemsInPane(); |
|
74 return 0; |
|
75 } |
|
76 |
|
77 void CAknFepUIAvkonMenuPaneImpl::SetItemDimmed(TInt aCommandId, TBool aDimmed) |
|
78 { |
|
79 TInt index(0); |
|
80 if (iMenuPane && MenuItemExists( aCommandId, index ) ) |
|
81 iMenuPane->SetItemDimmed(aCommandId, aDimmed); |
|
82 } |
|
83 |
|
84 void CAknFepUIAvkonMenuPaneImpl::SetMenuPane(CEikMenuPane* aMenuPane) |
|
85 { |
|
86 iMenuPane = aMenuPane; |
|
87 } |
|
88 |
|
89 CEikMenuPane* CAknFepUIAvkonMenuPaneImpl::GetMenuPane() |
|
90 { |
|
91 return iMenuPane; |
|
92 } |
|
93 |
|
94 CAknFepUIAvkonMenuBarImpl::CAknFepUIAvkonMenuBarImpl() |
|
95 { |
|
96 } |
|
97 |
|
98 CAknFepUiInterfaceMenuPane* CAknFepUIAvkonMenuBarImpl::MenuPane() |
|
99 { |
|
100 if (iMenuBar) |
|
101 { |
|
102 iTempMenuPane.iMenuPane = iMenuBar->MenuPane(); |
|
103 } |
|
104 return &iTempMenuPane; |
|
105 } |
|
106 |
|
107 void CAknFepUIAvkonMenuBarImpl::SetMenuType(TMenuType aMenuType) |
|
108 { |
|
109 if (iMenuBar) |
|
110 iMenuBar->SetMenuType(static_cast<CEikMenuBar::TMenuType>(aMenuType)); |
|
111 } |
|
112 |
|
113 void CAknFepUIAvkonMenuBarImpl::StopDisplayingMenuBar() |
|
114 { |
|
115 if (iMenuBar) |
|
116 iMenuBar->StopDisplayingMenuBar(); |
|
117 } |
|
118 |
|
119 void CAknFepUIAvkonMenuBarImpl::ReplaceAllMenuPanes(TInt aResourceId) |
|
120 { |
|
121 // remove app menu panes |
|
122 TInt count = iMenuBar->TitleArray()->Count() - 1; |
|
123 for (TInt ii = 0; ii<count; ii++) |
|
124 { |
|
125 delete iMenuBar->TitleArray()->At(0); |
|
126 iMenuBar->TitleArray()->Delete(0); |
|
127 } |
|
128 // add the mode menu |
|
129 iMenuBar->TitleArray()->At(0)->iData.iMenuPaneResourceId = aResourceId; |
|
130 } |
|
131 |
|
132 void CAknFepUIAvkonMenuBarImpl::TryDisplayMenuBarL() |
|
133 { |
|
134 if (iMenuBar) |
|
135 iMenuBar->TryDisplayMenuBarL(); |
|
136 } |
|
137 |
|
138 void CAknFepUIAvkonMenuBarImpl::SetFocus(TBool aFocus) |
|
139 { |
|
140 if (iMenuBar) |
|
141 iMenuBar->SetFocus(aFocus); |
|
142 } |
|
143 |
|
144 void CAknFepUIAvkonMenuBarImpl::RemoveFromStack() |
|
145 { |
|
146 if (iMenuBar) |
|
147 CCoeEnv::Static()->AppUi()->RemoveFromStack(iMenuBar); |
|
148 } |
|
149 |
|
150 TInt CAknFepUIAvkonMenuBarImpl::FirstMenuPaneResourceId() |
|
151 { |
|
152 if (iMenuBar) |
|
153 { |
|
154 CEikMenuBar::CTitleArray* titles = iMenuBar->TitleArray(); |
|
155 if( titles->Count() > 0 ) |
|
156 { |
|
157 return (*titles)[0]->iData.iMenuPaneResourceId; |
|
158 } |
|
159 } |
|
160 return 0; |
|
161 } |
|
162 |
|
163 TBool CAknFepUIAvkonMenuBarImpl::IsDisplayed() |
|
164 { |
|
165 if (iMenuBar) |
|
166 return iMenuBar->IsDisplayed(); |
|
167 return EFalse; |
|
168 } |
|
169 |
|
170 void CAknFepUIAvkonMenuBarImpl::AddToStackL(TInt aPriority, TInt aStackingFlags) |
|
171 { |
|
172 if (iMenuBar) |
|
173 CCoeEnv::Static()->AppUi()->AddToStackL(iMenuBar, aPriority, aStackingFlags); |
|
174 } |
|
175 |
|
176 void CAknFepUIAvkonMenuBarImpl::TryDisplayMenuBarWithoutFepMenusL() |
|
177 { |
|
178 if (iMenuBar) |
|
179 iMenuBar->TryDisplayMenuBarWithoutFepMenusL(); |
|
180 } |
|
181 |
|
182 void CAknFepUIAvkonMenuBarImpl::SetMenuTitleResourceId(TInt aResourceId) |
|
183 { |
|
184 if (iMenuBar) |
|
185 iMenuBar->SetMenuTitleResourceId(aResourceId); |
|
186 } |
|
187 |
|
188 void CAknFepUIAvkonMenuBarImpl::SetEditMenuObserver(MAknFepUiInterfaceMenuObserver* aEditMenuObserver) |
|
189 { |
|
190 iEditMenuObserver.iObserver = aEditMenuObserver; |
|
191 iMenuBar->SetEditMenuObserver(&iEditMenuObserver); |
|
192 } |
|
193 |
|
194 void CAknFepUIAvkonMenuBarImpl::RemoveEditMenuObserver(MAknFepUiInterfaceMenuObserver* aEditMenuObserver) |
|
195 { |
|
196 if (iEditMenuObserver.iObserver == aEditMenuObserver) |
|
197 { |
|
198 iMenuBar->RemoveEditMenuObserver(&iEditMenuObserver); |
|
199 } |
|
200 } |
|
201 |
|
202 void CAknFepUIAvkonMenuBarImpl::TEditMenuObserver::ProcessCommandL(TInt aCommandId) |
|
203 { |
|
204 if (iObserver) |
|
205 iObserver->ProcessCommandL(aCommandId); |
|
206 } |
|
207 |
|
208 void CAknFepUIAvkonMenuBarImpl::TEditMenuObserver::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) |
|
209 { |
|
210 if (iObserver) |
|
211 { |
|
212 iTempPane.iMenuPane = aMenuPane; |
|
213 iObserver->DynInitMenuPaneL(aResourceId, &iTempPane); |
|
214 } |
|
215 } |
|
216 |
|
217 void CAknFepUIAvkonMenuBarImpl::TEditMenuObserver::SetEmphasis(CCoeControl* /*aMenuControl*/,TBool aEmphasis) |
|
218 { |
|
219 // client code is not currently using aMenuControl |
|
220 if (iObserver) |
|
221 iObserver->SetEmphasis(NULL, aEmphasis); |
|
222 } |
|
223 |
|
224 |
|
225 CAknFepUIAvkonMenuBarOwningImpl::~CAknFepUIAvkonMenuBarOwningImpl() |
|
226 { |
|
227 delete iMenuBar; |
|
228 } |
|
229 |
|
230 void CAknFepUIAvkonMenuBarOwningImpl::ConstructL(MAknFepUiInterfaceMenuObserver* aObserver, TInt aHotKeyResourceId, TInt aMenuTitleResourceId) |
|
231 { |
|
232 iObserver = aObserver; |
|
233 iMenuBar = new (ELeave) CEikMenuBar() ; |
|
234 iMenuBar->ConstructL(this, aHotKeyResourceId, aMenuTitleResourceId) ; |
|
235 } |
|
236 |
|
237 void CAknFepUIAvkonMenuBarOwningImpl::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) |
|
238 { |
|
239 iTempMenuPane.iMenuPane = aMenuPane; |
|
240 if (iObserver) |
|
241 iObserver->DynInitMenuPaneL(aResourceId, &iTempMenuPane); |
|
242 } |
|
243 |
|
244 void CAknFepUIAvkonMenuBarOwningImpl::DynInitMenuBarL(TInt aResourceId,CEikMenuBar* /*aMenuBar*/) |
|
245 { |
|
246 if (iObserver) |
|
247 iObserver->DynInitMenuBarL(aResourceId, this); |
|
248 } |
|
249 |
|
250 void CAknFepUIAvkonMenuBarOwningImpl::SetEmphasis(CCoeControl* aMenuControl,TBool aEmphasis) |
|
251 { |
|
252 CBase* obj = this; |
|
253 if (aMenuControl != iMenuBar) |
|
254 { |
|
255 iTempMenuPane.iMenuPane = static_cast<CEikMenuPane*>(aMenuControl); |
|
256 obj = &iTempMenuPane; |
|
257 } |
|
258 if (iObserver) |
|
259 iObserver->SetEmphasis(obj, aEmphasis); |
|
260 } |
|
261 |
|
262 void CAknFepUIAvkonMenuBarOwningImpl::ProcessCommandL(TInt aCommandId) |
|
263 { |
|
264 if (iObserver) |
|
265 iObserver->ProcessCommandL(aCommandId); |
|
266 } |
|
267 |
|