--- a/idlehomescreen/xmluirendering/uiengine/src/xnwidgetextensionadapter.cpp Wed Mar 31 21:17:19 2010 +0300
+++ b/idlehomescreen/xmluirendering/uiengine/src/xnwidgetextensionadapter.cpp Wed Apr 14 15:47:59 2010 +0300
@@ -19,16 +19,15 @@
#include <coecntrl.h>
#include <coemain.h>
#include <AknUtils.h>
+#include <gfxtranseffect/gfxtranseffect.h>
+#include <akntransitionutils.h>
// User includes
#include "xnwidgetextensionadapter.h"
#include "xncontroladapter.h"
-
#include "xncomponentnodeimpl.h"
#include "xncomponent.h"
-
#include "xnuiengine.h"
-#include "xnhittest.h"
#include "xnnode.h"
#include "xnnodepluginif.h"
@@ -46,9 +45,6 @@
#include "xnviewdata.h"
#include "xnplugindata.h"
-#include <gfxtranseffect/gfxtranseffect.h>
-#include <akntransitionutils.h>
-
// Constants
_LIT8( KPopup, "popup" );
_LIT8( KPositionHint, "_s60-position-hint" );
@@ -215,60 +211,9 @@
if ( aVisible && iPopup )
{
- // read position-hint property and set-up its variable
- CXnProperty* positionHintProp = NULL;
- TRAP_IGNORE( positionHintProp = iNode.Node().GetPropertyL( KPositionHint ) );
-
- if ( positionHintProp )
- {
- const TDesC8& displayHintVal = positionHintProp->StringValue();
-
- if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KAboveLeft )
- {
- iPositionHint = EAboveLeft;
- }
- else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KAboveRight )
- {
- iPositionHint = EAboveRight;
- }
- else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KBelowLeft )
- {
- iPositionHint = EBelowLeft;
- }
- else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KBelowRight )
- {
- iPositionHint = EBelowRight;
- }
- else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KRight )
- {
- iPositionHint = ERight;
- }
- else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KLeft )
- {
- iPositionHint = ELeft;
- }
- else
- {
- // if the value if of unknown type, use default one
- if ( AknLayoutUtils::LayoutMirrored() )
- {
- iPositionHint = EAboveRight;
- }
- else
- {
- iPositionHint = EAboveLeft;
- }
- }
-
- if ( iPositionHint != ENone )
- {
- // the popup is going visible and position-hind is available
- // calculate its position
- CalculatePosition();
- }
- }
+ ChangePopupPosition();
}
-
+
TBool effectStarted = EFalse;
if ( iAppUiAdapter->IsForeground() )
{
@@ -373,10 +318,88 @@
//
void CXnWidgetExtensionAdapter::Draw( const TRect& aRect ) const
{
+ SystemGc().Clear( aRect );
CXnControlAdapter::Draw( aRect );
}
// -----------------------------------------------------------------------------
+// CXnWidgetExtensionAdapter::DoHandlePropertyChangeL
+//
+// -----------------------------------------------------------------------------
+//
+void CXnWidgetExtensionAdapter::DoHandlePropertyChangeL( CXnProperty* /*aProperty*/ )
+ {
+ if( iNode.Node().IsLaidOut() && IsVisible() )
+ {
+ ChangePopupPosition();
+ }
+ }
+
+// -----------------------------------------------------------------------------
+// CXnWidgetExtensionAdapter::ChangePopupPosition
+//
+// -----------------------------------------------------------------------------
+//
+void CXnWidgetExtensionAdapter::ChangePopupPosition()
+ {
+ if ( iPopup )
+ {
+ // read position-hint property and set-up its variable
+ CXnProperty* positionHintProp = NULL;
+ TRAP_IGNORE( positionHintProp = iNode.Node().GetPropertyL( KPositionHint ) );
+
+ if ( positionHintProp )
+ {
+ const TDesC8& displayHintVal = positionHintProp->StringValue();
+
+ if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KAboveLeft )
+ {
+ iPositionHint = EAboveLeft;
+ }
+ else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KAboveRight )
+ {
+ iPositionHint = EAboveRight;
+ }
+ else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KBelowLeft )
+ {
+ iPositionHint = EBelowLeft;
+ }
+ else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KBelowRight )
+ {
+ iPositionHint = EBelowRight;
+ }
+ else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KRight )
+ {
+ iPositionHint = ERight;
+ }
+ else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KLeft )
+ {
+ iPositionHint = ELeft;
+ }
+ else
+ {
+ // if the value if of unknown type, use default one
+ if ( AknLayoutUtils::LayoutMirrored() )
+ {
+ iPositionHint = EAboveRight;
+ }
+ else
+ {
+ iPositionHint = EAboveLeft;
+ }
+ }
+
+ if ( iPositionHint != ENone )
+ {
+ // the popup is going visible and position-hind is available
+ // calculate its position
+ CalculatePosition();
+ }
+ }
+ }
+ }
+
+// -----------------------------------------------------------------------------
// CalculatePosition
// This is used only for popup element with position hint
// -----------------------------------------------------------------------------
@@ -385,8 +408,8 @@
// widget's rectangle
TRect controlRect;
- // get popup's window size
- TRect popupRect = this->Rect();
+ // get popup's size.
+ TSize popupSize = iNode.BorderRect().Size();
TRect clientRect = static_cast<CEikAppUi&>( *iAppUiAdapter ).ClientRect();
@@ -434,16 +457,16 @@
// if this position does not fit the screen,
// and if below left is more suitable, use it
- if ( spaceAbove < popupRect.Height() && spaceBelow > spaceAbove )
+ if ( spaceAbove < popupSize.iHeight && spaceBelow > spaceAbove )
{
rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ),
- TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iBr.iY + popupRect.Height() ) );
+ TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iBr.iY + popupSize.iHeight ) );
}
else
{
// use the above-left position
- rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupRect.Height() ),
- TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iTl.iY ) );
+ rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupSize.iHeight ),
+ TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iTl.iY ) );
}
break;
@@ -452,15 +475,15 @@
// if this position does not fit the screen,
// and if below right is more suitable, use it
- if ( spaceAbove < popupRect.Height() && spaceBelow > spaceAbove )
+ if ( spaceAbove < popupSize.iHeight && spaceBelow > spaceAbove )
{
- rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iBr.iY ),
- TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupRect.Height() ) );
+ rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iBr.iY ),
+ TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupSize.iHeight ) );
}
else
{
// use the above-right position
- rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iTl.iY - popupRect.Height() ),
+ rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iTl.iY - popupSize.iHeight ),
TPoint( controlRect.iBr.iX, controlRect.iTl.iY ) );
}
break;
@@ -469,16 +492,16 @@
// if this position does not fit the screen,
// and if above left is more suitable, use it
- if ( spaceBelow < popupRect.Height() && spaceBelow < spaceAbove )
+ if ( spaceBelow < popupSize.iHeight && spaceBelow < spaceAbove )
{
- rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupRect.Height() ),
- TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iTl.iY ) );
+ rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupSize.iHeight ),
+ TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iTl.iY ) );
}
else
{
// use the below-left position
rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ),
- TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iBr.iY + popupRect.Height() ) );
+ TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iBr.iY + popupSize.iHeight ) );
}
break;
@@ -486,16 +509,16 @@
// if this position does not fit the screen,
// and if above right is more suitable, use it
- if ( spaceBelow < popupRect.Height() && spaceBelow < spaceAbove )
+ if ( spaceBelow < popupSize.iHeight && spaceBelow < spaceAbove )
{
- rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iTl.iY - popupRect.Height() ),
+ rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iTl.iY - popupSize.iHeight ),
TPoint( controlRect.iBr.iX, controlRect.iTl.iY ) );
}
else
{
// use the below-right position
- rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iBr.iY ),
- TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupRect.Height() ) );
+ rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iBr.iY ),
+ TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupSize.iHeight ) );
}
break;
@@ -503,33 +526,33 @@
// if this position does not fit the screen,
// and if left or above-left is more suitable, use it
- if ( spaceRight < popupRect.Width() )
+ if ( spaceRight < popupSize.iWidth )
{
// use the left position if the space is big enough
- if ( spaceLeft >= popupRect.Width() )
+ if ( spaceLeft >= popupSize.iWidth )
{
// use left position
- rect = TRect( TPoint( controlRect.iTl.iX - popupRect.Width(), controlRect.iTl.iY ),
- TPoint( controlRect.iTl.iX, controlRect.iTl.iY + popupRect.Height() ) );
+ rect = TRect( TPoint( controlRect.iTl.iX - popupSize.iWidth, controlRect.iTl.iY ),
+ TPoint( controlRect.iTl.iX, controlRect.iTl.iY + popupSize.iHeight ) );
}
- else if ( spaceAbove >= popupRect.Height() )
+ else if ( spaceAbove >= popupSize.iHeight )
{
// use the above-right position
- rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iTl.iY - popupRect.Height() ),
+ rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iTl.iY - popupSize.iHeight ),
TPoint( controlRect.iBr.iX, controlRect.iTl.iY ) );
}
else
{
// use the below-right position
- rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iBr.iY ),
- TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupRect.Height() ) );
+ rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iBr.iY ),
+ TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupSize.iHeight ) );
}
}
else
{
// use the right position
rect = TRect( TPoint( controlRect.iBr.iX, controlRect.iTl.iY ),
- TPoint( controlRect.iBr.iX + popupRect.Width(), controlRect.iTl.iY + popupRect.Height() ) );
+ TPoint( controlRect.iBr.iX + popupSize.iWidth, controlRect.iTl.iY + popupSize.iHeight ) );
}
break;
@@ -538,32 +561,32 @@
// if this position does not fit the screen,
// and if right is more suitable, use it
- if ( spaceLeft < popupRect.Width() )
+ if ( spaceLeft < popupSize.iWidth )
{
// use the right position, if it the space is big enough
- if ( spaceRight >= popupRect.Width() )
+ if ( spaceRight >= popupSize.iWidth )
{
rect = TRect( TPoint( controlRect.iBr.iX, controlRect.iTl.iY ),
- TPoint( controlRect.iBr.iX + popupRect.Width(), controlRect.iTl.iY + popupRect.Height() ) );
+ TPoint( controlRect.iBr.iX + popupSize.iWidth, controlRect.iTl.iY + popupSize.iHeight ) );
}
- else if ( spaceAbove >= popupRect.Height() )
+ else if ( spaceAbove >= popupSize.iHeight )
{
// use the above-left position
- rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupRect.Height() ),
- TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iTl.iY ) );
+ rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupSize.iHeight ),
+ TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iTl.iY ) );
}
else
{
// use the below-left position
rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ),
- TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iBr.iY + popupRect.Height() ) );
+ TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iBr.iY + popupSize.iHeight ) );
}
}
else
{
// use the left position
- rect = TRect( TPoint( controlRect.iTl.iX - popupRect.Width(), controlRect.iTl.iY ),
- TPoint( controlRect.iTl.iX, controlRect.iTl.iY + popupRect.Height() ) );
+ rect = TRect( TPoint( controlRect.iTl.iX - popupSize.iWidth, controlRect.iTl.iY ),
+ TPoint( controlRect.iTl.iX, controlRect.iTl.iY + popupSize.iHeight ) );
}
break;
default: