Ejemplo n.º 1
0
 /**
  * \brief
  * Calculate and set the RA frequency
  *
  * This function calculates the required frequency for the RA
  * stepper motor based on the current value of buttons. Then if required, it changes
  * the frequency of timer 1.
  */
 void CalculateAndSetFrequency(struct MotorStatus* pStatus)
 {
 	if (FastOn())
	{
		// For fast mode it is not important if we are tracking
		if(pStatus->ButtonForward())
		{
			SetAxisFrequency(pStatus, pStatus->fastFrequency, +1);
		}
		else if (pStatus->ButtonBackward())
		{
			SetAxisFrequency(pStatus, pStatus->fastFrequency, -1);
		}
		else
		{
			if (IsTracking())
			{
				SetAxisFrequency(pStatus, trackingFrequency, +1);
			}
			else
			{
				SetAxisFrequency(pStatus, 0., 0);
			}
		}
	}
	else 
	{
		if (IsTracking())
		{
			if (pStatus->ButtonForward())
			{
				SetAxisFrequency(pStatus, trackingFrequency * 1.5, +1);
			}
			else if (pStatus->ButtonBackward())
			{
				SetAxisFrequency(pStatus, trackingFrequency * 0.5, +1);
			}
			else 
			{
				SetAxisFrequency(pStatus, trackingFrequency, +1);
			}
		}
		else
		{
			if (pStatus->ButtonForward())
			{
				SetAxisFrequency(pStatus, trackingFrequency, +1);
			}
			else if (pStatus->ButtonBackward())
			{
				SetAxisFrequency(pStatus, trackingFrequency, -1);
			}
			else
			{
				SetAxisFrequency(pStatus, 0.0, 0);
			}
		}
	}
 } 
Ejemplo n.º 2
0
void
BButton::Draw(BRect updateRect)
{
	BRect rect(Bounds());
	rgb_color background = LowColor();
	rgb_color base = background;
	uint32 flags = be_control_look->Flags(this);
	if (_Flag(FLAG_DEFAULT))
		flags |= BControlLook::B_DEFAULT_BUTTON;
	if (_Flag(FLAG_FLAT) && !IsTracking())
		flags |= BControlLook::B_FLAT;
	if (_Flag(FLAG_INSIDE))
		flags |= BControlLook::B_HOVER;

	be_control_look->DrawButtonFrame(this, rect, updateRect,
		base, background, flags);

	if (fBehavior == B_POP_UP_BEHAVIOR) {
		be_control_look->DrawButtonWithPopUpBackground(this, rect, updateRect,
			base, flags);
	} else {
		be_control_look->DrawButtonBackground(this, rect, updateRect,
			base, flags);
	}

	// always leave some room around the label
	rect.InsetBy(kLabelMargin, kLabelMargin);

	const BBitmap* icon = IconBitmap(
		(Value() == B_CONTROL_OFF
				? B_INACTIVE_ICON_BITMAP : B_ACTIVE_ICON_BITMAP)
			| (IsEnabled() ? 0 : B_DISABLED_ICON_BITMAP));
	be_control_look->DrawLabel(this, Label(), icon, rect, updateRect,
		base, flags, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
}
Ejemplo n.º 3
0
LRESULT CMDIFrameWnd::OnCommandHelp(WPARAM wParam, LPARAM lParam)
{
	if (lParam == 0 && IsTracking())
		lParam = HID_BASE_COMMAND+m_nIDTracking;

	CMDIChildWnd* pActiveChild = MDIGetActive();
	if (pActiveChild != NULL && AfxCallWndProc(pActiveChild,
	  pActiveChild->m_hWnd, WM_COMMANDHELP, wParam, lParam) != 0)
	{
		// handled by child
		return TRUE;
	}

	if (CFrameWnd::OnCommandHelp(wParam, lParam))
	{
		// handled by our base
		return TRUE;
	}

	if (lParam != 0)
	{
		CWinApp* pApp = AfxGetApp();
		if (pApp != NULL)
		{
			AfxGetApp()->WinHelpInternal(lParam);
			return TRUE;
		}
	}
	return FALSE;
}
Ejemplo n.º 4
0
void
CPUButton::MessageReceived(BMessage *message)
{
    switch (message->what) {
    case B_ABOUT_REQUESTED: {
        BAlert *alert = new BAlert(B_TRANSLATE("Info"),
                                   B_TRANSLATE("Pulse\n\nBy David Ramsey and Arve Hjønnevåg\n"
                                               "Revised by Daniel Switkin"), B_TRANSLATE("OK"));
        // Use the asynchronous version so we don't block the window's thread
        alert->Go(NULL);
        break;
    }
    case PV_REPLICANT_PULSE: {
        // Make sure we're consistent with our CPU
        if (_kern_cpu_enabled(fCPU) != Value() && !IsTracking())
            SetValue(!Value());
        break;
    }
    case kDeleteReplicant: {
        Window()->PostMessage(kDeleteReplicant, this, NULL);
        break;
    }
    default:
        BControl::MessageReceived(message);
        break;
    }
}
Ejemplo n.º 5
0
void
BChannelSlider::MouseMoved(BPoint where, uint32 code, const BMessage* message)
{
	if (IsEnabled() && IsTracking())
		_MouseMovedCommon(where, B_ORIGIN);
	else
		BChannelControl::MouseMoved(where, code, message);
}
Ejemplo n.º 6
0
void
CPUButton::MouseMoved(BPoint point, uint32 transit, const BMessage *message)
{
    if (IsTracking()) {
        if (transit == B_ENTERED_VIEW || transit == B_EXITED_VIEW)
            SetValue(!Value());
    }
}
Ejemplo n.º 7
0
void BitmapControl::MouseMoved(BPoint point, uint32 transit,
                               const BMessage *msg)
{
    if (IsTracking() &&
            (transit == B_ENTERED_VIEW || transit == B_EXITED_VIEW))
    {
        SetValue(!value);
    }
}
Ejemplo n.º 8
0
//!	This one calls _Update() if needed; BControl::SetTracking() isn't virtual.
void
BIconButton::_SetTracking(bool tracking)
{
	if (IsTracking() == tracking)
		return;

	SetTracking(tracking);
	_Update();
}
Ejemplo n.º 9
0
/*!	Override the BSlider functionality to be able to grab the knob when
	it's over 0 dB for some pixels.
*/
void
VolumeControl::MouseMoved(BPoint where, uint32 transit,
	const BMessage* dragMessage)
{
	if (!IsTracking()) {
		BSlider::MouseMoved(where, transit, dragMessage);
		return;
	}

	float cursorPosition = Orientation() == B_HORIZONTAL ? where.x : where.y;

	if (fSnapping && cursorPosition >= fMinSnap && cursorPosition <= fMaxSnap) {
		// Don't move the slider, keep the current value for a few
		// more pixels
		return;
	}

	fSnapping = false;

	int32 oldValue = Value();
	int32 newValue = ValueForPoint(where);
	if (oldValue == newValue) {
		BSlider::MouseMoved(where, transit, dragMessage);
		return;
	}

	// Check if there is a 0 dB transition at all
	if ((oldValue < 0 && newValue >= 0) || (oldValue > 0 && newValue <= 0)) {
		SetValue(0);
		if (ModificationMessage() != NULL)
			Messenger().SendMessage(ModificationMessage());

		float snapPoint = _PointForValue(0);
		const float kMinSnapOffset = 6;

		if (oldValue > newValue) {
			// movement from right to left
			fMinSnap = _PointForValue(-4);
			if (fabs(snapPoint - fMinSnap) < kMinSnapOffset)
				fMinSnap = snapPoint - kMinSnapOffset;

			fMaxSnap = _PointForValue(1);
		} else {
			// movement from left to right
			fMinSnap = _PointForValue(-1);
			fMaxSnap = _PointForValue(4);
			if (fabs(snapPoint - fMaxSnap) < kMinSnapOffset)
				fMaxSnap = snapPoint + kMinSnapOffset;
		}

		fSnapping = true;
		return;
	}

	BSlider::MouseMoved(where, transit, dragMessage);
}
Ejemplo n.º 10
0
void
TransportButton::MouseMoved(BPoint point, uint32 code, const BMessage *)
{
    if (IsTracking() && Bounds().Contains(point) != Value()) {
        if (!Value())
            MouseStartPressing();
        else
            MouseCancelPressing();
    }
}
Ejemplo n.º 11
0
void
CPUButton::MouseUp(BPoint point)
{
    if (IsTracking()) {
        if (Bounds().Contains(point))
            Invoke();

        SetTracking(false);
    }
}
Ejemplo n.º 12
0
void 
UpDownButton::MouseMoved(BPoint point, uint32 transit, const BMessage *message)
{
	if (!IsTracking())
		return;
		
	fTrackingY = point.y;
	Draw(Bounds());
	Flush();
}
Ejemplo n.º 13
0
void
BButton::MouseMoved(BPoint point, uint32 transit, const BMessage *message)
{
	if (!IsTracking())
		return;

	bool inside = Bounds().Contains(point);

	if ((Value() == B_CONTROL_ON) != inside)
		SetValue(inside ? B_CONTROL_ON : B_CONTROL_OFF);
}
Ejemplo n.º 14
0
void
BButton::MouseUp(BPoint point)
{
	if (!IsTracking())
		return;

	if (Bounds().Contains(point))
		Invoke();

	SetTracking(false);
}
Ejemplo n.º 15
0
void
BPictureButton::MouseMoved(BPoint point, uint32 transit, const BMessage* msg)
{
	if (IsEnabled() && IsTracking()) {
		if (transit == B_EXITED_VIEW)
			SetValue(B_CONTROL_OFF);
		else if (transit == B_ENTERED_VIEW)
			SetValue(B_CONTROL_ON);
	} else
		BControl::MouseMoved(point, transit, msg);
}
Ejemplo n.º 16
0
void
TransportButton::MouseUp(BPoint point)
{
    if (IsTracking()) {
        if (Bounds().Contains(point))
            MouseDonePressing();
        else
            MouseCancelPressing();
        SetTracking(false);
    }
}
Ejemplo n.º 17
0
void
BSlider::MouseUp(BPoint point)
{
	if (IsTracking()) {
		if (_Location() != fInitialLocation)
			Invoke();

		SetTracking(false);
	} else
		BControl::MouseUp(point);
}
Ejemplo n.º 18
0
void
BIconButton::MouseMoved(BPoint where, uint32 transit, const BMessage* message)
{
	if (!IsValid())
		return;

	uint32 buttons = 0;
	Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons);
	// catch a mouse up event that we might have missed
	if (!buttons && _HasFlags(STATE_PRESSED)) {
		MouseUp(where);
		return;
	}
	if (buttons != 0 && !IsTracking())
		return;

	SetInside((transit == B_INSIDE_VIEW || transit == B_ENTERED_VIEW)
		&& IsEnabled());
	if (IsTracking())
		_SetFlags(STATE_PRESSED, Bounds().Contains(where));
}
Ejemplo n.º 19
0
void
BChannelSlider::MouseUp(BPoint where)
{
	if (IsEnabled() && IsTracking()) {
		_FinishChange();
		SetTracking(false);
		fAllChannels = false;
		fCurrentChannel = -1;
		fMinPoint = 0;
	} else {
		BChannelControl::MouseUp(where);
	}
}
void
BRadioButton::MouseMoved(BPoint point, uint32 transit, const BMessage* message)
{
	if (!IsTracking())
		return;

	bool inside = Bounds().Contains(point);

	if (fOutlined != inside) {
		fOutlined = inside;
		Invalidate();
	}
}
Ejemplo n.º 21
0
void
VolumeSlider::MouseUp(BPoint point)
{
	if (!IsTracking())
		return;
	if (fSoundPlayer && Bounds().InsetBySelf(2,2).Contains(point)) {
		_UpdateVolume(point);
	}
	
	Invoke();
	SetTracking(false);
	Draw(Bounds());
	Flush();
}
Ejemplo n.º 22
0
void
BSlider::MouseMoved(BPoint point, uint32 transit, const BMessage *message)
{
	if (IsTracking()) {
		if (_ConstrainPoint(point, _Location())) {
			int32 value = ValueForPoint(point);
			if (value != Value()) {
				SetValue(value);
				InvokeNotify(ModificationMessage(), B_CONTROL_MODIFIED);
			}
		}
	} else
		BControl::MouseMoved(point, transit, message);
}
Ejemplo n.º 23
0
void
BRadioButton::MouseMoved(BPoint where, uint32 code,
	const BMessage* dragMessage)
{
	if (!IsTracking())
		return;

	bool inside = Bounds().Contains(where);

	if (fOutlined != inside) {
		fOutlined = inside;
		Invalidate();
	}
}
Ejemplo n.º 24
0
void
BButton::MouseUp(BPoint where)
{
	if (!IsTracking())
		return;

	if (Bounds().Contains(where)) {
		if (fBehavior == B_TOGGLE_BEHAVIOR)
			SetValue(_Flag(FLAG_WAS_PRESSED) ? B_CONTROL_OFF : B_CONTROL_ON);

		Invoke();
	} else if (_Flag(FLAG_FLAT))
		Invalidate();

	SetTracking(false);
}
void
BRadioButton::MouseUp(BPoint point)
{
	if (!IsTracking())
		return;

	fOutlined = Bounds().Contains(point);
	if (fOutlined) {
		fOutlined = false;
		SetValue(B_CONTROL_ON);
		Invoke();
	}
	Invalidate();

	SetTracking(false);
}
Ejemplo n.º 26
0
void
BPictureButton::MouseUp(BPoint point)
{
	if (IsEnabled() && IsTracking()) {
		if (Bounds().Contains(point)) {
			if (fBehavior == B_ONE_STATE_BUTTON) {
				if (Value() == B_CONTROL_ON) {
					snooze(75000);
					SetValue(B_CONTROL_OFF);
				}
			}
			Invoke();
		}

		SetTracking(false);
	}
}
Ejemplo n.º 27
0
void CollapsableBox::MouseMoved(BPoint where, uint32 transit, const BMessage *message)
{
	if (!IsTracking())
		return;

	if (where == m_click)
		return;

	m_click = where;
	bool inside = m_collapsed_rect.Contains(where);

	if (m_pressing != inside) {
		m_pressing = inside;
		Draw(Bounds());
		Flush();
	};
}
Ejemplo n.º 28
0
void
UpDownButton::MouseUp(BPoint point)
{
	if (!IsTracking())
		return;
	
	if((Bounds().top + Bounds().Height()/2) > (fTrackingY + 3))
		SetValue(B_CONTROL_ON);
	else if((Bounds().top + Bounds().Height()/2) < (fTrackingY - 3))
		SetValue(B_CONTROL_OFF);
	
	if(Value()!=fLastValue)
		Invoke();
	SetTracking(false);
	Draw(Bounds());
	Flush();
	fLastValue = Value();
}
Ejemplo n.º 29
0
void CollapsableBox::MouseUp(BPoint where)
{
	if (!IsTracking())
		return;

	bool inside = m_collapsed_rect.Contains(where);
	if (inside)
		SetValue(Value() == B_CONTROL_OFF ? B_CONTROL_ON : B_CONTROL_OFF);
	else {
		Draw(Bounds());
		Flush();
	};

	m_pressing = false;

	SetTracking(false);		
	SetMouseEventMask(0, 0);
}
Ejemplo n.º 30
0
void
BButton::MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage)
{
	bool inside = Bounds().Contains(where);
	if (_SetFlag(FLAG_INSIDE, inside))
		Invalidate();

	if (!IsTracking())
		return;

	if (fBehavior == B_TOGGLE_BEHAVIOR) {
		bool pressed = inside ^ _Flag(FLAG_WAS_PRESSED);
		SetValue(pressed ? B_CONTROL_ON : B_CONTROL_OFF);
	} else {
		if ((Value() == B_CONTROL_ON) != inside)
			SetValue(inside ? B_CONTROL_ON : B_CONTROL_OFF);
	}
}