static Boolean DialogVariantsHandleEvent (EventPtr e) { Boolean handled = false; FormPtr frm; CALLBACK_PROLOGUE switch (e->eType) { case frmOpenEvent: frm = FrmGetActiveForm(); FrmDrawForm(frm); handled = true; break; case ctlSelectEvent: if( stor.currplayer >= 0 ) { /* The player *cannot* continue a game once they alter variants */ ResetCubes(); } switch(e->data.ctlSelect.controlID) { case check_Bump: ToggleCheck( check_Bump, flag_Bump ); if( (stor.flags & flag_Eclipse) && (stor.flags & flag_Bump ) ) { ToggleCheck( check_Eclipse, flag_Eclipse ); } break; case check_Eclipse: ToggleCheck( check_Eclipse, flag_Eclipse ); if( (stor.flags & flag_Eclipse) && (stor.flags & flag_Bump ) ) { ToggleCheck( check_Bump, flag_Bump ); } break; case check_Sampler: ToggleCheck( check_Sampler, flag_Sampler ); break; case check_nTW: ToggleCheck( check_nTW, flag_nTW ); break; case check_FullHouse: ToggleCheck(check_FullHouse, flag_FullHouse ); break; case check_Suspend: ToggleCheck(check_Suspend, flag_Suspend ); break; } break; default: break; } CALLBACK_EPILOGUE return handled; }
bool EPropertyCheck::OnLButtonDown( EPropWnd* pParent , CPoint p ) { bool bPropertyChanged = false; if( m_IconRect.PtInRect(p) ) { bPropertyChanged = ToggleCheck(); } return bPropertyChanged; }
static Boolean DialogVariantsHandleEvent (EventPtr e) { Boolean handled = false; FormPtr frm; switch (e->eType) { case frmOpenEvent: frm = FrmGetActiveForm(); FrmDrawForm(frm); handled = true; break; case ctlSelectEvent: if( isGameOn() ) { /* The player *cannot* continue a game once they alter variants */ ResetCubes(); } switch(e->data.ctlSelect.controlID) { case check_Bump: ToggleCheck( check_Bump, flag_Bump ); if( GetFlag(flag_Eclipse) && GetFlag(flag_Bump) ) { ToggleCheck( check_Eclipse, flag_Eclipse ); } break; case check_Eclipse: ToggleCheck( check_Eclipse, flag_Eclipse ); if( GetFlag(flag_Eclipse) && GetFlag(flag_Bump ) ) { ToggleCheck( check_Bump, flag_Bump ); } break; case check_Sampler: ToggleCheck( check_Sampler, flag_Sampler ); break; case check_nTW: ToggleCheck( check_nTW, flag_nTW ); break; case check_Suspend: ToggleCheck(check_Suspend, flag_Suspend ); break; } break; default: break; } return handled; }
void CheckBox::MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam) { if (fEnabled) { // set mouse-on flag depending on whether mouse is over box area fMouseOn = Inside<int32_t>(iX, 0, rcBounds.Hgt) && Inside<int32_t>(iY, 0, rcBounds.Hgt); // left-click within checkbox toggles it if (iButton == C4MC_Button_LeftDown && fMouseOn) { ToggleCheck(true); return; } } // not recognized; base call Control::MouseInput(rMouse, iButton, iX, iY, dwKeyParam); }
int operatorDriveTrain() { int ErrorCode; //ToggleCheck(btnOldNewDrive, btnOldNewDrivePressed, (int) OldNewDrive); ToggleCheck(btnFrontBackDrive, btnFrontBackDrivePressed, (int) FrontBackDrive); if (OldNewDrive == PLAIN) { // Deadband control for each axis. if(!(abs(stkDriveX) > JOYSTICKDEADZONE)) stkDriveX = 0; if(!(abs(stkDriveY) > JOYSTICKDEADZONE)) stkDriveY = 0; if(!(abs(stkDriveS) > JOYSTICKDEADZONE * 2)) stkDriveS = 0; JoystickMax = 127+((10)+(0-cos(atan((stkDriveY/stkDriveX)*4)*(10)))); JoystickPower = sqrt(pow(stkDriveY,2)+pow(stkDriveX,2)+pow(stkDriveS,2)); motorLeftFrontDrive = stkDriveY + stkDriveX + stkDriveS; motorLeftBackDrive = stkDriveY + stkDriveX - stkDriveS; motorRightFrontDrive = stkDriveY - stkDriveX - stkDriveS; motorRightBackDrive = stkDriveY - stkDriveX + stkDriveS; } else { if((abs(stkDriveY) > JOYSTICKDEADZONE) || (abs(stkDriveX) > JOYSTICKDEADZONE)) //If the Joystick has been pushed far enough { motorLeftFrontDrive = stkDriveY + stkDriveX; motorLeftBackDrive = stkDriveY + stkDriveX; motorRightFrontDrive = stkDriveY - stkDriveX; motorRightBackDrive = stkDriveY - stkDriveX; } else { motorLeftFrontDrive = 0; motorLeftBackDrive = 0; motorRightFrontDrive = 0; motorRightBackDrive = 0; } } // Make sure our values are within the appropriate range RangeCheck(0-MOTORDRIVEMAX, motorLeftFrontDrive, MOTORDRIVEMAX); RangeCheck(0-MOTORDRIVEMAX, motorLeftBackDrive, MOTORDRIVEMAX); RangeCheck(0-MOTORDRIVEMAX, motorRightFrontDrive, MOTORDRIVEMAX); RangeCheck(0-MOTORDRIVEMAX, motorRightBackDrive, MOTORDRIVEMAX); return ErrorCode; }
int operatorTines() { ToggleCheck(btnTines, btnTinesPressed, (int) TinesPosition); return 0; }
//**************************************************************************************** void CBCGPDateTimeCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { if (!IsWindowEnabled ()) { return; } if (isdigit (nChar)) { PushDigit (nChar - '0'); return; } if (nChar >= VK_NUMPAD0 && nChar <= VK_NUMPAD9) { PushDigit (nChar - VK_NUMPAD0); return; } if (isalpha (nChar)) { switch (m_CurrPartType) { case MONTH: if (m_monthFormat != 2) { ChangeMonth (nChar); } break; case AMPM: ChangeAmPm (nChar); break; } return; } m_iPrevDigit = -1; switch (nChar) { case VK_DOWN: ScrollCurrPart (-1); break; case VK_UP: ScrollCurrPart (1); break; case VK_RIGHT: SelectNext (); break; case VK_LEFT: SelectPrev (); break; case VK_HOME: ScrollCurrPartToLimit (TRUE); break; case VK_END: ScrollCurrPartToLimit (FALSE); break; case VK_SPACE: if (m_CurrPartType == CHECK_BOX) { ToggleCheck (); } else if (m_CurrPartType == AMPM) { ScrollCurrPart (1); } break; } CButton::OnKeyDown(nChar, nRepCnt, nFlags); }
//************************************************************************************ void CBCGPDateTimeCtrl::OnLButtonDown(UINT /*nFlags*/, CPoint point) { m_iPrevDigit = -1; int iPrevPart = m_iPartNum; SetFocus (); if (m_rectDropButton.PtInRect (point) && IsWindowEnabled()) { if (m_dropCalendar && m_bIsChecked && m_showDate) { m_bDropButtonIsPressed = TRUE; SetCapture (); RedrawWindow (m_rectDropButton); OnShowCalendarPopup (); } return; } int iPartNum = GetPartFromPoint (point); if (iPartNum == -1) { m_CurrPartType = NO; if (m_rectText.PtInRect (point)) { do { point.x++; if (point.x > m_rectText.right) { return; } iPartNum = GetPartFromPoint (point); } while (iPartNum == -1); } else { return; } } if (!m_bIsChecked && m_arPartsOrder [iPartNum] != CHECK_BOX) { return; } m_iPartNum = iPartNum; m_CurrPartType = m_arPartsOrder [m_iPartNum]; if (m_CurrPartType == CHECK_BOX) { ToggleCheck (); } if (iPrevPart != m_iPartNum) { CRect rectPrevPart = m_arPartRects [iPrevPart]; rectPrevPart.InflateRect (1, 1); RedrawWindow (rectPrevPart); CRect rectPart = m_arPartRects [m_iPartNum]; rectPart.InflateRect (1, 1); RedrawWindow (rectPart); } }
bool CheckBox::OnHotkey(char cHotkey) { if (cHotkey != this->cHotkey) return false; ToggleCheck(true); return true; }
bool EPropertyCheck::OnSpaceKey() { return ToggleCheck(); }
int operatorDriveTrain() { int joystickDriveMax = 127; //Maximum distance of drive stick from center int motorDriveMax = 127; //Maximum power we want our motors to go float JoystickAngleSin; //Sine of the Drive Stick float JoystickAngleCos; //Cosine of the Drive Stick ToggleCheck(btnHoloStraight, btnHoloStraightPressed, (int) HolonomicMode); ToggleCheck(btnOldNewDrive, btnOldNewDrivePressed, bOldNewDrive); ToggleCheck(btnFrontBackDrive, btnFrontBackDrivePressed, bFrontBackDrive); if(HolonomicMode == STRAIGHT) { } else { if (!bOldNewDrive) { joystickDrivePower = sqrt((stkDriveX*stkDriveX)+(stkDriveY*stkDriveY)); // Calculate Joystick Hypotenuse JoystickAngleSin = stkDriveY/joystickDriveMax; // Calculate Joystick Sin JoystickAngleCos = stkDriveX/joystickDriveMax; // Calculate Joystick Cosin motorLeftDriveTrain = (JoystickAngleSin + JoystickAngleCos) * joystickDrivePower; motorRightDriveTrain = (JoystickAngleSin - JoystickAngleCos) * joystickDrivePower; if(joystickDrivePower > joystickDriveDeadzone) //If the Joystick has been pushed far enough { RangeCheck(0-motorDriveMax, motorLeftDriveTrain, motorDriveMax); RangeCheck(0-motorDriveMax, motorRightDriveTrain, motorDriveMax); /*motorLeftDriveTrain = (motorLeftDriveTrain > motorDriveMax) ? motorDriveMax : motorLeftDriveTrain; motorRightDriveTrain = (motorRightDriveTrain > motorDriveMax) ? motorDriveMax : motorRightDriveTrain; motorLeftDriveTrain = (motorLeftDriveTrain < (0-motorDriveMax)) ? (0-motorDriveMax) : motorLeftDriveTrain; motorRightDriveTrain = (motorRightDriveTrain < (0-motorDriveMax)) ? (0-motorDriveMax) : motorRightDriveTrain;*/ } else { motorLeftDriveTrain = 0; motorRightDriveTrain = 0; } } /*else //Old Drive { joystickDrivePower = sqrt((stkDriveX*stkDriveX)+(stkDriveY*stkDriveY)); motorLeftDriveTrain = stkDriveY + stkDriveX; motorRightDriveTrain = stkDriveY - stkDriveX; if(joystickDrivePower > joystickDriveDeadzone) //If the Joystick has been pushed far enough { motorLeftDriveTrain = (motorLeftDriveTrain > motorDriveMax) ? motorDriveMax : motorLeftDriveTrain; motorRightDriveTrain = (motorRightDriveTrain > motorDriveMax) ? motorDriveMax : motorRightDriveTrain; motorLeftDriveTrain = (motorLeftDriveTrain < (0-motorDriveMax)) ? (0-motorDriveMax) : motorLeftDriveTrain; motorRightDriveTrain = (motorRightDriveTrain < (0-motorDriveMax)) ? (0-motorDriveMax) : motorRightDriveTrain; } else { motorLeftDriveTrain = 0; motorRightDriveTrain = 0; } }*/ //*********Commented because we ran out of space on the brain! } //return errorcode; return 0; }