Exemplo n.º 1
0
void SetArrangeScroll(int offsetY, int height, VerticalZoomCenter center)
{
	HWND hwnd = GetArrangeWnd();
	SCROLLINFO si = { sizeof(SCROLLINFO), };
	si.fMask = SIF_ALL;
	CoolSB_GetScrollInfo(hwnd, SB_VERT, &si);

	int newPos = si.nPos;
	const int objUpperHalf = offsetY + (height / 4);
	const int objMid = offsetY + (height / 2);
	const int objLowerHalf = offsetY + (height / 4) * 3;
	const int objEnd = offsetY + height;
	const int pageEnd = si.nPos + (int)si.nPage + SCROLLBAR_W;

	switch (center)
	{
	case CLIP_IN_ARRANGE:
	{
		if (offsetY < si.nPos)
			newPos = offsetY;
		else if (objEnd > pageEnd)
			newPos = objEnd - (int)si.nPage - SCROLLBAR_W;
		break;
	}
	case MID_ARRANGE:
	{
		newPos = objMid - (int)(si.nPage / 2 + 0.5f) - (int)(SCROLLBAR_W / 2 + 0.5f);
		break;
	}
	case MOUSE_CURSOR:
	{
		POINT cr;
		GetCursorPos(&cr);
		ScreenToClient(hwnd, &cr);
		newPos = objMid - cr.y;
		break;
	}
	case UPPER_HALF:
	{
		newPos = objUpperHalf - (int)(si.nPage / 2 + 0.5f) - (int)(SCROLLBAR_W / 2 + 0.5f);
		break;
	}
	case LOWER_HALF:
	{
		newPos = objLowerHalf - (int)(si.nPage / 2 + 0.5f) - (int)(SCROLLBAR_W / 2 + 0.5f);
		break;
	}
	}

	if (newPos == si.nPos)
		return;
	else if (newPos < si.nMin)
		newPos = si.nMin;
	else if (newPos > si.nMax)
		newPos = si.nMax - si.nPage + 1;

	si.nPos = newPos;
	CoolSB_SetScrollInfo(hwnd, SB_VERT, &si, true);
	SendMessage(hwnd, WM_VSCROLL, si.nPos << 16 | SB_THUMBPOSITION, NULL);
}
Exemplo n.º 2
0
static void ContinuousActionTimer ()
{
	if (g_actionInProgress && g_actionInProgress->cmd)
	{
		// Don't let other windows steal our keyboard accelerator
		SetFocus(GetArrangeWnd());

		// Make sure tooltip is not displayed if mouse is over another window (tooltip only follows mouse movements in arrange/ruler)
		if (g_actionInProgress->SetTooltip)
		{
			POINT p;
			GetCursorPos(&p);
			HWND hwnd = WindowFromPoint(p);
			if (hwnd != GetArrangeWnd() && hwnd != GetRulerWnd())
				SetTooltip(NULL, NULL);
		}
		Main_OnCommand(g_actionInProgress->cmd, ACTION_FLAG);
	}
}
Exemplo n.º 3
0
HWND GetTrackWnd()
{
	return GetArrangeWnd(); // BR: will take care of any localization issues
}
Exemplo n.º 4
0
int GetCurrentTcpMaxHeight()
{
	RECT r;
	GetClientRect(GetArrangeWnd(), &r);
	return r.bottom - r.top;
}
Exemplo n.º 5
0
static bool ContinuousActionInit (bool init, int cmd, BR_ContinuousAction* action)
{
	static accelerator_register_t s_accelerator = { ContinuousActionTranslateAccel, TRUE, NULL };

	bool initSuccessful = true;
	if (init)
	{
		GetConfig("tooltips", g_tooltips);
		g_actionInProgress = action;
		if (g_actionInProgress)
		{
			if (g_actionInProgress->Init)
				initSuccessful = g_actionInProgress->Init(true);
		}
		else
			initSuccessful = false;

		if (initSuccessful)
		{
			if (g_actionInProgress->SetMouseCursor || g_actionInProgress->SetTooltip)
			{
				SetConfig("tooltips", SetBit(SetBit(SetBit(g_tooltips, 0), 1), 2));

				if (!g_arrangeWndProc && GetArrangeWnd())
				{
					if (g_actionInProgress->SetTooltip)
					{
						WDL_FastString tooltip = g_actionInProgress->SetTooltip(BR_ContinuousAction::ARRANGE);
						if (tooltip.GetLength())
						{
							POINT p; GetCursorPos(&p);
							SetTooltip(tooltip.Get(), &p);
						}
					}
					g_arrangeWndProc = (WNDPROC)SetWindowLongPtr(GetArrangeWnd(), GWLP_WNDPROC, (LONG_PTR)ArrangeWndProc);
					if (g_actionInProgress->SetMouseCursor && g_actionInProgress->SetMouseCursor(BR_ContinuousAction::ARRANGE))
						SendMessage(GetArrangeWnd(), WM_SETCURSOR, (WPARAM)GetArrangeWnd(), 0);
					InvalidateRect(GetArrangeWnd(), NULL, TRUE); // kill existing native tooltip, if any
				}

				if (!g_rulerWndProc && GetRulerWndAlt())
				{
					if (g_actionInProgress->SetTooltip)
					{
						WDL_FastString tooltip = g_actionInProgress->SetTooltip(BR_ContinuousAction::RULER);
						if (tooltip.GetLength())
						{
							POINT p; GetCursorPos(&p);
							SetTooltip(tooltip.Get(), &p);
						}
					}

					g_rulerWndProc = (WNDPROC)SetWindowLongPtr(GetRulerWndAlt(), GWLP_WNDPROC, (LONG_PTR)RulerWndProc);
					if (g_actionInProgress->SetMouseCursor && g_actionInProgress->SetMouseCursor(BR_ContinuousAction::RULER))
						SendMessage(GetRulerWndAlt(), WM_SETCURSOR, (WPARAM)GetRulerWndAlt(), 0);
					InvalidateRect(GetRulerWndAlt(), NULL, TRUE);
				}
			}

			plugin_register("accelerator", &s_accelerator);
			plugin_register("timer", (void*)ContinuousActionTimer);
		}
		else
		{
			g_actionInProgress = NULL;
		}
	}
	else
	{
		SetConfig("tooltips", g_tooltips);

		if (g_arrangeWndProc && GetArrangeWnd())
		{
			SetWindowLongPtr(GetArrangeWnd(), GWLP_WNDPROC, (LONG_PTR)g_arrangeWndProc);
			SendMessage(GetArrangeWnd(), WM_SETCURSOR, (WPARAM)GetArrangeWnd(), 0);
			InvalidateRect(GetArrangeWnd(), NULL, FALSE);
			g_arrangeWndProc = NULL;
		}

		if (g_rulerWndProc && GetRulerWndAlt())
		{
			SetWindowLongPtr(GetRulerWndAlt(), GWLP_WNDPROC, (LONG_PTR)g_rulerWndProc);
			SendMessage(GetRulerWndAlt(), WM_SETCURSOR, (WPARAM)GetRulerWndAlt(), 0);
			InvalidateRect(GetRulerWndAlt(), NULL, FALSE);
			g_rulerWndProc = NULL;
		}

		SetTooltip(NULL, NULL);

		plugin_register("-accelerator", &s_accelerator);
		plugin_register("-timer", (void*)ContinuousActionTimer);

		if (g_actionInProgress->Init)
			g_actionInProgress->Init(false);
		g_actionInProgress = NULL;
	}

	return initSuccessful;
}