uifw/EikStd/coctlsrc/EIKSCRLB.CPP
branchRCL_3
changeset 25 941195f2d488
parent 23 3d340a0166ff
child 38 c52421ed5f07
equal deleted inserted replaced
23:3d340a0166ff 25:941195f2d488
    39 
    39 
    40 #include "AknDoubleSpanScrollIndicator.h"
    40 #include "AknDoubleSpanScrollIndicator.h"
    41 #include "eikscrlb.h"
    41 #include "eikscrlb.h"
    42 #include "EIKSBEXT.H"
    42 #include "EIKSBEXT.H"
    43 
    43 
    44 const TInt KIntensity = 100; // 100%
       
    45 
       
    46 const TInt KScrollBarWidth=9;
    44 const TInt KScrollBarWidth=9;
    47 // const TInt KScrollButtonHeight=10;
    45 // const TInt KScrollButtonHeight=10;
    48 // const TInt KArrowHeadScrollBarLength=20;
    46 // const TInt KArrowHeadScrollBarLength=20;
    49 
    47 
    50 // Constants for double span scrollbar
    48 // Constants for double span scrollbar
   669     {
   667     {
   670     AKNTASHOOK_REMOVE();
   668     AKNTASHOOK_REMOVE();
   671     if ( iAvkonAppUiBase )
   669     if ( iAvkonAppUiBase )
   672         {
   670         {
   673         CAknPointerEventModifier* modifier = iAvkonAppUiBase->PointerEventModifier();
   671         CAknPointerEventModifier* modifier = iAvkonAppUiBase->PointerEventModifier();
   674         
   672 
   675         if ( modifier )
   673         if ( modifier )
   676             {
   674             {
   677             modifier->Pop( *this );
   675             modifier->Pop( *this );
   678             }
   676             }
   679         }
   677         }
   680         
   678 
   681     AknsUtils::DeregisterControlPosition( this );
   679     AknsUtils::DeregisterControlPosition( this );
   682     }
   680     }
   683 
   681 
   684 EXPORT_C void CAknDoubleSpanScrollBar::ConstructL(TBool aWindowOwning, MEikScrollBarObserver* aScrollBarObserver,const CCoeControl* aParent,
   682 EXPORT_C void CAknDoubleSpanScrollBar::ConstructL(TBool aWindowOwning, MEikScrollBarObserver* aScrollBarObserver,const CCoeControl* aParent,
   685                                                  TOrientation aOrientation,TInt /*aLength*/,TInt aScrollBarFlags )
   683                                                  TOrientation aOrientation,TInt /*aLength*/,TInt aScrollBarFlags )
   824 
   822 
   825 
   823 
   826 EXPORT_C void CAknDoubleSpanScrollBar::MakeVisible(TBool aVisible)
   824 EXPORT_C void CAknDoubleSpanScrollBar::MakeVisible(TBool aVisible)
   827     {
   825     {
   828     CAknPointerEventModifier* modifier = iAvkonAppUiBase ? iAvkonAppUiBase->PointerEventModifier() : NULL;
   826     CAknPointerEventModifier* modifier = iAvkonAppUiBase ? iAvkonAppUiBase->PointerEventModifier() : NULL;
   829     
   827 
   830     if ( modifier )
   828     if ( modifier )
   831         {
   829         {
   832         CAknDoubleSpanScrollBarExtension* extension = static_cast<CAknDoubleSpanScrollBarExtension*> (iExtension);
   830         CAknDoubleSpanScrollBarExtension* extension = static_cast<CAknDoubleSpanScrollBarExtension*> (iExtension);
   833         if ( aVisible  && (extension->iScrollIndicator->ScrollSpan() > 0)  && !( extension->iExtensionType & ENoExpandedTouchArea ) )
   831         if ( aVisible  && (extension->iScrollIndicator->ScrollSpan() > 0)  && !( extension->iExtensionType & ENoExpandedTouchArea ) )
   834             {
   832             {
   894 
   892 
   895 
   893 
   896 EXPORT_C void CAknDoubleSpanScrollBar::SizeChanged()
   894 EXPORT_C void CAknDoubleSpanScrollBar::SizeChanged()
   897     {
   895     {
   898     CAknPointerEventModifier* modifier = iAvkonAppUiBase ? iAvkonAppUiBase->PointerEventModifier() : NULL;
   896     CAknPointerEventModifier* modifier = iAvkonAppUiBase ? iAvkonAppUiBase->PointerEventModifier() : NULL;
   899     
   897 
   900     if (iExtension)
   898     if (iExtension)
   901             {
   899             {
   902             CAknDoubleSpanScrollBarExtension* extension = static_cast<CAknDoubleSpanScrollBarExtension*> (iExtension);          
   900             CAknDoubleSpanScrollBarExtension* extension = static_cast<CAknDoubleSpanScrollBarExtension*> (iExtension);
   903 			if ( modifier && IsVisible() && !( extension->iExtensionType & ENoExpandedTouchArea ) )
   901             if ( modifier && IsVisible() && !( extension->iExtensionType & ENoExpandedTouchArea ) )
   904 				{
   902                 {
   905 				modifier->Update( *this, ExtensionArea() );
   903                 modifier->Update( *this, ExtensionArea() );
   906 				}
   904                 }
   907           }
   905           }
   908     else
   906     else
   909     	{
   907         {
   910 		if ( modifier && IsVisible()  )
   908         if ( modifier && IsVisible()  )
   911 			{
   909             {
   912 			modifier->Update( *this, ExtensionArea() );
   910             modifier->Update( *this, ExtensionArea() );
   913 			}
   911             }
   914     	}
   912         }
   915 
   913 
   916     AknsUtils::RegisterControlPosition( this );
   914     AknsUtils::RegisterControlPosition( this );
   917     if (iExtension)
   915     if (iExtension)
   918         {
   916         {
   919         CAknDoubleSpanScrollBarExtension* extension = static_cast<CAknDoubleSpanScrollBarExtension*> (iExtension);
   917         CAknDoubleSpanScrollBarExtension* extension = static_cast<CAknDoubleSpanScrollBarExtension*> (iExtension);
  1043     // clear the pointer down info on pen up and hide info popup
  1041     // clear the pointer down info on pen up and hide info popup
  1044     TInt lastPointerDownOn = extension->iPointerDownOn;
  1042     TInt lastPointerDownOn = extension->iPointerDownOn;
  1045     // The real span area available (as pixels)
  1043     // The real span area available (as pixels)
  1046     scrollSpanPix -= thumbSpanPix;
  1044     scrollSpanPix -= thumbSpanPix;
  1047 
  1045 
  1048             
  1046 
  1049          // touch release on thumb
  1047      // touch release on thumb
  1050          TBool thumbPressed = 
  1048     TBool thumbPressed =
  1051                  ( position < (thumbPositionPix + thumbSpanPix) 
  1049              ( position < (thumbPositionPix + thumbSpanPix)
  1052                          && position > thumbPositionPix );
  1050                      && position > thumbPositionPix );
  1053          if ( thumbPressed &&
  1051     if ( thumbPressed &&
  1054               aPointerEvent.iType == TPointerEvent::EButton1Up &&
  1052           aPointerEvent.iType == TPointerEvent::EButton1Up &&
  1055               thumbSpan < scrollSpan )
  1053           thumbSpan < scrollSpan )
       
  1054         {
       
  1055          MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  1056 
       
  1057          CCoeControl* parent = Parent();
       
  1058          TBool feedbackEnabled = !IsDimmed() && IsVisible();
       
  1059          if (parent && feedbackEnabled)
  1056              {
  1060              {
  1057              MTouchFeedback* feedback = MTouchFeedback::Instance();
  1061              // check the same for the parent
  1058 
  1062              feedbackEnabled = !parent->IsDimmed() && parent->IsVisible();
  1059              CCoeControl* parent = Parent();
       
  1060              TBool feedbackEnabled = !IsDimmed() && IsVisible();
       
  1061              if (parent && feedbackEnabled)
       
  1062                  {
       
  1063                  // check the same for the parent
       
  1064                  feedbackEnabled = !parent->IsDimmed() && parent->IsVisible();
       
  1065                  }
       
  1066              if ( feedback && feedbackEnabled )
       
  1067                  {
       
  1068                  feedback->InstantFeedback( this, 
       
  1069                                             ETouchFeedbackSlider, 
       
  1070                                             ETouchFeedbackVibra, 
       
  1071                                             aPointerEvent );
       
  1072                  }
       
  1073              }
  1063              }
  1074      
  1064          if ( feedback && feedbackEnabled )
       
  1065              {
       
  1066              feedback->InstantFeedback( this,
       
  1067                                         ETouchFeedbackSlider,
       
  1068                                         ETouchFeedbackVibra,
       
  1069                                         aPointerEvent );
       
  1070              }
       
  1071          }
       
  1072 
       
  1073      if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
  1074          {
       
  1075          extension->iPointerDownOn = CEikScrollBar::ENone;
       
  1076 
       
  1077          // Highlight off always when the pointer is lifted
       
  1078          indicator->SetHandleHighlight( EFalse );
       
  1079          indicator->DrawDeferred();
       
  1080          indicator->SetBackgroudHighlight( EFalse );
       
  1081 
       
  1082          if ( extension->iPopupController )
       
  1083              {
       
  1084              extension->iPopupController->HideInfoPopupNote();
       
  1085                  extension->iShowPopup = EFalse;
       
  1086              }
       
  1087          }
  1075     // check that scroll bar is useful
  1088     // check that scroll bar is useful
  1076     if (thumbSpan < scrollSpan)
  1089     if (thumbSpan < scrollSpan)
  1077         {
  1090         {
  1078         // check where the pointer down occured
  1091         // check where the pointer down occured
  1079         if(aPointerEvent.iType == TPointerEvent::EButton1Down )
  1092         if(aPointerEvent.iType == TPointerEvent::EButton1Down )
  1109                 {
  1122                 {
  1110                 extension->iPointerDownOn = CEikScrollBar::EIncreaseShaft;
  1123                 extension->iPointerDownOn = CEikScrollBar::EIncreaseShaft;
  1111                 }
  1124                 }
  1112             }
  1125             }
  1113 
  1126 
  1114         if (aPointerEvent.iType == TPointerEvent::EButton1Up)
       
  1115             {
       
  1116             extension->iPointerDownOn = CEikScrollBar::ENone;
       
  1117 
       
  1118             // Highlight off always when the pointer is lifted
       
  1119             indicator->SetHandleHighlight( EFalse );
       
  1120             indicator->DrawDeferred();
       
  1121             indicator->SetBackgroudHighlight( EFalse );
       
  1122 
       
  1123             if ( extension->iPopupController )
       
  1124                 {
       
  1125                 extension->iPopupController->HideInfoPopupNote();
       
  1126                     extension->iShowPopup = EFalse;
       
  1127                 }
       
  1128             }
       
  1129 
       
  1130         // respond to the pointer event
  1127         // respond to the pointer event
  1131         switch(extension->iPointerDownOn)
  1128         switch(extension->iPointerDownOn)
  1132             {
  1129             {
  1133             case CEikScrollBar::EDecreaseShaft:
  1130             case CEikScrollBar::EDecreaseShaft:
  1134             case CEikScrollBar::EIncreaseShaft:
  1131             case CEikScrollBar::EIncreaseShaft:
  1143                         thumbPosition -= thumbSpan;
  1140                         thumbPosition -= thumbSpan;
  1144                         thumbPosition = Max(0, thumbPosition);
  1141                         thumbPosition = Max(0, thumbPosition);
  1145 
  1142 
  1146 
  1143 
  1147                         TInt prevPosValue = extension->ThumbPosition();
  1144                         TInt prevPosValue = extension->ThumbPosition();
  1148                         
  1145 
  1149                         // This will update the thumb's pixel extent, used
  1146                         // This will update the thumb's pixel extent, used
  1150                         // below
  1147                         // below
  1151                         extension->SetModelThumbPosition(thumbPosition);
  1148                         extension->SetModelThumbPosition(thumbPosition);
  1152                         indicator->SetIndicatorValues(scrollSpan, thumbPosition, thumbSpan, 0, 0);
  1149                         indicator->SetIndicatorValues(scrollSpan, thumbPosition, thumbSpan, 0, 0);
  1153 
  1150 
  1186                                 ignoreRect.iBr = TPoint(newThumbPosPix, rt.iBr.iY);
  1183                                 ignoreRect.iBr = TPoint(newThumbPosPix, rt.iBr.iY);
  1187                                 }
  1184                                 }
  1188                             // repeat until thumb reaches the stylus down position
  1185                             // repeat until thumb reaches the stylus down position
  1189                             pointerWindow->RequestPointerRepeatEvent(KScrollRepeatTimeout, ignoreRect);
  1186                             pointerWindow->RequestPointerRepeatEvent(KScrollRepeatTimeout, ignoreRect);
  1190                             }
  1187                             }
  1191                         
  1188 
  1192 
  1189 
  1193                         }
  1190                         }
  1194                     else
  1191                     else
  1195                         {
  1192                         {
  1196                         event = iOrientation==EHorizontal ? EEikScrollPageRight : EEikScrollPageDown;
  1193                         event = iOrientation==EHorizontal ? EEikScrollPageRight : EEikScrollPageDown;
  1237                                 }
  1234                                 }
  1238                             // repeat until thumb reaches the stylus down position
  1235                             // repeat until thumb reaches the stylus down position
  1239                             pointerWindow->RequestPointerRepeatEvent(KScrollRepeatTimeout, ignoreRect);
  1236                             pointerWindow->RequestPointerRepeatEvent(KScrollRepeatTimeout, ignoreRect);
  1240 
  1237 
  1241                             }
  1238                             }
  1242                         
  1239 
  1243                         }
  1240                         }
  1244 
  1241 
  1245                     if(indicator->DrawBackgroundState())
  1242                     if(indicator->DrawBackgroundState())
  1246                         indicator->DrawNow();
  1243                         indicator->DrawNow();
  1247                     else
  1244                     else
  1261                     {
  1258                     {
  1262                     MTouchFeedback* feedback = MTouchFeedback::Instance();
  1259                     MTouchFeedback* feedback = MTouchFeedback::Instance();
  1263 
  1260 
  1264                     if ( feedback )
  1261                     if ( feedback )
  1265                         {
  1262                         {
  1266                         TTouchFeedbackType fbType = TTouchFeedbackType( 
  1263                         TTouchFeedbackType fbType = TTouchFeedbackType(
  1267                                                         ETouchFeedbackAudio |
  1264                                                         ETouchFeedbackAudio |
  1268                                                         ETouchFeedbackVibra );
  1265                                                         ETouchFeedbackVibra );
  1269                           
  1266 
  1270                         feedback->InstantFeedback( this, ETouchFeedbackSlider, fbType, aPointerEvent );
  1267                         feedback->InstantFeedback( this, ETouchFeedbackSlider, fbType, aPointerEvent );
  1271                         }
  1268                         }
  1272                     }
  1269                     }
  1273 
  1270 
  1274                 if( aPointerEvent.iType == TPointerEvent::EDrag 
  1271                 if( aPointerEvent.iType == TPointerEvent::EDrag
  1275                    || aPointerEvent.iType == TPointerEvent::EButtonRepeat )
  1272                    || aPointerEvent.iType == TPointerEvent::EButtonRepeat )
  1276                     {
  1273                     {
  1277                     // performace improving. Too many drag event received, handling every single event 
  1274                     // performace improving. Too many drag event received, handling every single event
  1278                     // will use too much CPU time.
  1275                     // will use too much CPU time.
  1279                     TTime now;
  1276                     TTime now;
  1280                     now.HomeTime();                    
  1277                     now.HomeTime();
  1281                     if ( extension->iDragged &&
  1278                     if ( extension->iDragged &&
  1282                          now.MicroSecondsFrom( extension->iLastDrag ) 
  1279                          now.MicroSecondsFrom( extension->iLastDrag )
  1283                          < KScrollDragTimeout )
  1280                          < KScrollDragTimeout )
  1284                         {                        
  1281                         {
  1285                         break; // ignore drag for this time
  1282                         break; // ignore drag for this time
  1286                         }
  1283                         }
  1287                     extension->iDragged = ETrue; // after this time, iLastDragged has value.
  1284                     extension->iDragged = ETrue; // after this time, iLastDragged has value.
  1288                     extension->iLastDrag = now;
  1285                     extension->iLastDrag = now;
  1289                     
  1286 
  1290                     thumbPositionPix = position - extension->iPointerOffsetFromThumb;
  1287                     thumbPositionPix = position - extension->iPointerOffsetFromThumb;
  1291                     TInt oldPosition = thumbPosition;
  1288                     TInt oldPosition = thumbPosition;
  1292                     TReal newPosition = thumbPositionPix * ( scrollSpan - thumbSpan ) / (TReal)scrollSpanPix;
  1289                     TReal newPosition = thumbPositionPix * ( scrollSpan - thumbSpan ) / (TReal)scrollSpanPix;
  1293                     thumbPosition = newPosition;
  1290                     thumbPosition = newPosition;
  1294 
  1291 
  1302                     thumbPosition = Max(0, thumbPosition);
  1299                     thumbPosition = Max(0, thumbPosition);
  1303                     thumbPosition = Min((scrollSpan - thumbSpan), thumbPosition);
  1300                     thumbPosition = Min((scrollSpan - thumbSpan), thumbPosition);
  1304 
  1301 
  1305                     if(thumbPosition != oldPosition)
  1302                     if(thumbPosition != oldPosition)
  1306                         {
  1303                         {
  1307                         // Smooth continuous tactile feedback is produced
       
  1308                         // during thumb dragging. The tactile feedback API 
       
  1309                         // filters out possible re-startings of the effect.
       
  1310                         MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  1311 
       
  1312                         if ( feedback )
       
  1313                             {
       
  1314                             TTimeIntervalMicroSeconds32 timeout( 300000 );
       
  1315                             feedback->StartFeedback( this, 
       
  1316                                                      ETouchContinuousSlider, 
       
  1317                                                      &aPointerEvent, 
       
  1318                                                      KIntensity, // intensity 100%
       
  1319                                                      timeout );
       
  1320                             }
       
  1321                         extension->SetModelThumbPosition(thumbPosition);
  1304                         extension->SetModelThumbPosition(thumbPosition);
  1322                         indicator->SetIndicatorValues(scrollSpan, thumbPosition, thumbSpan, 0, 0);
  1305                         indicator->SetIndicatorValues(scrollSpan, thumbPosition, thumbSpan, 0, 0);
  1323 
  1306 
  1324                         if(indicator->DrawBackgroundState())
  1307                         if(indicator->DrawBackgroundState())
  1325                             indicator->DrawNow();
  1308                             indicator->DrawNow();
  1365                         }
  1348                         }
  1366                     }
  1349                     }
  1367                 break;
  1350                 break;
  1368 
  1351 
  1369             case CEikScrollBar::ENone:
  1352             case CEikScrollBar::ENone:
  1370                 {
       
  1371                 // Stop the continuous tactile feedback that may be playing
       
  1372                 // at the time due to possible previous thumb dragging.
       
  1373                 MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  1374 
       
  1375                 if ( feedback )
       
  1376                     {
       
  1377                     feedback->StopFeedback( this );
       
  1378                     }
       
  1379                 }
       
  1380 
       
  1381                 if(lastPointerDownOn == CEikScrollBar::EThumb)
  1353                 if(lastPointerDownOn == CEikScrollBar::EThumb)
  1382                     {
  1354                     {
  1383                     if(extension->ScrollBarObserver())
  1355                     if(extension->ScrollBarObserver())
  1384                         {
  1356                         {
  1385                         extension->ScrollBarObserver()->HandleScrollEventL(
  1357                         extension->ScrollBarObserver()->HandleScrollEventL(
  1588 //
  1560 //
  1589 void CAknDoubleSpanScrollBar::ResetPressedDownHighlight()
  1561 void CAknDoubleSpanScrollBar::ResetPressedDownHighlight()
  1590     {
  1562     {
  1591     CAknDoubleSpanScrollBarExtension* extension =
  1563     CAknDoubleSpanScrollBarExtension* extension =
  1592         static_cast<CAknDoubleSpanScrollBarExtension*>( iExtension );
  1564         static_cast<CAknDoubleSpanScrollBarExtension*>( iExtension );
  1593         
  1565 
  1594     CAknDoubleSpanScrollIndicator* indicator = extension->iScrollIndicator;
  1566     CAknDoubleSpanScrollIndicator* indicator = extension->iScrollIndicator;
  1595     
  1567 
  1596     indicator->SetHandleHighlight( EFalse );
  1568     indicator->SetHandleHighlight( EFalse );
  1597     }
  1569     }
  1598 
  1570 
  1599 
  1571 
  1600 //
  1572 //
  1771                         iActiveScheduledDraw->Start(TCallBack(ScheduledDraw,this));
  1743                         iActiveScheduledDraw->Start(TCallBack(ScheduledDraw,this));
  1772                     }
  1744                     }
  1773                 }
  1745                 }
  1774             else
  1746             else
  1775                 {
  1747                 {
  1776                 iParent->DrawDeferred();                 
  1748                 iParent->DrawDeferred();
  1777                 }
  1749                 }
  1778 
  1750 
  1779             }
  1751             }
  1780         }
  1752         }
  1781     }
  1753     }
  2343     {
  2315     {
  2344     // Usage of hard-coded parent rectangle is acceptable since we're
  2316     // Usage of hard-coded parent rectangle is acceptable since we're
  2345     // interested in only about the ratio between scrollbar and extension.
  2317     // interested in only about the ratio between scrollbar and extension.
  2346     TAknLayoutRect layoutRect;
  2318     TAknLayoutRect layoutRect;
  2347     layoutRect.LayoutRect( TRect( 0, 0, 200, 200 ), AknLayoutScalable_Avkon::listscroll_gen_pane( 0 ).LayoutLine() );
  2319     layoutRect.LayoutRect( TRect( 0, 0, 200, 200 ), AknLayoutScalable_Avkon::listscroll_gen_pane( 0 ).LayoutLine() );
  2348     
  2320 
  2349     TRect parent( layoutRect.Rect() ); // parent of both extension and scrollbar
  2321     TRect parent( layoutRect.Rect() ); // parent of both extension and scrollbar
  2350     
  2322 
  2351     layoutRect.LayoutRect( parent, AknLayoutScalable_Avkon::scroll_pane( 0 ).LayoutLine() );
  2323     layoutRect.LayoutRect( parent, AknLayoutScalable_Avkon::scroll_pane( 0 ).LayoutLine() );
  2352     
  2324 
  2353     TRect scrollbar( layoutRect.Rect() );
  2325     TRect scrollbar( layoutRect.Rect() );
  2354     
  2326 
  2355     CAknDoubleSpanScrollBarExtension* extension1 = static_cast<CAknDoubleSpanScrollBarExtension*> (iExtension);
  2327     CAknDoubleSpanScrollBarExtension* extension1 = static_cast<CAknDoubleSpanScrollBarExtension*> (iExtension);
  2356     if( extension1->iExtensionType & ENormalExpandedTouchArea )
  2328     if( extension1->iExtensionType & ENormalExpandedTouchArea )
  2357         layoutRect.LayoutRect( parent, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar( 0 ).LayoutLine() );
  2329         layoutRect.LayoutRect( parent, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar( 0 ).LayoutLine() );
  2358     else if( extension1->iExtensionType & EScaleExpandedTouchArea )
  2330     else if( extension1->iExtensionType & EScaleExpandedTouchArea )
  2359         layoutRect.LayoutRect( parent, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar_cale( 0 ).LayoutLine() );
  2331         layoutRect.LayoutRect( parent, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar_cale( 0 ).LayoutLine() );
  2360     else
  2332     else
  2361         layoutRect.LayoutRect( parent, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar( 0 ).LayoutLine() );
  2333         layoutRect.LayoutRect( parent, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar( 0 ).LayoutLine() );
  2362     TRect extension( layoutRect.Rect() );
  2334     TRect extension( layoutRect.Rect() );
  2363 
  2335 
  2364     TRect area;
  2336     TRect area;
  2365     
  2337 
  2366     if ( iParentControl )
  2338     if ( iParentControl )
  2367         {
  2339         {
  2368         CCoeControl* windowOwningParent = iParentControl;
  2340         CCoeControl* windowOwningParent = iParentControl;
  2369         while ( windowOwningParent && !windowOwningParent->OwnsWindow() )
  2341         while ( windowOwningParent && !windowOwningParent->OwnsWindow() )
  2370             {
  2342             {
  2371             windowOwningParent = windowOwningParent->Parent();
  2343             windowOwningParent = windowOwningParent->Parent();
  2372             }       
  2344             }
  2373         
  2345 
  2374         if ( windowOwningParent )
  2346         if ( windowOwningParent )
  2375             {
  2347             {
  2376             TInt xGap = 0;
  2348             TInt xGap = 0;
  2377             TRect scrollBarRect = Rect();   
  2349             TRect scrollBarRect = Rect();
  2378             TRect parentRect = windowOwningParent->Rect();
  2350             TRect parentRect = windowOwningParent->Rect();
  2379                                
  2351 
  2380             if ( OwnsWindow() ) 
  2352             if ( OwnsWindow() )
  2381                 {
  2353                 {
  2382                 scrollBarRect.Move( Position().iX - 
  2354                 scrollBarRect.Move( Position().iX -
  2383                     windowOwningParent->Position().iX, 0 );
  2355                     windowOwningParent->Position().iX, 0 );
  2384                 } 
  2356                 }
  2385             if ( iOrientation == CEikScrollBar::EVertical )
  2357             if ( iOrientation == CEikScrollBar::EVertical )
  2386             	{
  2358                 {
  2387 				// left to right layout in use
  2359                 // left to right layout in use
  2388 				if ( !AknLayoutUtils::LayoutMirrored() )
  2360                 if ( !AknLayoutUtils::LayoutMirrored() )
  2389 					{
  2361                     {
  2390 					xGap = parentRect.iBr.iX - scrollBarRect.iBr.iX;  
  2362                     xGap = parentRect.iBr.iX - scrollBarRect.iBr.iX;
  2391 					if ( Abs( xGap ) < scrollBarRect.Width() )
  2363                     if ( Abs( xGap ) < scrollBarRect.Width() )
  2392 						{
  2364                         {
  2393 						extension.iBr.iX += xGap;
  2365                         extension.iBr.iX += xGap;
  2394 						}				
  2366                         }
  2395 					}
  2367                     }
  2396 				// right to left layout in use
  2368                 // right to left layout in use
  2397 				else
  2369                 else
  2398 					{				
  2370                     {
  2399 					xGap = parentRect.iTl.iX - scrollBarRect.iTl.iX;
  2371                     xGap = parentRect.iTl.iX - scrollBarRect.iTl.iX;
  2400 					if ( Abs( xGap ) < scrollBarRect.Width() )
  2372                     if ( Abs( xGap ) < scrollBarRect.Width() )
  2401 						{
  2373                         {
  2402 						extension.iTl.iX += xGap;
  2374                         extension.iTl.iX += xGap;
  2403 						}
  2375                         }
  2404 					} 
  2376                     }
  2405             	}
  2377                 }
  2406             else
  2378             else
  2407             	{
  2379                 {
  2408 				xGap = parentRect.iBr.iY - scrollBarRect.iBr.iY;  
  2380                 xGap = parentRect.iBr.iY - scrollBarRect.iBr.iY;
  2409 				if ( Abs( xGap ) < scrollBarRect.Height() )
  2381                 if ( Abs( xGap ) < scrollBarRect.Height() )
  2410 					{
  2382                     {
  2411 					extension.iBr.iY += xGap;
  2383                     extension.iBr.iY += xGap;
  2412 					}
  2384                     }
  2413             	}             
  2385                 }
  2414             }
  2386             }
  2415         }     
  2387         }
  2416     
  2388 
  2417     if ( iOrientation == CEikScrollBar::EVertical )
  2389     if ( iOrientation == CEikScrollBar::EVertical )
  2418         {
  2390         {
  2419         area.iTl.iX = extension.iTl.iX - scrollbar.iTl.iX;
  2391         area.iTl.iX = extension.iTl.iX - scrollbar.iTl.iX;
  2420         area.iTl.iY = scrollbar.iTl.iY - extension.iTl.iY;
  2392         area.iTl.iY = scrollbar.iTl.iY - extension.iTl.iY;
  2421         area.iBr.iX = area.iTl.iX + extension.Width();
  2393         area.iBr.iX = area.iTl.iX + extension.Width();
  2424     else
  2396     else
  2425         {
  2397         {
  2426         area.iTl.iX = scrollbar.iTl.iY - extension.iTl.iY;
  2398         area.iTl.iX = scrollbar.iTl.iY - extension.iTl.iY;
  2427         area.iTl.iY = scrollbar.Width() - extension.Width();
  2399         area.iTl.iY = scrollbar.Width() - extension.Width();
  2428         area.iBr.iX = iSize.iWidth + ( extension.Height() - scrollbar.Height() );
  2400         area.iBr.iX = iSize.iWidth + ( extension.Height() - scrollbar.Height() );
  2429         area.iBr.iY = area.iTl.iY + extension.Height();
  2401         area.iBr.iY = area.iTl.iY + extension.Width();
  2430         }
  2402         }
  2431     
  2403 
  2432     return area;
  2404     return area;
  2433     }
  2405     }
  2434 
  2406