uifw/AvKon/src/AknPreviewPopUpController.cpp
branchRCL_3
changeset 4 8ca85d2f0db7
parent 0 2f259fa3e83a
child 55 aecbbf00d063
--- a/uifw/AvKon/src/AknPreviewPopUpController.cpp	Tue Feb 02 01:00:49 2010 +0200
+++ b/uifw/AvKon/src/AknPreviewPopUpController.cpp	Fri Feb 19 23:04:46 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 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"
@@ -231,93 +231,62 @@
             resize = ETrue;
             }
 
-        // allowed rect
-        TRect clientRect;
-        AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, clientRect );
-        
-        // Control is allowed to be on top of the status pane but it cannot
-        // overlay either stacon pane or control pane.
-        
-        //switch ( iAvkonAppUi->StatusPane()->CurrentLayoutResId() )
-        CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current();
-        TInt currentStatusPaneLayoutResId = 0;
-        if (statusPane)
-            {
-            currentStatusPaneLayoutResId = statusPane->CurrentLayoutResId();
-            }
-        else
-            {
-            // If this app does not have statuspane, then we ask the layout from AknCapServer.
-            currentStatusPaneLayoutResId = CAknSgcClient::CurrentStatuspaneResource();        
-            }
-            
-        switch ( currentStatusPaneLayoutResId )
-            {
-            case R_AVKON_STACON_PANE_LAYOUT_USUAL_SOFTKEYS_RIGHT:
-            case R_AVKON_STACON_PANE_LAYOUT_USUAL_SOFTKEYS_LEFT:
-            case R_AVKON_STACON_PANE_LAYOUT_IDLE_SOFTKEYS_RIGHT:
-            case R_AVKON_STACON_PANE_LAYOUT_IDLE_SOFTKEYS_LEFT:
-            case R_AVKON_STACON_PANE_LAYOUT_EMPTY_SOFTKEYS_RIGHT:
-            case R_AVKON_STACON_PANE_LAYOUT_EMPTY_SOFTKEYS_LEFT:
-                break;
-                
-            default:
-                TRect statusPaneRect;
-                AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, 
-                                                   statusPaneRect );
-
-                clientRect.BoundingRect( statusPaneRect );
-            }
+        // Adjust the position if the popup would go outside of the screen
+        // rect with the given position.
+        TRect screenRect;
+        AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect );
+        TInt screenWidth( screenRect.Width() );
+        TInt screenHeight( screenRect.Height() );
 
         TPoint finalPosition;
 
-        // resize if the popup is too wide
-        if ( popupSize.iWidth > clientRect.Width() )
+        // Resize if the popup is too wide.
+        if ( popupSize.iWidth > screenWidth )
             {
             resize = ETrue;
-            popupSize.iWidth = clientRect.Width();
+            popupSize.iWidth = screenWidth;
             }
 
-        // resize if the popup is too tall
-        if ( popupSize.iHeight > clientRect.Height() )
-        	{
+        // Resize if the popup is too tall.
+        if ( popupSize.iHeight > screenHeight )
+            {
             resize = ETrue;
-            popupSize.iHeight = clientRect.Height();
-        	}
+            popupSize.iHeight = screenHeight;
+            }
 
-        // default horizontal position is left from the given point
-        if ( askedPoint.iX - popupSize.iWidth >= clientRect.iTl.iX )
+        // Default horizontal position is left from the given point.
+        if ( askedPoint.iX - popupSize.iWidth >= screenRect.iTl.iX )
             {
             finalPosition.iX = askedPoint.iX - popupSize.iWidth;
             }
         else
             {
             // outside left border, move to left border
-            finalPosition.iX = clientRect.iTl.iX;
+            finalPosition.iX = screenRect.iTl.iX;
             }
 
-        // check the right border
-        if ( finalPosition.iX + popupSize.iWidth > clientRect.iBr.iX )
+        // Check the right border.
+        if ( finalPosition.iX + popupSize.iWidth > screenRect.iBr.iX )
             {
-            finalPosition.iX = clientRect.iBr.iX - popupSize.iWidth;
+            finalPosition.iX = screenRect.iBr.iX - popupSize.iWidth;
             }
 
-        // default vertical position is up from the given point
-        // coordinates grow from top to bottom
-        if ( askedPoint.iY > clientRect.iTl.iY )
+        // Default vertical position is up from the given point.
+        // Coordinates grow from top to bottom.
+        if ( askedPoint.iY > screenRect.iTl.iY )
             {
             finalPosition.iY = askedPoint.iY;
             }
         else
             {
-            // outside top border, move to top border
-            finalPosition.iY = clientRect.iTl.iY;
+            // Outside top border, move to top border.
+            finalPosition.iY = screenRect.iTl.iY;
             }
 
-        // outside bottom border, move to bottom border
-        if ( ( askedPoint.iY + popupSize.iHeight ) > clientRect.iBr.iY )
+        // Outside bottom border, move to bottom border.
+        if ( ( askedPoint.iY + popupSize.iHeight ) > screenRect.iBr.iY )
             {
-            finalPosition.iY = clientRect.iBr.iY - popupSize.iHeight;
+            finalPosition.iY = screenRect.iBr.iY - popupSize.iHeight;
             }
 
         if ( resize )