33 #include <bacline.h> |
33 #include <bacline.h> |
34 #include <escapeutils.h> |
34 #include <escapeutils.h> |
35 #include <browserlauncher.h> |
35 #include <browserlauncher.h> |
36 #include <centralrepository.h> |
36 #include <centralrepository.h> |
37 |
37 |
|
38 #include "wmimageconverter.h" |
38 #include "wmportalbutton.h" |
39 #include "wmportalbutton.h" |
39 #include "wmcommon.h" |
40 #include "wmcommon.h" |
40 #include "wmplugin.h" |
41 #include "wmplugin.h" |
41 #include "wmresourceloader.h" |
42 #include "wmresourceloader.h" |
42 #include "wmmaincontainer.h" |
43 #include "wmmaincontainer.h" |
137 KAknsIIDQsnFrButtonCenterPressed, |
138 KAknsIIDQsnFrButtonCenterPressed, |
138 KAknsIIDQsnFrButtonInactive, |
139 KAknsIIDQsnFrButtonInactive, |
139 KAknsIIDQsnFrButtonCenterInactive ); |
140 KAknsIIDQsnFrButtonCenterInactive ); |
140 |
141 |
141 // start image converter for the icon |
142 // start image converter for the icon |
142 iImageConverter = CWmImageConverter::NewL( this ); |
143 iImageConverter = CWmImageConverter::NewL(); |
143 TSize iconsize( LayoutIconSize() ); |
144 TSize iconsize( LayoutIconSize() ); |
144 iImageConverter->HandleIconString( |
145 iImageConverter->HandleIconString( |
145 iconsize.iWidth, iconsize.iHeight, aIcon ); |
146 iconsize, |
|
147 aIcon, |
|
148 iButtonIcon, |
|
149 iButtonIconMask ); |
146 // observe our own press events |
150 // observe our own press events |
147 SetObserver( this ); |
151 SetObserver( this ); |
148 |
152 |
149 SetFocusing( ETrue ); |
153 SetFocusing( ETrue ); |
150 SetRequestExit( ETrue ); // notification request for button up event |
154 SetRequestExit( ETrue ); // notification request for button up event |
349 SetTextVerticalAlignment( CAknButton::ECenter ); |
353 SetTextVerticalAlignment( CAknButton::ECenter ); |
350 |
354 |
351 // resize icon |
355 // resize icon |
352 if ( iButtonIcon && iButtonIconMask ) |
356 if ( iButtonIcon && iButtonIconMask ) |
353 { |
357 { |
354 TSize size = LayoutIconSize(); |
358 iImageConverter->UpdateImageSize( |
355 AknIconUtils::SetSize( |
359 LayoutIconSize(), |
356 iButtonIcon, size, EAspectRatioPreserved ); |
360 iWmMainContainer->Configuration().PortalButtonIcon( |
357 AknIconUtils::SetSize( |
361 iPortalButtonIndex ), |
358 iButtonIconMask, size, EAspectRatioPreserved ); |
362 *iButtonIcon, |
|
363 *iButtonIconMask ); |
359 } |
364 } |
360 |
365 |
361 TBool landscape = Layout_Meta_Data::IsLandscapeOrientation(); |
366 TBool landscape = Layout_Meta_Data::IsLandscapeOrientation(); |
362 SetTextAndIconAlignment( |
367 SetTextAndIconAlignment( |
363 landscape ? CAknButton::EIconOverText : CAknButton::EIconBeforeText ); |
368 landscape ? CAknButton::EIconOverText : CAknButton::EIconBeforeText ); |
364 } |
|
365 |
|
366 // --------------------------------------------------------- |
|
367 // CWmPortalButton::NotifyCompletion |
|
368 // --------------------------------------------------------- |
|
369 // |
|
370 void CWmPortalButton::NotifyCompletion( TInt aError ) |
|
371 { |
|
372 if ( KErrNone == aError ) |
|
373 { |
|
374 // take ownership of icon |
|
375 delete iButtonIcon; |
|
376 iButtonIcon = NULL; |
|
377 iButtonIcon = iImageConverter->Bitmap(); |
|
378 delete iButtonIconMask; |
|
379 iButtonIconMask = NULL; |
|
380 iButtonIconMask = iImageConverter->Mask(); |
|
381 if ( iButtonIcon && iButtonIconMask ) |
|
382 { |
|
383 TSize size = LayoutIconSize(); |
|
384 if ( iButtonIcon->SizeInPixels() != size ) |
|
385 { |
|
386 AknIconUtils::SetSize( |
|
387 iButtonIcon, size, EAspectRatioPreserved ); |
|
388 } |
|
389 if ( iButtonIconMask->SizeInPixels() != size ) |
|
390 { |
|
391 AknIconUtils::SetSize( |
|
392 iButtonIconMask, size, EAspectRatioPreserved ); |
|
393 } |
|
394 DrawDeferred(); |
|
395 } |
|
396 } |
|
397 else |
|
398 { |
|
399 // no image available. Do nothing. |
|
400 } |
|
401 } |
369 } |
402 |
370 |
403 // --------------------------------------------------------- |
371 // --------------------------------------------------------- |
404 // CWmPortalButton::Draw |
372 // CWmPortalButton::Draw |
405 // --------------------------------------------------------- |
373 // --------------------------------------------------------- |
466 { |
434 { |
467 TInt variety = (landscape ? 7 : 4); |
435 TInt variety = (landscape ? 7 : 4); |
468 imageLayout.LayoutRect( rect, AknLayoutScalable_Apps |
436 imageLayout.LayoutRect( rect, AknLayoutScalable_Apps |
469 ::wgtman_btn_pane_g1( variety ).LayoutLine() ); |
437 ::wgtman_btn_pane_g1( variety ).LayoutLine() ); |
470 } |
438 } |
471 imageLayout.DrawImage( gc, iButtonIcon, iButtonIconMask ); |
439 |
|
440 gc.DrawBitmapMasked( |
|
441 imageLayout.Rect(), |
|
442 iButtonIcon, |
|
443 TRect(TPoint( 0, 0 ), iButtonIcon->SizeInPixels() ), |
|
444 iButtonIconMask, |
|
445 EFalse ); |
472 } |
446 } |
473 |
447 |
474 // draw text if portrait |
448 // draw text if portrait |
475 if ( !landscape ) |
449 if ( !landscape ) |
476 { |
450 { |