uifw/EikStd/coctlsrc/AknButton.cpp
branchRCL_3
changeset 12 941195f2d488
parent 10 3d340a0166ff
child 15 c52421ed5f07
equal deleted inserted replaced
10:3d340a0166ff 12:941195f2d488
   285     CFbsBitmap* iPressedDownBmpMask;
   285     CFbsBitmap* iPressedDownBmpMask;
   286     CAknResourceProvider* iResourceProvider;
   286     CAknResourceProvider* iResourceProvider;
   287     
   287     
   288     //Previous touch down or drag position, valid only with pressed state. 
   288     //Previous touch down or drag position, valid only with pressed state. 
   289     TPoint iPrePointerPos;
   289     TPoint iPrePointerPos;
       
   290     CAknsFrameBackgroundControlContext* iHighlightContext;  
       
   291     // buffer for visually ordered text
       
   292     TBuf<255 + KAknBidiExtraSpacePerLine> iVisualText; 
       
   293     TBool iFeedbackEnabled; 
   290     };
   294     };
   291 
   295 
   292 // ============================ MEMBER FUNCTIONS ===============================
   296 // ============================ MEMBER FUNCTIONS ===============================
   293 
   297 
   294 // -----------------------------------------------------------------------------
   298 // -----------------------------------------------------------------------------
   304       iUnderlineStyle( EUnderlineOff ),
   308       iUnderlineStyle( EUnderlineOff ),
   305       iFrameAndCenterIds( 2 ),
   309       iFrameAndCenterIds( 2 ),
   306       iVerticalIconAlignment( CAknButton::ECenter ),
   310       iVerticalIconAlignment( CAknButton::ECenter ),
   307       iHorizontalIconAlignment( CAknButton::ECenter ),
   311       iHorizontalIconAlignment( CAknButton::ECenter ),
   308       iTextAndIconAlignment( CAknButton::EIconBeforeText ),
   312       iTextAndIconAlignment( CAknButton::EIconBeforeText ),
   309       iResourceProvider( 0 )
   313       iResourceProvider( 0 ),
       
   314       iFeedbackEnabled( ETrue )
   310     {
   315     {
   311     // default margins, these are applied to both text and icon
   316     // default margins, these are applied to both text and icon
   312     iMargins.SetAllValuesTo( 
   317     iMargins.SetAllValuesTo( 
   313         AknLayoutScalable_Avkon::aid_value_unit2().LayoutLine().iW / 10 );
   318         AknLayoutScalable_Avkon::aid_value_unit2().LayoutLine().iW / 10 );
   314         
   319         
   331     {
   336     {
   332     delete iLongPressTimer;
   337     delete iLongPressTimer;
   333     iPictographInterface = NULL; // not owned
   338     iPictographInterface = NULL; // not owned
   334     iFrameAndCenterIds.Close();
   339     iFrameAndCenterIds.Close();
   335     DeletePressedBmps();
   340     DeletePressedBmps();
       
   341     delete iHighlightContext; 
   336     }
   342     }
   337 
   343 
   338 // -----------------------------------------------------------------------------
   344 // -----------------------------------------------------------------------------
   339 // CAknButtonExtension::NewL
   345 // CAknButtonExtension::NewL
   340 // Symbian two-phased constructor.
   346 // Symbian two-phased constructor.
   369     iFrameAndCenterIds.AppendL( KAknsIIDQsnFrButtonPressed );
   375     iFrameAndCenterIds.AppendL( KAknsIIDQsnFrButtonPressed );
   370     iFrameAndCenterIds.AppendL( KAknsIIDQsnFrButtonCenterPressed );
   376     iFrameAndCenterIds.AppendL( KAknsIIDQsnFrButtonCenterPressed );
   371     // Latched dimmed frame and center
   377     // Latched dimmed frame and center
   372     iFrameAndCenterIds.AppendL( KAknsIIDQsnFrButtonInactive );
   378     iFrameAndCenterIds.AppendL( KAknsIIDQsnFrButtonInactive );
   373     iFrameAndCenterIds.AppendL( KAknsIIDQsnFrButtonCenterInactive );
   379     iFrameAndCenterIds.AppendL( KAknsIIDQsnFrButtonCenterInactive );
       
   380     if ( !iHighlightContext )
       
   381         {
       
   382         iHighlightContext = CAknsFrameBackgroundControlContext::NewL(
       
   383             KAknsIIDNone, TRect(), TRect(), EFalse );
       
   384         iHighlightContext->SetFrame( KAknsIIDQsnFrButtonHighlight ); 
       
   385         iHighlightContext->SetCenter( KAknsIIDQsnFrButtonHighlightCenter ); 
       
   386         }
   374     }
   387     }
   375 
   388 
   376 // -----------------------------------------------------------------------------
   389 // -----------------------------------------------------------------------------
   377 // CAknButtonExtension::StartLongPressTimerL
   390 // CAknButtonExtension::StartLongPressTimerL
   378 // Starts the long press timer. The timer is constructed when used for the
   391 // Starts the long press timer. The timer is constructed when used for the
   515     return retval;
   528     return retval;
   516     }
   529     }
   517 
   530 
   518 void CAknButtonExtension::HandleFeedbackAreaChange()
   531 void CAknButtonExtension::HandleFeedbackAreaChange()
   519     {
   532     {
       
   533     if ( !iFeedbackEnabled )
       
   534         {
       
   535         return; 
       
   536         }
   520     // it is possible that feedback does not exist, eg. while booting.
   537     // it is possible that feedback does not exist, eg. while booting.
   521     // try getting one, and give up if that fails.
   538     // try getting one, and give up if that fails.
   522     if ( !iFeedback )
   539     if ( !iFeedback )
   523         {
   540         {
   524         iFeedback = MTouchFeedback::Instance();
   541         iFeedback = MTouchFeedback::Instance();
   580     TAknsItemID iId;
   597     TAknsItemID iId;
   581     TAknsItemID iDimmedId;
   598     TAknsItemID iDimmedId;
   582     TAknsItemID iPressedId;
   599     TAknsItemID iPressedId;
   583     TAknsItemID iHoverId;
   600     TAknsItemID iHoverId;
   584     TScaleMode iScaleMode;
   601     TScaleMode iScaleMode;
       
   602     TBool iFlagsChanged; 
       
   603     TBool iTextChanged; 
   585     };
   604     };
   586 
   605 
   587 // ============================ MEMBER FUNCTIONS ===============================
   606 // ============================ MEMBER FUNCTIONS ===============================
   588 
   607 
   589 // -----------------------------------------------------------------------------
   608 // -----------------------------------------------------------------------------
   992     {
  1011     {
   993     delete iText;
  1012     delete iText;
   994     iText = NULL;
  1013     iText = NULL;
   995 
  1014 
   996     iText = aText.AllocL();
  1015     iText = aText.AllocL();
       
  1016     iExtension->iTextChanged = ETrue; 
   997     }
  1017     }
   998 
  1018 
   999 // -----------------------------------------------------------------------------
  1019 // -----------------------------------------------------------------------------
  1000 // CAknButtonState::SetHelpTextL
  1020 // CAknButtonState::SetHelpTextL
  1001 // Sets the text inside the help note
  1021 // Sets the text inside the help note
  1014 // Sets state flags.
  1034 // Sets state flags.
  1015 // -----------------------------------------------------------------------------
  1035 // -----------------------------------------------------------------------------
  1016 //
  1036 //
  1017 EXPORT_C void CAknButtonState::SetFlags( const TInt aFlags )
  1037 EXPORT_C void CAknButtonState::SetFlags( const TInt aFlags )
  1018     {
  1038     {
       
  1039     if ( iFlags & KAknButtonStateHasLatchedFrame != 
       
  1040         aFlags & KAknButtonStateHasLatchedFrame )
       
  1041         {
       
  1042         iExtension->iFlagsChanged = ETrue; 
       
  1043         }
  1019     iFlags = aFlags;
  1044     iFlags = aFlags;
  1020     }
  1045     }
  1021 
  1046 
  1022 // -----------------------------------------------------------------------------
  1047 // -----------------------------------------------------------------------------
  1023 // CAknButtonState::UpdateIconL
  1048 // CAknButtonState::UpdateIconL
  1336 // -----------------------------------------------------------------------------    
  1361 // -----------------------------------------------------------------------------    
  1337 void CAknButtonState::SetGeneratedDimmedIcon( TBool aDimmedIconCreatedByButton )
  1362 void CAknButtonState::SetGeneratedDimmedIcon( TBool aDimmedIconCreatedByButton )
  1338     {
  1363     {
  1339     iExtension->iGeneratedDimmedIcon = aDimmedIconCreatedByButton;
  1364     iExtension->iGeneratedDimmedIcon = aDimmedIconCreatedByButton;
  1340     }
  1365     }
       
  1366 // -----------------------------------------------------------------------------
       
  1367 // CAknButtonState::FlagsChanged
       
  1368 // Returns ETrue if button state flags are changed so that 
       
  1369 // KAknStateHasLatchedDownFrame is setted or cleared
       
  1370 // -----------------------------------------------------------------------------    
       
  1371 TBool CAknButtonState::FlagsChanged()
       
  1372     {
       
  1373     return iExtension->iFlagsChanged;
       
  1374     }
       
  1375 
       
  1376 // -----------------------------------------------------------------------------
       
  1377 // CAknButtonState::ResetFlagsChanged
       
  1378 // Frame has been updated so boolean iFlagsChanged can be set to EFalse
       
  1379 // -----------------------------------------------------------------------------
       
  1380 void CAknButtonState::ResetFlagsChanged()
       
  1381     {
       
  1382     iExtension->iFlagsChanged = EFalse;
       
  1383     }
       
  1384 
       
  1385 // -----------------------------------------------------------------------------
       
  1386 // CAknButtonState::TextChanged
       
  1387 // Returns ETrue if text is changed and button's visual text has 
       
  1388 // not been updated. 
       
  1389 // -----------------------------------------------------------------------------    
       
  1390 TBool CAknButtonState::TextChanged()
       
  1391     {
       
  1392     return iExtension->iTextChanged;
       
  1393     }
       
  1394 
       
  1395 // -----------------------------------------------------------------------------
       
  1396 // CAknButtonState::ResetTextChanged
       
  1397 // Visual text has been updated so boolean iTextChanged can be set to EFalse
       
  1398 // -----------------------------------------------------------------------------
       
  1399 void CAknButtonState::ResetTextChanged()
       
  1400     {
       
  1401     iExtension->iTextChanged = EFalse;
       
  1402     }
       
  1403 
  1341 
  1404 
  1342 // -----------------------------------------------------------------------------
  1405 // -----------------------------------------------------------------------------
  1343 // CAknButtonState::Extension
  1406 // CAknButtonState::Extension
  1344 // -----------------------------------------------------------------------------
  1407 // -----------------------------------------------------------------------------
  1345 //
  1408 //
  1577     if ( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), textColor, 
  1640     if ( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), textColor, 
  1578         iTextColorTableId, iTextColorIndex ) == KErrNone )
  1641         iTextColorTableId, iTextColorIndex ) == KErrNone )
  1579         {
  1642         {
  1580         OverrideColorL( EColorButtonText, textColor );
  1643         OverrideColorL( EColorButtonText, textColor );
  1581         }
  1644         }
  1582 
  1645     
       
  1646     if ( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), textColor, 
       
  1647             iTextColorTableId, EAknsCIQsnTextColorsCG84 ) == KErrNone )
       
  1648         {
       
  1649         OverrideColorL( EColorButtonTextPressed, textColor );
       
  1650         }
  1583     if ( !iStates )
  1651     if ( !iStates )
  1584         {
  1652         {
  1585         iStates = new ( ELeave ) CArrayPtrFlat<CAknButtonState>( 2 );
  1653         iStates = new ( ELeave ) CArrayPtrFlat<CAknButtonState>( 2 );
  1586         }
  1654         }
  1587 
  1655 
  1609     if ( iFlags & KAknButtonTextLeft )
  1677     if ( iFlags & KAknButtonTextLeft )
  1610         {
  1678         {
  1611         iHorizontalAlignment = CGraphicsContext::ELeft;
  1679         iHorizontalAlignment = CGraphicsContext::ELeft;
  1612         }
  1680         }
  1613     iExtension->HandleFeedbackAreaChange();
  1681     iExtension->HandleFeedbackAreaChange();
       
  1682     SetFrameIDs(); 
       
  1683     ConvertTextToVisualAndClip();
  1614     }
  1684     }
  1615 
  1685 
  1616 // -----------------------------------------------------------------------------
  1686 // -----------------------------------------------------------------------------
  1617 // CAknButton::ConstructL
  1687 // CAknButton::ConstructL
  1618 // Symbian 2nd phase constructor for 1 state button.
  1688 // Symbian 2nd phase constructor for 1 state button.
  1811                 iTextColorTableId, iTextColorIndex ) == KErrNone )
  1881                 iTextColorTableId, iTextColorIndex ) == KErrNone )
  1812             {
  1882             {
  1813             TRAP_IGNORE( OverrideColorL( EColorButtonText, textColor ) );
  1883             TRAP_IGNORE( OverrideColorL( EColorButtonText, textColor ) );
  1814             }
  1884             }
  1815     
  1885     
       
  1886         if ( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), textColor, 
       
  1887                     iTextColorTableId, EAknsCIQsnTextColorsCG84 ) == KErrNone )
       
  1888             {
       
  1889             TRAP_IGNORE( OverrideColorL( EColorButtonTextPressed, textColor ) );
       
  1890             }
  1816         // generated pressed frame has to be regenerated
  1891         // generated pressed frame has to be regenerated
  1817         if ( iFlags & KAknButtonNoFrame && iFlags & KAknButtonPressedDownFrame )
  1892         if ( iFlags & KAknButtonNoFrame && iFlags & KAknButtonPressedDownFrame )
  1818             {
  1893             {
  1819             iExtension->DeletePressedBmps();
  1894             iExtension->DeletePressedBmps();
  1820             TRAP_IGNORE( CreatePressedDownFrameL() );
  1895             TRAP_IGNORE( CreatePressedDownFrameL() );
  1904         StopKeyRepeatTimer();
  1979         StopKeyRepeatTimer();
  1905         StopLongPressTimer();
  1980         StopLongPressTimer();
  1906         HideHelp();
  1981         HideHelp();
  1907         iButtonPressed = EFalse;
  1982         iButtonPressed = EFalse;
  1908         }
  1983         }
  1909     
       
  1910     if ( aDimmed )
  1984     if ( aDimmed )
  1911         {
  1985         {
  1912         iExtension->iFlags.Set( CAknButtonExtension::EDimmed );
  1986         iExtension->iFlags.Set( CAknButtonExtension::EDimmed );
  1913         }
  1987         }
  1914     else
  1988     else
  1915         {
  1989         {
  1916         iExtension->iFlags.Clear( CAknButtonExtension::EDimmed );
  1990         iExtension->iFlags.Clear( CAknButtonExtension::EDimmed );
  1917         }
  1991         }
  1918     if ( iExtension->iFeedback )
  1992     if ( iExtension->iFeedbackEnabled && iExtension->iFeedback )
  1919         {
  1993         {
  1920         if ( aDimmed )
  1994         if ( aDimmed )
  1921             {
  1995             {
  1922             iExtension->iFeedback->MoveFeedbackAreaToFirstPriority( this, 0 );
  1996             iExtension->iFeedback->MoveFeedbackAreaToFirstPriority( this, 0 );
  1923             }        
  1997             }        
  1948     // None of states has help text, CCoeControl::SetDimmed can be used        
  2022     // None of states has help text, CCoeControl::SetDimmed can be used        
  1949     if ( !hasHelp )
  2023     if ( !hasHelp )
  1950         {
  2024         {
  1951         CCoeControl::SetDimmed( aDimmed );
  2025         CCoeControl::SetDimmed( aDimmed );
  1952         }
  2026         }
       
  2027     SetFrameIDs(); 
  1953     }
  2028     }
  1954 
  2029 
  1955 // -----------------------------------------------------------------------------
  2030 // -----------------------------------------------------------------------------
  1956 // CAknButton::OfferKeyEventL
  2031 // CAknButton::OfferKeyEventL
  1957 // Handles key events.
  2032 // Handles key events.
  1979                 {
  2054                 {
  1980                 // show press changes
  2055                 // show press changes
  1981                 iButtonPressed = ETrue;
  2056                 iButtonPressed = ETrue;
  1982                 iExtension->iPrePointerPos.SetXY( -1, -1 );
  2057                 iExtension->iPrePointerPos.SetXY( -1, -1 );
  1983                 
  2058                 
       
  2059                 SetFrameIDs(); 
  1984                 if ( NeedsRedrawWhenPressed() )
  2060                 if ( NeedsRedrawWhenPressed() )
  1985                     {
  2061                     {
  1986                     DrawNow();
  2062                     DrawNow();
  1987                     }
  2063                     }
  1988                 }
  2064                 }
  2013         else if ( aType == EEventKeyUp )
  2089         else if ( aType == EEventKeyUp )
  2014             {
  2090             {
  2015             if ( iButtonPressed )
  2091             if ( iButtonPressed )
  2016                 {
  2092                 {
  2017                 iButtonPressed = EFalse;
  2093                 iButtonPressed = EFalse;
       
  2094                 SetFrameIDs(); 
  2018 
  2095 
  2019                 if ( NeedsRedrawWhenPressed() )
  2096                 if ( NeedsRedrawWhenPressed() )
  2020                     {
  2097                     {
  2021                     DrawNow();
  2098                     DrawNow();
  2022                     }
  2099                     }
  2049                         CAknButton::ELongPressEndedEvent ) );
  2126                         CAknButton::ELongPressEndedEvent ) );
  2050                     }
  2127                     }
  2051                 iExtension->iFlags.Clear( CAknButtonExtension::ELongPressReported );
  2128                 iExtension->iFlags.Clear( CAknButtonExtension::ELongPressReported );
  2052                 iExtension->iFlags.Clear( CAknButtonExtension::EKeyRepeatEventReported );
  2129                 iExtension->iFlags.Clear( CAknButtonExtension::EKeyRepeatEventReported );
  2053                 }
  2130                 }
  2054 
  2131             
  2055             if ( iKeyDownReported && RequestExit() && Observer() )
  2132             TInt reported = iKeyDownReported;
       
  2133             iKeyDownReported = EFalse;            
       
  2134             if ( reported && RequestExit() && Observer() )
  2056                 {
  2135                 {
  2057                 Observer()->HandleControlEventL( this,
  2136                 Observer()->HandleControlEventL( this,
  2058                     MCoeControlObserver::EEventRequestExit );
  2137                     MCoeControlObserver::EEventRequestExit );
  2059                 }
  2138                 }            
  2060 
       
  2061             iKeyDownReported = EFalse;
       
  2062             }
  2139             }
  2063         // we don't want aKeyEvent to go somewhere else :)
  2140         // we don't want aKeyEvent to go somewhere else :)
  2064         return EKeyWasConsumed;
  2141         return EKeyWasConsumed;
  2065         }
  2142         }
  2066 
  2143 
  2075 EXPORT_C void CAknButton::MakeVisible( TBool aVisible )
  2152 EXPORT_C void CAknButton::MakeVisible( TBool aVisible )
  2076     {
  2153     {
  2077     if ( aVisible != IsVisible() )
  2154     if ( aVisible != IsVisible() )
  2078         {
  2155         {
  2079         CAknControl::MakeVisible( aVisible );
  2156         CAknControl::MakeVisible( aVisible );
  2080         if ( iExtension->iFeedback )
  2157         if ( iExtension->iFeedbackEnabled && iExtension->iFeedback )
  2081             {
  2158             {
  2082             if ( aVisible )
  2159             if ( aVisible )
  2083                 {
  2160                 {
  2084                 iExtension->iFeedback->MoveFeedbackAreaToFirstPriority( this, 
  2161                 iExtension->iFeedback->MoveFeedbackAreaToFirstPriority( this, 
  2085                                                                         0 );
  2162                                                                         0 );
  2175     // Pressed down frame has to be regenerated
  2252     // Pressed down frame has to be regenerated
  2176     if ( iFlags & KAknButtonNoFrame && iFlags & KAknButtonPressedDownFrame ) 
  2253     if ( iFlags & KAknButtonNoFrame && iFlags & KAknButtonPressedDownFrame ) 
  2177        {
  2254        {
  2178         TRAP_IGNORE( CreatePressedDownFrameL() );
  2255         TRAP_IGNORE( CreatePressedDownFrameL() );
  2179         }
  2256         }
       
  2257     SetFrameRects(); 
       
  2258     ConvertTextToVisualAndClip(); 
  2180 
  2259 
  2181     iExtension->HandleFeedbackAreaChange();
  2260     iExtension->HandleFeedbackAreaChange();
  2182     }
  2261     }
  2183 
  2262 
  2184 // -----------------------------------------------------------------------------
  2263 // -----------------------------------------------------------------------------
  2228                 else if ( buttonEvent )
  2307                 else if ( buttonEvent )
  2229                     {
  2308                     {
  2230                     if ( !iButtonPressed )
  2309                     if ( !iButtonPressed )
  2231                         {
  2310                         {
  2232                         iButtonPressed = ETrue;
  2311                         iButtonPressed = ETrue;
       
  2312                         SetFrameIDs(); 
  2233                         // feedback/basic on down event, if hit test is
  2313                         // feedback/basic on down event, if hit test is
  2234                         // used. Area registry is used for rectangular
  2314                         // used. Area registry is used for rectangular
  2235                         // buttons
  2315                         // buttons
  2236                         if ( ( iFlags & KAknButtonHitTest ) 
  2316                         if ( ( iFlags & KAknButtonHitTest ) 
  2237                            && !IsDimmed() 
  2317                            && !IsDimmed() 
  2295                     if ( !buttonEvent && iButtonPressed )
  2375                     if ( !buttonEvent && iButtonPressed )
  2296                         {
  2376                         {
  2297                         // Redraw button, if needed
  2377                         // Redraw button, if needed
  2298                         if ( NeedsRedrawWhenPressed() )
  2378                         if ( NeedsRedrawWhenPressed() )
  2299                             {
  2379                             {
  2300                             iButtonPressed = EFalse;
       
  2301                             redrawNeeded = ETrue;
  2380                             redrawNeeded = ETrue;
  2302                             }
  2381                             }
  2303                         iButtonPressed = EFalse;
  2382                         iButtonPressed = EFalse;
       
  2383                         SetFrameIDs(); 
  2304 
  2384 
  2305                         StopKeyRepeatTimer();
  2385                         StopKeyRepeatTimer();
  2306                         StopLongPressTimer();
  2386                         StopLongPressTimer();
  2307 
  2387 
  2308                         if ( !IsFocused() )
  2388                         if ( !IsFocused() )
  2320 
  2400 
  2321                     // Pointer is dragged back into button area
  2401                     // Pointer is dragged back into button area
  2322                     else if ( buttonEvent && !iButtonPressed && !IsDimmed() )
  2402                     else if ( buttonEvent && !iButtonPressed && !IsDimmed() )
  2323                         {
  2403                         {
  2324                         iButtonPressed = ETrue;
  2404                         iButtonPressed = ETrue;
       
  2405                         SetFrameIDs(); 
  2325 
  2406 
  2326                         // Redraw button, if needed
  2407                         // Redraw button, if needed
  2327                         if ( NeedsRedrawWhenPressed() )
  2408                         if ( NeedsRedrawWhenPressed() )
  2328                             {
  2409                             {
  2329                             redrawNeeded = ETrue;
  2410                             redrawNeeded = ETrue;
  2368                             {
  2449                             {
  2369                             redrawNeeded = ETrue;
  2450                             redrawNeeded = ETrue;
  2370                             }
  2451                             }
  2371                         }
  2452                         }
  2372                     iButtonPressed = EFalse;
  2453                     iButtonPressed = EFalse;
       
  2454                     SetFrameIDs(); 
  2373                     }
  2455                     }
  2374 
  2456 
  2375                 TBool hasDrawn( EFalse );
  2457                 TBool hasDrawn( EFalse );
  2376                 if ( buttonEvent && !IsDimmed() )
  2458                 if ( buttonEvent && !IsDimmed() )
  2377                     {
  2459                     {
  2485     //Reset state if observer moved button position.
  2567     //Reset state if observer moved button position.
  2486     if ( iButtonPressed && iExtension && !Rect().Contains( iExtension->iPrePointerPos ) )
  2568     if ( iButtonPressed && iExtension && !Rect().Contains( iExtension->iPrePointerPos ) )
  2487     	{
  2569     	{
  2488     	ResetState();
  2570     	ResetState();
  2489     	}
  2571     	}
       
  2572     SetFrameRects(); 
  2490     }
  2573     }
  2491     
  2574     
  2492 // -----------------------------------------------------------------------------
  2575 // -----------------------------------------------------------------------------
  2493 // CAknButton::FocusChanged
  2576 // CAknButton::FocusChanged
  2494 // This function is called whenever a control gains or loses focus.
  2577 // This function is called whenever a control gains or loses focus.
  2497 EXPORT_C void CAknButton::FocusChanged( TDrawNow aDrawNow )
  2580 EXPORT_C void CAknButton::FocusChanged( TDrawNow aDrawNow )
  2498     {
  2581     {
  2499     if ( !IsFocused() && iButtonPressed )
  2582     if ( !IsFocused() && iButtonPressed )
  2500         {
  2583         {
  2501         iButtonPressed = EFalse; 
  2584         iButtonPressed = EFalse; 
       
  2585         SetFrameIDs(); 
  2502         iKeyDownReported = EFalse; 
  2586         iKeyDownReported = EFalse; 
  2503         }
  2587         }
  2504     if ( IsVisible() )
  2588     if ( IsVisible() )
  2505         {
  2589         {
  2506         
  2590         
  2541 // -----------------------------------------------------------------------------
  2625 // -----------------------------------------------------------------------------
  2542 //
  2626 //
  2543 EXPORT_C void CAknButton::Draw( const TRect& /*aRect*/ ) const
  2627 EXPORT_C void CAknButton::Draw( const TRect& /*aRect*/ ) const
  2544     {
  2628     {
  2545     TRect rect( Rect() );
  2629     TRect rect( Rect() );
  2546     TAknLayoutRect centerLayout;
       
  2547     centerLayout.LayoutRect( rect,
       
  2548         AknLayoutScalable_Avkon::toolbar_button_pane_g1().LayoutLine() );
       
  2549     TRect innerRect( centerLayout.Rect() );
       
  2550     TRect highlightRect( HighlightRect() );
  2630     TRect highlightRect( HighlightRect() );
  2551     CWindowGc& gc = SystemGc();
  2631     CWindowGc& gc = SystemGc();
  2552     CAknButtonState* state = State();
  2632     CAknButtonState* state = State();
  2553 
  2633 
  2554     // Skin ids are determined here (a bit too early than necessary) so that 
  2634     if ( !( iFlags & KAknButtonNoFrame ) && !iButtonPressed && state && 
  2555     // we can avoid doing the same thing in DrawMaskedL.
  2635             state->FlagsChanged() )
  2556     if ( !( iFlags & KAknButtonNoFrame ) )
  2636         {
  2557         {
  2637         SetFrameIDs(); 
  2558         TInt frameIdIndex = KFrameId;
       
  2559 
       
  2560         if ( iButtonPressed )
       
  2561             {
       
  2562             frameIdIndex = KPressedFrameId;
       
  2563             }
       
  2564         else if ( state && state->Flags() & KAknButtonStateHasLatchedFrame )
       
  2565             {
       
  2566             if ( IsDimmed() )
       
  2567                 {
       
  2568                 // dimmed latched frame
       
  2569                 frameIdIndex = KLatchedDimmedFrameId;
       
  2570                 }
       
  2571             else
       
  2572                 {
       
  2573                 // latched down
       
  2574                 frameIdIndex = KLatchedFrameId;
       
  2575                 }
       
  2576             }
       
  2577         else if ( IsDimmed())
       
  2578             {
       
  2579             // dimmed frame
       
  2580             frameIdIndex = KDimmedFrameId;
       
  2581             }
       
  2582 
       
  2583         if ( SkinIID( frameIdIndex ) != KAknsIIDNone )
       
  2584             {
       
  2585             iBgContext->SetFrame( SkinIID( frameIdIndex ) );
       
  2586             iBgContext->SetCenter( SkinIID( ++frameIdIndex ) );
       
  2587             iBgContext->SetFrameRects( rect, innerRect );
       
  2588             }
       
  2589         }
  2638         }
  2590 
  2639 
  2591     if ( !iExtension->iFlags.IsSet( CAknButtonExtension::EUseAdditionalMask ) )
  2640     if ( !iExtension->iFlags.IsSet( CAknButtonExtension::EUseAdditionalMask ) )
  2592         {
  2641         {
  2593         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  2642         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  2605                 }
  2654                 }
  2606                 
  2655                 
  2607 
  2656 
  2608             if ( IsFocused() && !highlightRect.IsEmpty() )
  2657             if ( IsFocused() && !highlightRect.IsEmpty() )
  2609                 {
  2658                 {
  2610                 iBgContext->SetFrame( KAknsIIDQsnFrButtonHighlight ); 
       
  2611                 iBgContext->SetCenter( KAknsIIDQsnFrButtonHighlightCenter ); 
       
  2612                 iBgContext->SetFrameRects( rect, innerRect );
       
  2613 
       
  2614                 // frame graphics
  2659                 // frame graphics
  2615                 if ( !AknsDrawUtils::Background( skin, iBgContext, NULL, gc,
  2660                 if ( !AknsDrawUtils::Background( skin, 
  2616                       rect, KAknsDrawParamNoClearUnderImage ) )
  2661                       iExtension->iHighlightContext, NULL, gc, rect, 
       
  2662                       KAknsDrawParamNoClearUnderImage ) )
  2617                     {
  2663                     {
  2618                     gc.SetBrushColor( KRgbRed );
  2664                     gc.SetBrushColor( KRgbRed );
  2619                     gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
  2665                     gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
  2620                     gc.DrawRect( rect );
  2666                     gc.DrawRect( rect );
  2621                     }
  2667                     }
  2779 // Sets the button flags
  2825 // Sets the button flags
  2780 // -----------------------------------------------------------------------------
  2826 // -----------------------------------------------------------------------------
  2781 //
  2827 //
  2782 EXPORT_C void CAknButton::SetButtonFlags( const TInt aFlags )
  2828 EXPORT_C void CAknButton::SetButtonFlags( const TInt aFlags )
  2783     {
  2829     {
  2784     if ( !(iFlags & KAknButtonNoFrame ) && aFlags & KAknButtonNoFrame )
  2830     if ( !( iFlags & KAknButtonNoFrame ) )
  2785         {
  2831         {
  2786         iExtension->iMargins.SetAllValuesTo( 0 );
  2832         if ( aFlags & KAknButtonNoFrame ) 
       
  2833             {
       
  2834             iExtension->iMargins.SetAllValuesTo( 0 );
       
  2835             ConvertTextToVisualAndClip();
       
  2836             }
       
  2837         // aFlags does not include KAknButtonNoFrame
       
  2838         else if ( iFlags & KAknButtonTextInsideFrame != 
       
  2839                 aFlags & KAknButtonTextInsideFrame )
       
  2840             {
       
  2841             ConvertTextToVisualAndClip(); 
       
  2842             }
  2787         }
  2843         }
  2788     if ( aFlags & KAknButtonHitTest )
  2844     if ( aFlags & KAknButtonHitTest )
  2789         {
  2845         {
  2790         SetHitTest( iExtension );
  2846         SetHitTest( iExtension );
  2791         iExtension->HandleFeedbackAreaChange();
  2847         iExtension->HandleFeedbackAreaChange();
  2792         }
  2848         }
  2793     if ( aFlags & KAknButtonNoFrame && aFlags & KAknButtonPressedDownFrame )
  2849     if ( aFlags & KAknButtonNoFrame && aFlags & KAknButtonPressedDownFrame )
  2794         {
  2850         {
  2795         TRAP_IGNORE ( CreatePressedDownFrameL() );
  2851         TRAP_IGNORE ( CreatePressedDownFrameL() );
       
  2852         }
       
  2853     if ( iFlags & KAknButtonNoFrame && !( aFlags & KAknButtonNoFrame ) )
       
  2854         {
       
  2855         SetFrameIDs(); 
       
  2856         if ( aFlags & KAknButtonTextInsideFrame )
       
  2857             {
       
  2858             ConvertTextToVisualAndClip(); 
       
  2859             }
  2796         }
  2860         }
  2797     iFlags = aFlags;
  2861     iFlags = aFlags;
  2798     }
  2862     }
  2799 
  2863 
  2800 // -----------------------------------------------------------------------------
  2864 // -----------------------------------------------------------------------------
  2856         }
  2920         }
  2857     if ( aLatchedDimmedCenterId != KAknsIIDDefault )
  2921     if ( aLatchedDimmedCenterId != KAknsIIDDefault )
  2858         {
  2922         {
  2859         skinIds[KLatchedDimmedCenterId] = aLatchedDimmedCenterId;
  2923         skinIds[KLatchedDimmedCenterId] = aLatchedDimmedCenterId;
  2860         }
  2924         }
       
  2925     SetFrameIDs(); 
  2861     }
  2926     }
  2862 
  2927 
  2863 // -----------------------------------------------------------------------------
  2928 // -----------------------------------------------------------------------------
  2864 // CAknButton::SetBackgroundIds
  2929 // CAknButton::SetBackgroundIds
  2865 // -----------------------------------------------------------------------------
  2930 // -----------------------------------------------------------------------------
  2887 // -----------------------------------------------------------------------------
  2952 // -----------------------------------------------------------------------------
  2888 //
  2953 //
  2889 EXPORT_C void CAknButton::SetTextFont( const CFont* aFont )
  2954 EXPORT_C void CAknButton::SetTextFont( const CFont* aFont )
  2890     {
  2955     {
  2891     iFont = aFont;
  2956     iFont = aFont;
       
  2957     ConvertTextToVisualAndClip(); 
  2892     }
  2958     }
  2893 
  2959 
  2894 // -----------------------------------------------------------------------------
  2960 // -----------------------------------------------------------------------------
  2895 // CAknButton::SetTextColorIds
  2961 // CAknButton::SetTextColorIds
  2896 // Sets the color table and color index for the button text.
  2962 // Sets the color table and color index for the button text.
  3181         {
  3247         {
  3182         newIndex = 0;
  3248         newIndex = 0;
  3183         }
  3249         }
  3184     
  3250     
  3185     TRAP_IGNORE( SetStateIndexL( newIndex ) );
  3251     TRAP_IGNORE( SetStateIndexL( newIndex ) );
       
  3252     // Updating background context might be needed if states flags differ
       
  3253     SetFrameIDs(); 
  3186     
  3254     
  3187     if ( aDrawNow )
  3255     if ( aDrawNow )
  3188         {
  3256         {
  3189         DrawNow();
  3257         DrawNow();
  3190         }
  3258         }
  3359 EXPORT_C void CAknButton::ResetState( )
  3427 EXPORT_C void CAknButton::ResetState( )
  3360     {
  3428     {
  3361     StopKeyRepeatTimer();
  3429     StopKeyRepeatTimer();
  3362     StopLongPressTimer();
  3430     StopLongPressTimer();
  3363     iButtonPressed = EFalse;
  3431     iButtonPressed = EFalse;
       
  3432     SetFrameIDs(); 
  3364     HideHelp();
  3433     HideHelp();
  3365     if ( iExtension )
  3434     if ( iExtension )
  3366         {
  3435         {
  3367         if ( iExtension->iFlags.IsSet( CAknButtonExtension::ELongPressReported ) && Observer() )
  3436         if ( iExtension->iFlags.IsSet( CAknButtonExtension::ELongPressReported ) && Observer() )
  3368             {
  3437             {
  3452     {
  3521     {
  3453     CAknButtonState* state = State();
  3522     CAknButtonState* state = State();
  3454     if ( !state || !state->HasText() )
  3523     if ( !state || !state->HasText() )
  3455         return;
  3524         return;
  3456 
  3525 
  3457     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  3526     if ( state->TextChanged() )
       
  3527         {
       
  3528         ConvertTextToVisualAndClip(); 
       
  3529         }
  3458 
  3530 
  3459     TRect textRect = iExtension->iMargins.InnerRect( Rect() );
  3531     TRect textRect = iExtension->iMargins.InnerRect( Rect() );
  3460 
  3532 
  3461     if ( !( iFlags & KAknButtonNoFrame ) && 
  3533     if ( !( iFlags & KAknButtonNoFrame ) && 
  3462          ( iFlags & KAknButtonTextInsideFrame ) )
  3534          ( iFlags & KAknButtonTextInsideFrame ) )
  3465         center.LayoutRect( Rect(), 
  3537         center.LayoutRect( Rect(), 
  3466             AknLayoutScalable_Avkon::toolbar_button_pane_g1().LayoutLine() );
  3538             AknLayoutScalable_Avkon::toolbar_button_pane_g1().LayoutLine() );
  3467 
  3539 
  3468         textRect = center.Rect();
  3540         textRect = center.Rect();
  3469         }
  3541         }
       
  3542     DrawText( aGc, textRect ); 
       
  3543     }
       
  3544 
       
  3545 // -----------------------------------------------------------------------------
       
  3546 // CAknButton::DrawText
       
  3547 // Continues drawing of the button which has text
       
  3548 // -----------------------------------------------------------------------------
       
  3549 //
       
  3550 void CAknButton::DrawText( CWindowGc& aGc, TRect& aTextRect ) const
       
  3551     {
       
  3552     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  3470 
  3553 
  3471     aGc.SetBrushStyle( CGraphicsContext::ENullBrush );
  3554     aGc.SetBrushStyle( CGraphicsContext::ENullBrush );
  3472 
  3555 
  3473     TRgb penColor;
  3556     TRgb penColor;
  3474     TRgb brushColor;
  3557     TRgb brushColor;
  3483         }
  3566         }
  3484     aGc.UseFont( font );
  3567     aGc.UseFont( font );
  3485 
  3568 
  3486     aGc.SetUnderlineStyle( iExtension->iUnderlineStyle );
  3569     aGc.SetUnderlineStyle( iExtension->iUnderlineStyle );
  3487 
  3570 
  3488     // buffer for visually ordered text
       
  3489     TBuf<255 + KAknBidiExtraSpacePerLine> visualText; 
       
  3490     TInt clipWidth = textRect.Width();
       
  3491 
       
  3492     // bidi processing - using AknBidiTextUtils.
       
  3493     AknBidiTextUtils::ConvertToVisualAndClip(
       
  3494         state->Text(),
       
  3495         visualText,
       
  3496         *font,
       
  3497         clipWidth,
       
  3498         clipWidth );
       
  3499 
  3571 
  3500     TInt baselineOffset = 0;
  3572     TInt baselineOffset = 0;
  3501     switch ( iVerticalAlignment )
  3573     switch ( iVerticalAlignment )
  3502         {
  3574         {
  3503         case ETop:
  3575         case ETop:
  3504             baselineOffset = font->AscentInPixels();
  3576             baselineOffset = font->AscentInPixels();
  3505             break;
  3577             break;
  3506 
  3578 
  3507         case EBottom:
  3579         case EBottom:
  3508             baselineOffset = textRect.Height();
  3580             baselineOffset = aTextRect.Height();
  3509             break;
  3581             break;
  3510 
  3582 
  3511         default:  // centered
  3583         default:  // centered
  3512             baselineOffset = font->AscentInPixels() +
  3584             baselineOffset = font->AscentInPixels() +
  3513                            ( textRect.Height() - font->AscentInPixels() ) / 2;
  3585                            ( aTextRect.Height() - font->AscentInPixels() ) / 2;
  3514         }
  3586         }
  3515 
  3587 
  3516     CGraphicsContext::TTextAlign horAlignment = iHorizontalAlignment;
  3588     CGraphicsContext::TTextAlign horAlignment = iHorizontalAlignment;
  3517 
  3589 
  3518     aGc.DrawText( visualText, textRect, baselineOffset, horAlignment );
  3590     aGc.DrawText( iExtension->iVisualText, aTextRect, baselineOffset, 
       
  3591             horAlignment );
  3519     if ( iExtension->iPictographInterface )
  3592     if ( iExtension->iPictographInterface )
  3520         {
  3593         {
  3521         // For Japanese variant only
  3594         // For Japanese variant only
  3522         iExtension->iPictographInterface->Interface()->DrawPictographsInText(
  3595         iExtension->iPictographInterface->Interface()->DrawPictographsInText(
  3523             aGc, *font, visualText, textRect, baselineOffset, horAlignment );
  3596             aGc, *font, iExtension->iVisualText, aTextRect, baselineOffset, 
       
  3597             horAlignment );
  3524         }
  3598         }
  3525     }
  3599     }
  3526 
  3600 
  3527 // -----------------------------------------------------------------------------
  3601 // -----------------------------------------------------------------------------
  3528 // CAknButton::DrawIconButton
  3602 // CAknButton::DrawIconButton
  3617     {
  3691     {
  3618     CAknButtonState* state = State();
  3692     CAknButtonState* state = State();
  3619     if ( !state  || !state->HasText() )
  3693     if ( !state  || !state->HasText() )
  3620         {
  3694         {
  3621         return;
  3695         return;
       
  3696         }
       
  3697     if ( state->TextChanged() )
       
  3698         {
       
  3699         ConvertTextToVisualAndClip(); 
  3622         }
  3700         }
  3623     
  3701     
  3624     const CGulIcon* icon = GetCurrentIcon();
  3702     const CGulIcon* icon = GetCurrentIcon();
  3625     if ( !icon )
  3703     if ( !icon )
  3626         {
  3704         {
  3773     else if ( buttonBmp )
  3851     else if ( buttonBmp )
  3774         {
  3852         {
  3775         aGc.BitBlt( iconPoint, buttonBmp, iconRect.Size() );
  3853         aGc.BitBlt( iconPoint, buttonBmp, iconRect.Size() );
  3776         }
  3854         }
  3777 
  3855 
  3778     const CFont* font = iFont;
  3856     DrawText( aGc, textRect ); 
  3779     if ( !font )
       
  3780         {
       
  3781         font = iCoeEnv->NormalFont();
       
  3782         }
       
  3783     aGc.UseFont( font );
       
  3784         
       
  3785     TRgb penColor;
       
  3786     TRgb brushColor;
       
  3787     GetTextColors( penColor, brushColor ); 
       
  3788     aGc.SetPenColor( penColor ); 
       
  3789     aGc.SetBrushColor( brushColor ); 
       
  3790 
       
  3791     aGc.SetUnderlineStyle( iExtension->iUnderlineStyle );
       
  3792 
       
  3793     TBuf<255 + KAknBidiExtraSpacePerLine> visualText; // buffer for visually ordered text
       
  3794     TInt clipWidth = textRect.Width();
       
  3795 
       
  3796     // bidi processing - using AknBidiTextUtils.
       
  3797     AknBidiTextUtils::ConvertToVisualAndClip(
       
  3798         state->Text(),
       
  3799         visualText,
       
  3800         *font,
       
  3801         clipWidth,
       
  3802         clipWidth );
       
  3803 
       
  3804     TInt baselineOffset = 0;
       
  3805     switch ( iVerticalAlignment )
       
  3806         {
       
  3807         case ETop:
       
  3808             baselineOffset = font->AscentInPixels();
       
  3809             break;
       
  3810 
       
  3811         case EBottom:
       
  3812             baselineOffset = textRect.Height();
       
  3813             break;
       
  3814 
       
  3815         default:  // centered
       
  3816             baselineOffset = font->AscentInPixels() +
       
  3817                            ( textRect.Height() - font->AscentInPixels() ) / 2;
       
  3818         }
       
  3819 
       
  3820     CGraphicsContext::TTextAlign horAlignment = iHorizontalAlignment;
       
  3821 
       
  3822     aGc.DrawText( visualText, textRect, baselineOffset, horAlignment );
       
  3823     if ( iExtension->iPictographInterface )
       
  3824         {
       
  3825         // For Japanese variant only
       
  3826         iExtension->iPictographInterface->Interface()->DrawPictographsInText(
       
  3827             aGc, *font, visualText, textRect, baselineOffset, horAlignment );
       
  3828         }
       
  3829     }
  3857     }
  3830 
  3858 
  3831 // -----------------------------------------------------------------------------
  3859 // -----------------------------------------------------------------------------
  3832 // Starts the long press timer.
  3860 // Starts the long press timer.
  3833 // -----------------------------------------------------------------------------
  3861 // -----------------------------------------------------------------------------
  4410         delete state;
  4438         delete state;
  4411         state = NULL;
  4439         state = NULL;
  4412         iStates->Delete( iStateIndex );
  4440         iStates->Delete( iStateIndex );
  4413         
  4441         
  4414         iStateIndex <= 0 ? iStateIndex = 0 : iStateIndex--;
  4442         iStateIndex <= 0 ? iStateIndex = 0 : iStateIndex--;
       
  4443         SetFrameIDs(); 
  4415         DrawNow();
  4444         DrawNow();
  4416         }
  4445         }
  4417     }
  4446     }
  4418 
  4447 
  4419 
  4448 
  4511         iHelpNote->SetTooltipModeL( ETrue );
  4540         iHelpNote->SetTooltipModeL( ETrue );
  4512         }
  4541         }
  4513     }
  4542     }
  4514 
  4543 
  4515 // -----------------------------------------------------------------------------
  4544 // -----------------------------------------------------------------------------
       
  4545 // CAknButton::SetFrameIDs
       
  4546 // Sets frame ids for background context
       
  4547 // -----------------------------------------------------------------------------
       
  4548 //
       
  4549 void CAknButton::SetFrameIDs() const
       
  4550     {
       
  4551     // Skin ids are determined here (a bit too early than necessary) so that 
       
  4552     // we can avoid doing the same thing in DrawMaskedL.
       
  4553     CAknButtonState* state = State();
       
  4554     if ( !( iFlags & KAknButtonNoFrame ) )
       
  4555         {
       
  4556         TInt frameIdIndex = KFrameId;
       
  4557 
       
  4558         if ( iButtonPressed )
       
  4559             {
       
  4560             frameIdIndex = KPressedFrameId;
       
  4561             }
       
  4562         else if ( state && state->Flags() & KAknButtonStateHasLatchedFrame )
       
  4563             {
       
  4564             if ( IsDimmed() )
       
  4565                 {
       
  4566                 // dimmed latched frame
       
  4567                 frameIdIndex = KLatchedDimmedFrameId;
       
  4568                 }
       
  4569             else
       
  4570                 {
       
  4571                 // latched down
       
  4572                 frameIdIndex = KLatchedFrameId;
       
  4573                 }
       
  4574             }
       
  4575         else if ( IsDimmed() )
       
  4576             {
       
  4577             // dimmed frame
       
  4578             frameIdIndex = KDimmedFrameId;
       
  4579             }
       
  4580 
       
  4581         if ( SkinIID( frameIdIndex ) != KAknsIIDNone )
       
  4582             {
       
  4583             iBgContext->SetFrame( SkinIID( frameIdIndex ) );
       
  4584             iBgContext->SetCenter( SkinIID( ++frameIdIndex) );
       
  4585             }
       
  4586         }
       
  4587     if ( state )
       
  4588         {
       
  4589         state->ResetFlagsChanged(); 
       
  4590         }
       
  4591     }
       
  4592 
       
  4593 // -----------------------------------------------------------------------------
       
  4594 // CAknButton::SetFrameRects
       
  4595 // -----------------------------------------------------------------------------
       
  4596 //
       
  4597 void CAknButton::SetFrameRects()
       
  4598     {
       
  4599     TRect rect( Rect() );
       
  4600     TAknLayoutRect centerLayout;
       
  4601     centerLayout.LayoutRect( rect,
       
  4602         AknLayoutScalable_Avkon::toolbar_button_pane_g1().LayoutLine() );
       
  4603     TRect innerRect( centerLayout.Rect() );
       
  4604 
       
  4605     iBgContext->SetFrameRects( rect, innerRect ); 
       
  4606     iExtension->iHighlightContext->SetFrameRects( rect, innerRect ); 
       
  4607     }
       
  4608 
       
  4609 // -----------------------------------------------------------------------------
       
  4610 // CAknButton::ConvertTextToVisualAndClip
       
  4611 // -----------------------------------------------------------------------------
       
  4612 //
       
  4613 void CAknButton::ConvertTextToVisualAndClip() const
       
  4614     {
       
  4615     CAknButtonState* state = State();
       
  4616     if ( !state || !state->HasText() )
       
  4617         {
       
  4618         if ( state ) 
       
  4619             {
       
  4620             state->ResetTextChanged();
       
  4621             } 
       
  4622         return;
       
  4623         }
       
  4624 
       
  4625     TRect textRect = iExtension->iMargins.InnerRect( Rect() );
       
  4626 
       
  4627     if ( !( iFlags & KAknButtonNoFrame ) && 
       
  4628          ( iFlags & KAknButtonTextInsideFrame ) )
       
  4629         {
       
  4630         TAknLayoutRect center;
       
  4631         center.LayoutRect( Rect(), 
       
  4632             AknLayoutScalable_Avkon::toolbar_button_pane_g1().LayoutLine() );
       
  4633 
       
  4634         textRect = center.Rect();
       
  4635         }
       
  4636 
       
  4637     TInt clipWidth = textRect.Width();
       
  4638 
       
  4639     const CFont* font = iFont;
       
  4640     if ( !font )
       
  4641         {
       
  4642         font = iCoeEnv->NormalFont();
       
  4643         }
       
  4644 
       
  4645     // bidi processing - using AknBidiTextUtils.
       
  4646     AknBidiTextUtils::ConvertToVisualAndClip(
       
  4647         state->Text(),
       
  4648         iExtension->iVisualText,
       
  4649         *font,
       
  4650         clipWidth,
       
  4651         clipWidth );
       
  4652     }
       
  4653 // -----------------------------------------------------------------------------
  4516 // CAknButton::TouchArea
  4654 // CAknButton::TouchArea
  4517 // Returns the button touchable area.
  4655 // Returns the button touchable area.
  4518 // -----------------------------------------------------------------------------
  4656 // -----------------------------------------------------------------------------
  4519 //
  4657 //
  4520 TRect CAknButton::TouchArea() const
  4658 TRect CAknButton::TouchArea() const
  4528             !Layout_Meta_Data::IsLandscapeOrientation() ).LayoutLine() );
  4666             !Layout_Meta_Data::IsLandscapeOrientation() ).LayoutLine() );
  4529         touchRect = layoutRect.Rect();
  4667         touchRect = layoutRect.Rect();
  4530         }
  4668         }
  4531     return touchRect;
  4669     return touchRect;
  4532     }
  4670     }
       
  4671 
       
  4672 // -----------------------------------------------------------------------------
       
  4673 // CAknButton::EnableFeedback
       
  4674 // Enables or disables tactile feedback
       
  4675 // -----------------------------------------------------------------------------
       
  4676 //
       
  4677 EXPORT_C void CAknButton::EnableFeedback( TBool aEnable )
       
  4678     {
       
  4679     if ( iExtension->iFeedbackEnabled == aEnable )
       
  4680         {
       
  4681         return; 
       
  4682         }
       
  4683     iExtension->iFeedbackEnabled = aEnable; 
       
  4684     if ( aEnable )
       
  4685         {
       
  4686         if ( !iExtension->iFeedback )
       
  4687             {
       
  4688             iExtension->iFeedback = MTouchFeedback::Instance();
       
  4689             }
       
  4690         if ( !iExtension->iFeedback )
       
  4691             {
       
  4692             return;
       
  4693             }
       
  4694         if ( IsVisible() )
       
  4695             {
       
  4696             iExtension->iFeedback->MoveFeedbackAreaToFirstPriority( this, 
       
  4697                                                                         0 );
       
  4698             iExtension->iFeedback->EnableFeedbackForControl( 
       
  4699                     this, 
       
  4700                    !IsDimmed() );
       
  4701             }
       
  4702         iExtension->HandleFeedbackAreaChange(); 
       
  4703         }
       
  4704     else 
       
  4705         {
       
  4706         // MTouchFeedback instance lives in AknAppUi. If there is no
       
  4707         // MTouchFeedback instance there is no need to remove any areas
       
  4708         // either.
       
  4709         MTouchFeedback* fb = MTouchFeedback::Instance();
       
  4710         if ( fb )
       
  4711             {
       
  4712             fb->RemoveFeedbackForControl( this );
       
  4713             }
       
  4714         }
       
  4715     }
  4533 // end of file
  4716 // end of file