|
1 /* |
|
2 * Copyright (c) 2002-2004 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: Implementation for wrapper for a menu |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <utf.h> |
|
20 #include <aknappui.h> |
|
21 #include <e32base.h> |
|
22 #include <coecntrl.h> |
|
23 #include <eikbtgpc.h> |
|
24 #include <eikcba.h> |
|
25 #include <barsread.h> |
|
26 #include <eiksoftkeyimage.h> |
|
27 #include <aknlayoutscalable_avkon.cdl.h> |
|
28 #include <layoutmetadata.cdl.h> |
|
29 |
|
30 #include <AknStatuspaneUtils.h> |
|
31 #include <AknUtils.h> |
|
32 #include <AknIconUtils.h> |
|
33 #include <eikspane.h> |
|
34 #include <AknSgcc.h> |
|
35 #include <aknview.h> |
|
36 #include <AknsConstants.h> |
|
37 |
|
38 // User includes |
|
39 #include "xnnodepluginif.h" |
|
40 #include "xntype.h" |
|
41 #include "xnproperty.h" |
|
42 |
|
43 #include "xndompropertyvalue.h" |
|
44 #include "xndomproperty.h" |
|
45 #include "xndomlist.h" |
|
46 |
|
47 #include "xnuienginepluginif.h" |
|
48 #include "xncomponent.h" |
|
49 |
|
50 #include "xnappuiadapter.h" |
|
51 #include "xnbitmap.h" |
|
52 #include "xnmenuadapter.h" |
|
53 #include "xncomponentnodeimpl.h" |
|
54 #include "c_xnutils.h" |
|
55 |
|
56 #undef _AVKON_CBA_LSC |
|
57 |
|
58 _LIT8( KEditMode, "Menu/EditMode" ); |
|
59 _LIT8( KNormalMode, "Menu/NormalMode" ); |
|
60 _LIT8( KContextEditMode, "ContextMenu/EditMode" ); |
|
61 _LIT8( KContextNormalMode, "ContextMenu/NormalMode" ); |
|
62 _LIT8( KAlwaysShown, "Menu/AlwaysShown" ); |
|
63 |
|
64 _LIT8( KHsShowHelp, "hs_show_help" ); |
|
65 |
|
66 const TInt KMenuCommandFirst = 6000; |
|
67 const TInt KMenuCommandLast = 6199; |
|
68 const TInt KCBACommandFirst = EAknSoftkeyOptions; |
|
69 const TInt KCBACommandSecond = EAknSoftkeyBack; |
|
70 const TInt KCBACommandMiddle = EAknSoftkeyDialler; |
|
71 |
|
72 const TInt KXnMenuArrayGranularity = 6; |
|
73 const TInt KWideScreenWidth = 640; |
|
74 |
|
75 using namespace XnPropertyNames; |
|
76 |
|
77 static CXnNodePluginIf* FindChildL(CXnNodePluginIf& aNode, |
|
78 const TDesC8& aType, const TDesC8& aTarget = KNullDesC8); |
|
79 |
|
80 class CXnSoftkeyItem: public CBase |
|
81 { |
|
82 public: |
|
83 CXnSoftkeyItem() |
|
84 : iNode( NULL ), |
|
85 iPosition( 0 ), |
|
86 iCommandId( 0 ), |
|
87 iLabel( NULL ), |
|
88 iBitmap( NULL ), |
|
89 iMask( NULL ), |
|
90 iImageOn( EFalse ), |
|
91 iInvertMask( EFalse ), |
|
92 iPreserveAspectRatio( EFalse ), |
|
93 iUpdateAppearance( ETrue ), |
|
94 iOwnBitmaps( ETrue ), |
|
95 iDefault( EFalse ), |
|
96 iId( KAknsIIDQsnIconColors ), |
|
97 iBmpFile( NULL ), |
|
98 iBmp( 0 ), |
|
99 iBmpM( 0 ) |
|
100 { |
|
101 } |
|
102 |
|
103 ~CXnSoftkeyItem() |
|
104 { |
|
105 Reset(); |
|
106 } |
|
107 |
|
108 void Reset() |
|
109 { |
|
110 delete iLabel; |
|
111 iLabel = NULL; |
|
112 if ( iOwnBitmaps ) |
|
113 { |
|
114 delete iBitmap; |
|
115 iBitmap = NULL; |
|
116 delete iMask; |
|
117 iMask = NULL; |
|
118 } |
|
119 else |
|
120 { |
|
121 iBitmap = NULL; |
|
122 iMask = NULL; |
|
123 } |
|
124 |
|
125 iImageOn = EFalse; |
|
126 iInvertMask = EFalse; |
|
127 iPreserveAspectRatio = EFalse; |
|
128 delete iBmpFile; |
|
129 iBmpFile = NULL; |
|
130 } |
|
131 |
|
132 CXnNodePluginIf* iNode; |
|
133 TInt iPosition; |
|
134 TInt iCommandId; |
|
135 HBufC* iLabel; |
|
136 CFbsBitmap* iBitmap; |
|
137 CFbsBitmap* iMask; |
|
138 TBool iImageOn; |
|
139 TBool iInvertMask; |
|
140 TBool iPreserveAspectRatio; |
|
141 TBool iUpdateAppearance; |
|
142 TBool iOwnBitmaps; |
|
143 TBool iDefault; |
|
144 TAknsItemID iId; |
|
145 HBufC* iBmpFile; |
|
146 TInt32 iBmp; |
|
147 TInt32 iBmpM; |
|
148 }; |
|
149 |
|
150 |
|
151 inline TAknWindowComponentLayout DoCompose( TAknWindowComponentLayout aLine1, |
|
152 TAknWindowComponentLayout aLine2 ) |
|
153 { |
|
154 return TAknWindowComponentLayout::Compose( aLine1, aLine2 ); |
|
155 } |
|
156 |
|
157 inline TAknTextComponentLayout DoComposeText( TAknWindowComponentLayout aLine1, |
|
158 TAknTextComponentLayout aLine2 ) |
|
159 { |
|
160 return TAknWindowComponentLayout::ComposeText( aLine1, aLine2 ); |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // IsNodeVisibleL |
|
165 // |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 static TBool IsNodeVisibleL(CXnNodePluginIf& aNode) |
|
169 { |
|
170 CXnProperty* propVisibility = aNode.VisibilityL(); |
|
171 |
|
172 if( propVisibility ) |
|
173 { |
|
174 const TDesC8& visibility = propVisibility->StringValue(); |
|
175 |
|
176 if( visibility == XnPropertyNames::style::common::visibility::KHidden ) |
|
177 { |
|
178 return EFalse; |
|
179 } |
|
180 } |
|
181 |
|
182 CXnProperty* propDisplay = aNode.DisplayL(); |
|
183 |
|
184 if( propDisplay ) |
|
185 { |
|
186 const TDesC8& display = propDisplay->StringValue(); |
|
187 |
|
188 if( display == XnPropertyNames::style::common::display::KNone ) |
|
189 { |
|
190 return EFalse; |
|
191 } |
|
192 } |
|
193 |
|
194 CXnProperty* propDisabled = aNode.GetPropertyL( XnPropertyNames::common::KDisabled ); |
|
195 |
|
196 if( propDisabled ) |
|
197 { |
|
198 const TDesC8& disabled = propDisabled->StringValue(); |
|
199 |
|
200 if( disabled == XnPropertyNames::KTrue ) |
|
201 { |
|
202 return EFalse; |
|
203 } |
|
204 } |
|
205 |
|
206 return ETrue; |
|
207 } |
|
208 |
|
209 #ifdef _AVKON_CBA_LSC |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 // Calculate touch sensitive softkey area for Top button (landscape) |
|
213 // ----------------------------------------------------------------------------- |
|
214 static TRect SoftkeyRectTopTouch() |
|
215 { |
|
216 TRect screen; |
|
217 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen ); |
|
218 |
|
219 TAknLayoutRect layoutRect; |
|
220 |
|
221 TAknWindowComponentLayout rightAreaLayout( |
|
222 AknLayoutScalable_Avkon::area_side_right_pane( 0 ) ); |
|
223 |
|
224 |
|
225 layoutRect.LayoutRect( screen, DoCompose( rightAreaLayout, |
|
226 AknLayoutScalable_Avkon::sctrl_sk_top_pane() ).LayoutLine() ); |
|
227 TRect topSKRect( layoutRect.Rect() ); |
|
228 |
|
229 layoutRect.LayoutRect( topSKRect, |
|
230 AknLayoutScalable_Avkon::aid_touch_sctrl_top().LayoutLine() ); |
|
231 return layoutRect.Rect(); |
|
232 } |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // |
|
236 // Calculate touch sensitive softkey area for right button (portrait) |
|
237 // ----------------------------------------------------------------------------- |
|
238 static TRect SoftkeyRectRightTouch() |
|
239 { |
|
240 TRect screen; |
|
241 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen ); |
|
242 |
|
243 TAknLayoutRect layoutRect; |
|
244 |
|
245 TAknWindowComponentLayout bottomAreaLayout( |
|
246 AknLayoutScalable_Avkon::area_bottom_pane( 0 ) ); |
|
247 |
|
248 |
|
249 layoutRect.LayoutRect( screen, DoCompose( bottomAreaLayout, |
|
250 AknLayoutScalable_Avkon::control_bg_pane() ).LayoutLine() ); |
|
251 TRect rightSKRect( layoutRect.Rect() ); |
|
252 layoutRect.LayoutRect( |
|
253 rightSKRect, |
|
254 AknLayoutScalable_Avkon::aid_touch_ctrl_right().LayoutLine() ); |
|
255 return layoutRect.Rect(); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // |
|
260 // Calculate touch sensitive softkey area for left button (portrait) |
|
261 // ----------------------------------------------------------------------------- |
|
262 static TRect SoftkeyRectLeftTouch() |
|
263 { |
|
264 TRect screen; |
|
265 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen ); |
|
266 |
|
267 TAknLayoutRect layoutRect; |
|
268 |
|
269 TAknWindowComponentLayout bottomAreaLayout( |
|
270 AknLayoutScalable_Avkon::area_bottom_pane( 0 ) ); |
|
271 |
|
272 |
|
273 layoutRect.LayoutRect( screen, DoCompose( bottomAreaLayout, |
|
274 AknLayoutScalable_Avkon::control_bg_pane() ).LayoutLine() ); |
|
275 TRect leftSKRect( layoutRect.Rect() ); |
|
276 layoutRect.LayoutRect( |
|
277 leftSKRect, |
|
278 AknLayoutScalable_Avkon::aid_touch_ctrl_left().LayoutLine() ); |
|
279 |
|
280 return layoutRect.Rect(); |
|
281 |
|
282 } |
|
283 |
|
284 // ----------------------------------------------------------------------------- |
|
285 // |
|
286 // Calculate touch sensitive softkey area for Bottom button (landscape) |
|
287 // ----------------------------------------------------------------------------- |
|
288 static TRect SoftkeyRectBottomTouch() |
|
289 { |
|
290 TRect screen; |
|
291 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen ); |
|
292 |
|
293 TAknLayoutRect layoutRect; |
|
294 |
|
295 TAknWindowComponentLayout rightAreaLayout( AknLayoutScalable_Avkon::area_side_right_pane( 0 ) ); |
|
296 |
|
297 layoutRect.LayoutRect( screen, DoCompose( rightAreaLayout, |
|
298 AknLayoutScalable_Avkon::sctrl_sk_bottom_pane() ).LayoutLine() ); |
|
299 TRect bottomSKRect( layoutRect.Rect() ); |
|
300 |
|
301 layoutRect.LayoutRect( bottomSKRect, |
|
302 AknLayoutScalable_Avkon::aid_touch_sctrl_bottom().LayoutLine() ); |
|
303 return layoutRect.Rect(); |
|
304 } |
|
305 #endif |
|
306 // ----------------------------------------------------------------------------- |
|
307 // |
|
308 // Calculate (whole) softkey area for Bottom button (landscape) |
|
309 // ----------------------------------------------------------------------------- |
|
310 static TBool HDLayoutActive() |
|
311 { |
|
312 TInt resourceId = 0; |
|
313 CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current(); |
|
314 |
|
315 if ( statusPane ) // Return the resource ID of app statuspane if it exists. |
|
316 { |
|
317 resourceId = statusPane->CurrentLayoutResId(); |
|
318 } |
|
319 else // If this app does not have statuspane, then we ask the layout from AknCapServer. |
|
320 { |
|
321 resourceId = CAknSgcClient::CurrentStatuspaneResource(); |
|
322 } |
|
323 |
|
324 TBool retVal = EFalse; |
|
325 |
|
326 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
327 { |
|
328 // Can be widescreen only in landscape orientation. |
|
329 retVal = ( resourceId == R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL || |
|
330 resourceId == R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE || |
|
331 resourceId == R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL_FLAT || |
|
332 resourceId == R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT ); |
|
333 } |
|
334 |
|
335 return retVal; |
|
336 } |
|
337 |
|
338 // ----------------------------------------------------------------------------- |
|
339 // |
|
340 // Calculate softkey image graphics area for Bottom button (landscape) |
|
341 // ----------------------------------------------------------------------------- |
|
342 static TRect SoftkeyRectBottomGraphics() |
|
343 { |
|
344 TRect screen; |
|
345 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen ); |
|
346 |
|
347 TAknWindowComponentLayout rightAreaLayout( |
|
348 AknLayoutScalable_Avkon::area_side_right_pane( 0 ) ); |
|
349 |
|
350 TAknWindowComponentLayout bottomSKLayout( |
|
351 DoCompose( rightAreaLayout, |
|
352 AknLayoutScalable_Avkon::sctrl_sk_bottom_pane() ) ); |
|
353 |
|
354 // Calculate softkey rects. |
|
355 // Left (bottom in landscape) softkey layout. |
|
356 TAknLayoutRect leftSoftkeyLayoutRect; |
|
357 leftSoftkeyLayoutRect.LayoutRect( screen, |
|
358 bottomSKLayout.LayoutLine() ); |
|
359 TRect leftSoftKeyButtonRect( leftSoftkeyLayoutRect.Rect() ); |
|
360 |
|
361 // Calculate softkey image layout. |
|
362 // Left (bottom in landscape) softkey layout. |
|
363 TAknWindowLineLayout leftSoftkeyImageLayout( |
|
364 DoCompose( |
|
365 bottomSKLayout, |
|
366 AknLayoutScalable_Avkon::sctrl_sk_bottom_pane_g1() ).LayoutLine() ); |
|
367 |
|
368 |
|
369 TAknLayoutRect qgn_graf_sk_left; |
|
370 qgn_graf_sk_left.LayoutRect( screen, leftSoftkeyImageLayout ); |
|
371 |
|
372 return qgn_graf_sk_left.Rect(); |
|
373 } |
|
374 |
|
375 // ----------------------------------------------------------------------------- |
|
376 // |
|
377 // Calculate softkey image graphics area for Top button (landscape) |
|
378 // ----------------------------------------------------------------------------- |
|
379 static TRect SoftkeyRectTopGraphics() |
|
380 { |
|
381 TRect screen; |
|
382 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen ); |
|
383 |
|
384 TAknWindowComponentLayout rightAreaLayout( |
|
385 AknLayoutScalable_Avkon::area_side_right_pane( 0 ) ); |
|
386 |
|
387 TAknWindowComponentLayout topSKLayout( |
|
388 DoCompose( rightAreaLayout, |
|
389 AknLayoutScalable_Avkon::sctrl_sk_top_pane() ) ); |
|
390 |
|
391 // Calculate softkey rects. |
|
392 // Right (top in landscape) softkey layout. |
|
393 TAknLayoutRect rightSoftkeyLayoutRect; |
|
394 rightSoftkeyLayoutRect.LayoutRect( screen, |
|
395 topSKLayout.LayoutLine() ); |
|
396 TRect rightSoftKeyButtonRect( rightSoftkeyLayoutRect.Rect() ); |
|
397 |
|
398 // Left (bottom in landscape) softkey layout. |
|
399 // Right (top in landscape) softkey layout. |
|
400 TAknWindowLineLayout rightSoftkeyImageLayout( |
|
401 DoCompose( |
|
402 topSKLayout, |
|
403 AknLayoutScalable_Avkon::sctrl_sk_top_pane_g1() ).LayoutLine() ); |
|
404 |
|
405 TAknLayoutRect qgn_graf_sk_right; |
|
406 qgn_graf_sk_right.LayoutRect( screen, rightSoftkeyImageLayout ); |
|
407 return qgn_graf_sk_right.Rect(); |
|
408 } |
|
409 |
|
410 |
|
411 // ----------------------------------------------------------------------------- |
|
412 // SoftkeyRectL |
|
413 // Calculate soft key rect |
|
414 // ----------------------------------------------------------------------------- |
|
415 static TRect SoftkeyRectL( CEikButtonGroupContainer& aContainer, TInt aPos, TBool aImageOn ) |
|
416 { |
|
417 TRect rect; |
|
418 |
|
419 if( AknStatuspaneUtils::StaconPaneActive() ) |
|
420 { |
|
421 TInt variety( 0 ); |
|
422 |
|
423 if( AknStatuspaneUtils::StaconSoftKeysLeft() ) |
|
424 { |
|
425 variety = 1; |
|
426 } |
|
427 |
|
428 TRect parentRect( iAvkonAppUi->ApplicationRect() ); |
|
429 |
|
430 switch( aPos ) |
|
431 { |
|
432 case CEikButtonGroupContainer::ELeftSoftkeyPosition: |
|
433 { |
|
434 TAknWindowComponentLayout layout0( AknLayoutScalable_Avkon::area_bottom_pane( 2 ) ); |
|
435 TAknWindowComponentLayout layout1( AknLayoutScalable_Avkon::stacon_bottom_pane() ); |
|
436 |
|
437 // If clock is shown in stacon, cba area is smaller. |
|
438 TInt bottomCbaVariety( variety ); |
|
439 |
|
440 if( AknStatuspaneUtils::ExtendedStaconPaneActive() ) |
|
441 { |
|
442 bottomCbaVariety += 2; |
|
443 } |
|
444 |
|
445 TAknWindowComponentLayout layout2( AknLayoutScalable_Avkon::control_bottom_pane_stacon( bottomCbaVariety ) ); |
|
446 |
|
447 if( aImageOn ) |
|
448 { |
|
449 // Icon layout |
|
450 TAknWindowComponentLayout iconLayout( AknLayoutScalable_Avkon::control_bottom_pane_stacon_g1() ); |
|
451 |
|
452 TAknWindowComponentLayout lskIconLayout( DoCompose( layout0, |
|
453 DoCompose( layout1, DoCompose( layout2, iconLayout ) ) ) ); |
|
454 |
|
455 TAknWindowLineLayout lskIcon( lskIconLayout.LayoutLine() ); |
|
456 |
|
457 TAknLayoutRect qgn_icon_lsk; |
|
458 |
|
459 qgn_icon_lsk.LayoutRect( parentRect, lskIcon ); |
|
460 |
|
461 rect = qgn_icon_lsk.Rect(); |
|
462 } |
|
463 else |
|
464 { |
|
465 // Text layout |
|
466 TAknTextComponentLayout textLayout( AknLayoutScalable_Avkon::control_bottom_pane_stacon_t1( variety ) ); |
|
467 |
|
468 TAknTextComponentLayout lskTextLayout( DoComposeText( layout0, |
|
469 DoComposeText( layout1, DoComposeText( layout2, textLayout ) ) ) ); |
|
470 |
|
471 TAknTextLineLayout lskText( lskTextLayout.LayoutLine() ); |
|
472 |
|
473 TAknLayoutText qgn_text_lsk; |
|
474 |
|
475 qgn_text_lsk.LayoutText( parentRect, lskText ); |
|
476 |
|
477 rect = qgn_text_lsk.TextRect(); |
|
478 } |
|
479 } |
|
480 break; |
|
481 case CEikButtonGroupContainer::ERightSoftkeyPosition: |
|
482 { |
|
483 TAknWindowComponentLayout layout0( AknLayoutScalable_Avkon::area_top_pane( 2 ) ); |
|
484 TAknWindowComponentLayout layout1( AknLayoutScalable_Avkon::stacon_top_pane() ); |
|
485 |
|
486 TInt topCbaVariety( variety ); |
|
487 |
|
488 if( AknStatuspaneUtils::ExtendedStaconPaneActive() ) |
|
489 { |
|
490 topCbaVariety += 4; |
|
491 } |
|
492 |
|
493 TAknWindowComponentLayout layout2( AknLayoutScalable_Avkon::control_top_pane_stacon( topCbaVariety ) ); |
|
494 |
|
495 if( aImageOn ) |
|
496 { |
|
497 // Icon layout |
|
498 TAknWindowComponentLayout iconLayout( AknLayoutScalable_Avkon::control_top_pane_stacon_g1() ); |
|
499 |
|
500 TAknWindowComponentLayout rskIconLayout( DoCompose( layout0, |
|
501 DoCompose( layout1, DoCompose( layout2, iconLayout ) ) ) ); |
|
502 |
|
503 TAknWindowLineLayout rskIcon( rskIconLayout.LayoutLine() ); |
|
504 |
|
505 TAknLayoutRect qgn_icon_rsk; |
|
506 |
|
507 qgn_icon_rsk.LayoutRect( parentRect, rskIcon ); |
|
508 |
|
509 rect = qgn_icon_rsk.Rect(); |
|
510 } |
|
511 else |
|
512 { |
|
513 // Text layout |
|
514 TAknTextComponentLayout textLayout( AknLayoutScalable_Avkon::control_top_pane_stacon_t1( variety ) ); |
|
515 |
|
516 TAknTextComponentLayout rskTextLayout( DoComposeText( layout0, |
|
517 DoComposeText( layout1, DoComposeText( layout2, textLayout ) ) ) ); |
|
518 |
|
519 TAknTextLineLayout rskText( rskTextLayout.LayoutLine() ); |
|
520 |
|
521 TAknLayoutText qgn_text_rsk; |
|
522 |
|
523 qgn_text_rsk.LayoutText( parentRect, rskText ); |
|
524 |
|
525 rect = qgn_text_rsk.TextRect(); |
|
526 } |
|
527 } |
|
528 break; |
|
529 default: |
|
530 User::Leave( KErrNotSupported ); |
|
531 break; |
|
532 |
|
533 } |
|
534 } |
|
535 else |
|
536 { |
|
537 TInt textVariety( 0 ); |
|
538 TInt graphVariety( 0 ); |
|
539 |
|
540 TBool mskEnabled( AknLayoutUtils::MSKEnabled() && Layout_Meta_Data::IsMSKEnabled() ); |
|
541 |
|
542 if ( mskEnabled ) |
|
543 { |
|
544 textVariety = Layout_Meta_Data::IsLandscapeOrientation() ? 2 : 3; |
|
545 graphVariety = Layout_Meta_Data::IsLandscapeOrientation() ? 2 : 4; |
|
546 } |
|
547 else |
|
548 { |
|
549 textVariety = Layout_Meta_Data::IsLandscapeOrientation() ? 2 : 0; |
|
550 graphVariety = Layout_Meta_Data::IsLandscapeOrientation() ? 2 : 4; |
|
551 } |
|
552 |
|
553 CEikCba* cba( static_cast< CEikCba* >( aContainer.ButtonGroup() ) ); |
|
554 |
|
555 TRect parentRect( cba->Rect() ); |
|
556 |
|
557 switch( aPos ) |
|
558 { |
|
559 case CEikButtonGroupContainer::ELeftSoftkeyPosition: |
|
560 { |
|
561 if( aImageOn ) |
|
562 { |
|
563 if ( HDLayoutActive() && |
|
564 AKN_LAYOUT_WINDOW_screen.iW == KWideScreenWidth ) |
|
565 { |
|
566 rect = SoftkeyRectBottomGraphics(); |
|
567 } |
|
568 else |
|
569 { |
|
570 |
|
571 TAknLayoutRect qgn_icon_lsk; |
|
572 |
|
573 qgn_icon_lsk.LayoutRect( parentRect, |
|
574 AknLayoutScalable_Avkon::control_pane_g1( graphVariety ).LayoutLine() ); |
|
575 |
|
576 rect = qgn_icon_lsk.Rect(); |
|
577 } |
|
578 } |
|
579 else |
|
580 { |
|
581 TAknLayoutText qgn_text_lsk; |
|
582 |
|
583 qgn_text_lsk.LayoutText( parentRect, |
|
584 AknLayoutScalable_Avkon::control_pane_t1( textVariety ).LayoutLine() ); |
|
585 |
|
586 rect = qgn_text_lsk.TextRect(); |
|
587 } |
|
588 } |
|
589 break; |
|
590 case CEikButtonGroupContainer::ERightSoftkeyPosition: |
|
591 { |
|
592 if( aImageOn ) |
|
593 { |
|
594 if ( HDLayoutActive() && |
|
595 AKN_LAYOUT_WINDOW_screen.iW == KWideScreenWidth ) |
|
596 { |
|
597 rect = SoftkeyRectTopGraphics(); |
|
598 } |
|
599 else |
|
600 { |
|
601 TAknLayoutRect qgn_icon_rsk; |
|
602 |
|
603 qgn_icon_rsk.LayoutRect( parentRect, |
|
604 AknLayoutScalable_Avkon::control_pane_g2( graphVariety ).LayoutLine() ); |
|
605 |
|
606 rect = qgn_icon_rsk.Rect(); |
|
607 } |
|
608 } |
|
609 else |
|
610 { |
|
611 TAknLayoutText qgn_text_rsk; |
|
612 |
|
613 qgn_text_rsk.LayoutText( parentRect, |
|
614 AknLayoutScalable_Avkon::control_pane_t2( textVariety ).LayoutLine() ); |
|
615 |
|
616 rect = qgn_text_rsk.TextRect(); |
|
617 } |
|
618 } |
|
619 break; |
|
620 case CEikButtonGroupContainer::EMiddleSoftkeyPosition: |
|
621 { |
|
622 if( !mskEnabled || aImageOn ) |
|
623 { |
|
624 // No msk, or asking image size for msk |
|
625 User::Leave( KErrNotSupported ); |
|
626 } |
|
627 else |
|
628 { |
|
629 TAknLayoutText qgn_text_msk; |
|
630 |
|
631 qgn_text_msk.LayoutText( parentRect, |
|
632 AknLayoutScalable_Avkon::control_pane_t3( textVariety ).LayoutLine() ); |
|
633 |
|
634 rect = qgn_text_msk.TextRect(); |
|
635 } |
|
636 } |
|
637 break; |
|
638 default: |
|
639 User::Leave( KErrNotFound ); |
|
640 break; |
|
641 } |
|
642 } |
|
643 |
|
644 return rect; |
|
645 } |
|
646 // ----------------------------------------------------------------------------- |
|
647 // Get softkey image rect |
|
648 // ----------------------------------------------------------------------------- |
|
649 static TRect SoftkeyImageRect(CEikButtonGroupContainer& aContainer, TInt aPosition) |
|
650 { |
|
651 TRect ret; |
|
652 #ifndef _AVKON_CBA_LSC |
|
653 TAknLayoutRect softkeyImg; |
|
654 CEikCba* cba( static_cast< CEikCba* >( aContainer.ButtonGroup() ) ); |
|
655 TRect parentRect( cba->Rect() ); |
|
656 |
|
657 if(Layout_Meta_Data::IsLandscapeOrientation()) |
|
658 { |
|
659 if(aPosition == CEikButtonGroupContainer::ELeftSoftkeyPosition) |
|
660 { |
|
661 TAknWindowComponentLayout wcl = AknLayoutScalable_Avkon::control_pane_g1(2); |
|
662 softkeyImg.LayoutRect(parentRect,wcl.LayoutLine() ); |
|
663 } |
|
664 else if(aPosition == CEikButtonGroupContainer::ERightSoftkeyPosition) |
|
665 { |
|
666 TAknWindowComponentLayout wcl = AknLayoutScalable_Avkon::control_pane_g2(2); |
|
667 softkeyImg.LayoutRect(parentRect,wcl.LayoutLine() ); |
|
668 } |
|
669 } |
|
670 else |
|
671 { |
|
672 if(aPosition == CEikButtonGroupContainer::ELeftSoftkeyPosition) |
|
673 { |
|
674 TAknWindowComponentLayout wcl = AknLayoutScalable_Avkon::control_pane_g1(4); |
|
675 softkeyImg.LayoutRect(parentRect,wcl.LayoutLine() ); |
|
676 } |
|
677 else if(aPosition == CEikButtonGroupContainer::ERightSoftkeyPosition) |
|
678 { |
|
679 TAknWindowComponentLayout wcl = AknLayoutScalable_Avkon::control_pane_g2(4); |
|
680 softkeyImg.LayoutRect(parentRect,wcl.LayoutLine() ); |
|
681 |
|
682 } |
|
683 } |
|
684 ret = softkeyImg.Rect(); |
|
685 #else |
|
686 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
687 { |
|
688 if(aPosition == CEikButtonGroupContainer::ELeftSoftkeyPosition) |
|
689 { |
|
690 ret = SoftkeyRectTopTouch(); |
|
691 } |
|
692 else if(aPosition == CEikButtonGroupContainer::ERightSoftkeyPosition) |
|
693 { |
|
694 ret = SoftkeyRectBottomTouch(); |
|
695 } |
|
696 } |
|
697 else // portrait |
|
698 { |
|
699 if(aPosition == CEikButtonGroupContainer::ELeftSoftkeyPosition) |
|
700 { |
|
701 ret = SoftkeyRectLeftTouch(); |
|
702 } |
|
703 else if(aPosition == CEikButtonGroupContainer::ERightSoftkeyPosition) |
|
704 { |
|
705 ret = SoftkeyRectRightTouch(); |
|
706 } |
|
707 } |
|
708 #endif |
|
709 return ret; |
|
710 } |
|
711 |
|
712 // ----------------------------------------------------------------------------- |
|
713 // CopyBitmapLC |
|
714 // Copy bitmap |
|
715 // ----------------------------------------------------------------------------- |
|
716 static CFbsBitmap* CopyBitmapL( const CFbsBitmap* aBitmap ) |
|
717 { |
|
718 CFbsBitmap* copy = new ( ELeave ) CFbsBitmap; |
|
719 CleanupStack::PushL( copy ); |
|
720 |
|
721 copy->Create( aBitmap->SizeInPixels(), aBitmap->DisplayMode() ); |
|
722 |
|
723 CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL( copy ); |
|
724 CleanupStack::PushL( dev ); |
|
725 |
|
726 CFbsBitGc* gc = CFbsBitGc::NewL(); |
|
727 CleanupStack::PushL( gc ); |
|
728 |
|
729 gc->Activate( dev ); |
|
730 gc->BitBlt( TPoint( 0, 0 ), aBitmap ); |
|
731 |
|
732 CleanupStack::PopAndDestroy( 2 ); // gc, dev |
|
733 |
|
734 CleanupStack::Pop( copy ); |
|
735 |
|
736 return copy; |
|
737 } |
|
738 |
|
739 // ----------------------------------------------------------------------------- |
|
740 // MenuTypeL |
|
741 // This is used to deactivate "active applications" menu item using the theme |
|
742 // Get the "menutype" property from menubar and check if it has value |
|
743 // "menuoptions" (default) or "menuoptionsnotaskswapper" and return |
|
744 // correct menu type. |
|
745 // ----------------------------------------------------------------------------- |
|
746 static CEikMenuBar::TMenuType MenuTypeL( CXnNodePluginIf& aMenubarNode ) |
|
747 { |
|
748 CEikMenuBar::TMenuType menuType( CEikMenuBar::EMenuOptions ); |
|
749 |
|
750 CXnProperty* property( aMenubarNode.GetPropertyL( XnPropertyNames::menu::KMenuType ) ); |
|
751 |
|
752 if( property ) |
|
753 { |
|
754 if( property->StringValue() == XnPropertyNames::menu::menutype::KMenuOptionsNoTaskSwapper ) |
|
755 { |
|
756 menuType = CEikMenuBar::EMenuOptionsNoTaskSwapper; |
|
757 } |
|
758 } |
|
759 |
|
760 return menuType; |
|
761 } |
|
762 |
|
763 // ----------------------------------------------------------------------------- |
|
764 // FindChildL |
|
765 // |
|
766 // ----------------------------------------------------------------------------- |
|
767 static CXnNodePluginIf* FindChildL( CXnNodePluginIf& aNode, |
|
768 const TDesC8& aType, const TDesC8& aTarget ) |
|
769 { |
|
770 RPointerArray<CXnNodePluginIf> children( aNode.ChildrenL() ); |
|
771 CleanupClosePushL( children ); |
|
772 |
|
773 CXnNodePluginIf* retval( NULL ); |
|
774 |
|
775 for( TInt i = 0; i < children.Count(); i++ ) |
|
776 { |
|
777 CXnNodePluginIf* child( children[i] ); |
|
778 |
|
779 if( child->Type()->Type() == aType ) |
|
780 { |
|
781 if( aTarget == KNullDesC8 ) |
|
782 { |
|
783 retval = child; |
|
784 break; |
|
785 } |
|
786 else |
|
787 { |
|
788 CXnProperty* target( child->GetPropertyL( KXnTarget ) ); |
|
789 |
|
790 if( target && target->StringValue() == aTarget ) |
|
791 { |
|
792 retval = child; |
|
793 break; |
|
794 } |
|
795 |
|
796 CXnProperty* source( child->GetPropertyL( KXnSource ) ); |
|
797 |
|
798 if( source && source->StringValue() == aTarget ) |
|
799 { |
|
800 retval = child; |
|
801 break; |
|
802 } |
|
803 } |
|
804 } |
|
805 } |
|
806 |
|
807 CleanupStack::PopAndDestroy( &children ); |
|
808 |
|
809 return retval; |
|
810 } |
|
811 |
|
812 // ----------------------------------------------------------------------------- |
|
813 // FindWidgetElementL |
|
814 // |
|
815 // ----------------------------------------------------------------------------- |
|
816 // |
|
817 static CXnNodePluginIf* FindWidgetElementL( CXnNodePluginIf& aPluginNode ) |
|
818 { |
|
819 CXnNodePluginIf* retval( NULL ); |
|
820 |
|
821 RPointerArray< CXnNodePluginIf > children( aPluginNode.ChildrenL() ); |
|
822 CleanupClosePushL( children ); |
|
823 |
|
824 for ( TInt i = 0; i < children.Count(); i++ ) |
|
825 { |
|
826 CXnNodePluginIf* node( children[i] ); |
|
827 |
|
828 if ( node->AppIfL().InternalDomNodeType() == XnPropertyNames::KWidget ) |
|
829 { |
|
830 retval = node; |
|
831 break; |
|
832 } |
|
833 } |
|
834 |
|
835 CleanupStack::PopAndDestroy( &children ); |
|
836 |
|
837 return retval; |
|
838 } |
|
839 |
|
840 // ============================ MEMBER FUNCTIONS =============================== |
|
841 |
|
842 // ----------------------------------------------------------------------------- |
|
843 // CXnMenuAdapter::NewL |
|
844 // Symbian static 1st phase constructor |
|
845 // ----------------------------------------------------------------------------- |
|
846 // |
|
847 CXnMenuAdapter* CXnMenuAdapter::NewL( CXnControlAdapter* aParent, CXnNodePluginIf& aNode ) |
|
848 { |
|
849 CXnMenuAdapter* self = new( ELeave ) CXnMenuAdapter; |
|
850 |
|
851 CleanupStack::PushL( self ); |
|
852 self->ConstructL( aParent, aNode ); |
|
853 CleanupStack::Pop( self ); |
|
854 |
|
855 return self; |
|
856 } |
|
857 |
|
858 // ----------------------------------------------------------------------------- |
|
859 // CXnMenuAdapter::ConstructL |
|
860 // Symbian 2nd phase constructor can leave. |
|
861 // ----------------------------------------------------------------------------- |
|
862 // |
|
863 void CXnMenuAdapter::ConstructL( CXnControlAdapter* /*aParent*/, CXnNodePluginIf& aNode ) |
|
864 { |
|
865 iRootNode = &aNode; |
|
866 |
|
867 CXnControlAdapter::ConstructL( aNode ); |
|
868 |
|
869 iUiEngine = iRootNode->UiEngineL(); |
|
870 |
|
871 CAknAppUi* appui( iAvkonAppUi ); |
|
872 |
|
873 iPreviousMenuPaneId = appui->StatusPane()->CurrentLayoutResId(); |
|
874 |
|
875 CEikMenuBar* current( iEikonEnv->AppUiFactory()->SwapMenuBar( NULL ) ); |
|
876 appui->RemoveFromStack( current ); |
|
877 |
|
878 delete current; |
|
879 current = NULL; |
|
880 |
|
881 InitSoftkeyItemsL(); |
|
882 } |
|
883 |
|
884 // ----------------------------------------------------------------------------- |
|
885 // CXnMenuAdapter::CXnMenuAdapter |
|
886 // C++ default constructor |
|
887 // ----------------------------------------------------------------------------- |
|
888 // |
|
889 CXnMenuAdapter::CXnMenuAdapter(): |
|
890 iMenuItems( KXnMenuArrayGranularity ), |
|
891 iIdCounter( KMenuCommandFirst ) |
|
892 { |
|
893 } |
|
894 |
|
895 // ----------------------------------------------------------------------------- |
|
896 // CXnMenuAdapter::~CXnMenuAdapter |
|
897 // C++ destructor |
|
898 // ----------------------------------------------------------------------------- |
|
899 // |
|
900 CXnMenuAdapter::~CXnMenuAdapter() |
|
901 { |
|
902 StopDisplayingMenu(); |
|
903 |
|
904 if ( iAvkonAppUi ) |
|
905 { |
|
906 iAvkonAppUi->RemoveFromStack( iMenuBar ); |
|
907 } |
|
908 |
|
909 if ( iMenuBar ) |
|
910 { |
|
911 delete iMenuBar; |
|
912 } |
|
913 |
|
914 iSoftkeyItems.ResetAndDestroy(); |
|
915 iMenuItems.Reset(); |
|
916 } |
|
917 |
|
918 // ----------------------------------------------------------------------------- |
|
919 // Create scaled bitmap from source bitmap. |
|
920 // ----------------------------------------------------------------------------- |
|
921 // |
|
922 void CreateScaledBitmapL( |
|
923 const TRect& aRect, |
|
924 CFbsBitmap*& aTrgBitmap, |
|
925 CFbsBitmap* aSrcBitmap, |
|
926 TBool aPreserveAspectRatio ) |
|
927 { |
|
928 TRect destRect = aRect; |
|
929 |
|
930 if( aPreserveAspectRatio ) |
|
931 { |
|
932 // Calculate the bitmap image dimensions so that it uses maximum space |
|
933 // of the given rectangle and maintains aspect ratio. |
|
934 TInt srcHeight = aSrcBitmap->SizeInPixels().iHeight; |
|
935 TInt srcWidth = aSrcBitmap->SizeInPixels().iWidth; |
|
936 TReal scaleRatio( 1 ); //no scale as defaul |
|
937 |
|
938 // If any dimension is 0, then we do not bother to scale |
|
939 if( aRect.Width() > 0 && aRect.Height() > 0 ) |
|
940 { |
|
941 TReal xRatio = ( (TReal )srcWidth / ( TReal )aRect.Width() ); |
|
942 TReal yRatio = ( ( TReal )srcHeight / ( TReal )aRect.Height() ); |
|
943 |
|
944 //Find out appropriate scaling factor |
|
945 xRatio > yRatio ? ( scaleRatio = xRatio ) : ( scaleRatio = yRatio ); |
|
946 } |
|
947 |
|
948 // Scale the size for target bitmap |
|
949 destRect.SetHeight( srcHeight / scaleRatio ); |
|
950 destRect.SetWidth( srcWidth / scaleRatio ); |
|
951 } |
|
952 |
|
953 aTrgBitmap = new ( ELeave ) CFbsBitmap; |
|
954 CleanupStack::PushL( aTrgBitmap ); |
|
955 |
|
956 // It is allowed to create zero height or width bitmap. |
|
957 TInt err( aTrgBitmap->Create( destRect.Size(), aSrcBitmap->DisplayMode() ) ); |
|
958 |
|
959 if( err == KErrNone ) |
|
960 { |
|
961 CXnUtils::ScaleBitmapL( destRect, aTrgBitmap, aSrcBitmap ); |
|
962 } |
|
963 |
|
964 // we do not own the bitmap so just Pop. |
|
965 CleanupStack::Pop( aTrgBitmap ); |
|
966 } |
|
967 |
|
968 // ----------------------------------------------------------------------------- |
|
969 // CXnMenuAdapter::PrepareSoftkeyImageL |
|
970 // Make a copy of originals and scale them to right size. |
|
971 // Finally place the scaled icon to right position of drawing area. |
|
972 // ----------------------------------------------------------------------------- |
|
973 CEikImage* CXnMenuAdapter::PrepareSoftkeyImageL( const CXnSoftkeyItem& aItem, const TSize& aSize ) |
|
974 { |
|
975 CFbsBitmap* bitmap( NULL ); |
|
976 CFbsBitmap* mask( NULL ); |
|
977 |
|
978 // Start from bitmap |
|
979 CFbsBitmap* source( aItem.iBitmap ); |
|
980 |
|
981 TInt count( 0 ); |
|
982 |
|
983 // Go through bitmap and mask |
|
984 for( TInt i = 0; i < 2; i++ ) |
|
985 { |
|
986 if( !source ) |
|
987 { |
|
988 source = aItem.iMask; |
|
989 continue; |
|
990 } |
|
991 |
|
992 CFbsBitmap* scaled( NULL ); |
|
993 |
|
994 TScaleMode mode( aItem.iPreserveAspectRatio ? EAspectRatioPreserved : EAspectRatioNotPreserved ); |
|
995 |
|
996 if( AknIconUtils::IsMifIcon( source ) ) |
|
997 { |
|
998 AknIconUtils::SetSize( source, aSize, mode ); |
|
999 |
|
1000 scaled = CopyBitmapL( source ); |
|
1001 } |
|
1002 else |
|
1003 { |
|
1004 CreateScaledBitmapL( TRect( aSize ), scaled, source, mode == EAspectRatioPreserved ); |
|
1005 } |
|
1006 |
|
1007 CleanupStack::PushL( scaled ); |
|
1008 |
|
1009 if( !aItem.iPreserveAspectRatio ) |
|
1010 { |
|
1011 count++; |
|
1012 |
|
1013 if( i == 0 ) |
|
1014 { |
|
1015 bitmap = scaled; |
|
1016 } |
|
1017 else |
|
1018 { |
|
1019 mask = scaled; |
|
1020 } |
|
1021 } |
|
1022 else |
|
1023 { |
|
1024 CFbsBitmap* target = new ( ELeave ) CFbsBitmap; |
|
1025 CleanupStack::PushL( target ); |
|
1026 |
|
1027 // Target is size of whole draw area |
|
1028 User::LeaveIfError( target->Create( aSize, source->DisplayMode() ) ); |
|
1029 |
|
1030 CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL( target ); |
|
1031 CleanupStack::PushL( dev ); |
|
1032 |
|
1033 CFbsBitGc* gc = CFbsBitGc::NewL(); |
|
1034 CleanupStack::PushL( gc ); |
|
1035 |
|
1036 gc->Activate( dev ); |
|
1037 |
|
1038 gc->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1039 gc->SetPenStyle( CGraphicsContext::ENullPen ); |
|
1040 |
|
1041 if( aItem.iInvertMask ) |
|
1042 { |
|
1043 // White, with full transparent alpha channel |
|
1044 gc->SetBrushColor( TRgb( 0x00FFFFFF, 0 ) ); |
|
1045 } |
|
1046 else |
|
1047 { |
|
1048 // Black, with full transparent alpha channel |
|
1049 gc->SetBrushColor( TRgb( 0x00000000, 0 ) ); |
|
1050 } |
|
1051 |
|
1052 // Make whole target area transparent |
|
1053 gc->DrawRect( TRect( aSize ) ); |
|
1054 |
|
1055 TPoint iconPos; |
|
1056 |
|
1057 switch( AknLayoutUtils::CbaLocation() ) |
|
1058 { |
|
1059 case AknLayoutUtils::EAknCbaLocationBottom: |
|
1060 // Rsk must be moved to right, lsk is in correct place by default |
|
1061 if ( aItem.iPosition != CEikButtonGroupContainer::ELeftSoftkeyPosition ) |
|
1062 { |
|
1063 iconPos.iX = aSize.iWidth - scaled->SizeInPixels().iWidth; |
|
1064 } |
|
1065 break; |
|
1066 case AknLayoutUtils::EAknCbaLocationRight: |
|
1067 // Rsk and lsk must be moved to right |
|
1068 iconPos.iX = aSize.iWidth - scaled->SizeInPixels().iWidth; |
|
1069 break; |
|
1070 case AknLayoutUtils::EAknCbaLocationLeft: |
|
1071 // Already in correct position |
|
1072 default: |
|
1073 break; |
|
1074 } |
|
1075 |
|
1076 // Align horizontally to center |
|
1077 iconPos.iY = iconPos.iX ? 0 : ( ( aSize.iHeight - scaled->SizeInPixels().iHeight ) / 2 ); |
|
1078 |
|
1079 gc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
1080 |
|
1081 // Blit image to correct position |
|
1082 gc->BitBlt( iconPos, scaled ); |
|
1083 |
|
1084 CleanupStack::PopAndDestroy( 2, dev ); |
|
1085 |
|
1086 CleanupStack::Pop( target ); |
|
1087 |
|
1088 CleanupStack::PopAndDestroy( scaled ); |
|
1089 |
|
1090 CleanupStack::PushL( target ); |
|
1091 count++; |
|
1092 |
|
1093 if( i == 0 ) |
|
1094 { |
|
1095 bitmap = target; |
|
1096 } |
|
1097 else |
|
1098 { |
|
1099 mask = target; |
|
1100 } |
|
1101 |
|
1102 |
|
1103 } |
|
1104 |
|
1105 // Go with mask next |
|
1106 source = aItem.iMask; |
|
1107 } |
|
1108 |
|
1109 // Takes ownership of scaled bitmap and mask |
|
1110 CEikImage* image = new ( ELeave ) CEikImage; |
|
1111 |
|
1112 image->SetPictureOwnedExternally( EFalse ); |
|
1113 image->SetPicture( bitmap, mask ); |
|
1114 |
|
1115 CleanupStack::Pop( count ); |
|
1116 |
|
1117 return image; |
|
1118 } |
|
1119 |
|
1120 // ----------------------------------------------------------------------------- |
|
1121 // CXnMenuAdapter::SetSoftkeyAppearanceL |
|
1122 // |
|
1123 // ----------------------------------------------------------------------------- |
|
1124 // |
|
1125 void CXnMenuAdapter::SetSoftkeyAppearanceL( CXnSoftkeyItem& aItem ) |
|
1126 { |
|
1127 if( iContainer && IsNodeVisibleL( *aItem.iNode) ) |
|
1128 { |
|
1129 if( aItem.iImageOn ) |
|
1130 { |
|
1131 ChangeSoftkeyImageL( aItem ); |
|
1132 } |
|
1133 else if( aItem.iLabel )// change label |
|
1134 { |
|
1135 if ( aItem.iPosition == CEikButtonGroupContainer::ELeftSoftkeyPosition ) |
|
1136 { |
|
1137 EikSoftkeyImage::SetLabel( iContainer, ETrue ); |
|
1138 } |
|
1139 else if ( aItem.iPosition == CEikButtonGroupContainer::ERightSoftkeyPosition ) |
|
1140 { |
|
1141 EikSoftkeyImage::SetLabel( iContainer, EFalse ); |
|
1142 } |
|
1143 |
|
1144 iContainer->SetCommandL( aItem.iPosition, aItem.iCommandId, *aItem.iLabel ); |
|
1145 } |
|
1146 } |
|
1147 } |
|
1148 |
|
1149 // ----------------------------------------------------------------------------- |
|
1150 // CXnMenuAdapter::InitSoftkeyItemsL |
|
1151 // |
|
1152 // ----------------------------------------------------------------------------- |
|
1153 // |
|
1154 void CXnMenuAdapter::InitSoftkeyItemsL() |
|
1155 { |
|
1156 // No layout calulations needed |
|
1157 iRootNode->SetLayoutCapable( EFalse ); |
|
1158 |
|
1159 // create softkeyitems to hold data |
|
1160 |
|
1161 RPointerArray< CXnNodePluginIf > children( iRootNode->ChildrenL() ); |
|
1162 CleanupClosePushL( children ); |
|
1163 CXnSoftkeyItem* item(0); |
|
1164 for(TInt i=0;i<children.Count();++i) |
|
1165 { |
|
1166 if(children[i]->Type()->Type() == XnPropertyNames::softkey::KNodeName) |
|
1167 { |
|
1168 item = AppendSoftkeyItemL(children[i]); |
|
1169 if(item) |
|
1170 { |
|
1171 item->iDefault = ETrue; |
|
1172 } |
|
1173 } |
|
1174 } |
|
1175 CleanupStack::PopAndDestroy( &children ); |
|
1176 |
|
1177 } |
|
1178 |
|
1179 // ----------------------------------------------------------------------------- |
|
1180 // CXnMenuAdapter::InitSoftkeyItemL |
|
1181 // |
|
1182 // ----------------------------------------------------------------------------- |
|
1183 // |
|
1184 void CXnMenuAdapter::InitSoftkeyItemImageL( CXnSoftkeyItem& aItem) |
|
1185 { |
|
1186 CXnNodePluginIf* node( aItem.iNode ); |
|
1187 |
|
1188 // No layout calulations needed |
|
1189 node->SetLayoutCapable( EFalse ); |
|
1190 |
|
1191 if ( aItem.iPosition == CEikButtonGroupContainer::EMiddleSoftkeyPosition ) |
|
1192 { |
|
1193 aItem.iImageOn = ETrue; |
|
1194 return; |
|
1195 } |
|
1196 |
|
1197 CXnProperty* pathProp( node->PathL() ); |
|
1198 if( pathProp ) |
|
1199 { |
|
1200 HBufC* bitmapPath( NULL ); |
|
1201 HBufC* maskPath( NULL ); |
|
1202 |
|
1203 bitmapPath = pathProp->StringValueL(); |
|
1204 CleanupStack::PushL( bitmapPath ); |
|
1205 TInt count( 1 ); |
|
1206 |
|
1207 CXnProperty* maskProp( node->MaskPathL() ); |
|
1208 |
|
1209 if( maskProp ) |
|
1210 { |
|
1211 maskPath = maskProp->StringValueL(); |
|
1212 CleanupStack::PushL( maskPath ); |
|
1213 count++; |
|
1214 } |
|
1215 |
|
1216 CFbsBitmap* bitmap( NULL ); |
|
1217 CFbsBitmap* mask( NULL ); |
|
1218 |
|
1219 // Call base class to get bitmap and mask |
|
1220 GetBitmapAndMask( bitmapPath ? *bitmapPath : KNullDesC(), |
|
1221 maskPath ? *maskPath : KNullDesC(), |
|
1222 bitmap, mask ); |
|
1223 |
|
1224 aItem.iImageOn = ETrue; |
|
1225 aItem.iBitmap = bitmap; |
|
1226 aItem.iMask = mask; |
|
1227 |
|
1228 CXnProperty* maskInvertedProp( node->GetPropertyL( XnPropertyNames::image::KMaskInverted ) ); |
|
1229 |
|
1230 if( maskInvertedProp ) |
|
1231 { |
|
1232 if( maskInvertedProp->StringValue() == XnPropertyNames::KTrue ) |
|
1233 { |
|
1234 aItem.iInvertMask = ETrue; |
|
1235 } |
|
1236 } |
|
1237 |
|
1238 CXnProperty* aspectRatioProp( node->GetPropertyL( XnPropertyNames::image::KS60AspectRatio ) ); |
|
1239 |
|
1240 if( aspectRatioProp ) |
|
1241 { |
|
1242 if( aspectRatioProp->StringValue() == XnPropertyNames::image::KPreserve ) |
|
1243 { |
|
1244 aItem.iPreserveAspectRatio = ETrue; |
|
1245 } |
|
1246 } |
|
1247 |
|
1248 CleanupStack::PopAndDestroy( count ); // path and/or mask |
|
1249 } |
|
1250 } |
|
1251 |
|
1252 // ----------------------------------------------------------------------------- |
|
1253 // CXnMenuAdapter::IsMskAvailable |
|
1254 // |
|
1255 // ----------------------------------------------------------------------------- |
|
1256 // |
|
1257 TBool CXnMenuAdapter::IsMskAvailable() |
|
1258 { |
|
1259 if( AknLayoutUtils::MSKEnabled() && Layout_Meta_Data::IsMSKEnabled() ) |
|
1260 { |
|
1261 return ETrue; |
|
1262 } |
|
1263 |
|
1264 return EFalse; |
|
1265 } |
|
1266 |
|
1267 // ----------------------------------------------------------------------------- |
|
1268 // CXnMenuAdapter::AddMenuItemL |
|
1269 // |
|
1270 // ----------------------------------------------------------------------------- |
|
1271 // |
|
1272 TInt CXnMenuAdapter::AddMenuItemL( TInt aParentIndex, |
|
1273 CXnNodePluginIf* aNode, RPointerArray< const TDesC8 >& aGroups ) |
|
1274 { |
|
1275 if ( !aNode ) |
|
1276 { |
|
1277 return 0; |
|
1278 } |
|
1279 |
|
1280 const TDesC8& name( aNode->Type()->Type() ); |
|
1281 |
|
1282 TInt retval( 0 ); |
|
1283 |
|
1284 TBool showByGroup( EFalse ); |
|
1285 |
|
1286 const TDesC8* id( NULL ); |
|
1287 |
|
1288 CXnProperty* prop( aNode->IdL() ); |
|
1289 |
|
1290 if( prop ) |
|
1291 { |
|
1292 id = &prop->StringValue(); |
|
1293 } |
|
1294 else |
|
1295 { |
|
1296 // If menuitem doesn't have id, group doesn't affect to it |
|
1297 showByGroup = ETrue; |
|
1298 } |
|
1299 |
|
1300 if( name == KXnMenuItem || |
|
1301 name == KXnDynMenuItem || |
|
1302 name == KXnWidgetMenuItem ) |
|
1303 { |
|
1304 const TDesC8& ns( aNode->Namespace() ); |
|
1305 |
|
1306 for( TInt i = 0; !showByGroup && i < aGroups.Count(); i++ ) |
|
1307 { |
|
1308 const TDesC8& groupId( *(aGroups)[i] ); |
|
1309 |
|
1310 CXnNodePluginIf* group( iUiEngine->FindNodeByIdL( groupId, ns ) ); |
|
1311 |
|
1312 if( group ) |
|
1313 { |
|
1314 RPointerArray< CXnNodePluginIf > |
|
1315 children( group->ChildrenL() ); |
|
1316 |
|
1317 CleanupClosePushL( children ); |
|
1318 |
|
1319 for( TInt j = 0; j < children.Count(); j++ ) |
|
1320 { |
|
1321 CXnProperty* prop( children[j]->GetPropertyL( |
|
1322 XnPropertyNames::action::KName ) ); |
|
1323 |
|
1324 if( prop ) |
|
1325 { |
|
1326 const TDesC8& name( prop->StringValue() ); |
|
1327 |
|
1328 if( name == *id ) |
|
1329 { |
|
1330 // The menuitem belongs to defined group |
|
1331 showByGroup = ETrue; |
|
1332 break; |
|
1333 } |
|
1334 } |
|
1335 } |
|
1336 |
|
1337 CleanupStack::PopAndDestroy( &children ); |
|
1338 } |
|
1339 } |
|
1340 |
|
1341 if( !showByGroup || !IsNodeVisibleL( *aNode ) ) |
|
1342 { |
|
1343 // Menuitem is invisible |
|
1344 return retval; |
|
1345 } |
|
1346 } |
|
1347 |
|
1348 TXnMenuItem item; |
|
1349 |
|
1350 item.iAutomaticSP = ETrue; |
|
1351 |
|
1352 item.iParentIndex = aParentIndex; |
|
1353 item.iData.iFlags = 0; |
|
1354 |
|
1355 CXnNodePluginIf* menuItem( NULL ); |
|
1356 |
|
1357 if( name == KXnMenuItem || name == KXnDynMenuItem ) |
|
1358 { |
|
1359 menuItem = aNode; |
|
1360 } |
|
1361 else if( name == KXnWidgetMenuItem ) |
|
1362 { |
|
1363 TRAP_IGNORE( menuItem = FindWidgetMenuItemL( aNode ) ); |
|
1364 } |
|
1365 |
|
1366 if( menuItem ) |
|
1367 { |
|
1368 const TDesC8& type( menuItem->Type()->Type() ); |
|
1369 |
|
1370 // check first if label comes from view |
|
1371 CXnProperty* label( aNode->LabelL() ); |
|
1372 |
|
1373 if ( !label ) |
|
1374 { |
|
1375 // get label from widget |
|
1376 label = menuItem->LabelL(); |
|
1377 } |
|
1378 |
|
1379 if( label ) |
|
1380 { |
|
1381 HBufC* itemLabel = label->StringValueL(); |
|
1382 item.iData.iText.Copy( *itemLabel ); |
|
1383 delete itemLabel; |
|
1384 } |
|
1385 else |
|
1386 { |
|
1387 item.iData.iText.Copy( KNullDesC ); |
|
1388 } |
|
1389 |
|
1390 TBool okToAdd( ETrue ); |
|
1391 |
|
1392 if( type == KXnDynMenuItem ) |
|
1393 { |
|
1394 okToAdd = EFalse; |
|
1395 |
|
1396 if( iObserver ) |
|
1397 { |
|
1398 okToAdd = iObserver->DynInitMenuItemL( menuItem->AppIfL() ); |
|
1399 } |
|
1400 } |
|
1401 |
|
1402 if( okToAdd ) |
|
1403 { |
|
1404 if ( id && *id == KHsShowHelp ) |
|
1405 { |
|
1406 // Help command id must be EAknCmdHelp to get editing input options |
|
1407 // shown correctly |
|
1408 item.iData.iCommandId = EAknCmdHelp; |
|
1409 } |
|
1410 else |
|
1411 { |
|
1412 item.iData.iCommandId = iIdCounter++; |
|
1413 } |
|
1414 |
|
1415 item.iData.iCascadeId = 0; |
|
1416 item.iNode = menuItem; |
|
1417 item.iIsCascade = EFalse; |
|
1418 iMenuItems.AppendL( item ); |
|
1419 |
|
1420 retval = 1; |
|
1421 } |
|
1422 } |
|
1423 |
|
1424 if( name == KXnMenu ) |
|
1425 { |
|
1426 // main level menu or submenu (cascade) |
|
1427 item.iData.iCommandId = iIdCounter++; |
|
1428 |
|
1429 if( aParentIndex == -1 ) |
|
1430 { |
|
1431 item.iData.iCascadeId = R_AVKON_MENUPANE_EMPTY; |
|
1432 } |
|
1433 else |
|
1434 { |
|
1435 item.iData.iCascadeId = iIdCounter++; |
|
1436 } |
|
1437 |
|
1438 item.iNode = aNode; |
|
1439 item.iIsCascade = ETrue; |
|
1440 iMenuItems.AppendL( item ); |
|
1441 |
|
1442 TInt currentIndex( iMenuItems.Count() - 1 ); |
|
1443 |
|
1444 RPointerArray< CXnNodePluginIf > children( aNode->ChildrenL() ); |
|
1445 CleanupClosePushL( children ); |
|
1446 |
|
1447 TInt count( 0 ); |
|
1448 |
|
1449 for( TInt i = 0; i < children.Count(); i++ ) |
|
1450 { |
|
1451 count += AddMenuItemL( currentIndex, children[i], aGroups ); |
|
1452 } |
|
1453 |
|
1454 if( aParentIndex != -1 && count == 0 ) |
|
1455 { |
|
1456 // Empty submenu, don't show it |
|
1457 iMenuItems.Delete( currentIndex ); |
|
1458 // Reverse counter as well |
|
1459 iIdCounter -= 2; |
|
1460 } |
|
1461 |
|
1462 CleanupStack::PopAndDestroy( &children ); |
|
1463 |
|
1464 retval = count; |
|
1465 } |
|
1466 |
|
1467 return retval; |
|
1468 } |
|
1469 |
|
1470 // ----------------------------------------------------------------------------- |
|
1471 // CXnMenuAdapter::PopulateMenuL |
|
1472 // |
|
1473 // ----------------------------------------------------------------------------- |
|
1474 // |
|
1475 void CXnMenuAdapter::PopulateMenuL() |
|
1476 { |
|
1477 iMenuItems.Reset(); |
|
1478 |
|
1479 iIdCounter = KMenuCommandFirst; |
|
1480 |
|
1481 RPointerArray< const TDesC8 > groups; |
|
1482 CleanupClosePushL( groups ); |
|
1483 |
|
1484 if ( !iUiEngine->IsTextEditorActive() ) |
|
1485 { |
|
1486 if( iUiEngine->EditMode() ) |
|
1487 { |
|
1488 groups.AppendL( |
|
1489 iContextMenu ? &KContextEditMode : &KEditMode ); |
|
1490 } |
|
1491 else |
|
1492 { |
|
1493 groups.AppendL( |
|
1494 iContextMenu ? &KContextNormalMode : &KNormalMode ); |
|
1495 } |
|
1496 } |
|
1497 |
|
1498 if ( !iContextMenu ) |
|
1499 { |
|
1500 groups.AppendL( &KAlwaysShown ); |
|
1501 } |
|
1502 |
|
1503 // Recursively add menuitems |
|
1504 AddMenuItemL( -1, iMenuBarNode, groups ); |
|
1505 |
|
1506 CleanupStack::PopAndDestroy( &groups ); |
|
1507 } |
|
1508 |
|
1509 // ----------------------------------------------------------------------------- |
|
1510 // CXnMenuAdapter::OfferKeyEventL |
|
1511 // ----------------------------------------------------------------------------- |
|
1512 // |
|
1513 TKeyResponse CXnMenuAdapter::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
1514 { |
|
1515 TKeyResponse resp( EKeyWasNotConsumed ); |
|
1516 |
|
1517 if( IsMenuFocused() && aKeyEvent.iScanCode == EStdKeyNo ) |
|
1518 { |
|
1519 StopDisplayingMenu(); |
|
1520 |
|
1521 iKeyEventNode = NULL; |
|
1522 |
|
1523 return resp; |
|
1524 } |
|
1525 |
|
1526 TInt pos( KErrNotFound ); |
|
1527 |
|
1528 if( aKeyEvent.iScanCode == EStdKeyDevice0 ) |
|
1529 { |
|
1530 pos = CEikButtonGroupContainer::ELeftSoftkeyPosition; |
|
1531 } |
|
1532 else if( aKeyEvent.iScanCode == EStdKeyDevice1 ) |
|
1533 { |
|
1534 pos = CEikButtonGroupContainer::ERightSoftkeyPosition; |
|
1535 } |
|
1536 else if( aKeyEvent.iScanCode == EStdKeyDevice3 ) |
|
1537 { |
|
1538 pos = CEikButtonGroupContainer::EMiddleSoftkeyPosition; |
|
1539 } |
|
1540 |
|
1541 CXnSoftkeyItem* softkey( NULL ); |
|
1542 |
|
1543 if ( pos != KErrNotFound ) |
|
1544 { |
|
1545 softkey = SoftkeyItemL( pos ); |
|
1546 } |
|
1547 |
|
1548 if ( softkey ) |
|
1549 { |
|
1550 CXnNodePluginIf* node( softkey->iNode ); |
|
1551 |
|
1552 if( aType == EEventKeyDown ) |
|
1553 { |
|
1554 iKeyEventNode = node; |
|
1555 } |
|
1556 |
|
1557 if( node && node == iKeyEventNode ) |
|
1558 { |
|
1559 // Let base class handle the event |
|
1560 resp = CXnControlAdapter::OfferKeyEventL( aKeyEvent, aType ); |
|
1561 } |
|
1562 } |
|
1563 |
|
1564 if( aType == EEventKeyUp ) |
|
1565 { |
|
1566 iKeyEventNode = NULL; |
|
1567 } |
|
1568 |
|
1569 return resp; |
|
1570 } |
|
1571 |
|
1572 // ----------------------------------------------------------------------------- |
|
1573 // CXnMenuAdapter::HandlePointerEventL |
|
1574 // ----------------------------------------------------------------------------- |
|
1575 // |
|
1576 void CXnMenuAdapter::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
1577 { |
|
1578 CXnNodePluginIf* node( FindSoftkeyItemByPosition( aPointerEvent.iParentPosition ) ); |
|
1579 |
|
1580 if( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
1581 { |
|
1582 // The sofkey node which received the button down event |
|
1583 iPointerEventNode = node; |
|
1584 } |
|
1585 |
|
1586 if( node && node == iPointerEventNode ) |
|
1587 { |
|
1588 iUiEngine->DisableRenderUiLC(); |
|
1589 |
|
1590 // Handle event if location is in the grabbing node's area |
|
1591 CXnControlAdapter::HandlePointerEventL( aPointerEvent ); |
|
1592 |
|
1593 CleanupStack::PopAndDestroy(); |
|
1594 } |
|
1595 |
|
1596 if( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
1597 { |
|
1598 // Reset grabbing node after the up event |
|
1599 iPointerEventNode = NULL; |
|
1600 } |
|
1601 } |
|
1602 |
|
1603 // ----------------------------------------------------------------------------- |
|
1604 // CXnMenuAdapter::DoEnterPowerSaveModeL |
|
1605 // Enter power save mode |
|
1606 // ----------------------------------------------------------------------------- |
|
1607 void CXnMenuAdapter::DoEnterPowerSaveModeL(TModeEvent /*aEvent*/) |
|
1608 { |
|
1609 } |
|
1610 |
|
1611 // ----------------------------------------------------------------------------- |
|
1612 // CXnMenuAdapter::DoExitPowerSaveModeL |
|
1613 // Enter power save mode |
|
1614 // ----------------------------------------------------------------------------- |
|
1615 void CXnMenuAdapter::DoExitPowerSaveModeL(TModeEvent /*aEvent*/) |
|
1616 { |
|
1617 } |
|
1618 |
|
1619 // ----------------------------------------------------------------------------- |
|
1620 // CXnMenuAdapter::RestoreMenuL |
|
1621 // ----------------------------------------------------------------------------- |
|
1622 // |
|
1623 void CXnMenuAdapter::RestoreMenuL( CCoeControl* aMenuControl, TInt aResourceId, |
|
1624 TMenuType aType ) |
|
1625 { |
|
1626 // let all menu pane resources propogate to default implementation, |
|
1627 // otherwise panic when trying to display menu |
|
1628 if ( aType == MEikMenuObserver::EMenuPane ) |
|
1629 { |
|
1630 if ( !( KMenuCommandFirst <= aResourceId && |
|
1631 aResourceId <= KMenuCommandLast ) |
|
1632 && aResourceId != R_AVKON_MENUPANE_EMPTY ) |
|
1633 { |
|
1634 MEikMenuObserver::RestoreMenuL( aMenuControl,aResourceId, aType ); |
|
1635 } |
|
1636 else |
|
1637 { |
|
1638 AddItemsToMenuPaneL( ( CEikMenuPane* )aMenuControl, aResourceId ); |
|
1639 } |
|
1640 } |
|
1641 } |
|
1642 |
|
1643 // ----------------------------------------------------------------------------- |
|
1644 // CXnMenuAdapter::DynInitMenuPaneL |
|
1645 // ----------------------------------------------------------------------------- |
|
1646 // |
|
1647 void CXnMenuAdapter::DynInitMenuPaneL( TInt aResourceId, |
|
1648 CEikMenuPane* aMenuPane ) |
|
1649 { |
|
1650 if ( aResourceId == R_AVKON_MENUPANE_EMPTY ) |
|
1651 { |
|
1652 RestoreMenuL( aMenuPane, aResourceId, MEikMenuObserver::EMenuPane ); |
|
1653 } |
|
1654 } |
|
1655 |
|
1656 // ----------------------------------------------------------------------------- |
|
1657 // CXnMenuAdapter::SetEmphasis |
|
1658 // ----------------------------------------------------------------------------- |
|
1659 // |
|
1660 void CXnMenuAdapter::SetEmphasis( CCoeControl* aMenuControl, |
|
1661 TBool aEmphasis ) |
|
1662 { |
|
1663 if ( iMenuBar && aMenuControl == iMenuBar ) |
|
1664 { |
|
1665 CXnAppUiAdapter* appui( |
|
1666 static_cast< CXnAppUiAdapter* >( iAvkonAppUi ) ); |
|
1667 |
|
1668 if ( aEmphasis && !iMenuShown ) |
|
1669 { |
|
1670 iMenuShown = ETrue; |
|
1671 |
|
1672 TRAP_IGNORE( appui->AddToStackL( appui->View(), |
|
1673 iMenuBar, |
|
1674 ECoeStackPriorityMenu ) ); |
|
1675 |
|
1676 iMenuBar->MakeVisible( ETrue ); |
|
1677 } |
|
1678 else if ( !aEmphasis && iMenuShown ) |
|
1679 { |
|
1680 iMenuShown = EFalse; |
|
1681 |
|
1682 appui->RemoveFromStack( iMenuBar ); |
|
1683 |
|
1684 iMenuBar->MakeVisible( EFalse ); |
|
1685 } |
|
1686 } |
|
1687 } |
|
1688 |
|
1689 // ----------------------------------------------------------------------------- |
|
1690 // CXnMenuAdapter::ProcessCommandL |
|
1691 // ----------------------------------------------------------------------------- |
|
1692 // |
|
1693 void CXnMenuAdapter::ProcessCommandL( TInt aCommand ) |
|
1694 { |
|
1695 if ( ( KMenuCommandFirst <= aCommand && aCommand <= KMenuCommandLast ) || |
|
1696 aCommand == EAknCmdHelp ) |
|
1697 { |
|
1698 // find item for this command |
|
1699 for ( TInt i = 0; i< iMenuItems.Count(); i++ ) |
|
1700 { |
|
1701 if ( iMenuItems[i].iData.iCommandId == aCommand ) |
|
1702 { |
|
1703 CXnNodePluginIf* node( iMenuItems[i].iNode ); |
|
1704 |
|
1705 if ( node ) |
|
1706 { |
|
1707 StopDisplayingMenu(); |
|
1708 |
|
1709 iUiEngine->DisableRenderUiLC(); |
|
1710 |
|
1711 node->SetStateL( XnPropertyNames::style::common::KActive ); |
|
1712 |
|
1713 CleanupStack::PopAndDestroy(); |
|
1714 |
|
1715 break; |
|
1716 } |
|
1717 } |
|
1718 } |
|
1719 } |
|
1720 else |
|
1721 { |
|
1722 StopDisplayingMenu(); |
|
1723 |
|
1724 if( aCommand == EEikCmdEditPaste ) |
|
1725 { |
|
1726 // Paste event for AknCcpuSupport |
|
1727 TKeyEvent pasteEvent = |
|
1728 { EKeyF18, EEikCmdEditPaste, EModifierCtrl, 1 }; |
|
1729 |
|
1730 iCoeEnv->SimulateKeyEventL( pasteEvent, EEventKey ); |
|
1731 } |
|
1732 } |
|
1733 } |
|
1734 |
|
1735 // ----------------------------------------------------------------------------- |
|
1736 // CXnMenuAdapter::SetContainerL |
|
1737 // |
|
1738 // ----------------------------------------------------------------------------- |
|
1739 // |
|
1740 void CXnMenuAdapter::SetContainerL( CEikButtonGroupContainer& aContainer ) |
|
1741 { |
|
1742 User::LeaveIfNull( &aContainer ); |
|
1743 |
|
1744 TBool updateNeeded( EFalse ); |
|
1745 |
|
1746 TInt statusPaneId( iAvkonAppUi->StatusPane()->CurrentLayoutResId() ); |
|
1747 |
|
1748 if(iPreviousMenuPaneId != statusPaneId) |
|
1749 { |
|
1750 updateNeeded = ETrue; |
|
1751 iPreviousMenuPaneId = statusPaneId; |
|
1752 } |
|
1753 |
|
1754 if((&aContainer) && (iContainer != &aContainer || updateNeeded)) |
|
1755 { |
|
1756 iUpdateLskAppearance = ETrue; |
|
1757 iUpdateMskAppearance = ETrue; |
|
1758 iUpdateRskAppearance = ETrue; |
|
1759 } |
|
1760 |
|
1761 iContainer = &aContainer; |
|
1762 |
|
1763 CEikCba* cba( static_cast< CEikCba* >( aContainer.ButtonGroup() ) ); |
|
1764 cba->SetButtonGroupFlags( cba->ButtonGroupFlags() | EEikCbaFlagSemiTransparent ); |
|
1765 |
|
1766 UpdateSoftkeyAppearancesL(); |
|
1767 } |
|
1768 |
|
1769 //-------------------------------------------------------------- |
|
1770 // CXnMenuAdapter::IsMenuFocused |
|
1771 // ------------------------------------------------------------ |
|
1772 TBool CXnMenuAdapter::IsMenuFocused() |
|
1773 { |
|
1774 return iMenuShown; |
|
1775 } |
|
1776 |
|
1777 // ----------------------------------------------------------------------------- |
|
1778 // CXnMenuAdapter::TryDisplayingMenuL |
|
1779 // Displays options menu |
|
1780 // ----------------------------------------------------------------------------- |
|
1781 // |
|
1782 void CXnMenuAdapter::TryDisplayingMenuL( const TDesC& aMenuNodeId, |
|
1783 TBool aContextMenu ) |
|
1784 { |
|
1785 HBufC8* id = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aMenuNodeId ); |
|
1786 CleanupStack::PushL( id ); |
|
1787 CXnNodePluginIf* node( iUiEngine->FindNodeByIdL( *id, iRootNode->Namespace() ) ); |
|
1788 CleanupStack::PopAndDestroy( id ); |
|
1789 |
|
1790 iContextMenu = aContextMenu; |
|
1791 |
|
1792 if( node && node->Type()->Type() == KXnMenu ) |
|
1793 { |
|
1794 TryDisplayingMenuL(); |
|
1795 } |
|
1796 } |
|
1797 |
|
1798 // ----------------------------------------------------------------------------- |
|
1799 // CXnMenuAdapter::TryDisplayingMenuL |
|
1800 // Displays options menu if it is defined for the softkey item |
|
1801 // ----------------------------------------------------------------------------- |
|
1802 // |
|
1803 void CXnMenuAdapter::TryDisplayingMenuL() |
|
1804 { |
|
1805 StopDisplayingMenu(); |
|
1806 |
|
1807 CreateMenuBarL(); |
|
1808 |
|
1809 if ( iMenuBar ) |
|
1810 { |
|
1811 CEikMenuBarTitle* title = new( ELeave ) CEikMenuBarTitle; |
|
1812 CleanupStack::PushL( title ); |
|
1813 |
|
1814 title->iData.iMenuPaneResourceId = R_AVKON_MENUPANE_EMPTY; |
|
1815 title->iTitleFlags = 0; |
|
1816 |
|
1817 // this cannot be done earlyer, than this callback |
|
1818 iMenuBar->TitleArray()->AddTitleL( title ); |
|
1819 CleanupStack::Pop( title ); |
|
1820 |
|
1821 iMenuBar->TryDisplayMenuBarL(); |
|
1822 } |
|
1823 } |
|
1824 |
|
1825 // ----------------------------------------------------------------------------- |
|
1826 // CXnMenuAdapter::StopDisplayingMenu |
|
1827 // ----------------------------------------------------------------------------- |
|
1828 // |
|
1829 void CXnMenuAdapter::StopDisplayingMenu() |
|
1830 { |
|
1831 if( iMenuBar ) |
|
1832 { |
|
1833 iMenuBar->StopDisplayingMenuBar(); |
|
1834 } |
|
1835 } |
|
1836 |
|
1837 // --------------------------------------------------------------------------- |
|
1838 // CXnMenuAdapter::CreateMenuBarL |
|
1839 // --------------------------------------------------------------------------- |
|
1840 // |
|
1841 void CXnMenuAdapter::CreateMenuBarL() |
|
1842 { |
|
1843 if ( iMenuBar ) |
|
1844 { |
|
1845 // All ready created |
|
1846 return; |
|
1847 } |
|
1848 |
|
1849 // Create |
|
1850 RPointerArray< CXnNodePluginIf > children( iRootNode->ChildrenL() ); |
|
1851 CleanupClosePushL( children ); |
|
1852 |
|
1853 for( TInt i = 0; i < children.Count(); i++ ) |
|
1854 { |
|
1855 CXnNodePluginIf* node( children[i] ); |
|
1856 |
|
1857 TPtrC8 type( node->Type()->Type() ); |
|
1858 |
|
1859 // Currently only one menubar is allowed, |
|
1860 // but it can be assigned to any of the CBAs |
|
1861 // To change this, we have to create and maintain a list of menubars |
|
1862 if( type == KXnMenu ) |
|
1863 { |
|
1864 iMenuBarNode = node; |
|
1865 |
|
1866 iMenuBar = new ( ELeave ) CEikMenuBar; |
|
1867 iMenuBar->ConstructL( this ); |
|
1868 iMenuBar->SetMenuType( MenuTypeL( *iRootNode ) ); |
|
1869 |
|
1870 // All done |
|
1871 break; |
|
1872 } |
|
1873 } |
|
1874 CleanupStack::PopAndDestroy( &children ); |
|
1875 } |
|
1876 |
|
1877 //-------------------------------------------------------------- |
|
1878 // CXnMenuAdapter::HandleResourceChange |
|
1879 // Handles a change to the control's resources of type aType |
|
1880 // ------------------------------------------------------------ |
|
1881 void CXnMenuAdapter::HandleResourceChange( TInt aType ) |
|
1882 { |
|
1883 if( iMenuBar ) |
|
1884 { |
|
1885 iMenuBar->HandleResourceChange( aType ); |
|
1886 } |
|
1887 } |
|
1888 |
|
1889 // ----------------------------------------------------------------------------- |
|
1890 // CXnMenuAdapter::SetSoftKeyImageL |
|
1891 // |
|
1892 // ----------------------------------------------------------------------------- |
|
1893 // |
|
1894 void CXnMenuAdapter::SetSoftKeyImageL( |
|
1895 CFbsBitmap* aBitmap, |
|
1896 CFbsBitmap* aMask, |
|
1897 XnMenuInterface::MXnMenuInterface::TSoftKeyPosition aPos, |
|
1898 CXnNodeAppIf* aNode, |
|
1899 TBool aPreserveAspectRatio, TBool aInvertMask, |
|
1900 TBool aTransferOwnership) |
|
1901 { |
|
1902 if( ( !aBitmap && !aMask ) || aPos == XnMenuInterface::MXnMenuInterface::ECenter ) |
|
1903 { |
|
1904 // No images present and image can be set only to lsk or rsk |
|
1905 User::Leave( KErrArgument ); |
|
1906 } |
|
1907 |
|
1908 CXnSoftkeyItem* softkey(NULL); |
|
1909 |
|
1910 if( aPos == XnMenuInterface::MXnMenuInterface::ELeft) |
|
1911 { |
|
1912 if( aNode ) |
|
1913 { |
|
1914 softkey = SoftkeyItemL( aNode ); |
|
1915 } |
|
1916 else |
|
1917 { |
|
1918 softkey = SoftkeyItemL(CEikButtonGroupContainer::ELeftSoftkeyPosition); |
|
1919 } |
|
1920 iUpdateLskAppearance = ETrue; |
|
1921 } |
|
1922 else if(aPos == XnMenuInterface::MXnMenuInterface::ERight) |
|
1923 { |
|
1924 if( aNode ) |
|
1925 { |
|
1926 softkey = SoftkeyItemL( aNode ); |
|
1927 } |
|
1928 else |
|
1929 { |
|
1930 softkey = SoftkeyItemL(CEikButtonGroupContainer::ERightSoftkeyPosition); |
|
1931 } |
|
1932 iUpdateRskAppearance = ETrue; |
|
1933 } |
|
1934 |
|
1935 if(softkey) |
|
1936 { |
|
1937 softkey->Reset(); |
|
1938 softkey->iImageOn = ETrue; |
|
1939 |
|
1940 // Save new icon data |
|
1941 softkey->iBitmap = aBitmap; |
|
1942 softkey->iMask = aMask; |
|
1943 softkey->iPreserveAspectRatio = aPreserveAspectRatio; |
|
1944 softkey->iInvertMask = aInvertMask; |
|
1945 softkey->iOwnBitmaps = aTransferOwnership; |
|
1946 // Image set, mark node as dirty |
|
1947 softkey->iNode->SetDirtyL(); |
|
1948 |
|
1949 } |
|
1950 } |
|
1951 |
|
1952 // ----------------------------------------------------------------------------- |
|
1953 // CXnMenuAdapter::SetSoftKeyImageL |
|
1954 // |
|
1955 // ----------------------------------------------------------------------------- |
|
1956 // |
|
1957 void CXnMenuAdapter::SetSoftKeyImageL( const TAknsItemID& aId, |
|
1958 const TDesC& aBmpFile, |
|
1959 const TInt32 aBmp, |
|
1960 const TInt32 aBmpM, |
|
1961 XnMenuInterface::MXnMenuInterface::TSoftKeyPosition aPos, |
|
1962 TBool /*aEnable*/ ) |
|
1963 { |
|
1964 CXnSoftkeyItem* softkey( NULL ); |
|
1965 |
|
1966 switch( aPos ) |
|
1967 { |
|
1968 case XnMenuInterface::MXnMenuInterface::ECenter: |
|
1969 { |
|
1970 softkey = SoftkeyItemL( CEikButtonGroupContainer::EMiddleSoftkeyPosition ); |
|
1971 iUpdateMskAppearance = ETrue; |
|
1972 break; |
|
1973 } |
|
1974 // Currently only MSK icon updating supported here |
|
1975 case XnMenuInterface::MXnMenuInterface::ELeft: |
|
1976 case XnMenuInterface::MXnMenuInterface::ERight: |
|
1977 default: |
|
1978 { |
|
1979 break; |
|
1980 } |
|
1981 } |
|
1982 |
|
1983 if( softkey ) |
|
1984 { |
|
1985 softkey->Reset(); |
|
1986 softkey->iImageOn = ETrue; |
|
1987 |
|
1988 // Save new icon data |
|
1989 softkey->iBitmap = NULL; |
|
1990 softkey->iMask = NULL; |
|
1991 softkey->iPreserveAspectRatio = EFalse; |
|
1992 softkey->iInvertMask = EFalse; |
|
1993 softkey->iOwnBitmaps = ETrue; |
|
1994 delete softkey->iBmpFile; |
|
1995 softkey->iBmpFile = NULL; |
|
1996 softkey->iBmpFile = aBmpFile.AllocL(); |
|
1997 softkey->iId.Set( aId ); |
|
1998 softkey->iBmp = aBmp; |
|
1999 softkey->iBmpM = aBmpM; |
|
2000 |
|
2001 // Image set, mark node as dirty |
|
2002 softkey->iNode->SetDirtyL(); |
|
2003 } |
|
2004 } |
|
2005 |
|
2006 // ----------------------------------------------------------------------------- |
|
2007 // CXnMenuAdapter::SetSoftKeyTextL |
|
2008 // |
|
2009 // ----------------------------------------------------------------------------- |
|
2010 // |
|
2011 void CXnMenuAdapter::SetSoftKeyTextL( const TDesC& aText, |
|
2012 XnMenuInterface::MXnMenuInterface::TSoftKeyPosition aPos ) |
|
2013 { |
|
2014 CXnSoftkeyItem* softkey(NULL); |
|
2015 |
|
2016 switch( aPos ) |
|
2017 { |
|
2018 case XnMenuInterface::MXnMenuInterface::ELeft: |
|
2019 softkey = SoftkeyItemL(CEikButtonGroupContainer::ELeftSoftkeyPosition); |
|
2020 iUpdateLskAppearance = ETrue; |
|
2021 break; |
|
2022 case XnMenuInterface::MXnMenuInterface::ERight: |
|
2023 softkey = SoftkeyItemL(CEikButtonGroupContainer::ERightSoftkeyPosition); |
|
2024 iUpdateRskAppearance = ETrue; |
|
2025 break; |
|
2026 case XnMenuInterface::MXnMenuInterface::ECenter: |
|
2027 softkey = SoftkeyItemL(CEikButtonGroupContainer::EMiddleSoftkeyPosition); |
|
2028 iUpdateMskAppearance = ETrue; |
|
2029 break; |
|
2030 default: |
|
2031 break; |
|
2032 } |
|
2033 if(softkey) |
|
2034 { |
|
2035 softkey->Reset(); |
|
2036 |
|
2037 softkey->iImageOn = EFalse; |
|
2038 |
|
2039 softkey->iLabel = aText.AllocL(); |
|
2040 // Text set, mark parent as dirty |
|
2041 softkey->iNode->SetDirtyL(); |
|
2042 } |
|
2043 } |
|
2044 |
|
2045 // ----------------------------------------------------------------------------- |
|
2046 // CXnMenuAdapter::SetSoftKeyL |
|
2047 // |
|
2048 // ----------------------------------------------------------------------------- |
|
2049 // |
|
2050 void CXnMenuAdapter::SetSoftKeyL( CXnNodePluginIf* aSoftkeyNode, |
|
2051 XnMenuInterface::MXnMenuInterface::TSoftKeyPosition aPos ) |
|
2052 { |
|
2053 |
|
2054 CXnSoftkeyItem* item = AppendSoftkeyItemL(aSoftkeyNode); |
|
2055 switch(aPos) |
|
2056 { |
|
2057 case XnMenuInterface::MXnMenuInterface::ELeft: |
|
2058 if(item) |
|
2059 { |
|
2060 iVisibleLSK = item; |
|
2061 } |
|
2062 else |
|
2063 { |
|
2064 iVisibleLSK = NULL; |
|
2065 } |
|
2066 iUpdateLskAppearance = ETrue; |
|
2067 break; |
|
2068 case XnMenuInterface::MXnMenuInterface::ECenter: |
|
2069 if(item) |
|
2070 { |
|
2071 iVisibleMSK = item; |
|
2072 } |
|
2073 else |
|
2074 { |
|
2075 iVisibleMSK = NULL; |
|
2076 } |
|
2077 iUpdateMskAppearance = ETrue; |
|
2078 break; |
|
2079 case XnMenuInterface::MXnMenuInterface::ERight: |
|
2080 if(item) |
|
2081 { |
|
2082 iVisibleRSK = item; |
|
2083 } |
|
2084 else |
|
2085 { |
|
2086 iVisibleRSK = NULL; |
|
2087 } |
|
2088 iUpdateRskAppearance = ETrue; |
|
2089 break; |
|
2090 } |
|
2091 } |
|
2092 |
|
2093 // ----------------------------------------------------------------------------- |
|
2094 // CXnMenuAdapter::SoftKeyL |
|
2095 // |
|
2096 // ----------------------------------------------------------------------------- |
|
2097 // |
|
2098 CXnNodePluginIf* CXnMenuAdapter::SoftKeyL( XnMenuInterface::MXnMenuInterface::TSoftKeyPosition aPos ) |
|
2099 { |
|
2100 CXnNodePluginIf* node(NULL); |
|
2101 CXnSoftkeyItem* item = SoftkeyItemL(aPos); |
|
2102 if(item) |
|
2103 { |
|
2104 node = item->iNode; |
|
2105 } |
|
2106 return node; |
|
2107 } |
|
2108 |
|
2109 // ----------------------------------------------------------------------------- |
|
2110 // CXnMenuAdapter::KeyEventNode |
|
2111 // |
|
2112 // ----------------------------------------------------------------------------- |
|
2113 // |
|
2114 CXnNodePluginIf* CXnMenuAdapter::KeyEventNode() |
|
2115 { |
|
2116 return iKeyEventNode; |
|
2117 } |
|
2118 |
|
2119 // ----------------------------------------------------------------------------- |
|
2120 // CXnMenuAdapter::HandleScreenDeviceChangedL |
|
2121 // |
|
2122 // ----------------------------------------------------------------------------- |
|
2123 // |
|
2124 void CXnMenuAdapter::HandleScreenDeviceChangedL() |
|
2125 { |
|
2126 CXnSoftkeyItem* left = |
|
2127 SoftkeyItemL(CEikButtonGroupContainer::ELeftSoftkeyPosition); |
|
2128 |
|
2129 CXnSoftkeyItem* middle = |
|
2130 SoftkeyItemL(CEikButtonGroupContainer::EMiddleSoftkeyPosition); |
|
2131 CXnSoftkeyItem* right = |
|
2132 SoftkeyItemL(CEikButtonGroupContainer::ERightSoftkeyPosition); |
|
2133 |
|
2134 if(left && left->iImageOn) |
|
2135 { |
|
2136 iUpdateLskAppearance = ETrue; |
|
2137 left->iNode->SetDirtyL(); |
|
2138 } |
|
2139 if(right && right->iImageOn) |
|
2140 { |
|
2141 iUpdateRskAppearance = ETrue; |
|
2142 right->iNode->SetDirtyL(); |
|
2143 } |
|
2144 if(middle && middle->iImageOn) |
|
2145 { |
|
2146 iUpdateMskAppearance = ETrue; |
|
2147 middle->iNode->SetDirtyL(); |
|
2148 } |
|
2149 CXnControlAdapter::HandleScreenDeviceChangedL(); |
|
2150 } |
|
2151 |
|
2152 // ----------------------------------------------------------------------------- |
|
2153 // CXnMenuAdapter::HandleMenuPropertyChangeL |
|
2154 // Change softkey appearance |
|
2155 // ----------------------------------------------------------------------------- |
|
2156 // |
|
2157 void CXnMenuAdapter::HandleMenuPropertyChangeL(CXnNodePluginIf* aNode, CXnProperty* aProperty) |
|
2158 { |
|
2159 if ( !aNode || !aProperty ) |
|
2160 { |
|
2161 return; |
|
2162 } |
|
2163 |
|
2164 const TDesC8& type( aNode->Type()->Type() ); |
|
2165 |
|
2166 if ( type != softkey::KNodeName) |
|
2167 { |
|
2168 return; |
|
2169 } |
|
2170 |
|
2171 // Find target softkey |
|
2172 CXnSoftkeyItem* softkey( SoftkeyItemL( aNode ) ); |
|
2173 |
|
2174 if ( !softkey ) |
|
2175 { |
|
2176 return; |
|
2177 } |
|
2178 |
|
2179 SetUpdateAppearanceL( softkey ); |
|
2180 |
|
2181 const TDesC8* name( &KNullDesC8() ); |
|
2182 |
|
2183 if ( aProperty ) |
|
2184 { |
|
2185 name = &aProperty->Property()->Name(); |
|
2186 } |
|
2187 |
|
2188 if ( *name == menu::KLabel ) |
|
2189 { |
|
2190 softkey->Reset(); |
|
2191 softkey->iImageOn = EFalse; |
|
2192 softkey->iLabel = aProperty->StringValueL(); |
|
2193 } |
|
2194 else if ( *name == style::common::KDisplay ) |
|
2195 { |
|
2196 if ( aProperty->StringValue() == XnPropertyNames::style::common::display::KNone ) |
|
2197 { |
|
2198 if ( softkey->iPosition == CEikButtonGroupContainer::ELeftSoftkeyPosition ) |
|
2199 { |
|
2200 EikSoftkeyImage::SetLabel( iContainer,ETrue ); |
|
2201 iContainer->SetCommandL( CEikButtonGroupContainer::ELeftSoftkeyPosition,KCBACommandFirst, KNullDesC ); |
|
2202 } |
|
2203 else if ( softkey->iPosition == CEikButtonGroupContainer::ERightSoftkeyPosition ) |
|
2204 { |
|
2205 EikSoftkeyImage::SetLabel( iContainer,EFalse ); |
|
2206 iContainer->SetCommandL( CEikButtonGroupContainer::ERightSoftkeyPosition,KCBACommandSecond, KNullDesC ); |
|
2207 } |
|
2208 else if ( softkey->iPosition == CEikButtonGroupContainer::EMiddleSoftkeyPosition ) |
|
2209 { |
|
2210 iContainer->SetCommandL( CEikButtonGroupContainer::EMiddleSoftkeyPosition,KCBACommandMiddle, KNullDesC ); |
|
2211 } |
|
2212 } |
|
2213 } |
|
2214 } |
|
2215 |
|
2216 // ----------------------------------------------------------------------------- |
|
2217 // CXnMenuAdapter::SetObserver |
|
2218 // |
|
2219 // ----------------------------------------------------------------------------- |
|
2220 // |
|
2221 void CXnMenuAdapter::SetObserver( XnMenuInterface::MXnMenuObserver& aObserver ) |
|
2222 { |
|
2223 iObserver = &aObserver; |
|
2224 } |
|
2225 |
|
2226 // ----------------------------------------------------------------------------- |
|
2227 // CXnMenuAdapter::RemoveObserver |
|
2228 // |
|
2229 // ----------------------------------------------------------------------------- |
|
2230 // |
|
2231 void CXnMenuAdapter::RemoveObserver() |
|
2232 { |
|
2233 iObserver = NULL; |
|
2234 } |
|
2235 |
|
2236 // --------------------------------------------------------------------------- |
|
2237 // CXnMenuAdapter::FindSoftKeyNodeByPosition |
|
2238 // --------------------------------------------------------------------------- |
|
2239 // |
|
2240 TBool CXnMenuAdapter::FindSoftKeyNodeByPosition( |
|
2241 const TPoint& aPosition, |
|
2242 CXnNodePluginIf*& aNode ) |
|
2243 { |
|
2244 CXnNodePluginIf* ret = FindSoftkeyItemByPosition(aPosition); |
|
2245 aNode = ret; |
|
2246 return (ret?ETrue:EFalse); |
|
2247 } |
|
2248 // --------------------------------------------------------------------------- |
|
2249 // CXnMenuAdapter::ButtonTouchableRectByPosition |
|
2250 // Gets a CBA button rectangle. Touchable are is larger than controls rect |
|
2251 // --------------------------------------------------------------------------- |
|
2252 // |
|
2253 TRect CXnMenuAdapter::ButtonTouchableRectByPosition( TInt aPosition) |
|
2254 { |
|
2255 TRect rect( 0, 0, 0, 0 ); |
|
2256 |
|
2257 TRect button1Rect( 0, 0, 0, 0 ); |
|
2258 TRect button2Rect( 0, 0, 0, 0 ); |
|
2259 TRect buttonMSKRect( 0, 0, 0, 0 ); |
|
2260 |
|
2261 // In touch layouts the button areas are read from the |
|
2262 // layout data because they are larger than the actual |
|
2263 // control size. |
|
2264 #ifndef _AVKON_CBA_LSC |
|
2265 CCoeControl* container = iContainer->ButtonGroup()->AsControl(); |
|
2266 TRect containerRect(container->PositionRelativeToScreen(),container->Size()); |
|
2267 TAknLayoutRect layoutRect; |
|
2268 layoutRect.LayoutRect( |
|
2269 containerRect, |
|
2270 AknLayoutScalable_Avkon::control_pane_g6( 0 ).LayoutLine() ); |
|
2271 button1Rect = layoutRect.Rect(); |
|
2272 |
|
2273 layoutRect.LayoutRect( |
|
2274 containerRect, |
|
2275 AknLayoutScalable_Avkon::control_pane_g8( 0 ).LayoutLine() ); |
|
2276 button2Rect = layoutRect.Rect(); |
|
2277 |
|
2278 layoutRect.LayoutRect( |
|
2279 containerRect, |
|
2280 AknLayoutScalable_Avkon::control_pane_g7( 0 ).LayoutLine() ); |
|
2281 buttonMSKRect = layoutRect.Rect(); |
|
2282 #else |
|
2283 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
2284 { |
|
2285 button1Rect = SoftkeyRectTopTouch(); |
|
2286 button2Rect= SoftkeyRectBottomTouch(); |
|
2287 |
|
2288 } |
|
2289 else // portrait |
|
2290 { |
|
2291 button1Rect = SoftkeyRectLeftTouch(); |
|
2292 button2Rect = SoftkeyRectRightTouch(); |
|
2293 } |
|
2294 #endif |
|
2295 |
|
2296 switch ( aPosition ) |
|
2297 { |
|
2298 case CEikButtonGroupContainer::ELeftSoftkeyPosition: |
|
2299 { |
|
2300 rect = button1Rect; |
|
2301 break; |
|
2302 } |
|
2303 |
|
2304 case CEikButtonGroupContainer::ERightSoftkeyPosition: |
|
2305 { |
|
2306 rect = button2Rect; |
|
2307 break; |
|
2308 } |
|
2309 |
|
2310 case CEikButtonGroupContainer::EMiddleSoftkeyPosition: |
|
2311 { |
|
2312 rect = buttonMSKRect; |
|
2313 break; |
|
2314 } |
|
2315 |
|
2316 default: |
|
2317 { |
|
2318 break; |
|
2319 } |
|
2320 } |
|
2321 |
|
2322 |
|
2323 return rect; |
|
2324 } |
|
2325 |
|
2326 // --------------------------------------------------------------------------- |
|
2327 // CXnMenuAdapter::FindSoftkeyNodeL |
|
2328 // --------------------------------------------------------------------------- |
|
2329 // |
|
2330 CXnNodePluginIf* CXnMenuAdapter::FindSoftkeyNodeL(const TDesC8& aNodeType) |
|
2331 { |
|
2332 CXnNodePluginIf* ret(0); |
|
2333 |
|
2334 RPointerArray< CXnNodePluginIf > children( iRootNode->ChildrenL() ); |
|
2335 CleanupClosePushL( children ); |
|
2336 for(TInt i=0;i<children.Count();++i) |
|
2337 { |
|
2338 if(children[i]->Type()->Type() == XnPropertyNames::softkey::KNodeName) |
|
2339 { |
|
2340 if( SoftkeyPlaceL(*children[i]) == aNodeType |
|
2341 && IsNodeVisibleL( *children[i]) ) |
|
2342 { |
|
2343 ret = children[i]; |
|
2344 break; |
|
2345 } |
|
2346 |
|
2347 } |
|
2348 } |
|
2349 CleanupStack::PopAndDestroy( &children ); |
|
2350 return ret; |
|
2351 } |
|
2352 |
|
2353 // --------------------------------------------------------------------------- |
|
2354 // CXnMenuAdapter::UpdateSoftkeyAppearancesL |
|
2355 // --------------------------------------------------------------------------- |
|
2356 // |
|
2357 void CXnMenuAdapter::UpdateSoftkeyAppearancesL() |
|
2358 { |
|
2359 |
|
2360 if(iUpdateLskAppearance) |
|
2361 { |
|
2362 CXnSoftkeyItem* left = |
|
2363 SoftkeyItemL(CEikButtonGroupContainer::ELeftSoftkeyPosition); |
|
2364 if( left ) |
|
2365 { |
|
2366 SetSoftkeyAppearanceL(*left); |
|
2367 } |
|
2368 iUpdateLskAppearance = EFalse; |
|
2369 } |
|
2370 if(iUpdateRskAppearance) |
|
2371 { |
|
2372 CXnSoftkeyItem* right = |
|
2373 SoftkeyItemL(CEikButtonGroupContainer::ERightSoftkeyPosition); |
|
2374 if(right) |
|
2375 { |
|
2376 SetSoftkeyAppearanceL(*right); |
|
2377 } |
|
2378 iUpdateRskAppearance = EFalse; |
|
2379 } |
|
2380 if(iUpdateMskAppearance) |
|
2381 { |
|
2382 CXnSoftkeyItem* middle = |
|
2383 SoftkeyItemL(CEikButtonGroupContainer::EMiddleSoftkeyPosition); |
|
2384 if(middle) |
|
2385 { |
|
2386 SetSoftkeyAppearanceL(*middle); |
|
2387 } |
|
2388 iUpdateMskAppearance = EFalse; |
|
2389 } |
|
2390 } |
|
2391 // --------------------------------------------------------------------------- |
|
2392 // CXnMenuAdapter::ChangeSoftkeyImageL |
|
2393 // --------------------------------------------------------------------------- |
|
2394 // |
|
2395 void CXnMenuAdapter::ChangeSoftkeyImageL(const CXnSoftkeyItem& aSoftkey) |
|
2396 { |
|
2397 if ( aSoftkey.iPosition == CEikButtonGroupContainer::ELeftSoftkeyPosition || |
|
2398 aSoftkey.iPosition == CEikButtonGroupContainer::ERightSoftkeyPosition ) |
|
2399 { |
|
2400 TSize size; |
|
2401 if(AknLayoutUtils::PenEnabled()) |
|
2402 { |
|
2403 size = SoftkeyImageRect(*iContainer,aSoftkey.iPosition).Size(); |
|
2404 } |
|
2405 else |
|
2406 { |
|
2407 size = SoftkeyRectL( *iContainer,aSoftkey.iPosition, aSoftkey.iImageOn ).Size(); |
|
2408 } |
|
2409 |
|
2410 CEikImage* image( PrepareSoftkeyImageL( aSoftkey, size ) ); |
|
2411 TBool left(ETrue); |
|
2412 |
|
2413 if(aSoftkey.iPosition != CEikButtonGroupContainer::ELeftSoftkeyPosition) |
|
2414 { |
|
2415 left = EFalse; |
|
2416 } |
|
2417 EikSoftkeyImage::SetImage( iContainer, *image, left ); |
|
2418 } |
|
2419 else if ( aSoftkey.iBmpFile ) |
|
2420 { |
|
2421 CEikCba* cba = static_cast< CEikCba* >( iContainer->ButtonGroup() ); |
|
2422 // use iAvkonAppUi |
|
2423 CAknAppUi* appUi = static_cast<CAknAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
2424 cba->UpdateMSKIconL( |
|
2425 aSoftkey.iId, |
|
2426 aSoftkey.iBmpFile->Des(), |
|
2427 aSoftkey.iBmp, |
|
2428 aSoftkey.iBmpM, |
|
2429 ETrue ); |
|
2430 } |
|
2431 } |
|
2432 |
|
2433 // --------------------------------------------------------------------------- |
|
2434 // CXnMenuAdapter::AddItemsToMenuPaneL |
|
2435 // --------------------------------------------------------------------------- |
|
2436 // |
|
2437 void CXnMenuAdapter::AddItemsToMenuPaneL(CEikMenuPane* aMenuPane, TInt aResourceId) |
|
2438 { |
|
2439 TInt parentIndexForNotification( 0 ); |
|
2440 |
|
2441 for ( TInt i = 0; i< iMenuItems.Count(); i++ ) |
|
2442 { |
|
2443 // find items belong to this pane |
|
2444 TInt parent( iMenuItems[i].iParentIndex ); |
|
2445 |
|
2446 if ( parent >= 0 ) |
|
2447 { |
|
2448 TInt cid( iMenuItems[parent].iData.iCascadeId ); |
|
2449 |
|
2450 if ( cid == aResourceId ) |
|
2451 { |
|
2452 if ( parent > 0 ) |
|
2453 { |
|
2454 parentIndexForNotification = parent; |
|
2455 break; |
|
2456 } |
|
2457 } |
|
2458 } |
|
2459 } |
|
2460 |
|
2461 TBool selectionEnabled( EFalse ); |
|
2462 TBool isRadio( EFalse ); |
|
2463 |
|
2464 if ( parentIndexForNotification != 0 ) |
|
2465 { |
|
2466 CXnNodePluginIf* node( iMenuItems[parentIndexForNotification].iNode ); |
|
2467 |
|
2468 CXnProperty* property( node->GetPropertyL( _L8( "selectiontype" ) ) ); |
|
2469 |
|
2470 if ( property && property->StringValue() == _L8( "multi" ) ) |
|
2471 { |
|
2472 selectionEnabled = ETrue; |
|
2473 } |
|
2474 else if ( property && property->StringValue() == _L8( "single" ) ) |
|
2475 { |
|
2476 selectionEnabled = ETrue; |
|
2477 isRadio = ETrue; |
|
2478 } |
|
2479 |
|
2480 node->SetStateL( XnPropertyNames::style::common::KActive ); |
|
2481 node->UnsetStateL( XnPropertyNames::style::common::KActive ); |
|
2482 } |
|
2483 |
|
2484 PopulateMenuL(); |
|
2485 |
|
2486 for ( TInt i = 0; i< iMenuItems.Count(); i++ ) |
|
2487 { |
|
2488 // find items belong to this pane |
|
2489 TInt parent( iMenuItems[i].iParentIndex ); |
|
2490 |
|
2491 if ( parent >= 0 ) |
|
2492 { |
|
2493 TInt cid( iMenuItems[parent].iData.iCascadeId ); |
|
2494 |
|
2495 if ( cid == aResourceId ) |
|
2496 { |
|
2497 if ( selectionEnabled ) |
|
2498 { |
|
2499 if ( !isRadio ) |
|
2500 { |
|
2501 iMenuItems[i].iData.iFlags |= |
|
2502 EEikMenuItemCheckBox; |
|
2503 } |
|
2504 else |
|
2505 { |
|
2506 iMenuItems[i].iData.iFlags |= |
|
2507 EEikMenuItemRadioStart| |
|
2508 EEikMenuItemRadioMiddle| |
|
2509 EEikMenuItemRadioEnd; |
|
2510 } |
|
2511 } |
|
2512 |
|
2513 aMenuPane->AddMenuItemL( iMenuItems[i].iData ); |
|
2514 |
|
2515 if ( selectionEnabled ) |
|
2516 { |
|
2517 CXnProperty* property( |
|
2518 iMenuItems[i].iNode->GetPropertyL( XnPropertyNames::menu::KChecked ) ); |
|
2519 |
|
2520 if ( property && property->StringValue() == XnPropertyNames::KTrue ) |
|
2521 { |
|
2522 aMenuPane->SetItemButtonState( |
|
2523 iMenuItems[i].iData.iCommandId, EEikMenuItemSymbolOn ); |
|
2524 } |
|
2525 } |
|
2526 } |
|
2527 } |
|
2528 } // for end |
|
2529 } |
|
2530 |
|
2531 // --------------------------------------------------------------------------- |
|
2532 // CXnMenuAdapter::AppendSoftkeyItemL |
|
2533 // --------------------------------------------------------------------------- |
|
2534 // |
|
2535 CXnSoftkeyItem* CXnMenuAdapter::AppendSoftkeyItemL(CXnNodePluginIf* aNode) |
|
2536 { |
|
2537 if(!aNode) |
|
2538 { |
|
2539 return NULL; |
|
2540 } |
|
2541 CXnProperty* property = |
|
2542 aNode->GetPropertyL( XnPropertyNames::softkey::KTypeAttribute ); |
|
2543 if(!property) |
|
2544 { |
|
2545 return NULL; |
|
2546 } |
|
2547 const TDesC8& skType = property->StringValue(); |
|
2548 if( skType != XnPropertyNames::softkey::type::KRight && |
|
2549 skType != XnPropertyNames::softkey::type::KLeft && |
|
2550 skType != XnPropertyNames::softkey::type::KMiddle ) |
|
2551 { |
|
2552 return NULL; |
|
2553 } |
|
2554 for( TInt i=0; i<iSoftkeyItems.Count(); i++ ) |
|
2555 { |
|
2556 if( iSoftkeyItems[i]->iNode == aNode ) |
|
2557 { |
|
2558 return iSoftkeyItems[i]; |
|
2559 } |
|
2560 } |
|
2561 CXnSoftkeyItem* softkey(0); |
|
2562 softkey = new (ELeave) CXnSoftkeyItem; |
|
2563 CleanupStack::PushL(softkey); |
|
2564 |
|
2565 if ( skType == XnPropertyNames::softkey::type::KRight ) |
|
2566 { |
|
2567 softkey->iPosition = CEikButtonGroupContainer::ERightSoftkeyPosition; |
|
2568 softkey->iCommandId = KCBACommandSecond; |
|
2569 } |
|
2570 else if ( skType == XnPropertyNames::softkey::type::KLeft ) |
|
2571 { |
|
2572 softkey->iPosition = CEikButtonGroupContainer::ELeftSoftkeyPosition; |
|
2573 softkey->iCommandId = KCBACommandFirst; |
|
2574 } |
|
2575 else |
|
2576 { |
|
2577 softkey->iPosition = CEikButtonGroupContainer::EMiddleSoftkeyPosition; |
|
2578 softkey->iCommandId = KCBACommandMiddle; |
|
2579 } |
|
2580 |
|
2581 softkey->iNode = aNode; |
|
2582 |
|
2583 CXnProperty* labelProp( aNode->LabelL() ); |
|
2584 CXnProperty* targetProp( aNode->GetPropertyL(KXnTarget) ); |
|
2585 |
|
2586 if(labelProp) |
|
2587 { |
|
2588 softkey->iImageOn = EFalse; |
|
2589 softkey->iLabel = labelProp->StringValueL(); |
|
2590 } |
|
2591 else if(targetProp) |
|
2592 { |
|
2593 softkey->iImageOn = EFalse; |
|
2594 softkey->iLabel = FindSoftkeyLabelL(aNode); |
|
2595 } |
|
2596 else |
|
2597 { |
|
2598 InitSoftkeyItemImageL( *softkey ); |
|
2599 } |
|
2600 |
|
2601 softkey->iUpdateAppearance = ETrue; |
|
2602 iSoftkeyItems.AppendL(softkey); |
|
2603 CleanupStack::Pop(softkey); |
|
2604 return softkey; |
|
2605 } |
|
2606 // --------------------------------------------------------------------------- |
|
2607 // CXnMenuAdapter::SoftkeyPlaceL |
|
2608 // --------------------------------------------------------------------------- |
|
2609 // |
|
2610 const TDesC8& CXnMenuAdapter::SoftkeyPlaceL(CXnNodePluginIf& aNode) |
|
2611 { |
|
2612 CXnProperty* property = |
|
2613 aNode.GetPropertyL( XnPropertyNames::softkey::KTypeAttribute ); |
|
2614 |
|
2615 if( property) |
|
2616 { |
|
2617 return property->StringValue(); |
|
2618 } |
|
2619 return KNullDesC8; |
|
2620 |
|
2621 } |
|
2622 |
|
2623 // ----------------------------------------------------------------------------- |
|
2624 // CXnMenuAdapter::FindSoftkeyItemByPosition |
|
2625 // |
|
2626 // ----------------------------------------------------------------------------- |
|
2627 CXnNodePluginIf* CXnMenuAdapter::FindSoftkeyItemByPosition( const TPoint& aPosition ) |
|
2628 { |
|
2629 CXnNodePluginIf* softkey(0); |
|
2630 TRAP_IGNORE( softkey = DoFindSoftkeyItemByPositionL( aPosition ) ); |
|
2631 return softkey; |
|
2632 } |
|
2633 |
|
2634 // ----------------------------------------------------------------------------- |
|
2635 // CXnMenuAdapter::DoFindSoftkeyItemByPositionL |
|
2636 // |
|
2637 // ----------------------------------------------------------------------------- |
|
2638 CXnNodePluginIf* CXnMenuAdapter::DoFindSoftkeyItemByPositionL( const TPoint& aPosition ) |
|
2639 { |
|
2640 TRect lsk( ButtonTouchableRectByPosition(CEikButtonGroupContainer::ELeftSoftkeyPosition) ); |
|
2641 TRect rsk( ButtonTouchableRectByPosition(CEikButtonGroupContainer::ERightSoftkeyPosition) ); |
|
2642 TRect msk( ButtonTouchableRectByPosition(CEikButtonGroupContainer::EMiddleSoftkeyPosition) ); |
|
2643 |
|
2644 CXnNodePluginIf* softkey(NULL); |
|
2645 CXnSoftkeyItem* item(NULL); |
|
2646 if ( lsk.Contains(aPosition) ) |
|
2647 { |
|
2648 item = SoftkeyItemL(CEikButtonGroupContainer::ELeftSoftkeyPosition); |
|
2649 } |
|
2650 else if(msk.Contains(aPosition)) |
|
2651 { |
|
2652 item = SoftkeyItemL(CEikButtonGroupContainer::EMiddleSoftkeyPosition); |
|
2653 } |
|
2654 else if( rsk.Contains(aPosition) ) |
|
2655 { |
|
2656 item = SoftkeyItemL(CEikButtonGroupContainer::ERightSoftkeyPosition); |
|
2657 } |
|
2658 if(item) |
|
2659 { |
|
2660 softkey = item->iNode; |
|
2661 } |
|
2662 return softkey; |
|
2663 } |
|
2664 |
|
2665 // ----------------------------------------------------------------------------- |
|
2666 // ----------------------------------------------------------------------------- |
|
2667 CXnSoftkeyItem* CXnMenuAdapter::SoftkeyItemL(TInt aPosition) |
|
2668 { |
|
2669 CXnSoftkeyItem* softkeyItem(0); |
|
2670 if(iVisibleLSK && aPosition == CEikButtonGroupContainer::ELeftSoftkeyPosition) |
|
2671 { |
|
2672 return iVisibleLSK; |
|
2673 } |
|
2674 else if(iVisibleRSK && aPosition == CEikButtonGroupContainer::ERightSoftkeyPosition) |
|
2675 { |
|
2676 return iVisibleRSK; |
|
2677 } |
|
2678 else if(iVisibleMSK && aPosition == CEikButtonGroupContainer::EMiddleSoftkeyPosition) |
|
2679 { |
|
2680 return iVisibleMSK; |
|
2681 } |
|
2682 |
|
2683 // return default |
|
2684 for(TInt i=0;i<iSoftkeyItems.Count();++i) |
|
2685 { |
|
2686 softkeyItem = iSoftkeyItems[i]; |
|
2687 if(softkeyItem->iPosition == aPosition && |
|
2688 softkeyItem->iDefault && |
|
2689 IsNodeVisibleL(*softkeyItem->iNode)) |
|
2690 { |
|
2691 return softkeyItem; |
|
2692 } |
|
2693 } |
|
2694 return NULL; |
|
2695 } |
|
2696 |
|
2697 // ----------------------------------------------------------------------------- |
|
2698 // ----------------------------------------------------------------------------- |
|
2699 CXnSoftkeyItem* CXnMenuAdapter::SoftkeyItemL(CXnNodePluginIf* aNode) |
|
2700 { |
|
2701 CXnSoftkeyItem* softkeyItem(0); |
|
2702 for(TInt i=0;i<iSoftkeyItems.Count();++i) |
|
2703 { |
|
2704 softkeyItem = iSoftkeyItems[i]; |
|
2705 if(softkeyItem->iNode == aNode) |
|
2706 { |
|
2707 return softkeyItem; |
|
2708 } |
|
2709 } |
|
2710 return NULL; |
|
2711 } |
|
2712 |
|
2713 CXnSoftkeyItem* CXnMenuAdapter::SoftkeyItemL(CXnNodeAppIf* aNode) |
|
2714 { |
|
2715 CXnSoftkeyItem* softkeyItem(0); |
|
2716 for(TInt i=0;i<iSoftkeyItems.Count();++i) |
|
2717 { |
|
2718 softkeyItem = iSoftkeyItems[i]; |
|
2719 if(&(softkeyItem->iNode->AppIfL()) == aNode) |
|
2720 { |
|
2721 return softkeyItem; |
|
2722 } |
|
2723 } |
|
2724 return NULL; |
|
2725 } |
|
2726 // ----------------------------------------------------------------------------- |
|
2727 // ----------------------------------------------------------------------------- |
|
2728 |
|
2729 void CXnMenuAdapter::SetUpdateAppearanceL(CXnSoftkeyItem* aItem) |
|
2730 { |
|
2731 if ( aItem && IsNodeVisibleL( *aItem->iNode ) ) |
|
2732 { |
|
2733 aItem->iNode->SetDirtyL(); |
|
2734 |
|
2735 switch ( aItem->iPosition ) |
|
2736 { |
|
2737 case CEikButtonGroupContainer::ELeftSoftkeyPosition: |
|
2738 iUpdateLskAppearance = ETrue; |
|
2739 iVisibleLSK = NULL; |
|
2740 break; |
|
2741 case CEikButtonGroupContainer::EMiddleSoftkeyPosition: |
|
2742 iUpdateMskAppearance = ETrue; |
|
2743 iVisibleMSK = NULL; |
|
2744 break; |
|
2745 case CEikButtonGroupContainer::ERightSoftkeyPosition: |
|
2746 iUpdateRskAppearance = ETrue; |
|
2747 iVisibleRSK = NULL; |
|
2748 break; |
|
2749 } |
|
2750 } |
|
2751 } |
|
2752 |
|
2753 // ----------------------------------------------------------------------------- |
|
2754 // CXnMenuAdapter::FindWidgetMenuItemL |
|
2755 // |
|
2756 // ----------------------------------------------------------------------------- |
|
2757 CXnNodePluginIf* CXnMenuAdapter::FindWidgetMenuItemL( CXnNodePluginIf* aNode ) |
|
2758 { |
|
2759 CXnNodePluginIf* focusedNode( iUiEngine->FocusedNodeL() ); |
|
2760 |
|
2761 CXnNodePluginIf* menuItem( NULL ); |
|
2762 |
|
2763 if ( focusedNode && aNode ) |
|
2764 { |
|
2765 // Get <plugin> element |
|
2766 CXnNodePluginIf& pluginNode( iUiEngine->PluginNodeL( focusedNode ) ); |
|
2767 |
|
2768 CXnNodePluginIf* widget( FindWidgetElementL( pluginNode ) ); |
|
2769 |
|
2770 CXnNodePluginIf* widgetExtNode( NULL ); |
|
2771 |
|
2772 if( widget ) |
|
2773 { |
|
2774 widgetExtNode = FindChildL( *widget, KXnMenuExtension ); |
|
2775 } |
|
2776 |
|
2777 if( !widgetExtNode ) |
|
2778 { |
|
2779 widgetExtNode = focusedNode; |
|
2780 } |
|
2781 |
|
2782 if ( widgetExtNode ) |
|
2783 { |
|
2784 CXnProperty* prop( aNode->GetPropertyL( KXnSource ) ); |
|
2785 |
|
2786 if ( prop ) |
|
2787 { |
|
2788 const TDesC8& source( prop->StringValue() ); |
|
2789 |
|
2790 // Try to find <menuitem> |
|
2791 menuItem = FindChildL( *widgetExtNode, |
|
2792 KXnMenuItem, |
|
2793 source ); |
|
2794 |
|
2795 if ( !menuItem ) |
|
2796 { |
|
2797 // Try to find <dynmenuitem> |
|
2798 menuItem = FindChildL( *widgetExtNode, |
|
2799 KXnDynMenuItem, |
|
2800 source ); |
|
2801 } |
|
2802 } |
|
2803 } |
|
2804 } |
|
2805 |
|
2806 if( menuItem && IsNodeVisibleL( *menuItem ) ) |
|
2807 { |
|
2808 return menuItem; |
|
2809 } |
|
2810 |
|
2811 return NULL; |
|
2812 } |
|
2813 |
|
2814 // ----------------------------------------------------------------------------- |
|
2815 // CXnMenuAdapter::FindSoftkeyLabelL |
|
2816 // |
|
2817 // ----------------------------------------------------------------------------- |
|
2818 HBufC* CXnMenuAdapter::FindSoftkeyLabelL( CXnNodePluginIf* aNode ) |
|
2819 { |
|
2820 if( !aNode ) |
|
2821 { |
|
2822 return NULL; |
|
2823 } |
|
2824 |
|
2825 CXnProperty* targerProp( aNode->GetPropertyL( KXnTarget ) ); |
|
2826 |
|
2827 if ( targerProp && iRootNode ) |
|
2828 { |
|
2829 CXnNodePluginIf* widgetSoftkeyNode( |
|
2830 FindChildL( *iRootNode, |
|
2831 KXnWidgetSoftkey, |
|
2832 targerProp->StringValue() ) ); |
|
2833 |
|
2834 if ( widgetSoftkeyNode ) |
|
2835 { |
|
2836 CXnProperty* label( widgetSoftkeyNode->LabelL() ); |
|
2837 |
|
2838 if( label ) |
|
2839 { |
|
2840 return label->StringValueL(); |
|
2841 } |
|
2842 } |
|
2843 } |
|
2844 |
|
2845 return NULL;; |
|
2846 } |
|
2847 |
|
2848 //end of file |