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 |
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 |
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 |
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 } |
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 |
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() ) |
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 // ----------------------------------------------------------------------------- |
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 |
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 // ----------------------------------------------------------------------------- |
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 |