textinput/peninputfingerhwr/src/peninputfingerhwrrangeselector.cpp
branchRCL_3
changeset 44 ecbabf52600f
equal deleted inserted replaced
43:ebd48d2de13c 44:ecbabf52600f
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0""
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation of char range selector.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE
       
    19 #include <peninputfingerhwrcn.rsg>
       
    20 
       
    21 #include <coemain.h>
       
    22 #include <s32mem.h>
       
    23 
       
    24 #include <aknlayoutscalable_apps.cdl.h>
       
    25 #include <aknlayoutscalable_avkon.cdl.h>
       
    26 #include <AknLayoutDef.h>
       
    27 #include <AknUtils.h>
       
    28 #include <AknsUtils.h>
       
    29 #include <AknIconUtils.h>
       
    30 #include <aknfeppeninputenums.h>
       
    31 #include <AknFepGlobalEnums.h>
       
    32 
       
    33 #include <peninputlayout.h>
       
    34 #include <peninputrepeatbutton.h>
       
    35 #include <peninputmultiimagebutton.h>
       
    36 
       
    37 #include "peninputfingerhwrevent.h"
       
    38 #include "peninputfingerhwrcontrolid.h"
       
    39 #include "peninputfingerhwrstoreconstants.h"
       
    40 
       
    41 #include "peninputfingerhwrrangeselector.h"
       
    42 
       
    43 
       
    44 //CONST DEFINATION
       
    45 const TInt KButtonInnerPadding = 6;
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // Symbian Constructor
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CPeninputFingerHwrRangeSelector* CPeninputFingerHwrRangeSelector::NewL( 
       
    52     CFepUiLayout* aUiLayout, TInt aId )
       
    53     {
       
    54     CPeninputFingerHwrRangeSelector* self = CPeninputFingerHwrRangeSelector::NewLC( 
       
    55             aUiLayout, aId );
       
    56     
       
    57     CleanupStack::Pop( self ); // self;
       
    58     return self;
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // Symbian Constructor
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 CPeninputFingerHwrRangeSelector* CPeninputFingerHwrRangeSelector::NewLC( 
       
    66     CFepUiLayout* aUiLayout, TInt aId )
       
    67     {
       
    68     CPeninputFingerHwrRangeSelector* self = new (ELeave) CPeninputFingerHwrRangeSelector( 
       
    69             aUiLayout, aId );
       
    70     CleanupStack::PushL( self );
       
    71     self->ConstructL();
       
    72     return self;
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // c++ destructor
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 CPeninputFingerHwrRangeSelector::~CPeninputFingerHwrRangeSelector()
       
    80     {
       
    81     iRangeChBtn = NULL;
       
    82     iRangeEnBtn = NULL;
       
    83     iRangeNumBtn = NULL;
       
    84      
       
    85     iRangeChMiBtn = NULL;
       
    86     iRangeEnMiBtn = NULL;
       
    87     iRangeNumMiBtn = NULL;      
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // popup the list.
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 void CPeninputFingerHwrRangeSelector::Popup( TInt aDirect )
       
    95     {
       
    96     CapturePointer( ETrue );
       
    97     iPopupVisible = ETrue;
       
    98     LayoutRangeButtons( iPermittedRanges, iCurRange, 
       
    99             iCurRangeActive, ETrue, aDirect );
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // cancel the popup.
       
   104 // ---------------------------------------------------------------------------
       
   105 //
       
   106 void CPeninputFingerHwrRangeSelector::CancelPopup()
       
   107     {
       
   108     TRect extendRect = Rect();
       
   109     LayoutRangeButtons( iPermittedRanges, iCurRange, 
       
   110             iCurRangeActive, EFalse, EPopDirAuto );
       
   111     CapturePointer( EFalse );
       
   112     iPopupVisible = EFalse;
       
   113 
       
   114     
       
   115     UpdateArea( extendRect, EFalse );
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // get visibility of popup.
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 TBool CPeninputFingerHwrRangeSelector::IsPopup()
       
   123     {
       
   124     return iPopupVisible;
       
   125     }
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 // set permitted char range.
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 void CPeninputFingerHwrRangeSelector::SetPermittedRanges( const TInt aPermittedRanges )
       
   132     {
       
   133     iPermittedRanges = aPermittedRanges;
       
   134     
       
   135     if ( IsPopup() )
       
   136         {
       
   137         CancelPopup();
       
   138         }
       
   139     
       
   140     LayoutRangeButtons( iPermittedRanges, iCurRange, iCurRangeActive, 
       
   141             EFalse, EPopDirAuto );
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------------------------
       
   145 // set current char range.
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 void CPeninputFingerHwrRangeSelector::SetCurRange( const TInt aCurRange, 
       
   149     const TBool aActive )
       
   150     {
       
   151     iCurRange = aCurRange;
       
   152     iCurRangeActive = aActive;
       
   153 
       
   154     if ( IsPopup() )
       
   155         {
       
   156         CancelPopup();
       
   157         }
       
   158     
       
   159     LayoutRangeButtons( iPermittedRanges, iCurRange, iCurRangeActive, 
       
   160             EFalse, EPopDirAuto );
       
   161     
       
   162     }
       
   163 
       
   164 // ---------------------------------------------------------------------------
       
   165 // set base rect of popup.
       
   166 // ---------------------------------------------------------------------------
       
   167 //
       
   168 void CPeninputFingerHwrRangeSelector::SetBaseRect( const TRect& aRect )
       
   169     {
       
   170     iPopupBaseRect = aRect;
       
   171 
       
   172     LayoutRangeButtons( iPermittedRanges, iCurRange, 
       
   173             iCurRangeActive, iPopupVisible, EPopDirAuto );
       
   174 
       
   175     UpdateArea( Rect(), EFalse );
       
   176     }
       
   177 
       
   178 
       
   179 // ---------------------------------------------------------------------------
       
   180 // Handle pointer down event.
       
   181 // ---------------------------------------------------------------------------
       
   182 //
       
   183 CFepUiBaseCtrl* CPeninputFingerHwrRangeSelector::HandlePointerDownEventL(
       
   184     const TPoint& aPoint )
       
   185     {
       
   186     CFepUiBaseCtrl* ctrl = CControlGroup::HandlePointerDownEventL( aPoint );
       
   187     
       
   188     if ( !ctrl )
       
   189         {
       
   190         if ( IsPopup() )
       
   191             {
       
   192             CancelPopup();
       
   193             }
       
   194         }
       
   195     
       
   196     return ctrl;
       
   197     }
       
   198 
       
   199 // ---------------------------------------------------------------------------
       
   200 // Handle pointer up event.
       
   201 // ---------------------------------------------------------------------------
       
   202 //
       
   203 CFepUiBaseCtrl* CPeninputFingerHwrRangeSelector::HandlePointerUpEventL(
       
   204     const TPoint& aPoint )
       
   205     {
       
   206 	if(IsPopup())
       
   207 	    {
       
   208 		if(iCurRangeActive)
       
   209 			{
       
   210 			if(iCurRange == EFingerHwrNativeRange)
       
   211 			    {
       
   212 				iRangeChBtn->SetHighlight(EFalse);
       
   213 				}
       
   214 			else if(iCurRange == EFingerHwrEnglishRange)
       
   215                 {
       
   216 				iRangeEnBtn->SetHighlight(EFalse);
       
   217 				}
       
   218             else
       
   219                 {
       
   220 				iRangeNumBtn->SetHighlight(EFalse);
       
   221 				}			
       
   222 			}
       
   223 		}
       
   224     CFepUiBaseCtrl* ctrl = CControlGroup::HandlePointerUpEventL( aPoint );
       
   225 
       
   226     iRangeChBtn->CancelPointerDownL();
       
   227     iRangeEnBtn->CancelPointerDownL();
       
   228     iRangeNumBtn->CancelPointerDownL(); 
       
   229     
       
   230     return ctrl;
       
   231     }
       
   232 
       
   233 // ---------------------------------------------------------------------------
       
   234 // Handle pointer move event.
       
   235 // ---------------------------------------------------------------------------
       
   236 //
       
   237 CFepUiBaseCtrl* CPeninputFingerHwrRangeSelector::HandlePointerMoveEventL(
       
   238     const TPoint& /*aPoint*/ )
       
   239     {
       
   240     //bypass    
       
   241     return NULL;
       
   242     }
       
   243 
       
   244 // ---------------------------------------------------------------------------
       
   245 // C++ constructor.
       
   246 // ---------------------------------------------------------------------------
       
   247 //
       
   248 CPeninputFingerHwrRangeSelector::CPeninputFingerHwrRangeSelector( 
       
   249     CFepUiLayout* aFepUiLayout, TInt aControlId )
       
   250     : CControlGroup( aFepUiLayout, aControlId, EFalse )
       
   251     {
       
   252  
       
   253     }
       
   254     
       
   255 // ---------------------------------------------------------------------------
       
   256 // Symbian second-phase constructor.
       
   257 // ---------------------------------------------------------------------------
       
   258 //
       
   259 void CPeninputFingerHwrRangeSelector::ConstructL()
       
   260     {
       
   261     BaseConstructL(); 
       
   262     
       
   263     //disable border
       
   264     SetBorderSize( TSize(0,0) );
       
   265     
       
   266     //create buttons
       
   267     iRangeChBtn = CreateEventBtnL( EHwrCtrlIdChineseButton, R_AKN_FEP_HWR_RANGE_CHINESE );
       
   268     iRangeEnBtn = CreateEventBtnL( EHwrCtrlIdEnglishButton, R_AKN_FEP_HWR_RANGE_ENGLISH );
       
   269     iRangeNumBtn = CreateEventBtnL( EHwrCtrlIdNumberButton, R_AKN_FEP_HWR_RANGE_NUMERIC );
       
   270     
       
   271     iRangeChMiBtn = CreateMultiBtnL( EHwrCtrlIdChineseMiButton, R_AKN_FEP_HWR_RANGE_CH_MI );
       
   272     iRangeEnMiBtn = CreateMultiBtnL( EHwrCtrlIdEnglishMiButton, R_AKN_FEP_HWR_RANGE_EN_MI );
       
   273     iRangeNumMiBtn = CreateMultiBtnL( EHwrCtrlIdNumberMiButton, R_AKN_FEP_HWR_RANGE_NUM_MI );
       
   274     }
       
   275 
       
   276 // ---------------------------------------------------------------------------
       
   277 // EventButton creation helper.
       
   278 // ---------------------------------------------------------------------------
       
   279 //
       
   280 CAknFepCtrlEventButton* CPeninputFingerHwrRangeSelector::CreateEventBtnL( 
       
   281     TInt aCtrlId, TInt32 aResId, TInt aEvent/*= 0xFFFF*/,TInt aUnicode/*=0*/ )
       
   282     {
       
   283     CAknFepCtrlEventButton* button = CAknFepCtrlEventButton::NewL( 
       
   284         UiLayout(), aCtrlId, aEvent, aUnicode,
       
   285         KAknsIIDQsnFrFunctionButtonNormal,
       
   286         KAknsIIDQsnFrFunctionButtonPressed,
       
   287         KAknsIIDQsnFrFunctionButtonInactive );
       
   288     
       
   289     button->SetResourceId( aResId );
       
   290     button->ConstructFromResourceL();
       
   291     button->AddEventObserver( UiLayout() );        
       
   292     AddControlL( button );
       
   293     return button;
       
   294     }
       
   295 
       
   296 // ---------------------------------------------------------------------------
       
   297 // MultiImageButton creation helper.
       
   298 // ---------------------------------------------------------------------------
       
   299 //
       
   300 CAknFepCtrlMultiImageButton* CPeninputFingerHwrRangeSelector::CreateMultiBtnL( 
       
   301     TInt aCtrlId, TInt32 aResId )
       
   302     {
       
   303     CAknFepCtrlMultiImageButton* button = CAknFepCtrlMultiImageButton::NewL( 
       
   304         UiLayout(), aCtrlId,
       
   305         KAknsIIDQsnFrFunctionButtonNormal,
       
   306         KAknsIIDQsnFrFunctionButtonPressed,
       
   307         KAknsIIDQsnFrFunctionButtonInactive );
       
   308 
       
   309     button->SetResourceId( aResId );      
       
   310     button->ConstructFromResourceL();
       
   311     button->AddEventObserver( UiLayout() );
       
   312     AddControlL( button );
       
   313     return button;
       
   314     }
       
   315 
       
   316 // ---------------------------------------------------------------------------
       
   317 //  EventButton layout helper. Move button to specified rect.
       
   318 // ---------------------------------------------------------------------------
       
   319 //
       
   320 void CPeninputFingerHwrRangeSelector::MoveIconButton( CAknFepCtrlEventButton* aButton, 
       
   321     const TRect& aRect, TInt aXPadding, TInt aYPadding, TBool aReloadImages )
       
   322     {
       
   323     if ( !aButton )
       
   324         {
       
   325         return;
       
   326         }
       
   327     
       
   328     aButton->SetRect( aRect );
       
   329     TRect rcInner = aRect;
       
   330     if ( rcInner.Width() > rcInner.Height() )
       
   331         {
       
   332         TInt dx = ( rcInner.Width() - rcInner.Height() ) / 2;
       
   333         rcInner.Move( dx, 0);
       
   334         rcInner.SetWidth( rcInner.Height() );
       
   335         }
       
   336     else
       
   337         {
       
   338         TInt dy = ( rcInner.Height() - rcInner.Width() ) / 2;
       
   339         rcInner.Move( 0, dy );
       
   340         rcInner.SetHeight( rcInner.Width() );        
       
   341         }
       
   342     
       
   343     rcInner.Shrink( aXPadding, aYPadding );
       
   344     aButton->SizeChanged( aRect, rcInner, aReloadImages );
       
   345     }
       
   346 
       
   347 // ---------------------------------------------------------------------------
       
   348 //  MultiIconButton layout helper. Move button to specified rect.
       
   349 // ---------------------------------------------------------------------------
       
   350 //
       
   351 void CPeninputFingerHwrRangeSelector::MoveMultiIconButton( 
       
   352     CAknFepCtrlMultiImageButton* aButton, const TRect& aRect,
       
   353     TInt aXPadding, TInt aYPadding, TBool aReloadImages )
       
   354     {
       
   355     if ( !aButton )
       
   356         {
       
   357         return;
       
   358         }
       
   359     
       
   360     aButton->SetRect( aRect );
       
   361     TRect rcInner=aRect;
       
   362     if ( rcInner.Width() > rcInner.Height() )
       
   363         {
       
   364         TInt dx = ( rcInner.Width() - rcInner.Height() ) / 2;
       
   365         rcInner.Move( dx, 0);
       
   366         rcInner.SetWidth( rcInner.Height() );
       
   367         }
       
   368     else
       
   369         {
       
   370         TInt dy = ( rcInner.Height() - rcInner.Width() ) / 2;
       
   371         rcInner.Move( 0, dy );
       
   372         rcInner.SetHeight( rcInner.Width() );        
       
   373         }
       
   374     
       
   375     rcInner.Shrink( aXPadding, aYPadding );
       
   376     aButton->SizeChanged( aRect, rcInner, aReloadImages );
       
   377     }
       
   378 
       
   379 // ---------------------------------------------------------------------------
       
   380 //  layout buttons.
       
   381 // ---------------------------------------------------------------------------
       
   382 //
       
   383 void CPeninputFingerHwrRangeSelector::LayoutRangeButtons( TInt aPermittedRanges, 
       
   384     TInt aCurRange, TBool aActive, TBool aShowDropList, TInt aDropDirect )
       
   385     {
       
   386     
       
   387     TRect rcBound  = UiLayout()->Rect();
       
   388     TRect rcBase = iPopupBaseRect;
       
   389     TRect rcTarget = rcBase;
       
   390     TInt pdx = KButtonInnerPadding;
       
   391     TInt pdy = KButtonInnerPadding;
       
   392     
       
   393    
       
   394     TInt count = 0;
       
   395     
       
   396     count += aPermittedRanges & ERangeNative  ? 1 : 0;
       
   397     count += aPermittedRanges & ERangeEnglish ? 1 : 0;
       
   398     count += aPermittedRanges & ERangeNumber  ? 1 : 0;
       
   399     
       
   400     if ( count == 1 || aShowDropList )
       
   401         {
       
   402         iRangeChMiBtn->Hide( ETrue );
       
   403         iRangeEnMiBtn->Hide( ETrue );
       
   404         iRangeNumMiBtn->Hide( ETrue );        
       
   405         }
       
   406     
       
   407     if ( count < 1 )
       
   408         {
       
   409         return;
       
   410         }
       
   411     
       
   412     if ( count == 1 )
       
   413         {
       
   414 
       
   415         switch( aCurRange )
       
   416             {
       
   417             case EFingerHwrNativeRange:
       
   418                 {
       
   419                 MoveIconButton( iRangeChBtn, rcBase, pdx, pdy, ETrue );
       
   420                 }
       
   421                 break;
       
   422             case EFingerHwrEnglishRange:
       
   423                 {
       
   424                 MoveIconButton( iRangeEnBtn, rcBase,  pdx, pdy, ETrue );
       
   425                 }
       
   426                 break;
       
   427             case EFingerHwrNumberRange:
       
   428                 {
       
   429                 MoveIconButton( iRangeNumBtn, rcBase,  pdx, pdy, ETrue );
       
   430                 }
       
   431                 break;
       
   432             default:
       
   433                 break;
       
   434             }
       
   435         iRangeChBtn->Hide( aCurRange != EFingerHwrNativeRange );
       
   436         iRangeEnBtn->Hide( aCurRange != EFingerHwrEnglishRange );
       
   437         iRangeNumBtn->Hide( aCurRange != EFingerHwrNumberRange );
       
   438         
       
   439         SetRect( rcTarget );
       
   440         
       
   441         iRangeChBtn->SetHighlight( EFalse );
       
   442         iRangeEnBtn->SetHighlight( EFalse );
       
   443         iRangeNumBtn->SetHighlight( EFalse );
       
   444         
       
   445         return;
       
   446         }
       
   447 
       
   448     if ( aShowDropList )
       
   449         {
       
   450         TRect rcBtn = rcBase;
       
   451         
       
   452         TPoint direct = CalcDropListDirection( rcBound, rcBtn.iTl, 
       
   453                 rcBtn.Size(), count, aDropDirect );
       
   454   
       
   455         TInt dx = direct.iX;
       
   456         TInt dy = direct.iY;
       
   457         
       
   458         CalcDropListRect( rcTarget, dx * count, dy * count );
       
   459         SetRect( rcTarget );
       
   460         
       
   461         if ( aPermittedRanges & ERangeNative )
       
   462             {
       
   463             MoveIconButton( iRangeChBtn, rcBtn, pdx, pdy, ETrue );
       
   464             rcBtn.Move( dx, dy );
       
   465             }
       
   466             
       
   467         if ( aPermittedRanges & ERangeEnglish )
       
   468             {
       
   469             MoveIconButton( iRangeEnBtn, rcBtn,  pdx, pdy, ETrue );
       
   470             rcBtn.Move( dx, dy );
       
   471             }
       
   472             
       
   473         if ( aPermittedRanges & ERangeNumber )
       
   474             {
       
   475             MoveIconButton( iRangeNumBtn, rcBtn,  pdx, pdy, ETrue );
       
   476             rcBtn.Move( dx, dy );
       
   477             }
       
   478         
       
   479         iRangeChBtn->Hide( !(aPermittedRanges & ERangeNative) );
       
   480         iRangeEnBtn->Hide( !(aPermittedRanges & ERangeEnglish) );
       
   481         iRangeNumBtn->Hide( !(aPermittedRanges & ERangeNumber) );
       
   482         
       
   483         iRangeChBtn->SetHighlight( aActive && aCurRange == EFingerHwrNativeRange );
       
   484         iRangeEnBtn->SetHighlight( aActive && aCurRange == EFingerHwrEnglishRange );
       
   485         iRangeNumBtn->SetHighlight( aActive && aCurRange == EFingerHwrNumberRange  ); 
       
   486         }
       
   487     else
       
   488         {
       
   489         SetRect( rcTarget );
       
   490         
       
   491         switch( aCurRange )
       
   492             {
       
   493             case EFingerHwrNativeRange:
       
   494                 {
       
   495                 MoveMultiIconButton( iRangeChMiBtn, rcBase, pdx, pdy, ETrue );
       
   496                 }
       
   497                 break;     
       
   498             case EFingerHwrEnglishRange:
       
   499                 {
       
   500                 MoveMultiIconButton( iRangeEnMiBtn, rcBase,  pdx, pdy, ETrue );
       
   501                 }
       
   502                 break;
       
   503             case EFingerHwrNumberRange:
       
   504                 {
       
   505                 MoveMultiIconButton( iRangeNumMiBtn, rcBase,  pdx, pdy, ETrue );
       
   506                 }
       
   507                 break;
       
   508             default:
       
   509                 break;
       
   510             }
       
   511         iRangeChMiBtn->Hide( aCurRange != EFingerHwrNativeRange );
       
   512         iRangeEnMiBtn->Hide( aCurRange != EFingerHwrEnglishRange );
       
   513         iRangeNumMiBtn->Hide( aCurRange != EFingerHwrNumberRange );
       
   514         
       
   515         iRangeChBtn->Hide( ETrue );
       
   516         iRangeEnBtn->Hide( ETrue );
       
   517         iRangeNumBtn->Hide( ETrue );        
       
   518         }
       
   519     }
       
   520 
       
   521 
       
   522 // ---------------------------------------------------------------------------
       
   523 //  calculates popup direction.
       
   524 // ---------------------------------------------------------------------------
       
   525 //
       
   526 TPoint CPeninputFingerHwrRangeSelector::CalcDropListDirection( const TRect& aBound, 
       
   527     const TPoint& aTarget, const TSize& aItemSize, 
       
   528     TInt aItemCount, TInt aDirect )
       
   529     {
       
   530     TInt dirx = 0;
       
   531     TInt diry = 0;
       
   532 
       
   533     TInt direct = aDirect;
       
   534     if( aDirect == EPopDirAuto )
       
   535         {
       
   536         //determine pop diretion, in this order: down, up, right, left
       
   537         const TInt minx = aBound.iTl.iX;
       
   538         TInt miny = aBound.iTl.iY;
       
   539         TInt maxy = aBound.iBr.iY;
       
   540         
       
   541         if( aTarget.iY + aItemSize.iHeight * aItemCount <= maxy )
       
   542             {
       
   543             direct = EPopDirDown;         
       
   544             }
       
   545         else if( aTarget.iY -  aItemSize.iHeight * ( aItemCount - 1 ) >= miny )
       
   546             {
       
   547             direct = EPopDirTop;       
       
   548             }
       
   549         else if( aTarget.iX +  aItemSize.iWidth * aItemCount <= maxy )
       
   550             {
       
   551             direct = EPopDirRight; 
       
   552             }
       
   553         else if( aTarget.iX -  aItemSize.iWidth * ( aItemCount - 1 ) >= minx )
       
   554             {
       
   555             direct = EPopDirLeft; 
       
   556             }
       
   557         else 
       
   558             {
       
   559             direct = EPopDirDown;
       
   560             }
       
   561         }
       
   562     
       
   563     switch( direct )
       
   564         {
       
   565         case EPopDirDown: 
       
   566             {
       
   567             diry = 1;
       
   568             }
       
   569             break;
       
   570         case EPopDirTop:
       
   571             {
       
   572             diry = -1;
       
   573             }
       
   574             break;
       
   575         case EPopDirRight:
       
   576             {
       
   577             dirx = 1;
       
   578             }
       
   579             break;
       
   580         case EPopDirLeft: 
       
   581             {
       
   582             dirx = -1;
       
   583             }
       
   584             break;
       
   585         default:
       
   586             {
       
   587             dirx = 0;
       
   588             diry = 1;
       
   589             }
       
   590             break;
       
   591         }
       
   592     return TPoint( dirx * aItemSize.iWidth, diry * aItemSize.iHeight );
       
   593     }
       
   594 
       
   595 
       
   596 // ---------------------------------------------------------------------------
       
   597 //  calculates popup rect.
       
   598 // ---------------------------------------------------------------------------
       
   599 //
       
   600 void CPeninputFingerHwrRangeSelector::CalcDropListRect( TRect& aRect, 
       
   601     const TInt aWidth, const TInt aHeight )
       
   602     {
       
   603     if ( aWidth > 0 )
       
   604         {
       
   605         aRect.SetWidth( aWidth );
       
   606         }
       
   607     else if ( aWidth < 0 )
       
   608         {
       
   609         aRect.Move( aWidth + aRect.Width(), 0 );
       
   610         aRect.SetWidth( - aWidth );
       
   611         }
       
   612     
       
   613     if ( aHeight > 0 )
       
   614         {
       
   615         aRect.SetHeight( aHeight );
       
   616         }
       
   617     else if ( aHeight < 0 )
       
   618         {
       
   619         aRect.Move( 0, aHeight + aRect.Height() );
       
   620         aRect.SetHeight( - aHeight );
       
   621         }    
       
   622     }
       
   623 // End Of File