|
1 /* |
|
2 * Copyright (c) 1997-1999 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
21 #include <uikon/eikctrlstatus.h> |
|
22 #include <uikon/eikenvinterface.h> |
|
23 #endif |
|
24 #include <eikcolib.h> |
|
25 #include <eikappui.h> |
|
26 #include <eiktbar.h> |
|
27 #include <eikcoctl.rsg> |
|
28 #include <eikenv.h> |
|
29 #include <eikdoc.h> |
|
30 #include <eiklabel.h> |
|
31 #include <uikon.hrh> |
|
32 #include <eikapp.h> |
|
33 #include <eikmenub.h> |
|
34 #include <eikhkeyt.h> |
|
35 #include <eikhkeyc.h> |
|
36 #include <eikpanic.h> |
|
37 #include <eikcmbut.h> |
|
38 #include <eiksfont.h> |
|
39 #include <eikedwin.h> |
|
40 #include <eikmnbut.h> |
|
41 #include <eikimage.h> |
|
42 #include <eiklbbut.h> |
|
43 #include <eiktxlbx.h> |
|
44 #include <eikfnlab.h> |
|
45 #include <eikbtgpc.h> |
|
46 #include <eikscrlb.h> |
|
47 #include <uiklaf/private/lafappui.h> |
|
48 #include "LAFMENUB.H" |
|
49 #include <eikbtpan.h> |
|
50 #include <barsread.h> |
|
51 #include <barsc.h> |
|
52 #include <eikcba.h> |
|
53 #include "eikmop.h" |
|
54 #include <AknSgcc.h> |
|
55 #include <AknLayout.lag> |
|
56 #include <eikcoctlpanic.h> |
|
57 #include <akntoolbar.h> |
|
58 #include <akntoolbarextension.h> |
|
59 #include <aknappui.h> |
|
60 |
|
61 #ifdef RD_SCALABLE_UI_V2 |
|
62 #include <featmgr.h> |
|
63 #include <bldvariant.hrh> |
|
64 #include <akntouchpane.h> |
|
65 #include <AknStatuspaneUtils.h> |
|
66 #include <aknpriv.rsg> |
|
67 #endif // RD_SCALABLE_UI_V2 |
|
68 |
|
69 #include <layoutmetadata.cdl.h> |
|
70 #include <aknlayoutscalable_avkon.cdl.h> |
|
71 #include <AknPriv.hrh> |
|
72 #include <aknlayout.cdl.h> |
|
73 |
|
74 // Static DLL functions |
|
75 GLDEF_C void Panic(TEikPanic aPanic) |
|
76 { |
|
77 _LIT(KPanicCat,"EIKCOCTL"); |
|
78 User::Panic(KPanicCat,aPanic); |
|
79 } |
|
80 |
|
81 GLDEF_C void Panic(TEikCoCtlPanic aPanic) |
|
82 { |
|
83 _LIT(KPanicCat,"AVKON-EIKCOCTL"); |
|
84 User::Panic(KPanicCat,aPanic); |
|
85 } |
|
86 |
|
87 /////////////////////////////////////////////////////////////////////////////////////// |
|
88 // |
|
89 // CEikAppUiFactoryExtension |
|
90 // |
|
91 /////////////////////////////////////////////////////////////////////////////////////// |
|
92 |
|
93 class CEikAppUiFactoryExtension : public CBase |
|
94 { |
|
95 public: |
|
96 static CEikAppUiFactoryExtension* NewL(); |
|
97 void ReadAppInfoResourceExtensionL( TInt aResourceId ); |
|
98 ~CEikAppUiFactoryExtension(); |
|
99 void CreateDefaultToolbarL(); |
|
100 private: |
|
101 CEikAppUiFactoryExtension(); |
|
102 void ConstructL(); |
|
103 public: |
|
104 CEikButtonGroupContainer* iCba; |
|
105 CAknTouchPane* iTouchPane; |
|
106 CAknToolbar* iPopupToolbar; |
|
107 CAknToolbar* iViewPopupToolbar; // not owned |
|
108 CAknToolbar* iFixedToolbar; |
|
109 CAknToolbar* iViewFixedToolbar; // not owned |
|
110 TBool iSplitInput; |
|
111 }; |
|
112 |
|
113 CEikAppUiFactoryExtension* CEikAppUiFactoryExtension::NewL() |
|
114 { |
|
115 CEikAppUiFactoryExtension* self = new(ELeave) CEikAppUiFactoryExtension; |
|
116 CleanupStack::PushL( self ); |
|
117 self->ConstructL(); |
|
118 CleanupStack::Pop( self ); |
|
119 return self; |
|
120 } |
|
121 |
|
122 CEikAppUiFactoryExtension::~CEikAppUiFactoryExtension() |
|
123 { |
|
124 delete iCba; |
|
125 #ifdef RD_SCALABLE_UI_V2 |
|
126 delete iTouchPane; |
|
127 delete iFixedToolbar; |
|
128 #endif // RD_SCALABLE_UI_V2 |
|
129 delete iPopupToolbar; |
|
130 |
|
131 } |
|
132 |
|
133 CEikAppUiFactoryExtension::CEikAppUiFactoryExtension() |
|
134 { |
|
135 iSplitInput = EFalse; |
|
136 } |
|
137 |
|
138 void CEikAppUiFactoryExtension::ConstructL() |
|
139 { |
|
140 } |
|
141 |
|
142 void CEikAppUiFactoryExtension::ReadAppInfoResourceExtensionL( TInt aExtResourceId ) |
|
143 { |
|
144 struct SEikAppInfoExtension |
|
145 { |
|
146 TInt iTouchPaneId; |
|
147 TInt iPopupToolbarId; |
|
148 TInt iSpare1Id; |
|
149 TInt iSpare2Id; |
|
150 } appInfoExt; |
|
151 |
|
152 TPtr8 ptr( ( TText8* )&appInfoExt, sizeof( appInfoExt ) ); |
|
153 // set all members of appInfo to zero, in case of ignored |
|
154 // leave during resource reading |
|
155 ptr.FillZ(ptr.MaxLength()); |
|
156 |
|
157 // if application resource structure has extension |
|
158 if ( aExtResourceId ) |
|
159 { |
|
160 CCoeEnv::Static()->ReadResourceAsDes8L( ptr, aExtResourceId ); |
|
161 } |
|
162 |
|
163 #ifdef RD_SCALABLE_UI_V2 |
|
164 FeatureManager::InitializeLibL(); |
|
165 if ( FeatureManager::FeatureSupported( KFeatureIdPenSupport ) ) |
|
166 { |
|
167 delete iTouchPane; iTouchPane = NULL; |
|
168 |
|
169 if ( appInfoExt.iTouchPaneId ) |
|
170 { |
|
171 iTouchPane = CAknTouchPane::NewL( appInfoExt.iTouchPaneId ); |
|
172 } |
|
173 else |
|
174 { |
|
175 iTouchPane = CAknTouchPane::NewL(); |
|
176 } |
|
177 } |
|
178 FeatureManager::UnInitializeLib(); |
|
179 #endif // RD_SCALABLE_UI_V2 |
|
180 |
|
181 if ( appInfoExt.iPopupToolbarId ) |
|
182 { |
|
183 if ( iPopupToolbar ) |
|
184 { |
|
185 delete iPopupToolbar; |
|
186 iPopupToolbar = NULL; |
|
187 } |
|
188 iPopupToolbar = CAknToolbar::NewL( appInfoExt.iPopupToolbarId ); |
|
189 CEikonEnv* eikEnv = CEikonEnv::Static(); |
|
190 CAknAppUi* base = (CAknAppUi*)eikEnv->EikAppUi(); |
|
191 if (base) |
|
192 { |
|
193 iPopupToolbar->SetMopParent(base); |
|
194 } |
|
195 #ifdef RD_SCALABLE_UI_V2 |
|
196 if ( iPopupToolbar->ToolbarFlags() & KAknToolbarFixed ) |
|
197 { |
|
198 iFixedToolbar = iPopupToolbar; |
|
199 iPopupToolbar = NULL; |
|
200 } |
|
201 if ( iTouchPane ) |
|
202 { |
|
203 iPopupToolbar->SetObserver( iTouchPane ); |
|
204 } |
|
205 #endif // RD_SCALABLE_UI_V2 |
|
206 } |
|
207 if ( !iFixedToolbar ) |
|
208 { |
|
209 CreateDefaultToolbarL(); |
|
210 } |
|
211 } |
|
212 |
|
213 void CEikAppUiFactoryExtension::CreateDefaultToolbarL() |
|
214 { |
|
215 if ( !iFixedToolbar ) |
|
216 { |
|
217 iFixedToolbar = CAknToolbar::NewL( R_AKNPRIV_TOOLBAR ); |
|
218 CEikonEnv* eikEnv = CEikonEnv::Static(); |
|
219 CAknAppUi* base = (CAknAppUi*)eikEnv->EikAppUi(); |
|
220 if (base) |
|
221 { |
|
222 iFixedToolbar->SetMopParent(base); |
|
223 } |
|
224 } |
|
225 } |
|
226 |
|
227 /////////////////////////////////////////////////////////////////////////////////////// |
|
228 // |
|
229 // CEikCoCtlLibrary |
|
230 // |
|
231 /////////////////////////////////////////////////////////////////////////////////////// |
|
232 CEikCoCtlLibrary::CEikCoCtlLibrary() |
|
233 { |
|
234 } |
|
235 |
|
236 /////////////////////////////////////////////////////////////////////////////////////// |
|
237 // |
|
238 // ResourceFile |
|
239 // |
|
240 /////////////////////////////////////////////////////////////////////////////////////// |
|
241 EXPORT_C TFileName CEikCoCtlLibrary::ResourceFile() |
|
242 { |
|
243 _LIT(KResFileName,"z:\\resource\\eikcoctl.rsc"); |
|
244 return KResFileName(); |
|
245 } |
|
246 |
|
247 /////////////////////////////////////////////////////////////////////////////////////// |
|
248 // |
|
249 // ControlFactory |
|
250 // |
|
251 /////////////////////////////////////////////////////////////////////////////////////// |
|
252 EXPORT_C TCreateByTypeFunction CEikCoCtlLibrary::ControlFactory() |
|
253 { |
|
254 return CreateByTypeL; |
|
255 } |
|
256 |
|
257 /** |
|
258 * @internal |
|
259 * Internal to Symbian |
|
260 * @since App-Framework_6.1 |
|
261 */ |
|
262 EXPORT_C TCreateButtonGroupByTypeFunction CEikCoCtlLibrary::ButtonGroupFactory() |
|
263 {//static |
|
264 return CreateButtonGroupByTypeL; |
|
265 } |
|
266 |
|
267 /////////////////////////////////////////////////////////////////////////////////////// |
|
268 // |
|
269 // CreateByTypeL |
|
270 // |
|
271 /////////////////////////////////////////////////////////////////////////////////////// |
|
272 SEikControlInfo CEikCoCtlLibrary::CreateByTypeL(TInt aControlType) |
|
273 { |
|
274 SEikControlInfo controlInfo; |
|
275 controlInfo.iControl = NULL; |
|
276 controlInfo.iTrailerTextId = 0; |
|
277 controlInfo.iFlags = 0; |
|
278 |
|
279 switch (aControlType) |
|
280 { |
|
281 case EEikCtEdwin: |
|
282 controlInfo.iControl = new(ELeave) CEikEdwin; |
|
283 break; |
|
284 case EEikCtListBox: |
|
285 controlInfo.iControl = new(ELeave) CEikTextListBox; |
|
286 break; |
|
287 case EEikCtLabel: |
|
288 controlInfo.iControl = new(ELeave) CEikLabel; |
|
289 controlInfo.iFlags = EEikControlIsNonFocusing|EEikControlHasExtraAscent; |
|
290 break; |
|
291 case EEikCtImage: |
|
292 controlInfo.iControl = new(ELeave) CEikImage; |
|
293 controlInfo.iFlags = EEikControlIsNonFocusing; |
|
294 break; |
|
295 case EEikCtCommandButton: |
|
296 controlInfo.iControl= new(ELeave) CEikCommandButton; |
|
297 controlInfo.iFlags = EEikControlIsNonFocusing; |
|
298 break; |
|
299 case EEikCtFileNameLabel: |
|
300 controlInfo.iControl = new(ELeave) CEikFileNameLabel; |
|
301 controlInfo.iFlags = EEikControlIsNonFocusing; |
|
302 break; |
|
303 case EEikCtMenuButton: |
|
304 controlInfo.iControl= new(ELeave) CEikMenuButton; |
|
305 break; |
|
306 case EEikCtTextButton: |
|
307 controlInfo.iControl= new(ELeave) CEikTextButton; |
|
308 controlInfo.iFlags = EEikControlIsNonFocusing; |
|
309 break; |
|
310 case EEikCtBitmapButton: |
|
311 controlInfo.iControl= new(ELeave) CEikBitmapButton; |
|
312 controlInfo.iFlags = EEikControlIsNonFocusing; |
|
313 break; |
|
314 case EEikCtLabeledButton: |
|
315 controlInfo.iControl = new(ELeave) CEikLabeledButton; |
|
316 controlInfo.iFlags = EEikControlIsNonFocusing; |
|
317 break; |
|
318 case EEikCtTwoPictureCommandButton: |
|
319 controlInfo.iControl= new(ELeave) CEikTwoPictureCommandButton; |
|
320 controlInfo.iFlags = EEikControlIsNonFocusing; |
|
321 break; |
|
322 case EEikCtInverterCommandButton: |
|
323 controlInfo.iControl= new(ELeave) CEikInverterCommandButton; |
|
324 controlInfo.iFlags = EEikControlIsNonFocusing; |
|
325 break; |
|
326 case EEikCtScrollBar: |
|
327 controlInfo.iControl = new(ELeave) CEikScrollBar; |
|
328 controlInfo.iFlags = EEikControlIsNonFocusing; |
|
329 break; |
|
330 case EAknCtToolbarExtension: |
|
331 controlInfo.iControl = CAknToolbarExtension::NewL(); |
|
332 break; |
|
333 default: |
|
334 break; |
|
335 } |
|
336 return controlInfo; |
|
337 } |
|
338 |
|
339 /** |
|
340 * Creates the button group identified by aButtonGroupType, if it exists in this button |
|
341 * group factory. Extra required information is supplied in aCreationData. If the button group |
|
342 * is to be added to the button group stack then this can be set in aAddToButtonGroupStack. |
|
343 * If the aButtonGroupType value does not exist, then it returns NULL. |
|
344 * |
|
345 * @internal |
|
346 * Internal to Symbian |
|
347 * @since App-Framework_6.1 |
|
348 */ |
|
349 MEikButtonGroup* CEikCoCtlLibrary::CreateButtonGroupByTypeL(TInt aButtonGroupType,EikButtonGroupFactory::TCreationData& aCreationData,TBool& aAddToButtonGroupStack) |
|
350 {//static |
|
351 MEikButtonGroup* buttonGroup = NULL; |
|
352 |
|
353 switch (aButtonGroupType) |
|
354 { |
|
355 case EEikBgToolBar: |
|
356 { |
|
357 CEikToolBar* toolBar=new(ELeave) CEikToolBar; |
|
358 CleanupStack::PushL(toolBar); |
|
359 TRect rect(CCoeEnv::Static()->ScreenDevice()->SizeInPixels()); |
|
360 toolBar->ConstructL(aCreationData.iCommandObserver,aCreationData.iResourceId,rect); |
|
361 CleanupStack::Pop(); // toolBar |
|
362 buttonGroup = toolBar; |
|
363 } |
|
364 break; |
|
365 case EEikBgButtonPanel: |
|
366 { |
|
367 CEikButtonPanel* buttonPanel=new(ELeave) CEikButtonPanel; |
|
368 CleanupStack::PushL(buttonPanel); |
|
369 CEikButtonGroupContainer* container = static_cast<CEikButtonGroupContainer*>(aCreationData.iCommandObserver); |
|
370 buttonPanel->SetContainerWindowL(*container); |
|
371 buttonPanel->SetCommandObserver(aCreationData.iCommandObserver); |
|
372 if (aCreationData.iResourceId==0) |
|
373 buttonPanel->ConstructL(); |
|
374 else |
|
375 { |
|
376 TResourceReader reader; |
|
377 CCoeEnv::Static()->CreateResourceReaderLC(reader,aCreationData.iResourceId); |
|
378 buttonPanel->ConstructFromResourceL(reader); |
|
379 CleanupStack::PopAndDestroy(); // reader |
|
380 } |
|
381 if (aCreationData.iOrientation==CEikButtonGroupContainer::EHorizontal) |
|
382 buttonPanel->SetHorizontal(); |
|
383 CleanupStack::Pop(); // buttonPanel |
|
384 buttonGroup = buttonPanel; |
|
385 } |
|
386 break; |
|
387 case EEikBgCba: |
|
388 { |
|
389 buttonGroup = CEikCba::NewLC(aCreationData.iResourceId, NULL, |
|
390 aCreationData.iCommandObserver, aCreationData.iParentWg, |
|
391 aCreationData.iFlags); |
|
392 CleanupStack::Pop(); // cba |
|
393 aAddToButtonGroupStack=ETrue; |
|
394 } |
|
395 break; |
|
396 default: |
|
397 break; |
|
398 } |
|
399 return buttonGroup; |
|
400 } |
|
401 |
|
402 |
|
403 /** |
|
404 * @internal |
|
405 */ |
|
406 EXPORT_C CEikAppUiFactory::CEikAppUiFactory() |
|
407 : iSidebarPopupId(-1) |
|
408 { |
|
409 } |
|
410 |
|
411 /** |
|
412 * @internal |
|
413 */ |
|
414 CEikAppUiFactory::~CEikAppUiFactory() |
|
415 { |
|
416 CCoeAppUi* appUi = CEikonEnv::Static()->EikAppUi(); |
|
417 if ( appUi ) |
|
418 appUi->RemoveFromStack(iMenuBar); |
|
419 delete(iMenuBar); |
|
420 delete(iToolBar); |
|
421 delete(iToolBand); |
|
422 delete(iTitleBand); |
|
423 delete(iStatusPane); |
|
424 delete(iExtension); |
|
425 } |
|
426 |
|
427 CEikCommandButton* CEikAppUiFactory::CreateStandardTabButtonL() const |
|
428 { |
|
429 CEikCommandButton *tabButton= new(ELeave) CEikCommandButton; |
|
430 CleanupStack::PushL(tabButton); |
|
431 TBuf<1> buf; |
|
432 buf.Append(TChar(ESymFontTabout)); |
|
433 tabButton->SetTextL(buf); |
|
434 tabButton->Label()->SetFont(CEikonEnv::Static()->SymbolFont()); |
|
435 const TInt height = CEikonEnv::Static()->EditableControlStandardHeight(); |
|
436 tabButton->SetSize(TSize(height+3,height)); |
|
437 CleanupStack::Pop(); |
|
438 return(tabButton); |
|
439 } |
|
440 |
|
441 void CEikAppUiFactory::CreateEmbeddedL(CEikonEnv& aEikonEnv) |
|
442 { |
|
443 CEikAppUiFactory* embeddedAppUiFactory = new(ELeave) CEikAppUiFactory(); |
|
444 CleanupStack::PushL(embeddedAppUiFactory); |
|
445 aEikonEnv.AddAppUiFactoryL(embeddedAppUiFactory); |
|
446 CleanupStack::Pop(); |
|
447 } |
|
448 |
|
449 void CEikAppUiFactory::DestroyEmbedded(CEikonEnv& aEikonEnv) |
|
450 { |
|
451 aEikonEnv.RemoveAppUiFactory(); |
|
452 delete this; |
|
453 } |
|
454 |
|
455 void CEikAppUiFactory::CreateResourceIndependentFurnitureL(CEikAppUi* aAppUi) |
|
456 { |
|
457 #ifdef RD_SCALABLE_UI_V2 |
|
458 FeatureManager::InitializeLibL(); |
|
459 if ( FeatureManager::FeatureSupported( KFeatureIdPenSupport ) ) |
|
460 { |
|
461 if ( !iExtension ) |
|
462 { |
|
463 iExtension = CEikAppUiFactoryExtension::NewL(); |
|
464 } |
|
465 |
|
466 if ( iExtension && !( iExtension->iTouchPane ) ) |
|
467 { |
|
468 iExtension->iTouchPane = CAknTouchPane::NewL(); |
|
469 } |
|
470 |
|
471 if ( iExtension ) |
|
472 { |
|
473 iExtension->CreateDefaultToolbarL(); |
|
474 } |
|
475 } |
|
476 FeatureManager::UnInitializeLib(); |
|
477 #endif // RD_SCALABLE_UI_V2 |
|
478 |
|
479 if(aAppUi->ContainerAppUi()) |
|
480 { |
|
481 AddTitleBandL(aAppUi); |
|
482 } |
|
483 CEikonEnv* eikEnv = CEikonEnv::Static(); |
|
484 if (eikEnv->StatusPaneCoreResId() != 0) |
|
485 { |
|
486 iStatusPane = CEikStatusPane::NewL(*eikEnv, &eikEnv->RootWin(), eikEnv->StatusPaneCoreResId(), EEikStatusPaneUseDefaults); |
|
487 CAknSgcClient::HandleChangeL(); // has to be called after iStatusPane is assigned |
|
488 } |
|
489 } |
|
490 |
|
491 void CEikAppUiFactory::AddTitleBandL(CEikAppUi* /*aAppUi*/) |
|
492 { |
|
493 /* AKNLAF - Series 60 does not require a title band for embedded apps |
|
494 iTitleBand=new(ELeave) CEikToolBar; |
|
495 iTitleBand->StaticConstructL(aAppUi,R_EIK_TBAR_TITLE); |
|
496 TBuf<64> tmp; |
|
497 const TApaAppCaption& object=aAppUi->Document()->AppCaption(); |
|
498 const TApaAppCaption& container=aAppUi->ContainerAppUi()->Document()->AppCaption(); |
|
499 CCoeEnv::Static()->Format128(tmp,R_EIK_TBUF_TITLE_BAR_LABEL,&object,&container); |
|
500 STATIC_CAST(CEikLabel*,iTitleBand->ControlById(EEikCidTitleBarLabel))->SetTextL(tmp); |
|
501 CCoeControl* ctrl=iTitleBand->ControlById(EEikCidTitleBatFileNameLabel); |
|
502 if (ctrl) |
|
503 { |
|
504 const TInt index=iTitleBand->IndexById(EEikCidTitleBatFileNameLabel); |
|
505 CArrayFix<TEikGroupControl>* ctrlArray=iTitleBand->ControlArray(); |
|
506 if (index==ctrlArray->Count()-1) |
|
507 { |
|
508 const TInt width=(iToolBar ? iToolBar->Size().iWidth : KEikStdFileNameLabelWidth); |
|
509 (*ctrlArray)[index].SetLength(width); |
|
510 STATIC_CAST(CEikFileNameLabel*,iTitleBand->ControlById(EEikCidTitleBatFileNameLabel))->UpdateL(); |
|
511 } |
|
512 } |
|
513 const TRect rect(aAppUi->ApplicationRect()); |
|
514 iTitleBand->SetBoundingRect(rect); |
|
515 if (!(iTitleBand->DelayActivation())) |
|
516 iTitleBand->ActivateL(); |
|
517 */ |
|
518 } |
|
519 |
|
520 |
|
521 TRect CEikAppUiFactory::ClientRect() |
|
522 { |
|
523 CCoeEnv* env = CCoeEnv::Static(); |
|
524 TRect rect = LafAppUi::ClientRect( *env, *this ); |
|
525 |
|
526 #ifdef RD_SCALABLE_UI_V2 |
|
527 if ( TouchPane() ) |
|
528 { |
|
529 TouchPane()->ReduceRect( rect ); |
|
530 } |
|
531 |
|
532 CAknToolbar* toolbar = CurrentFixedToolbar(); |
|
533 |
|
534 // reduce fixed toolbar's area |
|
535 if ( toolbar ) |
|
536 { |
|
537 TInt flags = toolbar->ToolbarFlags(); |
|
538 |
|
539 if ( flags & KAknToolbarFixed && !( flags & KAknToolbarDefault ) ) |
|
540 { |
|
541 toolbar->ReduceRect( rect ); |
|
542 } |
|
543 } |
|
544 |
|
545 // recaculate the client rect is splitinput is enabled. |
|
546 if ( iExtension && iExtension->iSplitInput ) |
|
547 { |
|
548 TInt inputTop = rect.iBr.iY; |
|
549 TAknLayoutRect splitwnd; |
|
550 TRect screenRect ; |
|
551 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect ); |
|
552 |
|
553 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
554 { |
|
555 splitwnd.LayoutRect( screenRect, AknLayoutScalable_Avkon::popup_fep_vkbss_window (0).LayoutLine() ); |
|
556 TRect wndRc = splitwnd.Rect(); |
|
557 inputTop = wndRc.iTl.iY; |
|
558 } |
|
559 else |
|
560 { |
|
561 splitwnd.LayoutRect( screenRect, AknLayoutScalable_Avkon::popup_fep_ituss_window(0).LayoutLine() ); |
|
562 TRect wndRc = splitwnd.Rect(); |
|
563 inputTop = wndRc.iTl.iY; |
|
564 } |
|
565 rect.iBr.iY = rect.iBr.iY > inputTop ? inputTop : rect.iBr.iY; |
|
566 rect.iTl.iY = 0; |
|
567 } |
|
568 |
|
569 #endif // RD_SCALABLE_UI_V2 |
|
570 |
|
571 return rect; |
|
572 } |
|
573 |
|
574 void CEikAppUiFactory::ReadAppInfoResourceL(TInt aResourceFileOffset, CEikAppUi* aAppUi) |
|
575 { |
|
576 const TInt resourceFileOffset=(aResourceFileOffset)? aResourceFileOffset : aAppUi->Application()->ResourceFileOffset(); |
|
577 SEikAppInfo appInfo; |
|
578 TPtr8 ptr((TText8*)&appInfo,sizeof(appInfo)); |
|
579 ptr.FillZ(ptr.MaxLength()); // set all members of appInfo to zero, in case of ignored leave during resource reading |
|
580 CCoeEnv::Static()->ReadResourceAsDes8L(ptr,EAppInfoResourceOffset+resourceFileOffset); |
|
581 |
|
582 if (!iExtension) |
|
583 { |
|
584 iExtension = CEikAppUiFactoryExtension::NewL(); |
|
585 } |
|
586 |
|
587 iExtension->ReadAppInfoResourceExtensionL(appInfo.iExtensionId); |
|
588 |
|
589 if (appInfo.iMenuBarId) |
|
590 { |
|
591 iMenuBar=new(ELeave) CEikMenuBar; |
|
592 iMenuBar->ConstructL(aAppUi,appInfo.iHotKeysId,appInfo.iMenuBarId); |
|
593 aAppUi->AddToStackL(iMenuBar,ECoeStackPriorityMenu,ECoeStackFlagRefusesFocus); |
|
594 if (LafMenuBar::IsAlwaysVisible()) |
|
595 { |
|
596 iMenuBar->TryDisplayMenuBarL(); |
|
597 } |
|
598 } |
|
599 TRect boundingRect=ClientRect(); // make toolband stretch to the screen width by default |
|
600 // !!! Toolbar / CBA decision should be made in the LAF. |
|
601 CEikonEnv* eikEnv = CEikonEnv::Static(); |
|
602 if (eikEnv->StatusPaneCoreResId() != 0) |
|
603 { |
|
604 iStatusPane = CEikStatusPane::NewL(*eikEnv, &eikEnv->RootWin(), eikEnv->StatusPaneCoreResId(), appInfo.iStatusPaneId); |
|
605 CAknSgcClient::HandleChangeL(); // has to be called after iStatusPane is assigned |
|
606 iStatusPane->ReduceRect(boundingRect); |
|
607 |
|
608 #ifdef RD_SCALABLE_UI_V2 |
|
609 // Hide touch pane when compatible statuspane is no active |
|
610 if ( TouchPane() && !AknStatuspaneUtils::TouchPaneCompatibleLayoutActive() ) |
|
611 { |
|
612 TouchPane()->MakeVisible( EFalse ); |
|
613 } |
|
614 #endif // RD_SCALABLE_UI_V2 |
|
615 |
|
616 #ifdef RD_SCALABLE_UI_V2 |
|
617 // Hide toolbar when compatible statuspane is not active |
|
618 if ( iExtension->iFixedToolbar && ( !AknStatuspaneUtils::TouchPaneCompatibleLayoutActive() || |
|
619 appInfo.iStatusPaneId == R_AVKON_STATUS_PANE_LAYOUT_EMPTY ) ) |
|
620 { |
|
621 iExtension->iFixedToolbar->SetToolbarVisibility( EFalse ); |
|
622 } |
|
623 #endif // RD_SCALABLE_UI_V2 |
|
624 |
|
625 |
|
626 } |
|
627 |
|
628 if (appInfo.iCbaId) |
|
629 { |
|
630 iExtension->iCba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba, |
|
631 CEikButtonGroupContainer::EHorizontal/*LafCba::Orientation()*/, aAppUi,appInfo.iCbaId); |
|
632 iExtension->iCba->SetBoundingRect(boundingRect); |
|
633 iExtension->iCba->ReduceRect(boundingRect); |
|
634 // iToolBar=CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba, |
|
635 // CEikButtonGroupContainer::EVertical, |
|
636 // aAppUi,appInfo.iCbaId); |
|
637 // iToolBar->SetBoundingRect(boundingRect); |
|
638 } |
|
639 if (appInfo.iToolBarId) |
|
640 { |
|
641 iToolBar=CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::EToolbar,CEikButtonGroupContainer::EVertical, |
|
642 aAppUi,appInfo.iToolBarId); |
|
643 iToolBar->SetBoundingRect(boundingRect); |
|
644 } |
|
645 if (aAppUi->ContainerAppUi()) |
|
646 AddTitleBandL(aAppUi); |
|
647 if (appInfo.iToolBandId) |
|
648 { |
|
649 boundingRect.iTl.iY=ClientRect().iTl.iY; |
|
650 iToolBand=new(ELeave) CEikToolBar; |
|
651 iToolBand->StaticConstructL(aAppUi,appInfo.iToolBandId); |
|
652 if (iTitleBand) |
|
653 iToolBand->SetAdjacent(EGulAdjTop); |
|
654 iToolBand->SetBoundingRect(boundingRect); |
|
655 if (!iToolBand->DelayActivation()) |
|
656 iToolBand->ActivateL(); |
|
657 if (iToolBar) // in case toolbar/band overlap, put bar in front |
|
658 iToolBar->DrawableWindow()->SetOrdinalPosition(0); |
|
659 } |
|
660 if (iTitleBand) // put title band in front |
|
661 iTitleBand->DrawableWindow()->SetOrdinalPosition(0); |
|
662 |
|
663 } |
|
664 |
|
665 void CEikAppUiFactory::LaunchPopupMenuL( |
|
666 TInt aResourceId, |
|
667 const TPoint& aTargetPos, |
|
668 TPopupTargetPosType aTargetType, |
|
669 const CEikHotKeyTable* aHotKeyTable, |
|
670 CEikAppUi* aAppUi) |
|
671 { |
|
672 ClosePopup(aAppUi); |
|
673 iPopup=new(ELeave) CEikMenuPane(aAppUi); |
|
674 TRAPD(err,DoLaunchPopupL(aResourceId,aTargetPos,aHotKeyTable,aTargetType, aAppUi)); |
|
675 if (err) |
|
676 { |
|
677 ClosePopup(aAppUi); |
|
678 User::Leave(err); |
|
679 } |
|
680 } |
|
681 |
|
682 void CEikAppUiFactory::DoLaunchPopupL(TInt aResourceId, |
|
683 const TPoint& aTargetPos, |
|
684 const CEikHotKeyTable* aHotKeyTable, |
|
685 TPopupTargetPosType aTargetType, |
|
686 CEikAppUi* aAppUi) |
|
687 { |
|
688 iPopup->ConstructL(NULL); |
|
689 aAppUi->RestoreMenuL(iPopup,aResourceId,MEikMenuObserver::EMenuPane); |
|
690 iPopup->SetPointerCapture(ETrue); |
|
691 aAppUi->AddToStackL(iPopup,ECoeStackPriorityDialog); |
|
692 iPopup->StartDisplayingMenuPane(aHotKeyTable,aTargetPos,NULL,0,aTargetType); |
|
693 } |
|
694 |
|
695 void CEikAppUiFactory::ClosePopup(CEikAppUi* aAppUi) |
|
696 { |
|
697 if (iPopup) |
|
698 { |
|
699 aAppUi->RemoveFromStack(iPopup); |
|
700 delete(iPopup); |
|
701 iPopup=NULL; |
|
702 } |
|
703 iSidebarPopupId=-1; |
|
704 } |
|
705 |
|
706 void CEikAppUiFactory::StopDisplayingMenuBar() |
|
707 { |
|
708 if (iMenuBar) |
|
709 iMenuBar->StopDisplayingMenuBar(); |
|
710 } |
|
711 |
|
712 void CEikAppUiFactory::HandleSideBarMenuL( |
|
713 TInt aResourceId, |
|
714 const TPoint& aPos, |
|
715 const CEikHotKeyTable* aHotKeyTable, |
|
716 CEikAppUi* aAppUi) |
|
717 { |
|
718 TBool launchSidebarPopup(iSidebarPopupId!=aResourceId && (aResourceId==R_EIK_SIDEBAR_EDIT_MENU || aResourceId==R_EIK_SIDEBAR_IRDA_MENU)); |
|
719 if (iPopup) |
|
720 ClosePopup(aAppUi);// sets iSidebarPopupId to -1 |
|
721 if (aResourceId==0) // 0 indicates menu bar |
|
722 { |
|
723 iMenuBar->TryDisplayMenuBarL(); |
|
724 const TInt title=iMenuBar->SelectedTitle(); |
|
725 const TInt item=iMenuBar->SelectedItem(); |
|
726 iMenuBar->MoveHighlightToL(title, (item>=0?item:0)); |
|
727 return; |
|
728 } |
|
729 // otherwise a popup menu |
|
730 if (iMenuBar) |
|
731 iMenuBar->StopDisplayingMenuBar(); |
|
732 if (launchSidebarPopup) |
|
733 { |
|
734 LaunchPopupMenuL(aResourceId,aPos,EPopupTargetTopLeft,aHotKeyTable, aAppUi); |
|
735 iSidebarPopupId=aResourceId; |
|
736 } |
|
737 } |
|
738 |
|
739 |
|
740 void CEikAppUiFactory::CreateHotKeyControlL(TInt aResourceId, CEikAppUi* aAppUi) |
|
741 { |
|
742 CEikHotKeyTable* table=new(ELeave) CEikHotKeyTable; |
|
743 CleanupStack::PushL(table); |
|
744 table->ConstructFromResourceL(aResourceId); |
|
745 CEikHotKeyControl* control=new(ELeave) CEikHotKeyControl(table,aAppUi); |
|
746 CleanupStack::Pop(); // table now owned by control |
|
747 CleanupStack::PushL(control); |
|
748 aAppUi->AddToStackL(control,ECoeStackPriorityMenu,ECoeStackFlagRefusesFocus|ECoeStackFlagOwnershipTransfered); |
|
749 CleanupStack::Pop(); |
|
750 } |
|
751 |
|
752 CEikMenuBar* CEikAppUiFactory::MenuBar() const |
|
753 { |
|
754 return iMenuBar; |
|
755 } |
|
756 |
|
757 CEikMenuBar* CEikAppUiFactory::SwapMenuBar(CEikMenuBar* aMenu) |
|
758 { |
|
759 CEikMenuBar* oldMenu=iMenuBar; |
|
760 iMenuBar=aMenu; |
|
761 return oldMenu; |
|
762 } |
|
763 |
|
764 CEikMenuPane* CEikAppUiFactory::Popup() const |
|
765 { |
|
766 return iPopup; |
|
767 } |
|
768 |
|
769 CEikButtonGroupContainer* CEikAppUiFactory::ToolBar() const |
|
770 { |
|
771 // return iToolBar; |
|
772 return (iExtension ? iExtension->iCba : NULL); |
|
773 } |
|
774 |
|
775 CEikButtonGroupContainer* CEikAppUiFactory::SwapButtonGroup(CEikButtonGroupContainer* aNewGroup) |
|
776 { |
|
777 CEikButtonGroupContainer* old=iToolBar; |
|
778 iToolBar=aNewGroup; |
|
779 return old; |
|
780 } |
|
781 |
|
782 CEikToolBar* CEikAppUiFactory::ToolBand() const |
|
783 { |
|
784 return iToolBand; |
|
785 } |
|
786 |
|
787 CEikToolBar* CEikAppUiFactory::TitleBand() const |
|
788 { |
|
789 return iTitleBand; |
|
790 } |
|
791 |
|
792 CEikStatusPane* CEikAppUiFactory::StatusPane() const |
|
793 { |
|
794 return iStatusPane; |
|
795 } |
|
796 |
|
797 CEikButtonGroupContainer* CEikAppUiFactory::Cba() const |
|
798 { |
|
799 return (iExtension ? iExtension->iCba : NULL); |
|
800 } |
|
801 |
|
802 CEikToolBar* CEikAppUiFactory::SwapToolBar(CEikToolBar* aToolBar,TToolBarType aType) |
|
803 { |
|
804 CEikToolBar* old=NULL; |
|
805 if (aType==EBand) |
|
806 { |
|
807 old=iToolBand; |
|
808 iToolBand=aToolBar; |
|
809 } |
|
810 else // aType==ETitle |
|
811 { |
|
812 old=iTitleBand; |
|
813 iTitleBand=aToolBar; |
|
814 } |
|
815 return old; |
|
816 } |
|
817 |
|
818 void CEikAppUiFactory::HandleResourceChangeL(TInt aType) |
|
819 { |
|
820 |
|
821 if ( iExtension ) |
|
822 { |
|
823 if ( aType == KAknSplitInputEnabled ) |
|
824 { |
|
825 iExtension->iSplitInput = ETrue; |
|
826 } |
|
827 else if ( aType == KAknSplitInputDisabled ) |
|
828 { |
|
829 iExtension->iSplitInput = EFalse; |
|
830 } |
|
831 } |
|
832 |
|
833 if(iStatusPane) |
|
834 iStatusPane->HandleResourceChange(aType); |
|
835 if(iExtension && iExtension->iCba) |
|
836 iExtension->iCba->HandleResourceChange(aType); |
|
837 if(iMenuBar) |
|
838 iMenuBar->HandleResourceChange(aType); |
|
839 if(iToolBar) |
|
840 iToolBar->HandleResourceChange(aType); |
|
841 if(iToolBand) |
|
842 iToolBand->HandleResourceChange(aType); |
|
843 if(iTitleBand) |
|
844 iTitleBand->HandleResourceChange(aType); |
|
845 if(iPopup) |
|
846 iPopup->HandleResourceChange(aType); |
|
847 #ifdef RD_SCALABLE_UI_V2 |
|
848 if (TouchPane()) |
|
849 TouchPane()->HandleResourceChange(aType); |
|
850 #endif // RD_SCALABLE_UI_V2 |
|
851 } |
|
852 |
|
853 EXPORT_C CAknTouchPane* CEikAppUiFactory::TouchPane() const |
|
854 { |
|
855 return (iExtension ? iExtension->iTouchPane : NULL); |
|
856 } |
|
857 |
|
858 // ----------------------------------------------------------------------------- |
|
859 // CEikAppUiFactory::PopupToolbar |
|
860 // Returns the toolbar for the application or NULL. |
|
861 // ----------------------------------------------------------------------------- |
|
862 // |
|
863 EXPORT_C CAknToolbar* CEikAppUiFactory::PopupToolbar() const |
|
864 { |
|
865 // if there is specific floating toolbar for appui then that will be |
|
866 // returned, otherwise fixed toolbar or NULL |
|
867 if ( iExtension ) |
|
868 { |
|
869 if ( iExtension->iPopupToolbar ) |
|
870 { |
|
871 return iExtension->iPopupToolbar; |
|
872 } |
|
873 else |
|
874 { |
|
875 #ifdef RD_SCALABLE_UI_V2 |
|
876 return iExtension->iFixedToolbar; |
|
877 #else |
|
878 return NULL; |
|
879 #endif |
|
880 |
|
881 } |
|
882 } |
|
883 return NULL; |
|
884 } |
|
885 |
|
886 // ----------------------------------------------------------------------------- |
|
887 // CEikAppUiFactory::CurrentPopupToolbar |
|
888 // If current view has toolbar it will return that one, otherwise it will return |
|
889 // application toolbar or NULL. |
|
890 // ----------------------------------------------------------------------------- |
|
891 // |
|
892 EXPORT_C CAknToolbar* CEikAppUiFactory::CurrentPopupToolbar() const |
|
893 { |
|
894 // if there is specific toolbar for the view then this one will be returned, otherwise |
|
895 // application toolbar will be returned. |
|
896 if (!iExtension) |
|
897 return NULL; |
|
898 |
|
899 return iExtension->iViewPopupToolbar ? iExtension->iViewPopupToolbar: |
|
900 iExtension->iPopupToolbar; |
|
901 } |
|
902 |
|
903 |
|
904 |
|
905 // ----------------------------------------------------------------------------- |
|
906 // CEikAppUiFactory::CurrentFixedToolbar |
|
907 // If current view has fixed toolbar it will return that one, otherwise it will |
|
908 // return application fixed toolbar or NULL. |
|
909 // ----------------------------------------------------------------------------- |
|
910 // |
|
911 EXPORT_C CAknToolbar* CEikAppUiFactory::CurrentFixedToolbar() const |
|
912 { |
|
913 // if there is specific toolbar for the view then this one will be returned, otherwise |
|
914 // application toolbar will be returned. |
|
915 if (!iExtension) |
|
916 return NULL; |
|
917 |
|
918 return iExtension->iViewFixedToolbar ? iExtension->iViewFixedToolbar : |
|
919 iExtension->iFixedToolbar; |
|
920 } |
|
921 |
|
922 |
|
923 // ----------------------------------------------------------------------------- |
|
924 // CEikAppUiFactory::SetViewPopupToolbar |
|
925 // Sets view specific toolbar when view is activated. Called by CAknView |
|
926 // ----------------------------------------------------------------------------- |
|
927 // |
|
928 EXPORT_C void CEikAppUiFactory::SetViewPopupToolbar(CAknToolbar* aViewPopupToolbar) |
|
929 { |
|
930 // not sure if we should try to create extension here |
|
931 if (iExtension) |
|
932 iExtension->iViewPopupToolbar = aViewPopupToolbar; |
|
933 } |
|
934 |
|
935 // ----------------------------------------------------------------------------- |
|
936 // CEikAppUiFactory::SetViewPopupToolbar |
|
937 // Sets view specific toolbar when view is activated. Called by CAknView |
|
938 // ----------------------------------------------------------------------------- |
|
939 // |
|
940 EXPORT_C void CEikAppUiFactory::SetViewFixedToolbar(CAknToolbar* aViewFixedToolbar) |
|
941 { |
|
942 // not sure if we should try to create extension here |
|
943 if (iExtension) |
|
944 iExtension->iViewFixedToolbar = aViewFixedToolbar; |
|
945 } |
|
946 |
|
947 |
|
948 |
|
949 void CEikAppUiFactory::ReduceRect(TScreenFurniture aScreenFurniture,TRect& aRect) const |
|
950 { |
|
951 switch (aScreenFurniture) |
|
952 { |
|
953 case EMenuBar: |
|
954 if (iMenuBar) |
|
955 iMenuBar->ReduceRect(aRect); |
|
956 break; |
|
957 case EButtonGroup: |
|
958 if (iToolBar) |
|
959 iToolBar->ReduceRect(aRect); |
|
960 break; |
|
961 case EToolBand: |
|
962 if (iToolBand) |
|
963 iToolBand->ReduceRect(aRect); |
|
964 break; |
|
965 case ETitleBand: |
|
966 if (iTitleBand) |
|
967 iTitleBand->ReduceRect(aRect); |
|
968 break; |
|
969 case EStatusPane: |
|
970 { |
|
971 CEikStatusPaneBase* statusPane=CEikStatusPaneBase::Current(); |
|
972 if (statusPane) |
|
973 statusPane->ReduceRect(aRect); |
|
974 break; |
|
975 } |
|
976 case ECba: |
|
977 if (iExtension && iExtension->iCba) |
|
978 iExtension->iCba->ReduceRect(aRect); |
|
979 break; |
|
980 default: |
|
981 break; |
|
982 } |
|
983 } |
|
984 |
|
985 TTypeUid::Ptr CEikAppUiFactory::MopSupplyObject(TTypeUid aId) |
|
986 { |
|
987 return SupplyMopObject(aId, (iExtension ? iExtension->iCba : NULL), iMenuBar); |
|
988 } |
|
989 |
|
990 ////////////////////////////////////////////////////////////////////////////////////// |
|
991 // |
|
992 // END OF FILE |
|
993 // |
|
994 ////////////////////////////////////////////////////////////////////////////////////// |