--- a/uifw/EikStd/coctlsrc/aknstyluspopupmenu.cpp Thu Aug 19 10:11:06 2010 +0300
+++ b/uifw/EikStd/coctlsrc/aknstyluspopupmenu.cpp Tue Aug 31 15:28:30 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
@@ -24,9 +24,7 @@
#include <eikapp.h>
#include <aknappui.h>
#include <AknDef.h>
-#include <touchfeedback.h>
-#include <akntranseffect.h>
-#include <akntransitionutils.h>
+
#include "aknstyluspopupmenu.h"
#include "aknstyluspopupmenucontent.h"
@@ -46,13 +44,11 @@
//
CAknStylusPopUpMenu::CAknStylusPopUpMenu( MEikMenuObserver* aObserver,
const TPoint& aPoint,
- CAknPreviewPopUpController* aPopup,
- const TInt aFlags )
+ CAknPreviewPopUpController* aPopup )
: iPosition ( aPoint ),
iMenuObserver( aObserver ),
iPreviewPopup( aPopup ),
- iPositionType( EPositionTypeLeftTop ),
- iModeFlags ( aFlags )
+ iPositionType( EPositionTypeLeftTop )
{
}
@@ -85,24 +81,6 @@
return self;
}
-// ---------------------------------------------------------------------------
-// CAknStylusPopUpMenu::NewL
-// ---------------------------------------------------------------------------
-//
-CAknStylusPopUpMenu* CAknStylusPopUpMenu::NewL( MEikMenuObserver* aObserver,
- const TPoint& aPoint,
- CAknPreviewPopUpController* aPopup,
- const TInt aFlags )
- {
- CAknStylusPopUpMenu* self = new ( ELeave ) CAknStylusPopUpMenu( aObserver,
- aPoint,
- aPopup,
- aFlags );
- CleanupStack::PushL( self );
- self->ConstructL();
- CleanupStack::Pop( self );
- return self;
- }
// ---------------------------------------------------------------------------
// CAknStylusPopUpMenu::NewL
@@ -141,10 +119,6 @@
//
CAknStylusPopUpMenu::~CAknStylusPopUpMenu()
{
- if ( iContent )
- {
- iContent->SetObserver(NULL);
- }
if ( iIsDeleted )
{
*iIsDeleted = ETrue;
@@ -198,56 +172,23 @@
//
EXPORT_C void CAknStylusPopUpMenu::ShowMenu()
{
- // if contoller exists, re-use it .
- if ( !iController )
+ TRAPD( err,
+ iController = CAknPreviewPopUpController::NewL( *iContent,
+ CAknPreviewPopUpController::ELayoutSubMenu |
+ CAknPreviewPopUpController::EAutoMirror |
+ CAknPreviewPopUpController::EDontClose ) );
+ if ( err )
{
- TInt err ( KErrNone );
-
- if ( iModeFlags & EConsumeKeyEvents )
- {
- TRAP( err, iController = CAknPreviewPopUpController::NewL(
- *iContent,
- CAknPreviewPopUpController::ELayoutSubMenu |
- CAknPreviewPopUpController::EAutoMirror |
- CAknPreviewPopUpController::EDontClose |
- CAknPreviewPopUpController::EConsumeKeys ) );
- }
- else
- {
- TRAP( err, iController = CAknPreviewPopUpController::NewL(
- *iContent,
- CAknPreviewPopUpController::ELayoutSubMenu |
- CAknPreviewPopUpController::EAutoMirror |
- CAknPreviewPopUpController::EDontClose ) );
- }
- if ( err )
- {
- return;
- }
+ return;
+ }
- iController->SetPopUpShowDelay( KDefaultPopUpShowDelay );
- iController->SetPopUpHideDelay( KDefaultPopUpHideDelay );
- }
+ iController->SetPopUpShowDelay( KDefaultPopUpShowDelay );
+ iController->SetPopUpHideDelay( KDefaultPopUpHideDelay );
+ iContent->Parent()->DrawableWindow()->SetNonFading(ETrue);
TSize size(iController->Size());
iController->ShowPopUp();
- if ( AknLayoutUtils::PenEnabled() )
- {
- MTouchFeedback* feedback = MTouchFeedback::Instance();
- if ( feedback )
- {
- TTouchLogicalFeedback feedbackType = ETouchFeedbackPopUp;
- if ( CAknTransitionUtils::TransitionsEnabled( AknTransEffect::EComponentTransitionsOff ) )
- {
- feedbackType = ETouchFeedbackOptionsMenuOpened;
- }
- feedback->InstantFeedback(
- iContent,
- feedbackType,
- ETouchFeedbackVibra,
- TPointerEvent() );
- }
- }
+
if ( size.iWidth == 0 && size.iHeight == 0 )
{
if ( iPositionType != KErrNotFound )
@@ -282,8 +223,7 @@
// CAknStylusPopUpMenu::SetPosition
// ---------------------------------------------------------------------------
//
-EXPORT_C void CAknStylusPopUpMenu::SetPosition( const TPoint& aPoint,
- TPositionType aPosType )
+EXPORT_C void CAknStylusPopUpMenu::SetPosition( const TPoint& aPoint, TPositionType aPosType )
{
TPoint adjustedPoint( aPoint );
if ( !iController )
@@ -292,106 +232,41 @@
iPositionType = aPosType;
return;
}
-
iController->UpdateContentSize();
TSize menuSize = iController->Size();
-
- // Calculate the position to right-top corner by aPosType and
- // popup menu size. Add also a margin between the screen borders and the
- // popup if the popup is too close to screen border.
- TBool layoutMirrored( AknLayoutUtils::LayoutMirrored() );
- TRect screenRect;
- AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen,
- screenRect );
-
- // Margin is read from the popup window's layout data
- // (left parameter used).
- TAknWindowLineLayout popupWindowLayout(
- AknLayoutScalable_Avkon::popup_touch_menu_window( 0 ).LayoutLine() );
- TInt windowMargin = layoutMirrored ? popupWindowLayout.ir :
- popupWindowLayout.il;
-
+ // calculate to right-top corner by aPosType and popup menu size
switch ( aPosType )
{
- case EPositionTypeRightTop:
- {
- break;
- }
-
- case EPositionTypeLeftTop:
- {
- if ( !layoutMirrored )
- {
- adjustedPoint.iX += menuSize.iWidth;
- }
-
+ case EPositionTypeRightTop:
break;
- }
-
- case EPositionTypeRightBottom:
- {
- adjustedPoint.iY -= menuSize.iHeight;
-
- break;
- }
-
- case EPositionTypeLeftBottom:
- {
- if ( !layoutMirrored )
+ case EPositionTypeLeftTop:
+ if( AknLayoutUtils::LayoutMirrored() )
+ {
+ adjustedPoint.iX -= menuSize.iWidth;
+ }
+ else
{
adjustedPoint.iX += menuSize.iWidth;
}
-
+ break;
+ case EPositionTypeRightBottom:
adjustedPoint.iY -= menuSize.iHeight;
-
- break;
- }
-
- default:
- {
break;
- }
- }
-
- // Check if margins need to be added.
- TInt xLeftPos( layoutMirrored ? adjustedPoint.iX :
- adjustedPoint.iX - menuSize.iWidth );
- TInt xRightPos( layoutMirrored ? adjustedPoint.iX + menuSize.iWidth :
- adjustedPoint.iX );
- TInt xPosRightMargin( screenRect.iBr.iX - windowMargin );
- TInt xPosBottomMargin( screenRect.iBr.iY - windowMargin );
-
- if ( xLeftPos < windowMargin )
- {
- // Too close to the left side of the screen.
- adjustedPoint.iX = windowMargin + menuSize.iWidth;
+ case EPositionTypeLeftBottom:
+ if( AknLayoutUtils::LayoutMirrored() )
+ {
+ adjustedPoint.iX -= menuSize.iWidth;
+ }
+ else
+ {
+ adjustedPoint.iX += menuSize.iWidth;
+ }
+ adjustedPoint.iY -= menuSize.iHeight;
+ break;
+ default:
+ break;
+
}
- else if ( xRightPos > xPosRightMargin )
- {
- // Too close to the right side of the screen.
- if ( layoutMirrored )
- {
- // In mirrored layout a left-top position must be provided
- // for the preview popup controller.
- adjustedPoint.iX = xPosRightMargin - menuSize.iWidth;
- }
- else
- {
- adjustedPoint.iX = xPosRightMargin;
- }
- }
-
- if ( adjustedPoint.iY < windowMargin )
- {
- // Too close to the top border of the screen.
- adjustedPoint.iY = windowMargin;
- }
- else if ( adjustedPoint.iY + menuSize.iHeight > xPosBottomMargin )
- {
- // Too close to the bottom border of the screen.
- adjustedPoint.iY = xPosBottomMargin - menuSize.iHeight;
- }
-
iPosition = adjustedPoint;
iController->SetPosition( adjustedPoint );
}
@@ -437,26 +312,19 @@
if ( iMenuObserver )
{
- TBool isAlreadySet = iFlags.IsSet( EIdleDisabled );
-
iFlags.Set( EIdleDisabled );
TBool isDeleted = EFalse;
iIsDeleted = &isDeleted;
- CleanupStack::PushL( TCleanupItem( CleanLocalRef, this ) );
iMenuObserver->ProcessCommandL( iContent->CurrentCommandId() );
- CleanupStack::Pop();
-
+
if ( isDeleted )
{
return;
}
iIsDeleted = NULL;
- if( !isAlreadySet )
- {
- iFlags.Clear( EIdleDisabled );
- }
+ iFlags.Clear( EIdleDisabled );
}
StartControllerIdleL();
@@ -467,7 +335,6 @@
{
iPreviewPopup->HidePopUp();
}
-
if ( iController )
{
iController->HidePopUp();
@@ -479,16 +346,9 @@
{
if ( iMenuObserver )
{
- TBool isAlreadySet = iFlags.IsSet( EIdleDisabled );
-
iFlags.Set( EIdleDisabled );
iMenuObserver->ProcessCommandL( KErrCancel );
-
- if( !isAlreadySet )
- {
- iFlags.Clear( EIdleDisabled );
- }
-
+ iFlags.Clear( EIdleDisabled );
}
StartControllerIdleL();
@@ -519,20 +379,6 @@
}
}
-
-// ---------------------------------------------------------------------------
-// CAknStylusPopUpMenu::HideMenu
-// ---------------------------------------------------------------------------
-//
-void CAknStylusPopUpMenu::HideMenu()
- {
- if ( iController )
- {
- iController->HidePopUp();
- }
- }
-
-
// -----------------------------------------------------------------------------
// CAknStylusPopUpMenu::StartControllerIdleL
// -----------------------------------------------------------------------------
@@ -578,12 +424,3 @@
iController = NULL;
}
}
-
-// -----------------------------------------------------------------------------
-// CAknStylusPopUpMenu::CleanLocalRef
-// -----------------------------------------------------------------------------
-//
-void CAknStylusPopUpMenu::CleanLocalRef( TAny* aParam )
- {
- static_cast<CAknStylusPopUpMenu*>( aParam )->iIsDeleted = NULL;
- }