void DoubleValueEditor::mouseMoveEvent(QMouseEvent* e)
{
	if (e->buttons() & Qt::LeftButton)
	{
		double dy = e->y() - last_pos.y();
		double step = default_step = singleStep();
		last_pos = e->posF();
		last_press = 0;

		if (e->modifiers() & Qt::ShiftModifier)
			setSingleStep(step /= 10.0);
		else if (e->modifiers() & Qt::ControlModifier)
			setSingleStep(step *= 10.0);

		if (dy < 0)
		{
			stepUp();
			emit valueUpdated();
		}
		else if (dy > 0)
		{
			stepDown();
			emit valueUpdated();
		}

		if (step != default_step)
			setSingleStep(default_step);
	}
}
void VScrollBar::logic()
{
    upButton->logic();
    downButton->logic();
    
    int event;
    while ( (event = myEvents.nextEvent()) ) switch ( event )
    {
        case Events::GoUp:   stepUp(); break;
        case Events::GoDown: stepDown(); break;
    }
    
    myEvents.reset();
    
    if ( repeat_scroll && repeat_timer.isTimeOut() )
    {
        if ( repeat_scroll > 0 )
        {
            pageDown();
        }
        else
        {
            pageUp();
        }

        repeat_timer.setTimeOut(repeat_other);
        repeat_timer.reset();

        if ( (value == 0) || (value == virtualTotalHeight) )
        {
            repeat_scroll = 0;
        }
    }

}
Exemple #3
0
void QSpinWidget::mousePressEvent( QMouseEvent *e )
{
    if ( e->button() != LeftButton ) {
	d->stopTimer();
	d->buttonDown = 0;
	d->theButton = 0;
	repaint( d->down.unite( d->up ), FALSE );
	return;
    }

    uint oldButtonDown = d->buttonDown;

    if ( d->down.contains( e->pos() ) && d->downEnabled )
	d->buttonDown = 1;
    else if ( d->up.contains( e->pos() ) && d->upEnabled )
	d->buttonDown = 2;
    else
	d->buttonDown = 0;

    d->theButton = d->buttonDown;
    if ( oldButtonDown != d->buttonDown ) {
	if ( !d->buttonDown ) {
	    repaint( d->down.unite( d->up ), FALSE );
	} else if ( d->buttonDown & 1 ) {
	    repaint( d->down, FALSE );
	    stepDown();
	    d->startTimer( FALSE, 300 );
	} else if ( d->buttonDown & 2 ) {
	    repaint( d->up, FALSE );
	    stepUp();
	    d->startTimer( TRUE, 300 );
	}
    }
}
void IntValueEditor::wheelEvent(QWheelEvent* e)
{
	if (!QSpinBox::isActiveWindow())
		QSpinBox::activateWindow();
	QSpinBox::setFocus(Qt::MouseFocusReason);

	int step = default_step = singleStep();
	if (e->modifiers() & Qt::ShiftModifier)
	{
		if (step >= 10.0)
			setSingleStep(step = (int)(step / 10.0));
	}
	else if (e->modifiers() & Qt::ControlModifier)
		setSingleStep(step = step * 10);

	if (e->delta() > 0)
		stepUp();
	else
		stepDown();

	if (step != default_step)
		setSingleStep(default_step);

	if (wheelEventSignal && WheelValueEditor::WHEEL_EVENTS_ENABLED)
		emit valueUpdated();
}
void core::ZoomControl::init()
{
//    Q_INIT_RESOURCE(core_media);

	layout()->setMargin(0);

	btnZoomIn = new QToolButton();
	btnZoomIn->setIcon(ICON_ZOOMIN);

	btnZoomOut = new QToolButton();
	btnZoomOut->setIcon(ICON_ZOOMOUT);

	sbZoom = new QSpinBox();
	sbZoom->setAlignment(Qt::AlignCenter);
	sbZoom->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
	sbZoom->setKeyboardTracking(true);
	sbZoom->setRange(10, 1000);
	sbZoom->setSingleStep(10);
	sbZoom->setButtonSymbols(QSpinBox::NoButtons);
	sbZoom->setSuffix("%");
	sbZoom->setValue(100);
	sbZoom->setAccelerated(true);

	addWidget(btnZoomIn);
	addWidget(sbZoom);
	addWidget(btnZoomOut);

	connect(sbZoom, SIGNAL(valueChanged(int)), SLOT(onEditZoomChanged(int)));
	connect(btnZoomIn, SIGNAL(pressed()), sbZoom, SLOT(stepUp()));
	connect(btnZoomOut, SIGNAL(pressed()), sbZoom, SLOT(stepDown()));
}
/*--------------------------------------------*/
void Quantize_Class::pingpong(int pot)
{
	uint8_t numSteps = stepsVals->objectAt(pot)->performModeVal;
	if(numSteps == 0) return;

	if(pingpongUp[pot] == true) stepUp(pot, fu2->GATE_MODE_PINGPONG);
	else stepDown(pot, fu2->GATE_MODE_PINGPONG);
}
void KinematicCharacterController::playerStep(btCollisionWorld* collisionWorld, btScalar dt)
{
	//	printf("playerStep(): ");
	//	printf("  dt = %f", dt);

	// quick check...
	if (!m_useWalkDirection && (m_velocityTimeInterval <= 0.0 || m_walkDirection.fuzzyZero())) {
		//		printf("\n");
		return;		// no motion
	}

	m_wasOnGround = onGround();

	// Update fall velocity.
	m_verticalVelocity -= m_gravity * dt;
	if (m_verticalVelocity > 0.0 && m_verticalVelocity > m_jumpSpeed)
	{
		m_verticalVelocity = m_jumpSpeed;
	}
	if (m_verticalVelocity < 0.0 && btFabs(m_verticalVelocity) > btFabs(m_fallSpeed))
	{
		m_verticalVelocity = -btFabs(m_fallSpeed);
	}
	m_verticalOffset = m_verticalVelocity * dt;


	btTransform xform;
	xform = m_ghostObject->getWorldTransform();

	//	printf("walkDirection(%f,%f,%f)\n",walkDirection[0],walkDirection[1],walkDirection[2]);
	//	printf("walkSpeed=%f\n",walkSpeed);

	stepUp(collisionWorld);
	if (m_useWalkDirection) {
		stepForwardAndStrafe(collisionWorld, m_walkDirection);
	}
	else {
		//printf("  time: %f", m_velocityTimeInterval);
		// still have some time left for moving!
		btScalar dtMoving =
			(dt < m_velocityTimeInterval) ? dt : m_velocityTimeInterval;
		m_velocityTimeInterval -= dt;

		// how far will we move while we are moving?
		btVector3 move = m_walkDirection * dtMoving;

		//printf("  dtMoving: %f", dtMoving);

		// okay, step
		stepForwardAndStrafe(collisionWorld, move);
	}
	stepDown(collisionWorld, dt);

	// printf("\n");

	xform.setOrigin(m_currentPosition);
	m_ghostObject->setWorldTransform(xform);
}
bool QDateTimeEditBase::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: stepUp(); break;
    case 1: stepDown(); break;
    default:
	return QWidget::qt_invoke( _id, _o );
    }
    return TRUE;
}
SpectrumWarsRxGuiWidget::SpectrumWarsRxGuiWidget(SWRxGuiParams params,
                                                 SWRxGuiCallback* callback,
                                                 QWidget *parent)
  :QWidget(parent)
{
  params_ = params;
  callback_ = callback;
  knob1_ = new KnobSpin("Frequency (MHz)", params_.minFreq, params_.maxFreq,
                        0.1, this);
  QShortcut* s11_ = new QShortcut(QKeySequence("Q"), this);
  connect(s11_, SIGNAL(activated()), knob1_->spin(), SLOT(stepUp()));
  QShortcut* s12_ = new QShortcut(QKeySequence("A"), this);
  connect(s12_, SIGNAL(activated()), knob1_->spin(), SLOT(stepDown()));

  knob2_ = new KnobSpin("Bandwidth (MHz)", params_.minBW, params_.maxBW,
                        0.25, this);
  QShortcut* s21_ = new QShortcut(QKeySequence("W"), this);
  connect(s21_, SIGNAL(activated()), knob2_->spin(), SLOT(stepUp()));
  QShortcut* s22_ = new QShortcut(QKeySequence("S"), this);
  connect(s22_, SIGNAL(activated()), knob2_->spin(), SLOT(stepDown()));

  knob3_ = new KnobSpin("Gain", params_.minGain, params_.maxGain,
                        1.0, this);
  QShortcut* s31_ = new QShortcut(QKeySequence("E"), this);
  connect(s31_, SIGNAL(activated()), knob3_->spin(), SLOT(stepUp()));
  QShortcut* s32_ = new QShortcut(QKeySequence("D"), this);
  connect(s32_, SIGNAL(activated()), knob3_->spin(), SLOT(stepDown()));

  connect(knob1_, SIGNAL(valueChanged(double)),
          this, SLOT(setFrequency(double)));
  connect(knob2_, SIGNAL(valueChanged(double)),
          this, SLOT(setBandwidth(double)));
  connect(knob3_, SIGNAL(valueChanged(double)),
          this, SLOT(setGain(double)));

  QHBoxLayout* hLayout1 = new QHBoxLayout(this);
  hLayout1->addWidget(knob1_);
  hLayout1->addWidget(knob2_);
  hLayout1->addWidget(knob3_);

  setPalette( QPalette( QColor( 192, 192, 192 ) ) );
  updateGradient();
}
Exemple #10
0
void QSpinWidget::timerDoneEx()
{
    if ( !d->buttonDown )
	return;
    if ( d->timerUp )
	stepUp();
    else
	stepDown();
    d->startTimer( 100 );
}
bool QSpinWidget::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: stepUp(); break;
    case 1: stepDown(); break;
    case 2: timerDone(); break;
    case 3: timerDoneEx(); break;
    default:
	return QWidget::qt_invoke( _id, _o );
    }
    return TRUE;
}
void MainWindow::buildToolBar()
{
    m_fileToolBar = addToolBar("File Tool Bar");
    m_fileToolBar->setMovable(true);
    QAction * newSystemAction = new QAction(QIcon("Icons/New.png"), "New", this);
    connect(newSystemAction, SIGNAL(triggered()), m_system, SLOT(newSystem()));
    QAction * openSystemAction = new QAction(QIcon("Icons/Open.png"), "Open", this);
    connect(openSystemAction, SIGNAL(triggered()), m_system, SLOT(openSystem()));
    QAction * saveSystemAction = new QAction(QIcon("Icons/Save.png"), "Save", this);
    connect(saveSystemAction, SIGNAL(triggered()), m_system, SLOT(saveSystem()));
    QAction * saveSystemAsAction = new QAction(QIcon("Icons/SaveAs.png"), QString::fromUtf8("Save As\u2026"), this);
    saveSystemAsAction->setIconText("AA");
    connect(saveSystemAsAction, SIGNAL(triggered()), m_system, SLOT(saveSystemAs()));
    m_fileToolBar->addAction(newSystemAction);
    m_fileToolBar->addAction(openSystemAction);
    m_fileToolBar->addAction(saveSystemAction);
    m_fileToolBar->addAction(saveSystemAsAction);

    m_deviceToolBar = addToolBar("Device Tool Bar");
    m_deviceToolBar->setMovable(true);
    QAction * addPlaneMirrorAction = new QAction(QIcon("Icons/PlaneMirror.png"), "Add Plane Mirror", this);
    connect(addPlaneMirrorAction, SIGNAL(triggered()), m_system, SLOT(addPlaneMirror()));
    QAction * addConcaveMirrorAction = new QAction(QIcon("Icons/ConcaveMirror.png"), "Add Concave Mirror", this);
    connect(addConcaveMirrorAction, SIGNAL(triggered()), m_system, SLOT(addConcaveMirror()));
    QAction * addDiffractionGratingAction = new QAction(QIcon("Icons/DiffractionGrating.png"), "Add Diffraction Grating", this);
    connect(addDiffractionGratingAction, SIGNAL(triggered()), m_system, SLOT(addDiffractionGrating()));
    QAction * addSlitAction = new QAction(QIcon("Icons/Slit.png"), "Add Slit", this);
    connect(addSlitAction, SIGNAL(triggered()), m_system, SLOT(addSlit()));
    QAction * addPointSourceAction = new QAction(QIcon("Icons/PointSource.png"), "Add Point Source", this);
    connect(addPointSourceAction, SIGNAL(triggered()), m_system, SLOT(addPointSource()));
    QAction * removeReflectorAction = new QAction(QIcon("Icons/RemoveReflector.png"), "Remove Reflector", this);
    connect(removeReflectorAction, SIGNAL(triggered()), m_system, SLOT(removeReflector()));
    QAction * removeLightSourceAction = new QAction(QIcon("Icons/RemoveLightSource.png"), "Remove Light Source", this);
    connect(removeLightSourceAction, SIGNAL(triggered()), m_system, SLOT(removeLightSource()));
    m_deviceToolBar->addAction(addPlaneMirrorAction);
    m_deviceToolBar->addAction(addConcaveMirrorAction);
    m_deviceToolBar->addAction(addDiffractionGratingAction);
    m_deviceToolBar->addAction(addSlitAction);
    m_deviceToolBar->addSeparator();
    m_deviceToolBar->addAction(addPointSourceAction);
    m_deviceToolBar->addSeparator();
    m_deviceToolBar->addAction(removeReflectorAction);
    m_deviceToolBar->addAction(removeLightSourceAction);

    m_zoomToolBar = addToolBar("Zoom Tool Bar");
    m_zoomToolBar->setMovable(true);
    ZoomWidget * zoomWidget = new ZoomWidget(this);
    connect(zoomWidget, SIGNAL(valueChanged(int)), m_system, SLOT(zoom(int)));
    m_zoomToolBar->addAction(QIcon("Icons/ZoomIn.png"), "Zoom In", zoomWidget, SLOT(stepUp()));
    m_zoomToolBar->addWidget(zoomWidget);
    m_zoomToolBar->addAction(QIcon("Icons/ZoomOut.png"), "Zoom Out", zoomWidget, SLOT(stepDown()));
}
void SwitecX25::advance()
{
  time0 = micros();
  
  // detect stopped state
  if (currentStep==targetStep && vel==0) {
    stopped = true;
    dir = 0;
    return;
  }
  
  // if stopped, determine direction
  if (vel==0) {
    dir = currentStep<targetStep ? 1 : -1;
    // do not set to 0 or it could go negative in case 2 below
    vel = 1; 
  }
  
  if (dir>0) {
    stepUp();
  } else {
    stepDown();
  }
  
  // determine delta, number of steps in current direction to target.
  // may be negative if we are headed away from target
  int delta = dir>0 ? targetStep-currentStep : currentStep-targetStep;
  
  if (delta>0) {
    // case 1 : moving towards target (maybe under accel or decel)
    if (delta < vel) {
      // time to declerate
      vel--;
    } else if (vel < maxVel) {
      // accelerating
      vel++;
    } else {
      // at full speed - stay there
    }
  } else {
    // case 2 : at or moving away from target (slow down!)
    vel--;
  }
    
  // vel now defines delay
  unsigned char i = 0;
  // this is why vel must not be greater than the last vel in the table.
  while (accelTable[i][0]<vel) {
    i++;
  }
  microDelay = accelTable[i][1];
}
Exemple #14
0
void bustrophedon(int busIndex, robot *r) {
  while (!isCritical(r)) {
    if (canStepUpVirtual(r))
      stepUp(r);
    else if (canStepDownVirtual(r))
      stepDown(r);
    else if (canStepRightVirtual(r))
      stepRight(r);
    else
      stepLeft(r);
    
    r->map->tiles[r->posX][r->posY]->bustrophedonIndex = busIndex;
  }
}
Exemple #15
0
int TablePrintDialog::exec()
{
  //GUI
  ui.setupUi(this);
  connect(ui.horizontalSlider, SIGNAL(valueChanged(int)), ui.pageSpinBox, SLOT(setValue(int)));
  connect(ui.prevToolButton, SIGNAL(clicked()), ui.pageSpinBox, SLOT(stepDown()));
  connect(ui.nextToolButton, SIGNAL(clicked()), ui.pageSpinBox, SLOT(stepUp()));

  ui.graphicsView->setScene(&pageScene);
  ui.graphicsView->ensureVisible(0,0,10,10);
  setupSpinBox();
  on_pageSpinBox_valueChanged(1);
  return QDialog::exec();
}
    //-----------------------------------------------------------------------
    //                         p l a y e r S t e p
    //-----------------------------------------------------------------------
    void TKinematicCharacterTest::playerStep ( btCollisionWorld* collisionWorld, btScalar dt)
    {
        // btKinematicCharacterController::playerStep(collisionWorld, dt);

        btTransform xform;
        xform = m_ghostObject->getWorldTransform ();

        stepUp (collisionWorld);
        stepForwardAndStrafe (collisionWorld, m_walkDirection);
        stepDown (collisionWorld, dt);

        xform.setOrigin (m_currentPosition);
        m_ghostObject->setWorldTransform (xform);

    }
/*--------------------------------------------*/
void Quantize_Class::stepDown(int pot, uint8_t gateType)
{
	uint8_t numSteps = stepsVals->objectAt(pot)->performModeVal;
	if(numSteps == 0) return;

	int stepSize = 255 / (numSteps - 1);
	int val2b = fu2->dpotVals2b[pot] - stepSize;


	if(val2b < 0)
	{
		if(gateType == fu2->GATE_MODE_PINGPONG) { pingpongUp[pot] = true; stepUp(pot, fu2->GATE_MODE_PINGPONG); return; }    	//if its less that zero and we're pingponging, step up from where we were on the last step
		else val2b = stepSize * numSteps;                        		                                                        //otherwise go back up to the highest quantized val
	}
	fu2->dpotVals2b[pot] = val2b;
}
int TDPreviewDialog::exec()
{
        //GUI
        ui.setupUi(this);
        this->setWindowTitle(titulol);
        connect(ui.horizontalSlider, SIGNAL(valueChanged(int)), ui.pageSpinBox, SLOT(setValue(int)));
        connect(ui.prevToolButton, SIGNAL(clicked()), ui.pageSpinBox, SLOT(stepDown()));
        connect(ui.nextToolButton, SIGNAL(clicked()), ui.pageSpinBox, SLOT(stepUp()));
        connect(ui.print, SIGNAL(clicked()), SLOT(print()));
        connect(ui.PDF, SIGNAL(clicked()), SLOT(exportPdf()));

        ui.graphicsView->setScene(&pageScene);
        ui.graphicsView->ensureVisible(0,0,10,10);
        setupSpinBox();
        on_pageSpinBox_valueChanged(1);
        return QDialog::exec();
}
int Q3SpinWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: stepUpPressed(); break;
        case 1: stepDownPressed(); break;
        case 2: stepUp(); break;
        case 3: stepDown(); break;
        case 4: timerDone(); break;
        case 5: timerDoneEx(); break;
        }
        _id -= 6;
    }
    return _id;
}
Exemple #20
0
void QSpinWidget::wheelEvent( QWheelEvent *e )
{
    e->accept();
    static float offset = 0;
    static QSpinWidget* offset_owner = 0;
    if ( offset_owner != this ) {
	offset_owner = this;
	offset = 0;
    }
    offset += -e->delta()/120;
    if ( QABS( offset ) < 1 )
	return;
    int ioff = int(offset);
    int i;
    for( i=0; i < QABS( ioff ); i++ )
	offset > 0 ? stepDown() : stepUp();
    offset -= ioff;
}
Exemple #21
0
void ISpinBox::draw()
{
    T_ASSERT(m_line != nullptr);
    T_ASSERT(m_buttonUp != nullptr);
    T_ASSERT(m_buttonDown != nullptr);

    const unsigned int time = getElapsedTime();
    unsigned int frameTime = time - m_timeLast;
    m_timeLast = time;

    if (m_buttonUp->isDown())
    {
        while (frameTime >= m_timeRepeat)
        {
            frameTime -= m_timeRepeat;
            m_timeRepeat = SpinBoxTimeRepeat;
            stepUp();
        }

        m_timeRepeat -= frameTime;
    }
    else if (m_buttonDown->isDown())
    {
        while (frameTime >= m_timeRepeat)
        {
            frameTime -= m_timeRepeat;
            m_timeRepeat = SpinBoxTimeRepeat;
            stepDown();
        }

        m_timeRepeat -= frameTime;
    }
    else
    {
        m_timeRepeat = SpinBoxTimeBeforeRepeat;
    }

    // Affichage des widgets
    m_line->draw();
    m_buttonUp->draw();
    m_buttonDown->draw();
}
void btKinematicCharacterController::playerStep (  btCollisionWorld* collisionWorld, btScalar dt)
{
//	printf("playerStep(): ");
//	printf("  dt = %f", dt);

	// quick check...
	if (!m_useWalkDirection && m_velocityTimeInterval <= 0.0) {
//		printf("\n");
		return;		// no motion
	}

	btTransform xform;
	xform = m_ghostObject->getWorldTransform ();

//	printf("walkDirection(%f,%f,%f)\n",walkDirection[0],walkDirection[1],walkDirection[2]);
//	printf("walkSpeed=%f\n",walkSpeed);

	stepUp (collisionWorld);
	if (m_useWalkDirection) {
		stepForwardAndStrafe (collisionWorld, m_walkDirection);
	} else {
		//printf("  time: %f", m_velocityTimeInterval);
		// still have some time left for moving!
		btScalar dtMoving =
		   (dt < m_velocityTimeInterval) ? dt : m_velocityTimeInterval;
		m_velocityTimeInterval -= dt;

		// how far will we move while we are moving?
		btVector3 move = m_walkDirection * dtMoving;

		// printf("  dtMoving: %f", dtMoving);

		// okay, step
		stepForwardAndStrafe(collisionWorld, move);
	}
	stepDown (collisionWorld, dt);

	// printf("\n");

	xform.setOrigin (m_currentPosition);
	m_ghostObject->setWorldTransform (xform);
}
bool NumberInputWidget::keyJustPressed(input::Key key)
{
	std::string text = getText();
	if (key == K(RETURN) || key == K(KP_ENTER))
	{
		submitFixedValue();
	}
	else if (key == K(UP))
	{
		stepUp();
	}
	else if (key == K(DOWN))
	{
		stepDown();
	}
	else
	{
		return TextInputWidget::keyJustPressed(key);
	}
	return true;
}
Exemple #24
0
void PosEdit::init()
      {
      ed       = new PosEditor(this, "pos editor");
      controls = new SpinBox(this);
      controls->setEditor(ed);
      setFocusProxy(ed);
      connect(controls, SIGNAL(stepUpPressed()), SLOT(stepUp()));
      connect(controls, SIGNAL(stepDownPressed()), SLOT(stepDown()));
      connect(this, SIGNAL(valueChanged(const Pos&)),SLOT(updateButtons()));

      overwrite = false;
      timerId   = 0;
      typing    = false;
      min       = Pos(0);
      max       = Pos(MAX_TICK);
      changed   = false;
      adv       = false;


      static Section s_midiSections[3] = {  // measure, beat, tick
            { 0, 4, 1, 0 },
            { 5, 2, 1, 0 },
            { 8, 3, 0, 0 }
            };
      static Section s_smpteSections[4] = {  // minute second frame subframe
            {  0, 3, 0, 0 },
            {  4, 2, 0, 0 },
            {  7, 2, 0, 0 },
            { 10, 2, 0, 0 }
            };
      memcpy(midiSections, s_midiSections, sizeof(s_midiSections));
      memcpy(smpteSections, s_smpteSections, sizeof(s_smpteSections));

      _smpte     = false;  // show position in smpte format
      sec       = midiSections;
      setSections();
      setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
      }
Exemple #25
0
void Q3SpinWidget::mousePressEvent(QMouseEvent *e)
{
    if (e->button() != Qt::LeftButton) {
        d->stopTimer();
        d->buttonDown = 0;
        d->theButton = 0;
        repaint(d->down.united(d->up));
        return;
    }

    uint oldButtonDown = d->buttonDown;

    if (d->down.contains(e->pos()) && d->downEnabled)
        d->buttonDown = 1;
    else if (d->up.contains(e->pos()) && d->upEnabled)
        d->buttonDown = 2;
    else
        d->buttonDown = 0;

    d->theButton = d->buttonDown;
    if (oldButtonDown != d->buttonDown) {
        if (!d->buttonDown) {
            repaint(d->down.united(d->up));
        } else if (d->buttonDown & 1) {
            repaint(d->down);
            stepDown();
            d->startTimer(false, 300);
        } else if (d->buttonDown & 2) {
            repaint(d->up);
            stepUp();
            d->startTimer(true, 300);
        }
    }

    if (!oldButtonDown && !d->buttonDown)
        e->ignore();

}
Exemple #26
0
NumberEdit::NumberEdit(QWidget* parent):
    QLineEdit(parent)
{
    setMinimumHeight(23);
    resize(200,23);
    //validator=new QMyDoubleValidator(this);
    setRange(-10,10);
    setDecimals(2);
    setSingleStep(1.0);
    suffix="";
    //setValidator(validator);
    setValue(0);
    buttonUp=new QToolButton(this);
    buttonDown=new QToolButton(this);
    buttonUp->setIcon(QIcon(":/NumberEdit/btn_up.png"));
    buttonDown->setIcon(QIcon(":/NumberEdit/btn_down.png"));
    int bw=(int)floor((double)height()/2.0);
    buttonUp->resize(bw, bw);
    buttonUp->move(width()-bw, 0);
    buttonUp->setCursor(Qt::ArrowCursor);
    buttonUp->setFocusPolicy(Qt::NoFocus);
    QFont f=buttonUp->font();
    f.setPointSizeF(f.pointSizeF()*0.85);
    buttonUp->setFont(f);
    buttonDown->setFont(f);
    buttonDown->resize(bw, bw+1);
    buttonDown->move(width()-bw, bw-1);
    buttonDown->setCursor(Qt::ArrowCursor);
    buttonDown->setFocusPolicy(Qt::NoFocus);
    connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(texttChanged(const QString&)));
    connect(this, SIGNAL(cursorPositionChanged(int,int)), this, SLOT(cursorChanged(int,int)));
    connect(buttonUp, SIGNAL(clicked()), this, SLOT(stepUp()));
    connect(buttonDown, SIGNAL(clicked()), this, SLOT(stepDown()));
    pal=palette();
    palError=pal;
    palError.setColor(QPalette::Base, QColor("tomato"));
}
Exemple #27
0
HIC::QHSpinBox::QHSpinBox(double minValue,double maxValue,double initialValue,double step,QWidget * parent,const char * name):QWidget(parent,name)
{
    m_min_value = minValue;
    m_max_value = maxValue;
    m_step      = step;
    m_value     = initialValue;    

    m_leftbutton  = new QPushButton("<<",this,"leftbutton");
    m_leftbutton->setAutoRepeat(true);
    QObject::connect(m_leftbutton, SIGNAL(clicked()), this, SLOT(stepDown()));
    m_rightbutton = new QPushButton(">>",this,"rightbutton");
    m_rightbutton->setAutoRepeat(true);
    QObject::connect(m_rightbutton ,SIGNAL(clicked()),this, SLOT(stepUp()));

    m_lineedit = new QLineEdit(QString::number(m_value),this,"lineedit");
    m_lineedit->setMaximumSize(60,20);
    QObject::connect(m_lineedit, SIGNAL(returnPressed()), this, SLOT(returnPressed()));

    Q3HBoxLayout * layout = new Q3HBoxLayout(this,1,5,"hspinlayout");
    layout->addWidget(m_leftbutton);
    layout->addWidget(m_lineedit);
    layout->addWidget(m_rightbutton);
    layout->setResizeMode(QLayout::SetFixedSize);
}
void btKinematicCharacterController::playerStep( btCollisionWorld* collisionWorld, btScalar dt )
{
    BT_PROFILE( "playerStep" );

    if( !m_useWalkDirection && m_velocityTimeInterval <= btScalar( 0.0 ) )
        return;

    bool wasOnGround = onGround();

    // Handle the gravity
    //
    m_verticalVelocity -= m_gravity * dt;

    if( m_verticalVelocity > 0.0 && m_verticalVelocity > m_jumpSpeed )
        m_verticalVelocity = m_jumpSpeed;

    if( m_verticalVelocity < 0.0 && btFabs( m_verticalVelocity ) > btFabs( m_fallSpeed ) )
        m_verticalVelocity = -btFabs( m_fallSpeed );

    m_verticalOffset = m_verticalVelocity * dt;

    // This forced stepping up can cause problems when the character
    // walks (jump in fact...) under too low ceilings.
    //
    btVector3 currentPosition = externalGhostObject->getWorldTransform().getOrigin();
    btScalar currentStepOffset;

    currentPosition = stepUp( collisionWorld, currentPosition, currentStepOffset );

    // Move in the air and slide against the walls ignoring the stair steps.
    //
    if( m_useWalkDirection )
        currentPosition = stepForwardAndStrafe( collisionWorld, currentPosition, m_walkDirection );

    else
    {
        btScalar dtMoving = ( dt < m_velocityTimeInterval ) ? dt : m_velocityTimeInterval;
        m_velocityTimeInterval -= dt;

        // How far will we move while we are moving ?
        //
        btVector3 moveDirection = m_walkDirection * dtMoving;

        currentPosition = stepForwardAndStrafe( collisionWorld, currentPosition, moveDirection );
    }

    // Finally find the ground.
    //
    currentStepOffset = addFallOffset( wasOnGround, currentStepOffset, dt );

    currentPosition = stepDown( collisionWorld, currentPosition, currentStepOffset );

    // Apply the new position to the collision objects.
    //
    btTransform tranform;
    tranform = externalGhostObject->getWorldTransform();
    tranform.setOrigin( currentPosition );

    externalGhostObject->setWorldTransform( tranform );
    internalGhostObject->setWorldTransform( tranform );
}
// Initialise Toolbar, Menus ScrollBar and other
void ktvschedule::init()
{
	// Creates central widgets
	
	tvgridbox = new QGroupBox ( this ); // Group box
	tvgridbox->setInsideMargin ( 15 );
		
	t_TVGrid=new TvGuideTable(this->tvgridbox, "t_TVGrid"); // Add TvGuideTable custom QTable
	
	QGridLayout *tvgridboxLayout = new QGridLayout( tvgridbox->layout() ); //Layout
	tvgridboxLayout->setAlignment ( Qt::AlignTop );
	tvgridboxLayout->addWidget ( t_TVGrid , 0 , 0 );
		
	setCentralWidget( tvgridbox );
  	tvgridbox->show();
	
////////////////////////////////
	//Check for home directory, if it does not exist, create it
	
       QString qstr(QDir::homeDirPath()+"/.kde/share/apps/ktvschedule"); //for some reason this only works with gcc 3.3 and not the previous version
       QDir d(qstr);
       if ( !d.exists() )
	{
		d.mkdir(qstr);
	}
	
	/*QDir d( QString(QDir::homeDirPath()+"/.kde/share/apps/ktvschedule") );
	if ( !d.exists() )
		{
			d.mkdir(QString(QDir::homeDirPath()+"/.kde/share/apps/ktvschedule"));
		}*/ // This worked for gcc 3.4 but not for 3.3

	
	//setRightJustification( TRUE );
	
////////////////////////////////

	this->setIcon( KGlobal::iconLoader()->loadIcon("ktvschedule", KIcon::Desktop) );
	
	// Creates the ToolBar
	KToolBar * TvToolBar = new KToolBar( this, KMainWindow::Top );
	
//////////////////////////////

	// Creates a QDateEdit Widget for future use
	date_show = new QDateEdit( QDate::currentDate() , TvToolBar );
	date_show->setOrder(QDateEdit::DMY);
	
////////////////////////////////
	// Define KActions
	
	 //KAction *actionGoHome = new KAction ( "Now Playing", KGlobal::iconLoader()->loadIcon("gohome", KIcon::NoGroup), CTRL+Key_P , t_TVGrid, SLOT (SetToCurrentTime() ), collector, "Now Playing");
	 
	 KAction *actionGoHome = new KAction ( i18n("Now &Playing"), "gohome", CTRL+Key_P , this, SLOT (SetToCurrentTime() ), actionCollection(), "Now Playing");

	 KAction *actionRefreshGuide = new KAction ( i18n("&Refresh Guide"), "reload", CTRL+Key_R , this, SLOT (RefreshXMLGuide() ), actionCollection(), "Refresh Guide");
	 
	 KAction *actionManageChannels = new KAction ( i18n("&Manage Channels"), "toggle_log", CTRL+Key_M , this, SLOT (channelList() ), actionCollection(), "Manage Channels");
	 
	 KAction *actionConfigure = new KAction ( i18n("&Configure"), "configure", CTRL+Key_C , this, SLOT (runConfig() ), actionCollection(), "Configure");
	 	 
	 KAction *actionExit = KStdAction::quit(this, SLOT(close()), 0);

	 KAction *actionPrevious = new KAction ( i18n("Pre&vious Day"), "previous", CTRL+Key_V , date_show, SLOT ( stepDown() ), actionCollection(), "PreviousDay");
 
	 KAction *actionNext = new KAction ( i18n("&Next Day"), "forward", CTRL+Key_N , date_show, SLOT ( stepUp() ), actionCollection(), "NextDay");
	 
	 KAction *actionEvent = KStdAction::configureNotifications(this, SLOT( notificationsEvent() ), actionCollection(), "settings_notifications" );
	 
	 KAction *actionFindCategory = new KAction (i18n("&Find Next Show"), "find", CTRL+Key_F , this, SLOT( findNextCategory() ), actionCollection(), "findnextshow");

//////////////////////////////////

	// Plug actions to ToolBar
	 
	
	 actionGoHome->plug ( TvToolBar);
	 actionRefreshGuide->plug (TvToolBar);
	 actionExit->plug (TvToolBar);
	 
	 TvToolBar->insertLineSeparator();
	 
	 actionManageChannels->plug (TvToolBar);
	 actionConfigure->plug (TvToolBar);

	 TvToolBar->insertLineSeparator();
	 
	 actionPrevious->plug (TvToolBar);
	 
	 // Add a QDateEdit widget for the ToolBar
	 TvToolBar->insertWidget (actionCollection()->count()+1,13, date_show );
	 
	 actionNext->plug (TvToolBar);
	 
	// Creates the KComboBox and adds it to the Toolbar
	 
	combo_Categories = new KComboBox(TvToolBar);
	combo_Categories->setMinimumWidth( combo_Categories->width ()+60); 
	combo_Categories->insertStringList(Categories);
	
	TvToolBar->insertWidget (actionCollection()->count()+1,15, combo_Categories);
	
	actionFindCategory->plug (TvToolBar);
//////////////////////////////////

	// Create menus
	 
	KPopupMenu *menuGrid = new KPopupMenu( this );
	KPopupMenu *menuConf = new KPopupMenu( this );
	
	menuBar()->insertItem( i18n("&Grid"), menuGrid );
  	menuBar()->insertItem( i18n("&Configure"), menuConf );
	
	// Plug KActions to menus
	
	actionGoHome->plug(menuGrid);
	actionRefreshGuide->plug(menuGrid);
	actionExit->plug(menuGrid);
	
	actionManageChannels->plug(menuConf);
	actionConfigure->plug(menuConf);
        actionEvent->plug(menuConf);
	
	KAboutData *_aboutData = new KAboutData("kTvSchedule", I18N_NOOP("KTvSchedule"), 
              "0.1.8", I18N_NOOP("TV Schedule.\n\n"
              "KDE Front end for TV Schedule programs.\n"
              "created by xmltv (tv_grab_xx)"),
              KAboutData::License_GPL, "(c) 2005, Alexios Beveratos",0,"http://www.kde-apps.org/content/show.php?content=22747","*****@*****.**");
	_aboutData->addAuthor("Alexios Beveratos", I18N_NOOP("Main Developper"), "*****@*****.**");
	_aboutData->addAuthor("Benoit Philipps",0,"*****@*****.**");
	//_aboutData->setHomepage("http://www.kde-apps.org/content/show.php?content=22747");
	//_aboutData->setBugAddress("http://developer.berlios.de/projects/ktvschedule/");
	
	 KHelpMenu *HelpMenu = new KHelpMenu( this, _aboutData );
 	 menuBar()->insertItem(i18n("&Help"), HelpMenu->menu() );	
	
//////////////////////////////////

	// Creates StatusBar
			  
	StatusBar = this->statusBar();
	led = new KLed(QColor ("#2EBB16"), KLed::On, KLed::Raised, KLed::Circular);
	StatusBar->addWidget ( led, 0, TRUE );
	
//////////////////////////////////

	// Other Initialisations
	
	date_show->setDate(QDate::currentDate ());
	date_show->setOrder(QDateEdit::DMY);
	
	FirstInput=QDate::currentDate();
	LastInput=QDate::currentDate();

//////////////////////////////////

	//Add connections
	connect( date_show, SIGNAL( valueChanged(const QDate&) ), this, SLOT( PopulateTvGrid() ) );
	//connect( combo_Categories, SIGNAL( activated(const QString &)),t_TVGrid,SLOT( highlightCategory(const QString& )));
	connect( combo_Categories, SIGNAL( activated(const QString &)),this,SLOT( highlightCategory(const QString& )));
	
	// Creates the scheduler class, and connects it. can be made better
	
	tvShowScheduler= new tvscheduler(); 
	connect( t_TVGrid, SIGNAL (infoContext(TvItem*) ), tvShowScheduler, SLOT (doNotMiss(TvItem*) ) );
	connect( t_TVGrid, SIGNAL (recordProgramSignal(TvItem* ) ), tvShowScheduler, SLOT (recordProgram(TvItem* ) ) );
	
/////////////////////////////////
	//If we use nxtvepg then disable some buttons
	if (Config().m_GrabberToUse == "nxtvepg")
	{
		actionRefreshGuide->setEnabled(FALSE);
		actionManageChannels->setEnabled(FALSE);
	}
}
Exemple #30
0
void Tree::stepPriv(float v) {
	for(std::vector<Link*>::iterator l = links.begin(); l!=links.end();) {
		switch((*l)->state) {
			case Link::LS_NORMAL:
				(*l)->age++;
				break;
			case Link::LS_DIED:
				l = links.erase(l);
				continue;
			case Link::LS_CUTTING:
				{
					float linkCuttingStep = normalLinkCuttingStep * genus->linkFactor;
					if((*l)->length > linkCuttingStep) {
						(*l)->stepDown(linkCuttingStep);
						v += linkCuttingStep;
					} else {
						v += (*l)->length;
						delete (*l);
						l = links.erase(l);
						continue;
					}
				}
				break;
		}
		++l;
	}

	int linkGrowingCount = 0, linkNormalCount = 0;
	for(std::vector<Link*>::iterator l = links.begin(); l!=links.end(); ++l) {
		switch((*l)->state) {
			case Link::LS_GROWING:
				linkGrowingCount++;
				break;
			case Link::LS_NORMAL:
				linkNormalCount++;
				break;
		}
	}

	float linkGrowingStep = normalLinkGrowingStep * genus->linkFactor;
	if(linkGrowingCount > 0) {
		float needForGroving = linkGrowingCount * linkGrowingStep;
		if(needForGroving > v + coma.getLength() + root.getLength()) {
			for(std::vector<Link*>::iterator l = links.begin(); l!=links.end(); ++l)
				if((*l)->state == Link::LS_GROWING)
					(*l)->cut();
		} else {
			for(std::vector<Link*>::iterator l = links.begin(); l!=links.end(); ++l) 
				if((*l)->state == Link::LS_GROWING) {
					(*l)->stepUp(linkGrowingStep);
					v -= linkGrowingStep;
				}
		}
	} 

	float cl = coma.getLength();
	if(cl<EPSILON) {
		int cutCount = 0;
		if(linkGrowingCount>0)
			for(std::vector<Link*>::iterator l = links.begin(); l!=links.end(); ++l) {
				if((*l)->state == Link::LS_GROWING) {
					(*l)->cut();
					cutCount++;
				}

			}
		else if(linkNormalCount>0)
			for(std::vector<Link*>::iterator l = links.begin(); l!=links.end(); ++l) {
				if((*l)->state == Link::LS_NORMAL) {
					(*l)->cut();
					cutCount++;
				}
			}

		if(cutCount>0)
			planet->playFX(SND_WEAK_TREE);
	}

	if(absf(v) < EPSILON)
		return;

	if(v>0) {
		if(cl<EPSILON) {
			v *= 0.5f;
			root.stepUp(v);
			coma.stepUp(v);
			return;
		}
		stepUp(v);
	} else {
		stepDown(-v);
	}
}