コード例 #1
0
void Ut_StatusIndicatorMenuWindow::testStatusIndicatorMenuIsClosedWhenStatusBarIsTapped()
{
    QFETCH(bool, pressInside);
    QFETCH(bool, releaseInside);
    QFETCH(MSceneWindow::SceneWindowState, sceneWindowState);

    statusIndicatorMenuWindow->displayActive();

    // Map the bounding rect to the scene
    QRectF statusBarGeometry(statusIndicatorMenuWindow->statusBar->sceneBoundingRect());
    QPoint pressPoint(statusBarGeometry.x(), statusBarGeometry.y());
    QPoint releasePoint(statusBarGeometry.x(), statusBarGeometry.y());

    if (!pressInside) {
        pressPoint += QPoint(-1, -1);
    }

    if (!releaseInside) {
        releasePoint += QPoint(-1, -1);
    }

    // Then map the press point to the viewport
    pressPoint = statusIndicatorMenuWindow->mapFromScene(pressPoint);
    releasePoint = statusIndicatorMenuWindow->mapFromScene(releasePoint);

    QMouseEvent pressEvent(QEvent::MouseButtonPress, pressPoint, Qt::LeftButton, Qt::MouseButtons(Qt::LeftButton), Qt::KeyboardModifiers(Qt::NoModifier));
    QMouseEvent releaseEvent(QEvent::MouseButtonRelease, releasePoint, Qt::LeftButton, Qt::MouseButtons(Qt::LeftButton), Qt::KeyboardModifiers(Qt::NoModifier));

    statusIndicatorMenuWindow->mousePressEvent(&pressEvent);
    statusIndicatorMenuWindow->mouseReleaseEvent(&releaseEvent);

    QCOMPARE(statusIndicatorMenuWindow->menuWidget->sceneWindowState(), sceneWindowState);
}
コード例 #2
0
ファイル: cwindow.cpp プロジェクト: Tiikara/RTS-3D
bool CWindow::mousePressEvent(float mouseX, float mouseY, bool leftMouse, bool rightMouse)
{
    transformCoordToLocal(&mouseX,&mouseY);

    if(notInWindowMouse(mouseX,mouseY))
        return false;

    return pressEvent(mouseX,mouseY,leftMouse,rightMouse);
}
コード例 #3
0
ファイル: MenuHandler.cpp プロジェクト: 469486139/DOOM-3-BFG
/*
================================================
idMenuHandler::Update
================================================
*/
bool idMenuHandler::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {

	widgetAction_t actionType = action.GetType();
	const idSWFParmList & parms = action.GetParms();

	switch ( actionType ) {
		case WIDGET_ACTION_ADJUST_FIELD: {
			if ( widget != NULL && widget->GetDataSource() != NULL ) {
				widget->GetDataSource()->AdjustField( widget->GetDataSourceFieldIndex(), parms[ 0 ].ToInteger() );
				widget->Update();
			}
			return true;
		}
		case WIDGET_ACTION_FUNCTION: {
			if ( verify( action.GetScriptFunction() != NULL ) ) {
				action.GetScriptFunction()->Call( event.thisObject, event.parms );
			}
			return true;
		}
		case WIDGET_ACTION_PRESS_FOCUSED: {
			idMenuScreen * const screen = menuScreens[ activeScreen ];
			if ( screen != NULL ) {
				idWidgetEvent pressEvent( WIDGET_EVENT_PRESS, 0, event.thisObject, idSWFParmList() );
				screen->ReceiveEvent( pressEvent );
			}
			return true;
		}
		case WIDGET_ACTION_START_REPEATER: {
			idWidgetAction repeatAction;
			widgetAction_t repeatActionType = static_cast< widgetAction_t >( parms[ 0 ].ToInteger() );
			assert( parms.Num() >= 2 );
			int repeatDelay = DEFAULT_REPEAT_TIME;
			if ( parms.Num() >= 3 ) {
				repeatDelay = parms[2].ToInteger();
			} 
			repeatAction.Set( repeatActionType, parms[ 1 ], repeatDelay );
			StartWidgetActionRepeater( widget, repeatAction, event );
			return true;
		}
		case WIDGET_ACTION_STOP_REPEATER: {
			ClearWidgetActionRepeater();
			return true;
		}
	}

	if ( !widget->GetHandlerIsParent() ) {
		for ( int index = 0; index < children.Num(); ++index ) {
			if ( children[index] != NULL ) {
				if ( children[index]->HandleAction( action, event, widget, forceHandled ) ) {
					return true;
				}
			}
		}
	}

	return false;
}
コード例 #4
0
ファイル: mediaview.cpp プロジェクト: CapnRat/tdesktop
void MediaView::touchEvent(QTouchEvent *e) {
	switch (e->type()) {
	case QEvent::TouchBegin:
		if (_touchPress || e->touchPoints().isEmpty()) return;
		_touchTimer.start(QApplication::startDragTime());
		_touchPress = true;
		_touchMove = _touchRightButton = false;
		_touchStart = e->touchPoints().cbegin()->screenPos().toPoint();
		break;

	case QEvent::TouchUpdate:
		if (!_touchPress || e->touchPoints().isEmpty()) return;
		if (!_touchMove && (e->touchPoints().cbegin()->screenPos().toPoint() - _touchStart).manhattanLength() >= QApplication::startDragDistance()) {
			_touchMove = true;
		}
		break;

	case QEvent::TouchEnd:
		if (!_touchPress) return;
		if (!_touchMove && App::wnd()) {
			Qt::MouseButton btn(_touchRightButton ? Qt::RightButton : Qt::LeftButton);
			QPoint mapped(mapFromGlobal(_touchStart)), winMapped(App::wnd()->mapFromGlobal(_touchStart));

			QMouseEvent pressEvent(QEvent::MouseButtonPress, mapped, winMapped, _touchStart, btn, Qt::MouseButtons(btn), Qt::KeyboardModifiers());
			pressEvent.accept();
			mousePressEvent(&pressEvent);

			QMouseEvent releaseEvent(QEvent::MouseButtonRelease, mapped, winMapped, _touchStart, btn, Qt::MouseButtons(btn), Qt::KeyboardModifiers());
			mouseReleaseEvent(&releaseEvent);

			if (_touchRightButton) {
				QContextMenuEvent contextEvent(QContextMenuEvent::Mouse, mapped, _touchStart);
				contextMenuEvent(&contextEvent);
			}
		} else if (_touchMove) {
			if ((!_leftNavVisible || !_leftNav.contains(mapFromGlobal(_touchStart))) && (!_rightNavVisible || !_rightNav.contains(mapFromGlobal(_touchStart)))) {
				QPoint d = (e->touchPoints().cbegin()->screenPos().toPoint() - _touchStart);
				if (d.x() * d.x() > d.y() * d.y() && (d.x() > st::medviewSwipeDistance || d.x() < -st::medviewSwipeDistance)) {
					moveToPhoto(d.x() > 0 ? -1 : 1);
				}
			}
		}
		_touchTimer.stop();
		_touchPress = _touchMove = _touchRightButton = false;
		break;

	case QEvent::TouchCancel:
		_touchPress = false;
		_touchTimer.stop();
		break;
	}
}
コード例 #5
0
ファイル: rcdraw.cpp プロジェクト: aricciva/Proyectos-Vision
void RCDraw::mousePressEvent ( QMouseEvent *e )
{
    if ( e->button() == Qt::LeftButton )
	{
            iniCoorSelected.setX(e->x());
            iniCoorSelected.setY(e->y());
            endCoorSelected.setX(e->x());
            endCoorSelected.setY(e->y());

            onSelection = true;
            emit pressEvent();
	}
}
コード例 #6
0
ファイル: moc_buybutton.cpp プロジェクト: Krutoy242/Game
int BuyButton::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QToolButton::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: pressEvent(); break;
        case 1: buildSome(); break;
        default: ;
        }
        _id -= 2;
    }
    return _id;
}
コード例 #7
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    numFoto=0;
    cap = new VideoCapture(0);
    if(!cap->isOpened())
        cap = new VideoCapture(1);
    capture = true;
    showColorImage = false;
    winSelected = false;
    cap->set(CV_CAP_PROP_FRAME_WIDTH, 320);
    cap->set(CV_CAP_PROP_FRAME_HEIGHT, 240);
    imgS = new QImage(320,240, QImage::Format_RGB888);
    visorS = new RCDraw(320,240, imgS, ui->imageFrameS);
    imgD = new QImage(320,240, QImage::Format_RGB888);
    visorD = new RCDraw(320,240, imgD, ui->imageFrameD);



    colorImage.create(240,320,CV_8UC3);
    grayImage.create(240,320,CV_8UC1);
    destColorImage.create(240,320,CV_8UC3);
    Black_Color_Image.create(240,320,CV_8UC3);
    Black_Gray_Image.create(240,320,CV_8UC1);

    destGrayImage.create(240,320,CV_8UC1);
    gray2ColorImage.create(240,320,CV_8UC3);
    destGray2ColorImage.create(240,320,CV_8UC3);

    connect(&timer,SIGNAL(timeout()),this,SLOT(compute()));
    connect(ui->captureButton,SIGNAL(clicked(bool)),this,SLOT(start_stop_capture(bool)));
    connect(ui->colorButton,SIGNAL(clicked(bool)),this,SLOT(change_color_gray(bool)));

    connect(visorS,SIGNAL(windowSelected(QPointF, int, int)),this,SLOT(selectWindow(QPointF, int, int)));
    connect(visorS,SIGNAL(pressEvent()),this,SLOT(deselectWindow()));
    timer.start(60);
    ContVideo=0;
    TamComp=320*240;
}
コード例 #8
0
ファイル: xevent.cpp プロジェクト: BackupTheBerlios/sax-svn
//====================================
// Event filter for application...
//------------------------------------
bool XInputEvent::eventFilter ( QObject*, QEvent* event ) {
	QMouseEvent* mouse = (QMouseEvent*)event;
	QWheelEvent* wheel = (QWheelEvent*)event;
	if ((! mouse) && (! wheel)) {
		return (false);
	}
	switch (mouse->type()) {
	case QEvent::MouseButtonDblClick:
		timer->stop();
		doubleClick   = TRUE;
		mouseReleased = FALSE;
		mBtn = mouse->button();
		doubleClickEvent (mBtn);
	break;
	case QEvent::MouseButtonPress:
		mBtn = mouse->button();
		pressEvent (mBtn);
		mouseReleased = FALSE;
		timer->start ( 300, TRUE );
		doubleClick = FALSE;
	break;
	case QEvent::MouseButtonRelease:
		if (! doubleClick) {
			mouseReleased = TRUE;
			mBtn = mouse->button();
			releaseEvent (mBtn);
		}
	break;
	case QEvent::Wheel:
		wheelEvent ( wheel->delta()/WHEEL_DELTA );
	break;
	case QEvent::MouseMove:
		moveEvent (mouse->x(),mouse->y());
	break;
	default:
	break;
	}
	return (false);
}
コード例 #9
0
ファイル: wmgeneral.c プロジェクト: aquette/wmnut
/*
 * This checks for X11 events. We distinguish the following:
 * - request to repaint the window
 * - request to quit (Close button)
 * - mouse request (click)
 */
void CheckX11Events()
{
  XEvent Event;

  while (XPending(display)) {
    XNextEvent(display, &Event);
    switch(Event.type) {
      case Expose:
	RedrawWindow();
	break;
      case ButtonPress:
	pressEvent(&Event.xbutton);
	break;
      case ButtonRelease:
	break;
      case ClientMessage:
	if ((Event.xclient.message_type == wm_protocols)
	    && (Event.xclient.data.l[0] == wm_delete_window))
	  Cleanup();
	break;
    }
  }
}
コード例 #10
0
/*
========================
idMenuScreen_Shell_Root::HandleAction
========================
*/
bool idMenuScreen_Shell_Root::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {

	if ( menuData == NULL ) {
		return true;
	}

	if ( menuData->ActiveScreen() != SHELL_AREA_ROOT ) {
		return false;
	}

	widgetAction_t actionType = action.GetType();
	const idSWFParmList & parms = action.GetParms();

	switch ( actionType ) {
		case WIDGET_ACTION_GO_BACK: {
			session->MoveToPressStart();
			return true;
		}
		case WIDGET_ACTION_PRESS_FOCUSED: {
			if ( menuData->GetPlatform() == 2 ) {

				idMenuHandler_Shell * shell = dynamic_cast< idMenuHandler_Shell * >( menuData );
				if ( !shell ) {
					return true;
				}

				idMenuWidget_MenuBar * menuBar = shell->GetMenuBar();

				if ( !menuBar ) {
					return true;
				}

				const idMenuWidget_MenuButton * buttonWidget = dynamic_cast< idMenuWidget_MenuButton * >( &menuBar->GetChildByIndex( menuBar->GetFocusIndex() ) );
				if ( !buttonWidget ) {
					return true;
				}

				idWidgetEvent pressEvent( WIDGET_EVENT_PRESS, 0, NULL, idSWFParmList() );
				menuBar->ReceiveEvent( pressEvent );
				return true;
			} 
			break;
		}
		case WIDGET_ACTION_SCROLL_HORIZONTAL: {

			if ( menuData->GetPlatform() != 2 ) {
				return true;
			}

			idMenuHandler_Shell * shell = dynamic_cast< idMenuHandler_Shell * >( menuData );
			if ( !shell ) {
				return true;
			}

			idMenuWidget_MenuBar * menuBar = shell->GetMenuBar();
			
			if ( !menuBar ) {
				return true;
			}

			int index = menuBar->GetViewIndex();			
			const int dir = parms[0].ToInteger();
#ifdef ID_RETAIL
			const int totalCount = menuBar->GetTotalNumberOfOptions() - 1;
#else
			const int totalCount = menuBar->GetTotalNumberOfOptions();
#endif
			index += dir;
			if ( index < 0 ) {
				index = totalCount - 1;
			} else if ( index >= totalCount ) {
				index = 0;
			}

			SetRootIndex( index );
			menuBar->SetViewIndex( index );
			menuBar->SetFocusIndex( index );			

			return true;
		}
		case WIDGET_ACTION_COMMAND: {
			switch ( parms[0].ToInteger() ) {
				case ROOT_CMD_START_DEMO: {
					cmdSystem->AppendCommandText( va( "devmap %s %d\n", "demo/enpro_e3_2012", 1 ) );
					break;
				}
				case ROOT_CMD_START_DEMO2: {
					cmdSystem->AppendCommandText( va( "devmap %s %d\n", "game/le_hell", 2 ) );
					break;
				}
				case ROOT_CMD_SETTINGS: {
					menuData->SetNextScreen( SHELL_AREA_SETTINGS, MENU_TRANSITION_SIMPLE );
					break;
				}
				case ROOT_CMD_QUIT: {
					HandleExitGameBtn();
					break;
				}
				case ROOT_CMD_DEV: {
					menuData->SetNextScreen( SHELL_AREA_DEV, MENU_TRANSITION_SIMPLE );
					break;
				}
				case ROOT_CMD_CAMPAIGN: {
					menuData->SetNextScreen( SHELL_AREA_CAMPAIGN, MENU_TRANSITION_SIMPLE );
					break;
				}
				case ROOT_CMD_MULTIPLAYER: {
					const idLocalUser * masterUser = session->GetSignInManager().GetMasterLocalUser();

					if ( masterUser == NULL ) {
						break;
					}

					if ( masterUser->GetOnlineCaps() & CAP_BLOCKED_PERMISSION ) {
						common->Dialog().AddDialog( GDM_ONLINE_INCORRECT_PERMISSIONS, DIALOG_CONTINUE, NULL, NULL, true, __FUNCTION__, __LINE__, false );
					} else if ( !masterUser->CanPlayOnline() ) { 
						class idSWFScriptFunction_Accept : public idSWFScriptFunction_RefCounted {
						public:
							idSWFScriptFunction_Accept() { }
							idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
								common->Dialog().ClearDialog( GDM_PLAY_ONLINE_NO_PROFILE );
								session->ShowOnlineSignin();
								return idSWFScriptVar();
							}
						};
						class idSWFScriptFunction_Cancel : public idSWFScriptFunction_RefCounted {
						public:
							idSWFScriptFunction_Cancel() { }
							idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
								common->Dialog().ClearDialog( GDM_PLAY_ONLINE_NO_PROFILE );
								return idSWFScriptVar();
							}
						};

						common->Dialog().AddDialog( GDM_PLAY_ONLINE_NO_PROFILE, DIALOG_ACCEPT_CANCEL, new (TAG_SWF) idSWFScriptFunction_Accept(), new (TAG_SWF) idSWFScriptFunction_Cancel(), false );
					} else {
						idMatchParameters matchParameters;
						matchParameters.matchFlags = DefaultPartyFlags;
						session->CreatePartyLobby( matchParameters );
					}
					break;
				}
				case ROOT_CMD_PLAYSTATION: {
					menuData->SetNextScreen( SHELL_AREA_PLAYSTATION, MENU_TRANSITION_SIMPLE );
					break;
				}
				case ROOT_CMD_CREDITS: {
					menuData->SetNextScreen( SHELL_AREA_CREDITS, MENU_TRANSITION_SIMPLE );
					break;
				}
			}
			return true;
		}
	}

	return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
コード例 #11
0
ファイル: windowmover.cpp プロジェクト: kolayuk/SwipeUnlock
void CWindowMover::HandlePointerEventL(const TPointerEvent& aPointerEvent)
    {
    CCoeControl* control =(viewer->winId());
    if (aPointerEvent.iType == TPointerEvent::EButton1Down)
        {
        iPointerPoint1=aPointerEvent.iPosition;
        iPointerPoint2=aPointerEvent.iPosition;
        MovingChanged(true);

        QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress);
        pressEvent.setScenePos(QPointF(iPointerPoint1.iX-control->Position().iX, iPointerPoint1.iY-control->Position().iY));
        qDebug()<<pressEvent.scenePos().x()<<pressEvent.scenePos().y();
        pressEvent.setButton(Qt::LeftButton);
        pressEvent.setButtons(Qt::LeftButton);
        QApplication::sendEvent(viewer->scene(), &pressEvent);
        }
    else if (aPointerEvent.iType == TPointerEvent::EDrag)
        {
        iDragged=ETrue;
        TInt dx=aPointerEvent.iPosition.iX-iPointerPoint1.iX;
        TInt dy=aPointerEvent.iPosition.iY-iPointerPoint1.iY;
        if (!axisSet)
        {
            if (abs(dy)>abs(dx)) {axisX=0; axisY=1;}
            else {axisX=1;axisY=0;}
            axisSet=true;
        }
        RWindow rWindow=(control->Window());
        control->SetPosition(TPoint(dx*axisX,dy*axisY));
        control->DrawBackground(TRect(control->Position(),control->Size()));
        }
    else if (aPointerEvent.iType==TPointerEvent::EButton1Up)
        {
        iPointerPoint2=aPointerEvent.iPosition;
        //MakeVisible(EFalse);
        int gest=settings->value("settings/gesture").toInt();
        if (gest==0) axisSet=false;

        float horSense=settings->value("settings/horsense",0.5).toFloat();
        float verSense=settings->value("settings/versense",0.5).toFloat();
        int width=control->Size().iWidth;
        int height=control->Size().iHeight;
        int x=control->Position().iX;
        int y=control->Position().iY;
        qDebug()<<"("<<x<<","<<y<<")"<<horSense<<verSense;
        if (x>(horSense)*width)
           {startAnim(EXAxis,width);}
        else if (x<(-horSense)*width)
           {startAnim(EXAxis,-width);}
        else if (x!=0)
           {startAnim(EXAxis,0);}
        if (y>(verSense)*height)
           {startAnim(EYAxis,height);}
        else if (y<(-verSense)*height)
           {startAnim(EYAxis,-height);}
        else if (y!=0)
           {startAnim(EYAxis,0);}
        if (abs(iPointerPoint1.iX-iPointerPoint2.iX)<20&&abs(iPointerPoint1.iY-iPointerPoint2.iY)<20)
        {
            QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
            releaseEvent.setScenePos(QPointF(iPointerPoint1.iX-control->Position().iX, iPointerPoint1.iY-control->Position().iY));
            releaseEvent.setButton(Qt::LeftButton);
            releaseEvent.setButtons(Qt::LeftButton);
            QApplication::sendEvent(viewer->scene(), &releaseEvent);
        }
        else
        {
            QGraphicsSceneMouseEvent moveEvent(QEvent::GraphicsSceneMouseMove);
            moveEvent.setScenePos(QPointF(iPointerPoint1.iX-control->Position().iX-10,iPointerPoint1.iY-control->Position().iY-10));
            moveEvent.setButton(Qt::LeftButton);
            moveEvent.setButtons(Qt::LeftButton);
            QApplication::sendEvent(viewer->scene(), &moveEvent);
            QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
            releaseEvent.setScenePos(QPointF(0,0));
            releaseEvent.setButton(Qt::LeftButton);
            releaseEvent.setButtons(Qt::LeftButton);
            QApplication::sendEvent(viewer->scene(), &releaseEvent);

        }
        MovingChanged(false);
        }
    CCoeControl::HandlePointerEventL(aPointerEvent);
    }
コード例 #12
0
ファイル: MyTextBrowser_v4.cpp プロジェクト: pvbrowser/pvb
void MyTextBrowser::moveContent(int pos)
{
  if(pos >= '\t' || pos < 0)
  {
     activateWindow();
     char text[16];
     text[0] = pos & 0x0ff;
     text[1] = '\0';
     int modifiers = pos & 0x07fffff00;
     int key = pos & 0x0ff;
     if     ((pos & 0x0ff) == '\t') key = Qt::Key_Tab;
     else if((pos & 0x0ff) == 0x0d) key = Qt::Key_Return;
     QKeyEvent pressEvent(  QEvent::KeyPress,   (Qt::Key) key, (Qt::KeyboardModifiers) modifiers, text);
     QKeyEvent releaseEvent(QEvent::KeyRelease, (Qt::Key) key, (Qt::KeyboardModifiers) modifiers, text);
     if((pos & 0x0ff) == '\t') QWidget::setFocus(Qt::TabFocusReason);
     keyPressEvent(&pressEvent);
     keyReleaseEvent(&releaseEvent);
     return;
  }
#ifdef NO_WEBKIT
  char buf[MAX_PRINTF_LENGTH];
  QString myurl;

  if(opt.arg_debug) printf("moveContent(%d)\n", pos);
  if     (pos == 0 && homeIsSet) 
  { 
    myurl = home; 
    setSource(QUrl(home)); 
  }
  else if(pos == 1)              
  { 
    forward();
    myurl = source().path();
  }  
  else if(pos == 2) 
  {
    backward();
    myurl = source().path();
  }  
  else if(pos == 3) 
  {
    reload();
    myurl = source().path();
  }  
#else
  char buf[MAX_PRINTF_LENGTH];
  QString myurl;
  QWebHistory *hist;

  if(opt.arg_debug) printf("moveContent(%d)\n", pos);
  if     (pos == 0 && homeIsSet) 
  { 
    myurl = home; 
    load(home); 
  }
  else if(pos == 1)              
  { 
    hist = history();
    if(hist != NULL && hist->canGoForward()) myurl = hist->forwardItem().url().toString(); 
    forward();
  }  
  else if(pos == 2) 
  {
    hist = history();
    if(hist != NULL && hist->canGoBack()) myurl = hist->backItem().url().toString(); 
    back();
  }  
  else if(pos == 3) 
  {
    hist = history();
    if(hist != NULL) myurl = hist->currentItem().url().toString(); 
    reload();
  }  
#endif

  if(myurl.isEmpty()) return;
  if(opt.arg_debug) printf("moveContent(%s)\n", (const char *) myurl.toUtf8());
  if(myurl.length()+40 > MAX_PRINTF_LENGTH) return;
  sprintf(buf,"text(%d,\"%s\")\n", id,decode(myurl));
  tcp_send(s,buf,strlen(buf));
}
コード例 #13
0
ファイル: scrollarea.cpp プロジェクト: 3ngineer/tdesktop
void ScrollArea::touchEvent(QTouchEvent *e) {
	if (!e->touchPoints().isEmpty()) {
		_touchPrevPos = _touchPos;
		_touchPos = e->touchPoints().cbegin()->screenPos().toPoint();
	}

	switch (e->type()) {
	case QEvent::TouchBegin:
		if (_touchPress || e->touchPoints().isEmpty()) return;
		_touchPress = true;
		if (_touchScrollState == TouchScrollAuto) {
			_touchScrollState = TouchScrollAcceleration;
			_touchWaitingAcceleration = true;
			_touchAccelerationTime = getms();
			touchUpdateSpeed();
			_touchStart = _touchPos;
		} else {
			_touchScroll = false;
			_touchTimer.start(QApplication::startDragTime());
		}
		_touchStart = _touchPrevPos = _touchPos;
		_touchRightButton = false;
		break;

	case QEvent::TouchUpdate:
		if (!_touchPress) return;
		if (!_touchScroll && (_touchPos - _touchStart).manhattanLength() >= QApplication::startDragDistance()) {
			_touchTimer.stop();
			_touchScroll = true;
			touchUpdateSpeed();
		}
		if (_touchScroll) {
			if (_touchScrollState == TouchScrollManual) {
				touchScrollUpdated(_touchPos);
			} else if (_touchScrollState == TouchScrollAcceleration) {
				touchUpdateSpeed();
				_touchAccelerationTime = getms();
				if (_touchSpeed.isNull()) {
					_touchScrollState = TouchScrollManual;
				}
			}
		}
		break;

	case QEvent::TouchEnd:
		if (!_touchPress) return;
		_touchPress = false;
		if (_touchScroll) {
			if (_touchScrollState == TouchScrollManual) {
				_touchScrollState = TouchScrollAuto;
				_touchPrevPosValid = false;
				_touchScrollTimer.start(15);
				_touchTime = getms();
			} else if (_touchScrollState == TouchScrollAuto) {
				_touchScrollState = TouchScrollManual;
				_touchScroll = false;
				touchResetSpeed();
			} else if (_touchScrollState == TouchScrollAcceleration) {
				_touchScrollState = TouchScrollAuto;
				_touchWaitingAcceleration = false;
				_touchPrevPosValid = false;
			}
		} else if (window() && widget()) { // one short tap -- like left mouse click, one long tap -- like right mouse click
#ifdef Q_OS_WIN
			Qt::MouseButton btn(_touchRightButton ? Qt::RightButton : Qt::LeftButton);
			QPoint mapped(widget()->mapFromGlobal(_touchStart)), winMapped(window()->mapFromGlobal(_touchStart));

			QMouseEvent pressEvent(QEvent::MouseButtonPress, mapped, winMapped, _touchStart, btn, Qt::MouseButtons(btn), Qt::KeyboardModifiers());
			pressEvent.accept();
			qt_sendSpontaneousEvent(widget(), &pressEvent);

			QMouseEvent releaseEvent(QEvent::MouseButtonRelease, mapped, winMapped, _touchStart, btn, Qt::MouseButtons(btn), Qt::KeyboardModifiers());
			qt_sendSpontaneousEvent(widget(), &releaseEvent);

			if (_touchRightButton) {
				QContextMenuEvent contextEvent(QContextMenuEvent::Mouse, mapped, _touchStart);
				qt_sendSpontaneousEvent(widget(), &contextEvent);
			}
#endif
		}
		_touchTimer.stop();
		_touchRightButton = false;
		break;

	case QEvent::TouchCancel:
		_touchPress = false;
		_touchScroll = false;
		_touchScrollState = TouchScrollManual;
		_touchTimer.stop();
		break;
	}
}
コード例 #14
0
ファイル: wmmixer-alsa.c プロジェクト: bbidulock/dockapps
int main(int argc, char **argv)
{
	XGCValues gcv;
	unsigned long gcm;
	int exact,left,right,device_index,i;
	XpmAttributes xpmattr;
	XpmColorSymbol xpmcsym[4];
	elementinfo *e;

	scanArgs(argc, argv);
	initXWin(argc, argv);
	exact=left=right=device_index=-1;

	init_mixer();
	cure=element;
	e=element;
	while(e)
	{
		if(!strcasecmp(e->info.eid.name,"Master Volume"))
			e->icon=0;
		else if(!strcasecmp(e->info.eid.name,"PCM Volume"))
			e->icon=1;
		else if(!strcasecmp(e->info.eid.name,"MIC Volume"))
			e->icon=5;
		else if(!strcasecmp(e->info.eid.name,"Line Volume"))
			e->icon=4;
		else if(!strcasecmp(e->info.eid.name,"CD Volume"))
			e->icon=3;
		else if(!strcasecmp(e->info.eid.name,"Synth Volume"))
			e->icon=2;
		else if(!strcasecmp(e->info.eid.name,"PC Speaker Volume"))
			e->icon=6;
		/*
		 * bass = 7
		 * treble = 8
		 */
		else
			e->icon=9;
		e=e->next;
	}

	gcm=GCGraphicsExposures;
	gcv.graphics_exposures=0;
	gc_gc=XCreateGC(d_display, w_root, gcm, &gcv);

	color[0]=mixColor(ledcolor, 0, backcolor, 100);
	color[1]=mixColor(ledcolor, 100, backcolor, 0);
	color[2]=mixColor(ledcolor, 60, backcolor, 40);
	color[3]=mixColor(ledcolor, 25, backcolor, 75);

	xpmcsym[0].name="back_color";
	xpmcsym[0].value=NULL;;
	xpmcsym[0].pixel=color[0];
	xpmcsym[1].name="led_color_high";
	xpmcsym[1].value=NULL;;
	xpmcsym[1].pixel=color[1];
	xpmcsym[2].name="led_color_med";
	xpmcsym[2].value=NULL;;
	xpmcsym[2].pixel=color[2];
	xpmcsym[3].name="led_color_low";
	xpmcsym[3].value=NULL;;
	xpmcsym[3].pixel=color[3];
	xpmattr.numsymbols=4;
	xpmattr.colorsymbols=xpmcsym;
	xpmattr.exactColors=0;
	xpmattr.closeness=40000;
	xpmattr.valuemask=XpmColorSymbols | XpmExactColors | XpmCloseness;
	XpmCreatePixmapFromData(d_display, w_root, wmmixer_xpm, &pm_main, &pm_mask, &xpmattr);
	XpmCreatePixmapFromData(d_display, w_root, tile_xpm, &pm_tile, NULL, &xpmattr);
	XpmCreatePixmapFromData(d_display, w_root, icons_xpm, &pm_icon, NULL, &xpmattr);
	pm_disp=XCreatePixmap(d_display, w_root, 64, 64, DefaultDepth(d_display, DefaultScreen(d_display)));

	if(wmaker || ushape || astep)
		XShapeCombineMask(d_display, w_activewin, ShapeBounding, winsize/2-32, winsize/2-32, pm_mask, ShapeSet);
	else
		XCopyArea(d_display, pm_tile, pm_disp, gc_gc, 0, 0, 64, 64, 0, 0);

	XSetClipMask(d_display, gc_gc, pm_mask);
	XCopyArea(d_display, pm_main, pm_disp, gc_gc, 0, 0, 64, 64, 0, 0);
	XSetClipMask(d_display, gc_gc, None);

	if(count==0)
		fprintf(stderr,"%s : Sorry, no supported channels found.\n", NAME);
	else
	{
		int done=0;
		XEvent xev;

		checkVol();
		XSelectInput(d_display, w_activewin, ExposureMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask);
		XMapWindow(d_display, w_main);

		while(!done)
		{
			while(XPending(d_display))
			{
				XNextEvent(d_display, &xev);
				switch(xev.type)
				{
					case Expose:
						repaint();
						break;
					case ButtonPress:
						pressEvent(&xev.xbutton);
						break;
					case ButtonRelease:
						releaseEvent(&xev.xbutton);
						break;
					case MotionNotify:
						motionEvent(&xev.xmotion);
						break;
					case ClientMessage:
						if(xev.xclient.data.l[0]==deleteWin)
							done=1;
						break;
				}
			}

			if(btnstate & (BTNPREV | BTNNEXT))
			{
				rpttimer++;
				if(rpttimer>=RPTINTERVAL)
				{
					if(btnstate & BTNNEXT)
					{
						cure=cure->next;
						if(!cure)
							cure=element;
					}
					else
					{
						cure=cure->prev;
						if(!cure)
						{
							elementinfo *e;
							e=element;
							while(e->next)
								e=e->next;
							cure=e;
						}
					}
					checkVol();
					rpttimer=0;
				}
			}
			else
				checkVol();
			XFlush(d_display);
			usleep(50000);
		}
	}
	XFreeGC(d_display, gc_gc);
	XFreePixmap(d_display, pm_main);
	XFreePixmap(d_display, pm_tile);
	XFreePixmap(d_display, pm_disp);
	XFreePixmap(d_display, pm_mask);
	XFreePixmap(d_display, pm_icon);
	freeXWin();
	return 0;
}
コード例 #15
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    numFoto=0;
    cap = new VideoCapture(1);
    if(!cap->isOpened())
        cap = new VideoCapture(1);
    capture = true;
    showColorImage = false;
    winSelected = false;
    cap->set(CV_CAP_PROP_FRAME_WIDTH, 320);
    cap->set(CV_CAP_PROP_FRAME_HEIGHT, 240);
    imgS = new QImage(320,240, QImage::Format_RGB888);
    visorS = new RCDraw(320,240, imgS, ui->imageFrameS);
    imgD = new QImage(320,240, QImage::Format_RGB888);
    visorD = new RCDraw(320,240, imgD, ui->imageFrameD);



    colorImage.create(240,320,CV_8UC3);
    grayImage.create(240,320,CV_8UC1);
    destColorImage.create(240,320,CV_8UC3);
    Black_Color_Image.create(240,320,CV_8UC3);
    Black_Gray_Image.create(240,320,CV_8UC1);

    destGrayImage.create(240,320,CV_8UC1);
    gray2ColorImage.create(240,320,CV_8UC3);
    destGray2ColorImage.create(240,320,CV_8UC3);



    connect(&timer,SIGNAL(timeout()),this,SLOT(compute()));
    connect(ui->captureButton,SIGNAL(clicked(bool)),this,SLOT(start_stop_capture(bool)));
    connect(ui->colorButton,SIGNAL(clicked(bool)),this,SLOT(change_color_gray(bool)));
    connect(ui->AddObjIma,SIGNAL(clicked()),this,SLOT(set_Image()));
    connect(ui->DelObjIma,SIGNAL(clicked()),this,SLOT(deleteImageInSet()));
    connect(ui->horizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(changeImage()));
    connect(ui->SelectComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(changeImage()));

    connect(visorS,SIGNAL(windowSelected(QPointF, int, int)),this,SLOT(selectWindow(QPointF, int, int)));
    connect(visorS,SIGNAL(pressEvent()),this,SLOT(deselectWindow()));

    ListaObjetosImagenes.resize(3);
    listaDescriptores.resize(3);
    ListaPuntosImagenes.resize(3);
    NombresObjetos.resize(3);
    NombresObjetos[0]="Objeto 1";
    NombresObjetos[1]="Objeto 2";
    NombresObjetos[2]="Objeto 3";
    LpFinal.resize(3);

    listaContadores.insert(listaContadores.begin(),3,0);

    Colores.resize(5);
    Colores[0]=Qt::red;
    Colores[1]=Qt::yellow;
    Colores[2]=Qt::blue;
    Colores[3]=Qt::green;
    Colores[4]=Qt::red+Qt::yellow;

    orb=ORB();
    bfm=BFMatcher(NORM_HAMMING,false);


    MaxDistance=50.0;
    timer.start(60);
    //------------------AMPLIACIONES-------------------
    LpFinalAmpliacion.resize(3);
}
コード例 #16
0
ファイル: wmGrabImage.c プロジェクト: d-torrance/dockapps
/*
 *   main
 */
int main(int argc, char *argv[]) {

struct tm	*gTime, *gmt;
struct stat	fi;
XEvent		event;
Pixmap		NewPixmap, NewShapeMask;
XpmAttributes	Attributes;
Colormap	cmap;
int		n, s, m, dt1, dt2, dt3, len;
int 		Year, Month, Day;
int		Hours, Mins, Secs;
int		i, j, Width, Height, yoff, fd, Flag;
long		CurrentLocalTime;
double		UT, hour24(), jd(), CurrentJD, OldFileUT, FileUT;
char		command[1040], ImageName[256];
int           havePixmap= 0;










    /*
     *  Parse any command line arguments.
     */
    ParseCMDLine(argc, argv);


    /*
     *  Figure out what the name of the image xpm file should be...
     */
    len = strlen(ImageURL);
    for (j = 0, i=0; i<len; ++i){ if (ImageURL[i] == '/') j = i; }
    strcpy(ImageName, ImageURL+j+1);
    sprintf(XpmFileName, "%s/.wmGrabImage/%s.xpm", getenv("HOME"), ImageName);
    sprintf(ImageFileName, "%s/.wmGrabImage/%s", getenv("HOME"), ImageName);


    openXwindow(argc, argv, wmGrabImage_master, wmGrabImage_mask_bits, wmGrabImage_mask_width, wmGrabImage_mask_height);

    cmap = DefaultColormap(display, DefaultScreen(display));



    /*
     *  Loop until we die
     */
    n = 32000;
    s = 32000;
    m = 32000;
    dt1 = 32000;
    dt2 = 32000;
    dt3 = 32000;
    DblClkDelay = 32000;
    UpToDate = 0;
    FileUT = -999.0;
    Flag = 1;
    NewShapeMask = 0;
    Attributes.nalloc_pixels = 0;
    while(1) {




	/*
	 *  Keep track of # of seconds
	 */
	if (m > 100){

	    m = 0;
	    ++dt1;
	    ++dt2;
	    ++dt3;

	} else {

	    /*
	     *  Increment counter
	     */
	    ++m;

	}






	/*
	 *  Double Click Delays
	 *  Keep track of click events. If Delay too long, set GotFirstClick's to False.
	 */
	if (DblClkDelay > 15) {

	    DblClkDelay = 0;
	    GotFirstClick1 = 0; GotDoubleClick1 = 0;
	    GotFirstClick2 = 0; GotDoubleClick2 = 0;
	    GotFirstClick3 = 0; GotDoubleClick3 = 0;

	} else {

	    ++DblClkDelay;

	}














	/*
	 *   Process any pending X events.
	 */
        while(XPending(display)){
            XNextEvent(display, &event);
            switch(event.type){
                case Expose:
                        RedrawWindow();
                        break;
                case ButtonPress:
                        pressEvent(&event.xbutton);
                        break;
                case ButtonRelease:
                        break;
            }
        }












	/*
	 *  Draw window.
	 */
	if (ForceUpdate||Flag){



            /*
             *  Compute Current Julian Date
             */
            CurrentLocalTime = time(CurrentTime);
            gTime = gmtime(&CurrentLocalTime);
            Year  = gTime->tm_year+1900;
            Month = gTime->tm_mon+1;
            Day   = gTime->tm_mday;
            Hours = gTime->tm_hour;
            Mins  = gTime->tm_min;
            Secs  = gTime->tm_sec;
            UT = (double)Hours + (double)Mins/60.0 + (double)Secs/3600.0;
            CurrentJD = jd(Year, Month, Day, UT);


	    /*
	     * Clear window.
	     */
	    copyXPMArea(5, 69, 54, 54, 5, 5);



	    if (havePixmap) {
	      /*
	       * free up the colors, if we alloc'd some before
	       */
	      if (Attributes.nalloc_pixels > 0)
		XFreeColors(display, cmap,  Attributes.alloc_pixels,
			    Attributes.nalloc_pixels, 0);
		/*
		 *  Free last pixmap -- we dont need it anymore...
		 *  A ShapeMask is returned if the Pixmap had the color None used.
		 *  We could probably change Transparent to None to make use of this, but for now,
		 *  lets just ignore it...
		 */
		if ( NewShapeMask != 0 )
		  XFreePixmap(display, NewShapeMask);
		XFreePixmap(display, NewPixmap);

		XpmFreeAttributes(&Attributes);

		havePixmap= 0;
	    }
	    /*
	     *   Grab new pixmap. Accept a reasonable color match.
	     */
	    Attributes.valuemask   = XpmExactColors | XpmCloseness | XpmReturnAllocPixels;
	    Attributes.exactColors = 0;
	    Attributes.closeness   = 40000;
	    if (XpmReadFileToPixmap(display, Root, XpmFileName, &NewPixmap, &NewShapeMask, &Attributes) >= 0){



		Height = Attributes.height;
		Width  = Attributes.width;
		yoff   = (CenterImage) ? (54 - Height)/2 : 0;
	        XCopyArea(display, NewPixmap, wmgen.pixmap, NormalGC, 0, 0, Width, Height, 5, 5+yoff);


		Flag = 0;
		ForceUpdate = 0;
		havePixmap= 1;
	    }






	    /*
	     * Make changes visible
	     */
	    RedrawWindow();



	}





	/*
	 *  Check xpm file status
	 */
	if (dt2 > 1){

	    dt2 = 0;

	    if ( (fd = open(XpmFileName, O_RDONLY)) >= 0 ) {

		fstat(fd, &fi);
		close(fd);
		gmt = gmtime(&fi.st_mtime);
		OldFileUT = FileUT;
		FileUT = (double)gmt->tm_hour + (double)gmt->tm_min/60.0 + (double)gmt->tm_sec/3600.0;
		if (FileUT != OldFileUT) ForceUpdate = 1;

	    }


	}









	/*
	 *  Check every 5 min if the values are not up to date...
	 */

	if (ForceUpdate2||(dt3 > UpdateDELAY)){

	    dt3 = 0;

	    /*
	     *  Execute Perl script to grab the Latest METAR Report
	     */
	    if (ConvertGeometry != NULL)
	      sprintf(command, "GrabImage %s %s &", ImageURL, ConvertGeometry);
	    else
	      sprintf(command, "GrabImage %s &", ImageURL);
	    system(command);

	    ForceUpdate = 1;
	    ForceUpdate2 = 0;

	}





	/*
	 *  Wait for next update
	 */
	usleep(DELAY);


     }



}