phoneuis/dialer/src/cdialerkeypadbutton.cpp
branchRCL_3
changeset 6 38529f706030
parent 4 24062c24fe38
child 7 544e34b3255a
equal deleted inserted replaced
5:2a26698d78ba 6:38529f706030
    17 */
    17 */
    18 
    18 
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include <gulicon.h>
    21 #include <gulicon.h>
    22 #include <aknutils.h>
    22 #include <AknUtils.h>
    23 #include <aknbutton.h>
    23 #include <aknbutton.h>
    24 #include <akncontrol.h>
    24 #include <AknControl.h>
    25 #include <aknsutils.h>
    25 #include <AknsUtils.h>
    26 #include <aknsskininstance.h>
    26 #include <AknsSkinInstance.h>
    27 #include <aknsdrawutils.h>
    27 #include <AknsDrawUtils.h>
    28 #include <data_caging_path_literals.hrh> // for KDC_APP_RESOURCE_DIR
    28 #include <data_caging_path_literals.hrh> // for KDC_APP_RESOURCE_DIR
    29 #include <touchfeedback.h>
    29 #include <touchfeedback.h>
    30 #include <aknlayoutscalable_avkon.cdl.h>
    30 #include <aknlayoutscalable_avkon.cdl.h>
    31 #include <aknlayoutscalable_apps.cdl.h>
    31 #include <aknlayoutscalable_apps.cdl.h>
    32 #include <aknsframebackgroundcontrolcontext.h>
    32 #include <AknsFrameBackgroundControlContext.h>
    33 
    33 
    34 #include "dialercommon.h"
    34 #include "dialercommon.h"
    35 #include "dialertrace.h"
    35 #include "dialertrace.h"
    36 #include "cdialerkeypadbutton.h"
    36 #include "cdialerkeypadbutton.h"
    37 
    37 
    49 
    49 
    50 // Vertical icon margin relative to button height. 
    50 // Vertical icon margin relative to button height. 
    51 static const TInt KIconMarginYPercent = 5;
    51 static const TInt KIconMarginYPercent = 5;
    52 
    52 
    53 static const TInt KCent = 100;
    53 static const TInt KCent = 100;
       
    54 
       
    55 // Copied from CAknButton
       
    56 const TInt KDragEventSensitivity = 1;
    54 
    57 
    55 // ---------------------------------------------------------------------------
    58 // ---------------------------------------------------------------------------
    56 // C++ default constructor
    59 // C++ default constructor
    57 // ---------------------------------------------------------------------------
    60 // ---------------------------------------------------------------------------
    58 //
    61 //
   229         iNumberLayout.LayoutText( buttonRect, 
   232         iNumberLayout.LayoutText( buttonRect, 
   230             AknLayoutScalable_Apps::cell_video_dialer_keypad_pane_t1() );        
   233             AknLayoutScalable_Apps::cell_video_dialer_keypad_pane_t1() );        
   231         }
   234         }
   232 
   235 
   233     SetIconLayout( buttonRect );
   236     SetIconLayout( buttonRect );
       
   237     }
       
   238 
       
   239 // ---------------------------------------------------------------------------
       
   240 // Pointer event handling. Implemented here just to detect when touch is 
       
   241 // dragged outside pressed button as no appropriate control event is sent 
       
   242 // by CAknButton when this happens.
       
   243 // ---------------------------------------------------------------------------
       
   244 // 
       
   245 void CDialerKeyPadButton::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   246     {   
       
   247     // Do the check before forwarding events to base class as it will update
       
   248     // iButtonPressed member variable used here. 
       
   249     // Own drag event counter has to be used.
       
   250     // Logic here to determine whether pointer is dragged outside button is 
       
   251     // the same as used in CAknButton.
       
   252     
       
   253     if ( State() && IsVisible() )
       
   254         {
       
   255         if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
   256             {
       
   257             iDragEventCounter = 0;
       
   258             }
       
   259          else if ( aPointerEvent.iType == TPointerEvent::EDrag )
       
   260             {
       
   261             iDragEventCounter++;
       
   262             if ( iDragEventCounter >= KDragEventSensitivity  )
       
   263                 {
       
   264                 iDragEventCounter = 0;
       
   265                 
       
   266                 TBool buttonEvent( Rect().Contains( aPointerEvent.iPosition ) );
       
   267                 
       
   268                 // Pointer is dragged outside the pressed button area
       
   269                 if ( !buttonEvent && iButtonPressed && Observer() )
       
   270                     {
       
   271                     Observer()->HandleControlEventL( this,
       
   272                             static_cast<MCoeControlObserver::TCoeEvent>( 
       
   273                             CDialerKeyPadButton::EEventDraggingOutsideButton ) );
       
   274                     }
       
   275                 }
       
   276             }
       
   277         }
       
   278 
       
   279     CAknButton::HandlePointerEventL( aPointerEvent );
   234     }
   280     }
   235 
   281 
   236 // -----------------------------------------------------------------------------
   282 // -----------------------------------------------------------------------------
   237 // Gets the correct text color.
   283 // Gets the correct text color.
   238 // -----------------------------------------------------------------------------
   284 // -----------------------------------------------------------------------------