textinput/peninputcommonctrls/src/peninputbuttons/peninputbutton.cpp
branchRCL_3
changeset 12 5e18d8c489d6
parent 9 e6a39382bb9c
child 13 1bbdde98cc2d
equal deleted inserted replaced
11:c8fb4cf7b3ae 12:5e18d8c489d6
    33 #include <peninputrawkeybutton.h>
    33 #include <peninputrawkeybutton.h>
    34 #include <peninputcommonbutton.h>
    34 #include <peninputcommonbutton.h>
    35 #include <peninputmultiimagebutton.h>
    35 #include <peninputmultiimagebutton.h>
    36 #include <peninputcommonctrls.hrh>
    36 #include <peninputcommonctrls.hrh>
    37 #include <peninputcommonlayoutglobalenum.h>
    37 #include <peninputcommonlayoutglobalenum.h>
       
    38 #include <peninputlongpressbutton.h>
    38 
    39 
    39 const TInt KInvalidBmp = -1 ;
    40 const TInt KInvalidBmp = -1 ;
    40 
    41 
    41 //default value for long press timer
    42 //default value for long press timer
    42 const TInt KLongPressInterval = 600000;
    43 const TInt KLongPressInterval = 600000;
  2452 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlRepeatButton::HandlePointerDownEventL(const TPoint& aPt)
  2453 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlRepeatButton::HandlePointerDownEventL(const TPoint& aPt)
  2453     {
  2454     {
  2454     //PRINTF((_L("CAknFepCtrlRepeatButton::HandleButtonDown()\n")));
  2455     //PRINTF((_L("CAknFepCtrlRepeatButton::HandleButtonDown()\n")));
  2455     
  2456     
  2456     //PRINTF((_L("Set long press Timer\n")));
  2457     //PRINTF((_L("Set long press Timer\n")));
       
  2458     if( IsDimmed() )
       
  2459     	{
       
  2460     	return NULL;
       
  2461     	}
  2457     iLongPressTimer->SetTimer(iLongPressInterval);
  2462     iLongPressTimer->SetTimer(iLongPressInterval);
  2458     TInt unicode = Unicode();
  2463     TInt unicode = Unicode();
  2459     TPtrC ptr = (TUint16*)(&unicode);
  2464     TPtrC ptr = (TUint16*)(&unicode);
  2460     ReportEvent(Event(), ptr);  
  2465     ReportEvent(Event(), ptr);  
  2461     return CAknFepCtrlCommonButton::HandlePointerDownEventL(aPt);
  2466     return CAknFepCtrlCommonButton::HandlePointerDownEventL(aPt);
  4097     CButtonBase::Move(aOffset);
  4102     CButtonBase::Move(aOffset);
  4098     iForground1BmpRect.Move( aOffset );
  4103     iForground1BmpRect.Move( aOffset );
  4099     iForground2BmpRect.Move( aOffset );
  4104     iForground2BmpRect.Move( aOffset );
  4100     }
  4105     }
  4101 
  4106 
       
  4107 // ---------------------------------------------------------
       
  4108 // Constructor
       
  4109 // ---------------------------------------------------------
       
  4110 //
       
  4111 EXPORT_C CAknFepCtrlLongPressButton* CAknFepCtrlLongPressButton::NewLC(CFepUiLayout* aUiLayout, 
       
  4112                                                                  TInt aCtrlId,
       
  4113                                                                  TInt aEvent,
       
  4114                                                                  TInt aUnicode,
       
  4115                                                                  TAknsItemID aNormalID,
       
  4116                                                                  TAknsItemID aPressedID,
       
  4117                                                                  TAknsItemID aInactiveID)
       
  4118     {
       
  4119     //PRINTF((_L("CAknFepCtrlLongPressButton::NewLC(), aCtrlId = %d\n"), aCtrlId));
       
  4120     CAknFepCtrlLongPressButton *self = new(ELeave) CAknFepCtrlLongPressButton(aUiLayout, 
       
  4121                                                                         aCtrlId, 
       
  4122                                                                         aEvent, 
       
  4123                                                                         aUnicode,
       
  4124                                                                         aNormalID,
       
  4125                                                                         aPressedID,
       
  4126                                                                         aInactiveID);
       
  4127 
       
  4128     CleanupStack::PushL(self);
       
  4129     self->ConstructL();
       
  4130     
       
  4131     return self;
       
  4132     }
       
  4133 
       
  4134 // ---------------------------------------------------------
       
  4135 // Constructor
       
  4136 // ---------------------------------------------------------
       
  4137 //
       
  4138 EXPORT_C CAknFepCtrlLongPressButton* CAknFepCtrlLongPressButton::NewL(CFepUiLayout* aUiLayout, 
       
  4139                                                                 TInt aCtrlId,
       
  4140                                                                 TInt aEvent,
       
  4141                                                                 TInt aUnicode,
       
  4142                                                                 TAknsItemID aNormalID,
       
  4143                                                                 TAknsItemID aPressedID,
       
  4144                                                                 TAknsItemID aInactiveID)
       
  4145     {
       
  4146     //PRINTF((_L("CAknFepCtrlLongPressButton::NewL(), aCtrlId = %d\n"), aCtrlId));
       
  4147     CAknFepCtrlLongPressButton *self = NewLC(aUiLayout, aCtrlId, aEvent, aUnicode,
       
  4148                                           aNormalID, aPressedID, aInactiveID);
       
  4149     CleanupStack::Pop(self);
       
  4150     
       
  4151     return self;
       
  4152     }
       
  4153         
       
  4154 // ---------------------------------------------------------
       
  4155 // Destructor
       
  4156 // ---------------------------------------------------------
       
  4157 //
       
  4158 EXPORT_C CAknFepCtrlLongPressButton::~CAknFepCtrlLongPressButton()
       
  4159     {
       
  4160     //PRINTF((_L("CAknFepCtrlLongPressButton::~CAknFepCtrlLongPressButton()\n")));
       
  4161     CancelTimer();
       
  4162 
       
  4163     delete iLongPressTimer;
       
  4164     }
       
  4165     
       
  4166 // ---------------------------------------------------------
       
  4167 // Constructor
       
  4168 // ---------------------------------------------------------
       
  4169 //
       
  4170 EXPORT_C CAknFepCtrlLongPressButton::CAknFepCtrlLongPressButton(CFepUiLayout* aUiLayout, 
       
  4171                                                           TInt aCtrlId,
       
  4172                                                           TInt aEvent,
       
  4173                                                           TInt aUnicode,
       
  4174                                                           TAknsItemID aNormalID,
       
  4175                                                           TAknsItemID aPressedID,
       
  4176                                                           TAknsItemID aInactiveID)
       
  4177     :CAknFepCtrlEventButton(aUiLayout, aCtrlId, aEvent, aUnicode,
       
  4178                                                         aNormalID,
       
  4179                                                         aPressedID,
       
  4180                                                         aInactiveID)
       
  4181     {
       
  4182     iLongPressInterval = KLongPressInterval;
       
  4183     }
       
  4184 
       
  4185 // ---------------------------------------------------------
       
  4186 // Constructor
       
  4187 // ---------------------------------------------------------
       
  4188 //
       
  4189 EXPORT_C void CAknFepCtrlLongPressButton::ConstructL()
       
  4190     {
       
  4191     //PRINTF((_L("CAknFepCtrlLongPressButton::ConstructL()\n")));
       
  4192     BaseConstructL();
       
  4193     iIsLongPress = EFalse;
       
  4194     iLongPressTimer = CAknFepTimer::NewL(this);
       
  4195     }
       
  4196     
       
  4197 // ---------------------------------------------------------
       
  4198 // Time out event handler of long press timer
       
  4199 // ---------------------------------------------------------
       
  4200 //
       
  4201 EXPORT_C void CAknFepCtrlLongPressButton::HandleTimerOut(const CAknFepTimer* aTimer)
       
  4202     {
       
  4203     //PRINTF((_L("CAknFepCtrlLongPressButton::HandleTimerOut()--")));
       
  4204     if (aTimer == iLongPressTimer)
       
  4205         {
       
  4206         iIsLongPress = ETrue;
       
  4207         CancelTimer();
       
  4208         TInt unicode = Unicode();
       
  4209         TPtrC ptr = (TUint16*)(&unicode);
       
  4210         ReportEvent(EPeninputLayoutEventMultiRangeLongPress, ptr);
       
  4211         }
       
  4212     }
       
  4213 
       
  4214 // ---------------------------------------------------------
       
  4215 // Handle button down start long press timer 
       
  4216 // ---------------------------------------------------------
       
  4217 //
       
  4218 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlLongPressButton::HandlePointerDownEventL(const TPoint& aPt)
       
  4219     {
       
  4220     //PRINTF((_L("CAknFepCtrlLongPressButton::HandleButtonDown()\n")));
       
  4221     //PRINTF((_L("Set long press Timer\n")));
       
  4222     if ( IsDimmed() )
       
  4223         {
       
  4224         return;
       
  4225         }
       
  4226     
       
  4227     iLongPressTimer->SetTimer(iLongPressInterval);
       
  4228 
       
  4229     return CAknFepCtrlCommonButton::HandlePointerDownEventL(aPt);
       
  4230     }
       
  4231                                                           
       
  4232 // ---------------------------------------------------------
       
  4233 // Handle button up cancel timer
       
  4234 // ---------------------------------------------------------
       
  4235 //
       
  4236 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlLongPressButton::HandlePointerUpEventL(const TPoint& aPt)
       
  4237     {
       
  4238     //PRINTF((_L("CAknFepCtrlLongPressButton::HandleButtonUp()\n")));
       
  4239 
       
  4240     if ( IsDimmed() )
       
  4241         {
       
  4242         return;
       
  4243         }
       
  4244 
       
  4245     CancelTimer();
       
  4246     
       
  4247     if (!iIsLongPress)
       
  4248         {
       
  4249         TInt unicode = Unicode();
       
  4250         TPtrC ptr = (TUint16*)(&unicode);
       
  4251         ReportEvent(EPeninputLayoutEventMultiRange, ptr);   
       
  4252         }
       
  4253 
       
  4254     iIsLongPress = EFalse;
       
  4255     
       
  4256     
       
  4257     return CAknFepCtrlCommonButton::HandlePointerUpEventL(aPt);
       
  4258     }
       
  4259 
       
  4260 // ---------------------------------------------------------
       
  4261 // Handle pointer leave event cancel timer 
       
  4262 // ---------------------------------------------------------
       
  4263 //
       
  4264 EXPORT_C void CAknFepCtrlLongPressButton::HandlePointerLeave(const TPoint& aPoint)
       
  4265     {
       
  4266     CAknFepCtrlCommonButton::HandlePointerLeave(aPoint);
       
  4267 
       
  4268     CancelTimer();
       
  4269     }
       
  4270 
       
  4271 // ---------------------------------------------------------------------------
       
  4272 // CAknFepCtrlLongPressButton::CancelPointerDownL
       
  4273 // Cancel pointer down event
       
  4274 // (other items were commented in a header).
       
  4275 // ---------------------------------------------------------------------------
       
  4276 //    
       
  4277 EXPORT_C void CAknFepCtrlLongPressButton::CancelPointerDownL()
       
  4278     {
       
  4279     // No implementation needed
       
  4280     }
       
  4281 
       
  4282 // ---------------------------------------------------------
       
  4283 // Cancel timer
       
  4284 // ---------------------------------------------------------
       
  4285 //
       
  4286 EXPORT_C void CAknFepCtrlLongPressButton::CancelTimer()
       
  4287     {
       
  4288     //PRINTF((_L("CAknFepCtrlLongPressButton::CancelTimer()\n")));
       
  4289     iLongPressTimer->Cancel();
       
  4290     }
  4102 //  End Of File
  4291 //  End Of File