Ejemplo n.º 1
0
LRESULT TrackView::onMouseMove(UINT /*flags*/, POINTS pos)
{
	if (GetCapture() == hwnd) {
		SyncDocument *doc = getDocument();
		const int posTrack = getTrackFromX(pos.x),
		    trackCount = getTrackCount();

		if (!doc || posTrack < 0 || posTrack >= trackCount)
			return FALSE;

		if (posTrack > anchorTrack) {
			for (int i = anchorTrack; i < posTrack; ++i)
				doc->swapTrackOrder(i, i + 1);
			anchorTrack = posTrack;
			setEditTrack(posTrack);
			InvalidateRect(hwnd, NULL, FALSE);
		} else if (posTrack < anchorTrack) {
			for (int i = anchorTrack; i > posTrack; --i)
				doc->swapTrackOrder(i, i - 1);
			anchorTrack = posTrack;
			setEditTrack(posTrack);
			InvalidateRect(hwnd, NULL, FALSE);
		}
	}
	return FALSE;
}
Ejemplo n.º 2
0
LRESULT TrackView::onKeyDown(UINT keyCode, UINT /*flags*/)
{
	SyncDocument *doc = getDocument();
	if (NULL == doc) return FALSE;
	
	if (!editString.empty())
	{
		switch(keyCode)
		{
		case VK_UP:
		case VK_DOWN:
		case VK_LEFT:
		case VK_RIGHT:
		case VK_PRIOR:
		case VK_NEXT:
		case VK_HOME:
		case VK_END:
			editEnterValue();
		}
	}
	
	if (editString.empty())
	{
		switch (keyCode)
		{
		case VK_LEFT:
			if (GetKeyState(VK_CONTROL) < 0) {
				if (0 < editTrack)
					doc->swapTrackOrder(editTrack, editTrack - 1);
				else
					MessageBeep(~0U);
			}
			if (0 != getTrackCount())
				setEditTrack(editTrack - 1);
			else
				MessageBeep(~0U);
			break;
		
		case VK_RIGHT:
			if (GetKeyState(VK_CONTROL) < 0) {
				if (int(getTrackCount()) > editTrack + 1)
					doc->swapTrackOrder(editTrack, editTrack + 1);
				else
					MessageBeep(~0U);
			}
			if (0 != getTrackCount())
				setEditTrack(editTrack + 1);
			else
				MessageBeep(~0U);
			break;
		}
	}

	if (editString.empty() && doc->clientSocket.clientPaused) {
		switch (keyCode) {
		case VK_UP:
			if (GetKeyState(VK_CONTROL) < 0)
			{
				float bias = 1.0f;
				if (GetKeyState(VK_SHIFT) < 0) bias = 0.1f;
				if (int(getTrackCount()) > editTrack) editBiasValue(bias);
				else
					MessageBeep(~0U);
			}
			else setEditRow(editRow - 1);
			break;
		
		case VK_DOWN:
			if (GetKeyState(VK_CONTROL) < 0)
			{
				float bias = 1.0f;
				if (GetKeyState(VK_SHIFT) < 0) bias = 0.1f;
				if (int(getTrackCount()) > editTrack) editBiasValue(-bias);
				else
					MessageBeep(~0U);
			}
			else setEditRow(editRow + 1);
			break;
		
		case VK_PRIOR:
			if (GetKeyState(VK_CONTROL) < 0)
			{
				float bias = 10.0f;
				if (GetKeyState(VK_SHIFT) < 0) bias = 100.0f;
				editBiasValue(bias);
			}
			else setEditRow(editRow - 0x10);
			break;
		
		case VK_NEXT:
			if (GetKeyState(VK_CONTROL) < 0)
			{
				float bias = 10.0f;
				if (GetKeyState(VK_SHIFT) < 0) bias = 100.0f;
				editBiasValue(-bias);
			}
			else setEditRow(editRow + 0x10);
			break;
		
		case VK_HOME:
			if (GetKeyState(VK_CONTROL) < 0) setEditTrack(0);
			else setEditRow(0);
			break;
		
		case VK_END:
			if (GetKeyState(VK_CONTROL) < 0) setEditTrack(int(getTrackCount()) - 1);
			else setEditRow(int(getRows()) - 1);
			break;
		}
	}
	
	switch (keyCode)
	{
	case VK_RETURN: editEnterValue(); break;
	case VK_DELETE: editDelete(); break;
	
	case VK_BACK:
		if (!editString.empty())
		{
			editString.resize(editString.size() - 1);
			invalidatePos(editTrack, editRow);
		}
		else
			MessageBeep(~0U);
		break;
	
	case VK_CANCEL:
	case VK_ESCAPE:
		if (!editString.empty()) {
			// return to old value (i.e don't clear)
			editString.clear();
			invalidatePos(editTrack, editRow);
			MessageBeep(~0U);
		}
		break;
	case VK_SPACE:
		if (!editString.empty()) {
			editString.clear();
			invalidatePos(editTrack, editRow);
			MessageBeep(~0U);
		}
		doc->clientSocket.sendPauseCommand( !doc->clientSocket.clientPaused );
		break;
	}
	return FALSE;
}