Esempio n. 1
0
void QTactileFeedback::touchFeedback(QEvent *event, const QWidget *widget)
{
    //Lets share the global instance for touch feedback (you are NOT allowed to try and delete it!).
    MTouchFeedback* feedback = MTouchFeedback::Instance();

    //If the widget itself is not handling focus, try to use focusProxy widget.
    const QWidget *w = ((widget->focusPolicy() == Qt::NoFocus) && (widget->focusProxy())) ? widget->focusProxy() : widget;

    //Only give tactile feedback for enabled widgets that take focus.
    if (feedback && w && w->isEnabled() && w->isWidgetType() && w->isVisible()) {
        //Scrollbars are 'special' that they don't take focus (nor they have focusProxy), yet we'd like to have tactile feedback for them
        if (w->focusPolicy() == Qt::NoFocus)
            if (!qobject_cast<const QScrollBar *>(w))
                return;

        //Don't give tactile feedback for widgets that are outside topmost dialog.
        QWidget *dialog = QApplication::activeModalWidget();
        if (dialog) {
            QList<const QWidget *> allChildren = dialog->findChildren<const QWidget *>();
            if (!allChildren.contains(w))
                return;
        }

        //Widget specific tactile feedback.
        if (qobject_cast<const QSlider *>(w) || qobject_cast<const QScrollBar *>(w))
            feedback->InstantFeedback(ETouchFeedbackSensitive);
        else
            feedback->InstantFeedback(ETouchFeedbackBasic);
    }
}
//-----------------------------------------------------------------------------
// WebPointerEventHandler::doTapL
//-----------------------------------------------------------------------------
void WebPointerEventHandler::doTapL()
{
    TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
    Frame* coreFrame = core(m_webview->mainFrame());
    
#ifdef BRDO_TOUCH_ENABLED_FF
    if (m_isHighlighted)
    {
        MTouchFeedback* feedback = MTouchFeedback::Instance();
        if (feedback)
           {
           feedback->InstantFeedback(ETouchFeedbackBasic);
           }
    }
#endif // BRDO_TOUCH_ENABLED_FF
    
     /*
      * We assume that if element visibility has been changed  
      * between "up" and "down" that means that some node event 
      * listener (onMouseOver etc) handling happened and we don't 
      * want to send a click (mouse press = mouse release) event.
      * The exception is editable element, since we want VKB anyway
      */
     if (!IS_NAVIGATION_NONE &&
         elType != TBrCtlDefs::EElementActivatedInputBox && 
         elType != TBrCtlDefs::EElementTextAreaBox &&     
         m_webview->page()->chrome()->client()->elementVisibilityChangedByMouse()) {
         return;
     }

     m_lastTapEvent.iPosition = m_buttonDownEvent.iPosition;
     m_lastTapEvent.iType = TPointerEvent::EButton1Up;
     m_lastTapEvent.iModifiers = 0;

    // don't pass the event if the text input is not in valid format
    if (isHighlitableElement(elType) || m_webview->fepTextEditor()->validateTextFormat()) {
        m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Up,  m_lastTapEvent.iPosition, coreFrame);
    }

    // special handling for broken image (why is this here??)
    if (elType == TBrCtlDefs::EElementBrokenImage) {
        loadFocusedImage(m_webview);
    }
    else if (elType == TBrCtlDefs::EElementActivatedObjectBox) {
        PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin();
        if(plugin && plugin->pluginWin() && plugin->getClipRect().Contains(m_lastTapEvent.iPosition)){
            plugin->pluginWin()->HandlePointerEventL(m_lastTapEvent);
        }
    }
    else {
        m_webview->activateVirtualKeyboard();
    }
}
void CEmTubeSplashViewContainer::ConstructL(const TRect& aRect)
	{
	iAlpha = KAlphaMax;

	iAppUi = STATIC_CAST(CEmTubeAppUi*, CEikonEnv::Static()->EikAppUi());

	CreateWindowL();

	TSize size( KBitmapSize, KBitmapSize );
	CFbsBitmap *bmp = AknIconUtils::CreateIconL( KBitmapFileName, EMbmOpenvideohubLogo_white );
	CleanupStack::PushL( bmp );
	AknIconUtils::SetSize( bmp, size );

    iBitmap = new (ELeave) CFbsBitmap();
    iBitmap->Create( size, EColor16MU );
    CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL( iBitmap );
    CleanupStack::PushL( bitmapDevice );
    CFbsBitGc* bitmapGc = CFbsBitGc::NewL();
    CleanupStack::PushL( bitmapGc );
    bitmapGc->Activate( bitmapDevice );
    bitmapGc->DrawBitmap( size, bmp );

	CleanupStack::PopAndDestroy( bitmapGc );
	CleanupStack::PopAndDestroy( bitmapDevice );
	CleanupStack::PopAndDestroy( bmp );

	iTmpBitmap = new (ELeave) CFbsBitmap;
	iTmpBitmap->Create( TSize(KBitmapSize, KBitmapSize), EColor16MU );

	SetRect(aRect);
	iClientRect = aRect;
	ActivateL();

	SetExtentToWholeScreen();
	iAppUi->StopDisplayingPopupToolbar();

	iFadeTimer = CEmTubeTimeOutTimer::NewL( *this );
	iFadeTimer->After( KFadePeriod, ECommandFadeIn );

	iTimer = CEmTubeTimeOutTimer::NewL( *this );
	iTimer->After( KSplashTime, ECommandFinish );

#ifdef __S60_50__
	MTouchFeedback* feedback = MTouchFeedback::Instance();
	if ( feedback )
		{
		feedback->EnableFeedbackForControl( this, ETrue );
		}
#endif
	}
EXPORT_C void CAknNoteWrapper::HandlePointerEventL(const TPointerEvent& aPointerEvent)
    {
    if ( AknLayoutUtils::PenEnabled() )
        {
        if (aPointerEvent.iType == TPointerEvent::EButton1Up)
            {
            MTouchFeedback* feedback = MTouchFeedback::Instance();
            if ( feedback )
                {
                feedback->InstantFeedback( ETouchFeedbackPopUp );
                }
            StaticDeleteL(this);     
            }
        }
    }
void CEmTubeSplashViewContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent)
    {
    // Check if touch is enabled or not
    if( !AknLayoutUtils::PenEnabled() )
        {
        return;
        }

    if (aPointerEvent.iType == TPointerEvent::EButton1Up)
        {
#ifdef __S60_50__
		MTouchFeedback* feedback = MTouchFeedback::Instance();
		if ( feedback )
			{
			feedback->InstantFeedback( this, ETouchFeedbackBasic );
			}
#endif
    	iView.HandleCommandL( EMTVActivateMainViewCommand );
        }

    // Call base class HandlePointerEventL()
    CCoeControl::HandlePointerEventL(aPointerEvent);
    }
// -----------------------------------------------------------------------------
// CAknInfoPopupNote::HandlePointerEventL
// 
// -----------------------------------------------------------------------------
//
void CAknInfoPopupNote::HandlePointerEventL( const TPointerEvent& aPointerEvent )
    {
    if ( AknLayoutUtils::PenEnabled() )
        {
        SetPointerCapture( ETrue );

        if ( aPointerEvent.iType == TPointerEvent::EButton1Down
             || aPointerEvent.iType == TPointerEvent::EButton1Up
             || aPointerEvent.iType == TPointerEvent::EDrag )
            {
            if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
                {
                MTouchFeedback* feedback = MTouchFeedback::Instance();
                if ( feedback )
                    {
                    feedback->InstantFeedback( ETouchFeedbackPopUp );
                    }
                }

            Hide();
            SetPointerCapture( EFalse ); 
            }
        }
    }
void CMsgBodyControlEditor::HandlePointerEventL( const TPointerEvent& aPointerEvent )
    {
    TBool forwardRequest( ETrue );
    
    if ( IsActivated() &&
         IsReadOnly() && 
         ( aPointerEvent.iType == TPointerEvent::EButton1Down ||
           aPointerEvent.iType == TPointerEvent::EButton1Up ) )
        {
        TPoint tapPoint( aPointerEvent.iPosition );
        TInt docPos( TextView()->XyPosToDocPosL( tapPoint ) );
        
        TInt start( 0 );
        TInt length( 0 );
        MParser* parser = iItemFinder;
        
        TBool tappedOverTag( RichText()->CursorOverTag( docPos, parser, start, length ) );
            
        if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
            {
            iPreviousItemStart = -1;
            iPreviousItemLength = -1;
            
            if ( tappedOverTag )
                {
                TPoint relativeTapPoint( aPointerEvent.iPosition - iPosition );
                if ( iItemFinder->ItemWasTappedL( relativeTapPoint ) )
                    {                
                    iPreviousItemStart = start;
                    iPreviousItemLength = length;
                    
                    forwardRequest = EFalse;
                    }
                }
            else
                {
                iItemFinder->ResetCurrentItem();
                }
            }
        else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
            {
            if ( tappedOverTag &&
                 start >= iPreviousItemStart &&
                 length <= iPreviousItemLength )
                {
                TKeyEvent event;
                event.iCode = EKeyDevice3;
                event.iScanCode = EStdKeyDevice3;
                event.iModifiers = 0;
                event.iRepeats = 0;
                
                iCoeEnv->WsSession().SimulateKeyEvent( event );
                
                forwardRequest = EFalse;
                }
            }
        }

    if ( forwardRequest )
        {
        CMsgExpandableControlEditor::HandlePointerEventL( aPointerEvent );
        }                
#ifdef RD_TACTILE_FEEDBACK         
    else if(aPointerEvent.iType == TPointerEvent::EButton1Down)
        {                                
        MTouchFeedback* feedback = MTouchFeedback::Instance();
        if ( feedback )
            {
            feedback->InstantFeedback( this, ETouchFeedbackBasic );
            }
        }
#endif //  RD_TACTILE_FEEDBACK      
    }
// ---------------------------------------------------------------------------
// CBCTestMix50Case::TestTouchFeedback()
// ( menu item -21- )
// ---------------------------------------------------------------------------
//
void CBCTestMix50Case::TestTouchFeedback()   
    {
    MTouchFeedback* feedback = MTouchFeedback::Instance();
    _LIT( KMTouchFeedbackInstance,
          "MTouchFeedback::Instance" );
    AssertTrueL( ETrue, KMTouchFeedbackInstance );   
    
    feedback->TouchFeedbackSupported();
    _LIT(KMTouchFBSupported, "TouchFeedbackSuppoted()!");
    AssertTrueL( ETrue, KMTouchFBSupported );  
    
    feedback->SetFeedbackEnabledForThisApp( ETrue );
    _LIT(KMSetFeedbackEnabledForThisApp, "SetFeedbackEnabledForThisApp()!");
    AssertTrueL( ETrue, KMSetFeedbackEnabledForThisApp );  
    
    TBool fb;
    fb = feedback->FeedbackEnabledForThisApp();
    _LIT(KMFeedbackEnabledForThisApp, "FeedbackEnabledForThisApp()!");
    AssertTrueL( ETrue, KMFeedbackEnabledForThisApp );  
    //AssertTrueL( ETrue, fb );
    
    feedback->FlushRegistryUpdates();
    _LIT(KMFlushRegUpdates, "FlushRegistryUpdates()!");
    AssertTrueL(ETrue, KMFlushRegUpdates);
    
 
    TTouchLogicalFeedback type;
    feedback->InstantFeedback(type);
    _LIT(KMInstantFeedback, "InstantFeedback()!");
    AssertTrueL(ETrue, KMInstantFeedback);
    
    CAknButton* aknCAknButton = CAknButton::NewL(); 
    CleanupStack::PushL( aknCAknButton );
    
    TUint32 index;
    TRect rect;
    TTouchEventType etype;
    feedback->SetFeedbackArea( aknCAknButton, index, rect, type, etype);
    _LIT(KMSetFeedbackArea, "SetFeedbackArea()!");
    AssertTrueL(ETrue, KMSetFeedbackArea);
    
    feedback->RemoveFeedbackArea(aknCAknButton, index);
    _LIT(KMRemoveFeedbackArea, "RemoveFeedbackArea()!");
    AssertTrueL( ETrue, KMRemoveFeedbackArea );
    
    feedback->RemoveFeedbackForControl(aknCAknButton);
    _LIT(KMRemoveFeedbackForControl, "RemoveFeedbackForControl()!");
    AssertTrueL( ETrue, KMRemoveFeedbackForControl );
    
    feedback->ChangeFeedbackArea(aknCAknButton, index, rect);
    _LIT(KMChangeFeedbackArea, "ChangeFeedbackArea()!");
    AssertTrueL( ETrue, KMChangeFeedbackArea );
    
    feedback->ChangeFeedbackType(aknCAknButton, index, type);
    _LIT(KMChangeFeedbackType, "ChangeFeedbackType()!");
    AssertTrueL( ETrue, KMChangeFeedbackType );
    
    feedback->MoveFeedbackAreaToFirstPriority(aknCAknButton, index);
    _LIT(KMMoveFeedbackAreaToFirstPriority, "MoveFeedbackAreaToFirstPriority()!");
    AssertTrueL(ETrue, KMMoveFeedbackAreaToFirstPriority);
    
    feedback->InstantFeedback(aknCAknButton, type);
    _LIT(KMInstantFeedback2, "InstantFeedback(aknCAknButton, type)!");
    AssertTrueL(ETrue, KMInstantFeedback2);
    
    feedback->ControlHasFeedback(aknCAknButton);
    _LIT(KMControlHasFeedback, "ControlHasFeedback()!");
    AssertTrueL(ETrue, KMControlHasFeedback);
    
    feedback->ControlHasFeedback(aknCAknButton, index);
    _LIT(KMControlHasFeedback2, "ControlHasFeedback(index)!");
    AssertTrueL(ETrue, KMControlHasFeedback2);
    
    feedback->EnableFeedbackForControl( aknCAknButton, fb );
    _LIT(KMEnableFeedbackForControl, "EnableFeedbackForControl()!");
    AssertTrueL(ETrue, KMEnableFeedbackForControl);
    
    
    
    
    CleanupStack::PopAndDestroy( aknCAknButton );
    
    if( !feedback )
        {
        MTouchFeedback*  feedbackCreated = MTouchFeedback::CreateInstanceL();
        _LIT( KMTouchFeedbackCreateInstanceL,
              "MTouchFeedback::CreateInstanceL" );
        AssertTrueL( ETrue, KMTouchFeedbackCreateInstanceL );     
        
        
        MTouchFeedback::DestroyInstance();
        _LIT( KMTouchFeedbackDestroyInstance,
              "MTouchFeedback::DestroyInstance" );
        AssertTrueL( ETrue, KMTouchFeedbackDestroyInstance );     
                
        }

		
    }