emailuis/emailui/src/ncspopuplistbox.cpp
branchRCL_3
changeset 10 f5907b1a1053
parent 8 e1b6206813b4
child 13 8592a65ad3fb
equal deleted inserted replaced
8:e1b6206813b4 10:f5907b1a1053
   417 	if( IsVisible() )
   417 	if( IsVisible() )
   418 		DrawDeferred();
   418 		DrawDeferred();
   419 	}
   419 	}
   420 
   420 
   421 // -----------------------------------------------------------------------------
   421 // -----------------------------------------------------------------------------
       
   422 // CNcsPopupListBox::RoundToItemHeight
       
   423 // -----------------------------------------------------------------------------
       
   424 TInt CNcsPopupListBox::RoundToItemHeight(const TInt aPopupHeight) const
       
   425     {
       
   426 	TReal fullItems; // number of full visible items in window
       
   427 	TInt err = Math::Round(fullItems, (aPopupHeight / ItemHeight()), 0);
       
   428 	if(err == KErrNone)
       
   429 	    {
       
   430 	    return (TInt)(fullItems * ItemHeight()); 
       
   431 	    }
       
   432 	return aPopupHeight; // in case of error
       
   433     }
       
   434 
       
   435 // -----------------------------------------------------------------------------
   422 // CNcsPopupListBox::SetPopupHeight
   436 // CNcsPopupListBox::SetPopupHeight
   423 // -----------------------------------------------------------------------------
   437 // -----------------------------------------------------------------------------
   424 void CNcsPopupListBox::SetPopupHeight()
   438 void CNcsPopupListBox::SetPopupHeight()
   425 	{
   439 	{
   426     FUNC_LOG;
   440     FUNC_LOG;
   427 	TRect newRect = iPopupMaxRect;
   441     // This is the total height in pixels needed to show all items
   428 
   442     TInt minimumHeight = CalcHeightBasedOnNumOfItems( Model()->NumberOfItems());
   429 	// This is the total height in pixels needed to show all items
   443     TRect newRect = iPopupMaxRect;
   430     TInt itemCount = Model()->NumberOfItems();
   444     TInt areaHeight = Parent()->Parent()->Rect().Height();
   431  	TInt minimumHeight = CalcHeightBasedOnNumOfItems( itemCount );
   445     TInt halfAreaHeight = areaHeight/2;
   432  	
   446 
   433  	// Shrink list size if maximum size is not needed
   447  	// Get height of one line in Address field
   434 	if( iPopupMaxRect.Height() > minimumHeight )
   448     CNcsHeaderContainer* headerObj = static_cast<CNcsHeaderContainer* >(Parent());
   435 	    {
   449     TInt toLineHeight = headerObj->GetToLineHeight(); // height of one line height
   436 		newRect.SetHeight( minimumHeight );
   450     if(toLineHeight == 0)
   437 	    }
   451     	{
       
   452         toLineHeight = ItemHeight();
       
   453     	}
       
   454     
       
   455     TInt newHeight = minimumHeight; // default window height
       
   456     
       
   457     //latch listbox on the bottom of the editor field
       
   458     if ( newRect.iTl.iY <= halfAreaHeight ) 
       
   459         {
       
   460         newHeight = RoundToItemHeight( areaHeight - newRect.iTl.iY );
       
   461         if(newHeight > minimumHeight)
       
   462         	{
       
   463             newHeight = minimumHeight; // shrink window (if needed)
       
   464           	}
       
   465         }
       
   466     //latch listbox on the top of the editor field
       
   467     else
       
   468      	{
       
   469         TInt yOffset = -minimumHeight - toLineHeight; // how much up
       
   470         TInt newTlY = newRect.iTl.iY + yOffset;       // new Top Left Y coordinate
       
   471         if(newTlY>=0)
       
   472           	{
       
   473             newRect.Move( 0, yOffset );
       
   474             }
       
   475         else
       
   476         	{
       
   477             // shrink height to visible area and move
       
   478             newHeight = RoundToItemHeight( minimumHeight + newTlY);
       
   479             newRect.Move( 0, -newHeight - toLineHeight);
       
   480             }
       
   481      	}
       
   482     newRect.SetHeight(newHeight); // set new height
   438 	SetRect( newRect );
   483 	SetRect( newRect );
   439 	}
   484 	}
   440 
   485 
   441 // -----------------------------------------------------------------------------
   486 // -----------------------------------------------------------------------------
   442 // CNcsPopupListBox::SetScrollBarVisibilityL
   487 // CNcsPopupListBox::SetScrollBarVisibilityL