Example #1
0
bool MouseEventMatcher::operator()(Event* e) {
    if (e->hash() != MouseEvent::chash()) return false;
    auto me = static_cast<MouseEvent*>(e);

    if (me->state() == MouseState::Move) {
        if (states_.value & me->state()) {
            if (modifiers_ == KeyModifiers(flags::any) || modifiers_ == me->modifiers()) {
                if (me->buttonState() != MouseButton::None) {
                    for (auto s : me->buttonState()) {
                        if (buttons_.value & s) {
                            return true;
                        }
                    }
                } else if (buttons_.value == MouseButton::None) {
                    return true;
                } else if (buttons_.value == MouseButtons(flags::any)) {
                    return true;
                }
            }
        }
    } else {
        if (buttons_.value & me->button()) {
            if (states_.value & me->state()) {
                if (modifiers_ == KeyModifiers(flags::any) || modifiers_ == me->modifiers()) {
                    return true;
                }
            }
        }
    }

    return false;
}
Example #2
0
void checkButtonPress(imgButton b)
{
	if(mousePosX <= b.xTopRight && mousePosX >= b.xTopLeft && mousePosY >= b.yTopRight && mousePosY <= b.yBottomRight)
	{
		if(stopRotation == 0) {
			stopRotation = 1;
			buttonState(0);
		}
		else {
			stopRotation = 0;
			buttonState(1);
		}
	}
}
Example #3
0
void MSEntryFieldCombo::buttonPress(const XEvent *pEvent_)
{
    if (sensitive()==MSTrue)
    {
        if(pEvent_->xbutton.x<_fieldValue->x()+_fieldValue->width())
        {
            MSEntryField::buttonPress(pEvent_);
        }
        else
        {
            activate();
            if (_editor->mapped()==MSFalse)
            {
                MSBoolean focusOK=MSTrue;
                if (acceptFocus()==MSTrue) focusOK=traverseFocus(this);
                if (focusOK==MSTrue)
                {
                    if (pEvent_->xbutton.button==Button1&&_buttonFlags!=0)
                    {
                        if (comboOrTextButton()==MSTrue&&
                                pEvent_->xbutton.x>=buttonRect().x()&&
                                pEvent_->xbutton.y>=buttonRect().y())
                        {
                            if(buttonState(ComboButton) == MSTrue)
                            {
                                buttonActivate();
                            }
                            else
                            {
                                drawTextButton(MSTrue);
                                _buttonSelected = MSTrue;
                            }
                        }
                        else if(buttonState(UpDownArrows) == MSTrue)
                        {
                            if (isProtected()==MSFalse)
                            {
                                if(pEvent_->xbutton.y <_fieldValue->y()
                                        +_fieldValue->height()/2) armUpArrow();
                                else armDownArrow();
                            }
                        }
                    }
                }
            }
        }
    }
}
Example #4
0
void W32TristateBox::setState(ZLBoolean3 state) {
	if (state != myState) {
		myState = state;
		if (myWindow != 0) {
			SendMessage(myWindow, BM_SETCHECK, buttonState(myState), 0);
		}
		fireEvent(STATE_CHANGED_EVENT);
	}
}
Example #5
0
	void GameInput::genKeyMove(UserInput& userInput)
	{
		int movespeed;
		int forward, side, up;

		//
		// adjust for speed key / running
		// the walking flag is to keep animations consistent
		// even during acceleration and develeration
		//
		movespeed = 127;

		forward = 0;
		side = 0;
		up = 0;

		side += movespeed * buttonState(MoveRight);
		side -= movespeed * buttonState(MoveLeft);

		up += movespeed * buttonState(MoveUp);
		up -= movespeed * buttonState(MoveDown);

		forward += movespeed * buttonState(MoveForward);
		forward -= movespeed * buttonState(MoveBackward);

		userInput.forwardmove = Math::clampSbyte(forward);
		userInput.rightmove = Math::clampSbyte(side);
		userInput.upmove = Math::clampSbyte(up);
	}
void TCluster::setState(ushort aState, Boolean enable) {
   TView::setState(aState, enable);
   if (aState == sfSelected) {
      int i = 0, s = sel - 1;
      do {
         i++;
         s++;
         if (s >= strings->getCount())
            s = 0;
      } while (!(buttonState(s) || i > strings->getCount()));

      moveSel(i, s);
   }

   drawView();
}
Example #7
0
void
StatusbarButton::compose(const PaintEvent& event)
{
    int y = 0;
    if (_state & PressedState)
        y = 55;
    else if (_state & ExposedState)
        y = 110;

    Painter p(this);
    p.begin(event);
    p.blitImage(bgDef, Rectangle(0, y, 15, 55), 0, 0);
    p.blitImage(bgDef, Rectangle(106, y, 20, 55), width() - 20, 0);

    p.stretchImage(bgDef, Rectangle(15, 0, width() - 35, 55), Rectangle(15, y, 90, 55)); // mid

    p.drawImage(_images[buttonState()], (width() - 48) / 2, (height() - 48) / 2);
    p.end();
}
void TCluster::drawMultiBox(const char *icon, const char *marker) {
   TDrawBuffer b;
   ushort color;
   int i, j, cur;

   ushort cNorm = getColor(0x0301);
   ushort cSel = getColor(0x0402);
   ushort cDis = getColor(0x0505);
   for (i = 0; i <= size.y; i++) {
      b.moveChar(0, ' ', (uchar)cNorm, size.x);
      for (j = 0; j <= (strings->getCount() - 1) / size.y + 1; j++) {
         cur = j * size.y + i;
         if (cur < strings->getCount()) {
            int col = column(cur);

            if (((col + strlen((const char *)strings->at(cur)) + 5) <
                  (sizeof(b) / sizeof(ushort))) && (col < size.x)) {
               if (!buttonState(cur))
                  color = cDis;
               else if ((cur == sel) && (state & sfSelected) != 0)
                  color = cSel;
               else
                  color = cNorm;
               b.moveChar(col, ' ', color, size.x - col);
               b.moveCStr(col, icon, color);

               b.putChar(col + 2, marker[multiMark(cur)]);
               b.moveCStr(col + 5, (char *)(strings->at(cur)), color);
               if (showMarkers && ((state & sfSelected) != 0) && cur == sel) {
                  b.putChar(col, specialChars[0]);
                  b.putChar(column(cur + size.y) - 1, specialChars[1]);
               }

            }
         }
      }
      writeBuf(0, i, size.x, 1, b);
   }
   setCursor(column(sel) + 2, row(sel));
}
Example #9
0
void MSEntryFieldCombo::buttonRelease(const XEvent *pEvent_)
{
    if (buttonState(UpDownArrows)==MSTrue&&
            (_upArrow->selected()==MSTrue||_downArrow->selected()==MSTrue))
    {
        if (_upArrow->selected()) _upArrow->select(MSFalse);
        else if (_downArrow->selected()) _downArrow->select(MSFalse);
        stopTimers();
    }
    else if(comboOrTextButton()==MSTrue&&_buttonSelected==MSTrue)
    {
        _buttonSelected=MSFalse;
        drawTextButton(MSFalse);
        if(pEvent_->xbutton.x >= buttonRect().x()&&
                pEvent_->xbutton.x <= buttonRect().x() + buttonRect().width()&&
                pEvent_->xbutton.y >= buttonRect().y() &&
                pEvent_->xbutton.y <= buttonRect().y() + buttonRect().height())
        {
            textButtonActivate();
        }
    }
    else MSEntryField::buttonRelease(pEvent_);
}
Example #10
0
void W32TristateBox::init(HWND parent, W32ControlCollection *collection) {
	W32StandardControl::init(parent, collection);
	::setWindowText(myWindow, myText);
	SendMessage(myWindow, BM_SETCHECK, buttonState(myState), 0);
}
void TCluster::handleEvent(TEvent &event) {
   TView::handleEvent(event);
   if (!(options & ofSelectable))
      return;
   if (event.what == evMouseDown) {
      TPoint mouse = makeLocal(event.mouse.where);
      int i = findSel(mouse);
      if ((i != -1) && buttonState(i))
         sel = i;
      drawView();
      do  {
         mouse = makeLocal(event.mouse.where);
         if ((findSel(mouse) == sel) && buttonState(sel))
            showCursor();
         else
            hideCursor();
      } while (mouseEvent(event, evMouseMove));
      showCursor();
      mouse = makeLocal(event.mouse.where);
      if (findSel(mouse) == sel) {
         press(sel);
         drawView();
      }
      clearEvent(event);
   } else if (event.what == evKeyDown) {
      int s = sel;
      switch (ctrlToArrow(event.keyDown.keyCode)) {
      case kbUp:
         if ((state & sfFocused) != 0) {
            int i = 0;
            do {
               i++; s--;
               if (s < 0)
                  s = strings->getCount() - 1;
            } while (!(buttonState(s) || (i > strings->getCount())));
            moveSel(i, s);
            clearEvent(event);
         }
         break;

      case kbDown:
         if ((state & sfFocused) != 0) {
            int i = 0;
            do {
               i++; s++;
               if (s >= strings->getCount())
                  s = 0;
            } while (!(buttonState(s) || (i > strings->getCount())));
            moveSel(i, s);
            clearEvent(event);
         }
         break;
      case kbRight:
         if ((state & sfFocused) != 0) {
            int i = 0;
            do {
               i++; s += size.y;
               if (s >= strings->getCount()) {   // BUG FIX - EFW - 10/25/94
                  s = (s +  1) % size.y;
                  if (s >= strings->getCount())
                     s =  0;
               }
            } while (!(buttonState(s) || (i > strings->getCount())));

            moveSel(i, s);    // BUG FIX - EFW - 10/25/94

            clearEvent(event);
         }
         break;
      case kbLeft:
         if ((state & sfFocused) != 0) {
            int i = 0;
            do {
               i++;
               if (s > 0) {
                  s -= size.y;
                  if (s < 0) {
                     s = ((strings->getCount() + size.y - 1) /
                          size.y) * size.y + s - 1;
                     if (s >= strings->getCount())
                        s = strings->getCount() - 1;
                  }
               } else
                  s = strings->getCount() - 1;

            } while (!(buttonState(s) || (i > strings->getCount())));

            moveSel(i, s);    // BUG FIX - EFW - 10/25/94
            clearEvent(event);
         }
         break;
      default:
         for (int i = 0; i < strings->getCount(); i++) {
            char c = hotKey((char *)(strings->at(i)));
            if (getAltCode(c) == event.keyDown.keyCode ||
                  ((owner->phase == phPostProcess ||
                    (state & sfFocused) != 0
                   ) &&
                   c != 0 &&
                   toupper(event.keyDown.charScan.charCode) == c
                  )
               ) {
               if (buttonState(i)) {
                  if (focus()) {
                     sel = i;
                     movedTo(sel);
                     press(sel);
                     drawView();
                  }
                  clearEvent(event);
               }
               return;
            }
         }
         if (event.keyDown.charScan.charCode == ' ' &&
               (state & sfFocused) != 0
            ) {
            press(sel);
            drawView();
            clearEvent(event);
         }
      }
   }
}
Example #12
0
void MSComboField::init(void)
{ buttonState(ComboButton, MSTrue); }
Example #13
0
bool Input::buttonReleased( Qt::MouseButton button )
{
    return buttonState(button) == InputReleased;
}
Example #14
0
bool Input::buttonPressed( Qt::MouseButton button )
{
    return buttonState(button) == InputPressed;
}
Example #15
0
bool Input::buttonTriggered( Qt::MouseButton button )
{
    return buttonState(button) == InputTriggered;
}