uifw/EikStd/coctlsrc/AknButton.cpp
branchRCL_3
changeset 16 71dd06cfe933
parent 9 aabf2c525e0f
child 23 3d340a0166ff
equal deleted inserted replaced
15:08e69e956a8c 16:71dd06cfe933
   262     // Fetches bitmaps from resource provider (if one exists)
   262     // Fetches bitmaps from resource provider (if one exists)
   263     TBool FetchProviderPressedBmpsL();
   263     TBool FetchProviderPressedBmpsL();
   264 
   264 
   265     // Sets bitmaps to resource provider (if one exists)
   265     // Sets bitmaps to resource provider (if one exists)
   266     void SetProviderPressedBmpsL();
   266     void SetProviderPressedBmpsL();
   267 
   267    
   268 private: // Data
   268 private: // Data
   269 
   269 
   270     CAknButton& iButton;
   270     CAknButton& iButton;
   271     CAknButton::TTooltipPosition iTooltipPosition;
   271     CAknButton::TTooltipPosition iTooltipPosition;
   272     CAknPictographInterface* iPictographInterface; // not owned
   272     CAknPictographInterface* iPictographInterface; // not owned
   282     TBitFlags iFlags;
   282     TBitFlags iFlags;
   283     MTouchFeedback* iFeedback;
   283     MTouchFeedback* iFeedback;
   284     CFbsBitmap* iPressedDownBmp;
   284     CFbsBitmap* iPressedDownBmp;
   285     CFbsBitmap* iPressedDownBmpMask;
   285     CFbsBitmap* iPressedDownBmpMask;
   286     CAknResourceProvider* iResourceProvider;
   286     CAknResourceProvider* iResourceProvider;
       
   287     
       
   288     //Previous touch down or drag position, valid only with pressed state. 
       
   289     TPoint iPrePointerPos;
   287     };
   290     };
   288 
   291 
   289 // ============================ MEMBER FUNCTIONS ===============================
   292 // ============================ MEMBER FUNCTIONS ===============================
   290 
   293 
   291 // -----------------------------------------------------------------------------
   294 // -----------------------------------------------------------------------------
  1974 
  1977 
  1975             if ( !iButtonPressed )
  1978             if ( !iButtonPressed )
  1976                 {
  1979                 {
  1977                 // show press changes
  1980                 // show press changes
  1978                 iButtonPressed = ETrue;
  1981                 iButtonPressed = ETrue;
       
  1982                 if ( iExtension )
       
  1983                     {
       
  1984                     iExtension->iPrePointerPos.SetXY( -1, -1 );
       
  1985                     }
  1979                 if ( NeedsRedrawWhenPressed() )
  1986                 if ( NeedsRedrawWhenPressed() )
  1980                     {
  1987                     {
  1981                     DrawNow();
  1988                     DrawNow();
  1982                     }
  1989                     }
  1983                 }
  1990                 }
  2083                     this, 
  2090                     this, 
  2084                     aVisible && !IsDimmed() );
  2091                     aVisible && !IsDimmed() );
  2085             }
  2092             }
  2086 
  2093 
  2087         CAknButtonState* state = State();
  2094         CAknButtonState* state = State();
  2088         if ( !aVisible && state && state->HasHelp() )
  2095         if ( !aVisible && iButtonPressed )
       
  2096             {
       
  2097             ResetState();
       
  2098             }
       
  2099         else if ( !aVisible && state && state->HasHelp() )
  2089             {
  2100             {
  2090             HideHelp();
  2101             HideHelp();
  2091             }
  2102             }
  2092         }
  2103         }
  2093     }
  2104     }
  2132 // this control.
  2143 // this control.
  2133 // -----------------------------------------------------------------------------
  2144 // -----------------------------------------------------------------------------
  2134 //
  2145 //
  2135 EXPORT_C void CAknButton::SizeChanged()
  2146 EXPORT_C void CAknButton::SizeChanged()
  2136     {
  2147     {
       
  2148     //Reset state if observer modified the rectangel.
       
  2149     if ( iButtonPressed && iExtension && !Rect().Contains( iExtension->iPrePointerPos ) )
       
  2150         {
       
  2151         ResetState();               
       
  2152         }
  2137     // If default icon size from LAF is used re-request that, otherwise trust
  2153     // If default icon size from LAF is used re-request that, otherwise trust
  2138     // that size will be updated by the utilising application.
  2154     // that size will be updated by the utilising application.
  2139     if ( iExtension->iFlags.IsSet( CAknButtonExtension::EUseDefaultIconSize ) )
  2155     if ( iExtension->iFlags.IsSet( CAknButtonExtension::EUseDefaultIconSize ) )
  2140         {
  2156         {
  2141         if ( iFlags & KAknButtonNoFrame && !State()->HasText() )
  2157         if ( iFlags & KAknButtonNoFrame && !State()->HasText() )
  2182             if ( iButtonPressed )
  2198             if ( iButtonPressed )
  2183                 {
  2199                 {
  2184                 ResetState();               
  2200                 ResetState();               
  2185                 }
  2201                 }
  2186             return;
  2202             return;
       
  2203             }
       
  2204         if ( iExtension )
       
  2205             {
       
  2206             iExtension->iPrePointerPos = aPointerEvent.iPosition;
  2187             }
  2207             }
  2188         TBool buttonEvent( TouchArea().Contains( aPointerEvent.iPosition ) );
  2208         TBool buttonEvent( TouchArea().Contains( aPointerEvent.iPosition ) );
  2189         CAknButtonState* state = State();
  2209         CAknButtonState* state = State();
  2190         if ( !state )
  2210         if ( !state )
  2191             {
  2211             {
  2328                 break;
  2348                 break;
  2329                 }
  2349                 }
  2330 
  2350 
  2331             case TPointerEvent::EButton1Up:
  2351             case TPointerEvent::EButton1Up:
  2332                 {
  2352                 {
       
  2353                 if ( iExtension )
       
  2354                     {
       
  2355                     iExtension->iPrePointerPos.SetXY( -1, -1 );
       
  2356                     }
  2333                 iNumberOfDragEvents = 0;
  2357                 iNumberOfDragEvents = 0;
  2334                 HideHelp();
  2358                 HideHelp();
  2335 
  2359 
  2336                 StopKeyRepeatTimer();
  2360                 StopKeyRepeatTimer();
  2337                 StopLongPressTimer();
  2361                 StopLongPressTimer();
  2457 //
  2481 //
  2458 EXPORT_C void CAknButton::PositionChanged()
  2482 EXPORT_C void CAknButton::PositionChanged()
  2459     {
  2483     {
  2460     if ( iExtension ) iExtension->HandleFeedbackAreaChange();
  2484     if ( iExtension ) iExtension->HandleFeedbackAreaChange();
  2461     CAknControl::PositionChanged();
  2485     CAknControl::PositionChanged();
       
  2486     
       
  2487     //Reset state if observer moved button position.
       
  2488     if ( iButtonPressed && iExtension && !Rect().Contains( iExtension->iPrePointerPos ) )
       
  2489     	{
       
  2490     	ResetState();
       
  2491     	}
  2462     }
  2492     }
  2463     
  2493     
  2464 // -----------------------------------------------------------------------------
  2494 // -----------------------------------------------------------------------------
  2465 // CAknButton::FocusChanged
  2495 // CAknButton::FocusChanged
  2466 // This function is called whenever a control gains or loses focus.
  2496 // This function is called whenever a control gains or loses focus.