textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutbasecontrol.cpp
branchRCL_3
changeset 11 c8fb4cf7b3ae
parent 9 e6a39382bb9c
child 12 5e18d8c489d6
equal deleted inserted replaced
9:e6a39382bb9c 11:c8fb4cf7b3ae
    57                         iAllowOverlap(EFalse),
    57                         iAllowOverlap(EFalse),
    58                         iUiLayout(aUiLayout),
    58                         iUiLayout(aUiLayout),
    59                         iOwnWndCtrl(ETrue),
    59                         iOwnWndCtrl(ETrue),
    60                         iOrdinalPos(EOrderNomal)
    60                         iOrdinalPos(EOrderNomal)
    61     {
    61     {
    62 #ifdef RD_TACTILE_FEEDBACK
    62     //todo code refactoring needed, move to BaseConstructL
    63     iReservered1 = reinterpret_cast<TInt>(new CFepUiBaseCtrlExtension(ETouchFeedbackNone));
    63     iExtension = new CFepUiBaseCtrlExtension();
    64 #endif // RD_TACTILE_FEEDBACK    
    64    
    65     iPenSize.SetSize(1,1);        
    65     iPenSize.SetSize(1,1);        
    66     iBorderSize.SetSize(KDefaultFrameWidth,KDefaultFrameWidth);
    66     iBorderSize.SetSize(KDefaultFrameWidth,KDefaultFrameWidth);
    67     iValidRegion.AddRect(iRect);
    67     iValidRegion.AddRect(iRect);
    68     iClipRegion.AddRect(iRect);
    68     iClipRegion.AddRect(iRect);
    69     }
    69     }
    92                     iIsActive(EFalse),
    92                     iIsActive(EFalse),
    93                     iAllowOverlap(EFalse),
    93                     iAllowOverlap(EFalse),
    94                     iUiLayout(aUiLayout),
    94                     iUiLayout(aUiLayout),
    95                     iOwnWndCtrl(aOwnership)
    95                     iOwnWndCtrl(aOwnership)
    96     {
    96     {
    97 #ifdef RD_TACTILE_FEEDBACK
    97     //todo code refactoring needed, move to BaseConstructL
    98     iReservered1 = reinterpret_cast<TInt>(new CFepUiBaseCtrlExtension(ETouchFeedbackNone));
    98     iExtension = new CFepUiBaseCtrlExtension();
    99 #endif // RD_TACTILE_FEEDBACK
    99     
   100     iRect = aControl->Rect();
   100     iRect = aControl->Rect();
   101     iControlId = aControl->UniqueHandle();
   101     iControlId = aControl->UniqueHandle();
   102     iValidRegion.AddRect(iRect);
   102     iValidRegion.AddRect(iRect);
   103     iClipRegion.AddRect(iRect);
   103     iClipRegion.AddRect(iRect);
   104     }
   104     }
   126     
   126     
   127 #ifdef RD_TACTILE_FEEDBACK     
   127 #ifdef RD_TACTILE_FEEDBACK     
   128     //de-register the area for tactile feedback
   128     //de-register the area for tactile feedback
   129     //if(aUiLayout) //there must be aUiLayout
   129     //if(aUiLayout) //there must be aUiLayout
   130     UiLayout()->DeRegisterFeedbackArea(reinterpret_cast<TInt>(this), Rect());   
   130     UiLayout()->DeRegisterFeedbackArea(reinterpret_cast<TInt>(this), Rect());   
   131 	delete reinterpret_cast<CFepUiBaseCtrlExtension*>(iReservered1);       
       
   132 #endif // RD_TACTILE_FEEDBACK 
   131 #endif // RD_TACTILE_FEEDBACK 
       
   132     
       
   133     delete iExtension; 
   133     }
   134     }
   134 
   135 
   135 // ---------------------------------------------------------------------------
   136 // ---------------------------------------------------------------------------
   136 // CFepUiBaseCtrl::BaseConstructL
   137 // CFepUiBaseCtrl::BaseConstructL
   137 // Handle UI event
   138 // Handle UI event
   182 // ---------------------------------------------------------------------------
   183 // ---------------------------------------------------------------------------
   183 //
   184 //
   184 EXPORT_C void CFepUiBaseCtrl::SetTactileFeedbackType(TInt aTactileType)
   185 EXPORT_C void CFepUiBaseCtrl::SetTactileFeedbackType(TInt aTactileType)
   185 	{
   186 	{
   186 #ifdef RD_TACTILE_FEEDBACK
   187 #ifdef RD_TACTILE_FEEDBACK
   187 	reinterpret_cast<CFepUiBaseCtrlExtension*>(iReservered1)->SetTactileFeedbackType(aTactileType);
   188     iExtension->SetTactileFeedbackType(aTactileType);
   188 #endif // RD_TACTILE_FEEDBACK 
   189 #endif // RD_TACTILE_FEEDBACK 
   189 	}
   190 	}
   190 
   191 
   191 
   192 
   192 // ---------------------------------------------------------------------------
   193 // ---------------------------------------------------------------------------
   533 // (other items were commented in a header).
   534 // (other items were commented in a header).
   534 // ---------------------------------------------------------------------------
   535 // ---------------------------------------------------------------------------
   535 //           
   536 //           
   536 EXPORT_C TBool CFepUiBaseCtrl::Contains(const TPoint& aPt)
   537 EXPORT_C TBool CFepUiBaseCtrl::Contains(const TPoint& aPt)
   537     {
   538     {
       
   539     if( iExtension->iExtResponseAreaActive )
       
   540         {
       
   541         return iExtension->iExtResponseArea.Contains( aPt );
       
   542         }
       
   543    
   538     return iRect.Contains(aPt);
   544     return iRect.Contains(aPt);
   539     //return iValidRegion.Contains(aPt);
   545     //return iValidRegion.Contains(aPt);
   540     }
   546     }
   541 
   547 
   542 // ---------------------------------------------------------------------------
   548 // ---------------------------------------------------------------------------
   763 // (other items were commented in a header).
   769 // (other items were commented in a header).
   764 // ---------------------------------------------------------------------------
   770 // ---------------------------------------------------------------------------
   765 //      
   771 //      
   766 EXPORT_C CFepUiBaseCtrl* CFepUiBaseCtrl::HandlePointerDownEventL(const TPoint& aPoint)
   772 EXPORT_C CFepUiBaseCtrl* CFepUiBaseCtrl::HandlePointerDownEventL(const TPoint& aPoint)
   767     {
   773     {
       
   774     if ( iExtension->iExtResponseAreaEnabled ) 
       
   775         {
       
   776         ActiveExtResponseArea();
       
   777         }
       
   778     
   768     iPointerDown = ETrue;
   779     iPointerDown = ETrue;
   769     if(iWndControl)
   780     if(iWndControl)
   770         {
   781         {
   771         TPointerEvent event;
   782         TPointerEvent event;
   772         event.iType = TPointerEvent::EButton1Down;
   783         event.iType = TPointerEvent::EButton1Down;
   787 // ---------------------------------------------------------------------------
   798 // ---------------------------------------------------------------------------
   788 //    
   799 //    
   789 EXPORT_C CFepUiBaseCtrl* CFepUiBaseCtrl::HandlePointerUpEventL(
   800 EXPORT_C CFepUiBaseCtrl* CFepUiBaseCtrl::HandlePointerUpEventL(
   790                                                          const TPoint& aPoint)
   801                                                          const TPoint& aPoint)
   791     {
   802     {
       
   803     if ( iExtension->iExtResponseAreaActive )
       
   804         {
       
   805         CancelExtResponseArea();
       
   806         }
       
   807     
   792     iPointerDown = EFalse;
   808     iPointerDown = EFalse;
   793     if(iWndControl)
   809     if(iWndControl)
   794         {
   810         {
   795         TPointerEvent event;
   811         TPointerEvent event;
   796         event.iType = TPointerEvent::EButton1Up;
   812         event.iType = TPointerEvent::EButton1Up;
   841 // (other items were commented in a header).
   857 // (other items were commented in a header).
   842 // ---------------------------------------------------------------------------
   858 // ---------------------------------------------------------------------------
   843 //    
   859 //    
   844 EXPORT_C void CFepUiBaseCtrl::CancelPointerDownL()
   860 EXPORT_C void CFepUiBaseCtrl::CancelPointerDownL()
   845     {
   861     {
       
   862     if ( iExtension->iExtResponseAreaActive )
       
   863         {
       
   864         CancelExtResponseArea();
       
   865         }
       
   866     
   846     if (PointerDown())
   867     if (PointerDown())
   847         {
   868         {
   848         iPointerDown = EFalse;
   869         iPointerDown = EFalse;
   849         iPointerLeft = EFalse;
   870         iPointerLeft = EFalse;
   850         //HandlePointerLeave(TPoint(0, 0));
   871         //HandlePointerLeave(TPoint(0, 0));
   984 // Handle pointer leave event
  1005 // Handle pointer leave event
   985 // ---------------------------------------------------------------------------
  1006 // ---------------------------------------------------------------------------
   986 //           
  1007 //           
   987 EXPORT_C void CFepUiBaseCtrl::HandlePointerLeave(const TPoint& /*aPt*/)
  1008 EXPORT_C void CFepUiBaseCtrl::HandlePointerLeave(const TPoint& /*aPt*/)
   988     {
  1009     {
       
  1010     if ( iExtension->iExtResponseAreaActive )
       
  1011         {
       
  1012         CancelExtResponseArea();
       
  1013         }
       
  1014     
   989     iPointerDown = EFalse;
  1015     iPointerDown = EFalse;
   990     iPointerLeft = ETrue;
  1016     iPointerLeft = ETrue;
   991     //report event
  1017     //report event
   992     ReportEvent(EEventPointerLeftControl);
  1018     ReportEvent(EEventPointerLeftControl);
   993     Draw();
  1019     Draw();
   998 // Handle pointer enter event
  1024 // Handle pointer enter event
   999 // ---------------------------------------------------------------------------
  1025 // ---------------------------------------------------------------------------
  1000 //           
  1026 //           
  1001 EXPORT_C void CFepUiBaseCtrl::HandlePointerEnter(const TPoint& aPt)
  1027 EXPORT_C void CFepUiBaseCtrl::HandlePointerEnter(const TPoint& aPt)
  1002     {
  1028     {
       
  1029     if ( iExtension->iExtResponseAreaEnabled ) 
       
  1030         {
       
  1031         ActiveExtResponseArea();
       
  1032         }
       
  1033     
  1003     iPointerDown = ETrue;
  1034     iPointerDown = ETrue;
  1004     iPointerLeft = EFalse;
  1035     iPointerLeft = EFalse;
  1005     TRAP_IGNORE(HandlePointerMoveEventL(aPt));
  1036     TRAP_IGNORE(HandlePointerMoveEventL(aPt));
  1006     //report event
  1037     //report event
  1007     ReportEvent(EEventPointerEnterControl);
  1038     ReportEvent(EEventPointerEnterControl);
  1332     if(ParentCtrl())
  1363     if(ParentCtrl())
  1333         order += ParentCtrl()->AbsOrderPos();
  1364         order += ParentCtrl()->AbsOrderPos();
  1334     return order;    
  1365     return order;    
  1335     }
  1366     }
  1336 
  1367 
  1337 
  1368 // ---------------------------------------------------------------------------
       
  1369 // CFepUiBaseCtrl::EnableExtResponseArea
       
  1370 // Enable/disable extra response area support
       
  1371 // ---------------------------------------------------------------------------
       
  1372 //  
       
  1373 EXPORT_C void CFepUiBaseCtrl::EnableExtResponseArea( TBool aEnable, 
       
  1374                                                      const TRect& aExtMargin )
       
  1375     {
       
  1376     iExtension->iExtResponseAreaEnabled = aEnable;
       
  1377     iExtension->iExtResponseAreaMargin = aExtMargin;
       
  1378     }
       
  1379 
       
  1380 // ---------------------------------------------------------------------------
       
  1381 // CFepUiBaseCtrl::EnableExtResponseArea
       
  1382 // Active extra response area
       
  1383 // ---------------------------------------------------------------------------
       
  1384 //  
       
  1385 EXPORT_C void CFepUiBaseCtrl::ActiveExtResponseArea()
       
  1386     {
       
  1387     if ( iExtension->iExtResponseAreaEnabled )
       
  1388         {
       
  1389         TRect response = Rect();
       
  1390         response.iTl -= iExtension->iExtResponseAreaMargin.iTl;
       
  1391         response.iBr += iExtension->iExtResponseAreaMargin.Size();
       
  1392         
       
  1393         UpdateExtResponseArea( response );
       
  1394         }    
       
  1395     }
       
  1396 
       
  1397 // ---------------------------------------------------------------------------
       
  1398 // CFepUiBaseCtrl::EnableExtResponseArea
       
  1399 // Cancel extra response area
       
  1400 // ---------------------------------------------------------------------------
       
  1401 //  
       
  1402 EXPORT_C void CFepUiBaseCtrl::CancelExtResponseArea()
       
  1403     {
       
  1404     iExtension->iExtResponseAreaActive = EFalse;
       
  1405     
       
  1406     CFepUiBaseCtrl* parent = ParentCtrl();
       
  1407     if( parent && parent->IsKindOfControl(ECtrlControlGroup) )
       
  1408         {
       
  1409         parent->CancelExtResponseArea();
       
  1410         }    
       
  1411     }
       
  1412 
       
  1413 // ---------------------------------------------------------------------------
       
  1414 // CFepUiBaseCtrl::EnableExtResponseArea
       
  1415 // Update extra response area
       
  1416 // ---------------------------------------------------------------------------
       
  1417 //
       
  1418 void CFepUiBaseCtrl::UpdateExtResponseArea( const TRect& aRect )
       
  1419     {
       
  1420     if ( aRect.iTl.iX < Rect().iTl.iX || aRect.iTl.iY < Rect().iTl.iY ||
       
  1421          aRect.iBr.iX > Rect().iBr.iX || aRect.iBr.iY > Rect().iBr.iY )
       
  1422         {
       
  1423         iExtension->iExtResponseAreaActive = ETrue;
       
  1424         iExtension->iExtResponseArea = Rect();
       
  1425         iExtension->iExtResponseArea.BoundingRect( aRect );
       
  1426 
       
  1427         //update parent
       
  1428         CFepUiBaseCtrl* parent = ParentCtrl();
       
  1429         if ( parent && parent->IsKindOfControl( ECtrlControlGroup ) )
       
  1430             {
       
  1431             parent->UpdateExtResponseArea( iExtension->iExtResponseArea );
       
  1432             }
       
  1433         }
       
  1434     }
  1338 
  1435 
  1339 // ---------------------------------------------------------------------------
  1436 // ---------------------------------------------------------------------------
  1340 // CFepUiBaseCtrl::CFepUiBaseCtrlExtension
  1437 // CFepUiBaseCtrl::CFepUiBaseCtrlExtension
  1341 // 
  1438 // 
  1342 // ---------------------------------------------------------------------------
  1439 // ---------------------------------------------------------------------------
  1343 //
  1440 //
  1344 
  1441 
  1345 CFepUiBaseCtrl::CFepUiBaseCtrlExtension::CFepUiBaseCtrlExtension(TInt aTactileType)
  1442 CFepUiBaseCtrl::CFepUiBaseCtrlExtension::CFepUiBaseCtrlExtension()
  1346 	{
  1443 	{
  1347 #ifdef RD_TACTILE_FEEDBACK
  1444 #ifdef RD_TACTILE_FEEDBACK
  1348 	iTactileType = aTactileType;
  1445 	iTactileType = ETouchFeedbackNone;
  1349 #endif // RD_TACTILE_FEEDBACK 
  1446 #endif // RD_TACTILE_FEEDBACK 
       
  1447 	
       
  1448 	//temp code, can be removed after refactoring of CFepUiBaseCtrl::iExtension
       
  1449     iExtResponseAreaActive = EFalse;
       
  1450     iExtResponseArea.SetRect( TPoint(0,0), TSize(0,0) );
       
  1451     iExtResponseAreaEnabled = EFalse;
       
  1452     iExtResponseAreaMargin.SetRect( TPoint(0,0), TSize(0,0) );
  1350 	}
  1453 	}
  1351 
  1454 
  1352 void CFepUiBaseCtrl::CFepUiBaseCtrlExtension::SetTactileFeedbackType(TInt aTactileType)
  1455 void CFepUiBaseCtrl::CFepUiBaseCtrlExtension::SetTactileFeedbackType(TInt aTactileType)
  1353 	{
  1456 	{
  1354 #ifdef RD_TACTILE_FEEDBACK
  1457 #ifdef RD_TACTILE_FEEDBACK