void CSkinVerticleScrollbar::OnLButtonDown(UINT nFlags, CPoint point) 
{
	SetCapture();
	CRect clientRect;
	GetClientRect(&clientRect);

	int nHeight = clientRect.Height() - 37;
	

	CRect rectUpArrow(0,11,20,37);
	CRect rectDownArrow(0,nHeight,20,nHeight+26);
	CRect rectThumb(0,nThumbTop,20,nThumbTop+26);

	if(rectThumb.PtInRect(point))
	{
		bMouseDown = true;
	}

	if(rectDownArrow.PtInRect(point))
	{
		bMouseDownArrowDown = true;
		SetTimer(2,250,NULL);
	}

	if(rectUpArrow.PtInRect(point))
	{
		bMouseDownArrowUp = true;
		SetTimer(2,250,NULL);
	}
	
	CStatic::OnLButtonDown(nFlags, point);
}
void CSkinVerticleScrollbar::OnLButtonUp(UINT nFlags, CPoint point) 
{
	UpdateThumbPosition();
	KillTimer(1);
	ReleaseCapture();
	
	bool bInChannel = true;

	CRect clientRect;
	GetClientRect(&clientRect);
	int nHeight = clientRect.Height() - 37;
	CRect rectUpArrow(0,11,20,37);
	CRect rectDownArrow(0,nHeight,20,nHeight+26);
	CRect rectThumb(0,nThumbTop,20,nThumbTop+26);



	if(rectUpArrow.PtInRect(point) && bMouseDownArrowUp)
	{
		ScrollUp();	
		bInChannel = false;
	}

	if(rectDownArrow.PtInRect(point) && bMouseDownArrowDown)
	{
		ScrollDown();
		bInChannel = false;
	}

	if(rectThumb.PtInRect(point))
	{
		bInChannel = false;
	}

	if(bInChannel == true && !bMouseDown)
	{
		if(point.y > nThumbTop)
		{
			PageDown();
		}
		else
		{
			PageUp();
		}
	}

	bMouseDown = false;
	bDragging = false;
	bMouseDownArrowUp = false;
	bMouseDownArrowDown = false;
	
	CStatic::OnLButtonUp(nFlags, point);
}
Exemple #3
0
///////////////////////////////////////////////////////////////////////////////
// OnLButtonUp
void CXScrollBar::OnLButtonUp(UINT nFlags, CPoint point)
{
	UpdateThumbPosition();
	KillTimer(1);
	ReleaseCapture();

	if (m_bHorizontal)
	{
		CRect rectLeftArrow(0, 0, m_nBitmapWidth, m_rectClient.Height());
		CRect rectRightArrow(m_rectClient.Width() - m_nBitmapWidth, 0, 
		m_rectClient.Width(), m_rectClient.Height());
		CRect rectThumb(m_nThumbLeft, 0, m_nThumbLeft + m_nBitmapWidth, 
		m_rectClient.Height());

		if (rectLeftArrow.PtInRect(point))
		{
			ScrollLeft();
		}
		else if (rectRightArrow.PtInRect(point))
		{
			ScrollRight();
		}
		else if (rectThumb.PtInRect(point))
		{
			m_bThumbHover = TRUE;
			Invalidate();
			SetTimer(TIMER_MOUSE_OVER_THUMB, 50, NULL);
		}

		m_bMouseDownArrowLeft = FALSE;
		m_bMouseDownArrowRight = FALSE;
	}
	else
	{
		CRect rectUpArrow(0, 0, m_rectClient.Width(), m_nBitmapHeight);
		CRect rectDownArrow(0, m_rectClient.Height() - m_nBitmapHeight, m_rectClient.Width(), m_rectClient.Height());
		CRect rectThumb(0, m_nThumbTop, m_rectClient.Width(), m_nThumbTop + m_nBitmapHeight);

		if (rectUpArrow.PtInRect(point))
		{
			ScrollUp();
		}
		else if (rectDownArrow.PtInRect(point))
		{
			ScrollDown();
		}
		else if (rectThumb.PtInRect(point))
		{
			m_bThumbHover = TRUE;
			Invalidate();
			SetTimer(TIMER_MOUSE_OVER_THUMB, 50, NULL);
		}

		m_bMouseDownArrowUp = FALSE;
		m_bMouseDownArrowDown = FALSE;
	}

	m_bMouseDown = FALSE;
	m_bDragging = FALSE;

	CStatic::OnLButtonUp(nFlags, point);
}
Exemple #4
0
///////////////////////////////////////////////////////////////////////////////
// OnLButtonDown
void CXScrollBar::OnLButtonDown(UINT nFlags, CPoint point)
{
	SetCapture();

	if (m_bHorizontal)
	{
		CRect rectLeftArrow(0, 0, m_nBitmapWidth, m_rectClient.Height());
		CRect rectRightArrow(m_rectClient.Width() - m_nBitmapWidth, 0, 
			m_rectClient.Width(), m_rectClient.Height());
		CRect rectThumb(m_nThumbLeft, 0, m_nThumbLeft + m_nBitmapWidth, 
			m_rectClient.Height());

		if (rectThumb.PtInRect(point))
		{
			m_bMouseDown = TRUE;
		}
		else if (rectRightArrow.PtInRect(point))
		{
			m_bMouseDownArrowRight = TRUE;
			SetTimer(TIMER_LBUTTON_PRESSED, 150, NULL);
		}
		else if (rectLeftArrow.PtInRect(point))
		{
			m_bMouseDownArrowLeft = TRUE;
			SetTimer(TIMER_LBUTTON_PRESSED, 150, NULL);
		}
		else	// button down in channel
		{
			m_nThumbLeft = point.x - m_nBitmapWidth / 2;
			SetPositionFromThumb();
			Draw();

			if (m_pParent && ::IsWindow(m_pParent->m_hWnd))
			{
				m_pParent->SendMessage(WM_HSCROLL, MAKELONG(SB_THUMBTRACK, m_nPos),
				(LPARAM)m_hWnd);
			}
		}
	}
	else
	{
		CRect rectUpArrow(0, 0, m_rectClient.Width(), m_nBitmapHeight);
		CRect rectDownArrow(0, m_rectClient.Height() - m_nBitmapHeight, m_rectClient.Width(), m_rectClient.Height());
		CRect rectThumb(0, m_nThumbTop, m_rectClient.Width(), m_nThumbTop + m_nBitmapHeight);

		if (rectThumb.PtInRect(point))
		{
			m_bMouseDown = TRUE;
		}
		else if (rectDownArrow.PtInRect(point))
		{
			m_bMouseDownArrowDown = TRUE;
			SetTimer(TIMER_LBUTTON_PRESSED, 150, NULL);
		}
		else if (rectUpArrow.PtInRect(point))
		{
			m_bMouseDownArrowUp = TRUE;
			SetTimer(TIMER_LBUTTON_PRESSED, 150, NULL);
		}
		else	// button down in channel
		{
			m_nThumbTop = point.y - m_nBitmapHeight / 2;
			SetPositionFromThumb();
			Draw();

			if (m_pParent && ::IsWindow(m_pParent->m_hWnd))
			{
				m_pParent->SendMessage(WM_VSCROLL, MAKELONG(SB_THUMBTRACK, m_nPos), 
				(LPARAM)m_hWnd);
			}
		}
	}

	CStatic::OnLButtonDown(nFlags, point);
}
Exemple #5
0
///////////////////////////////////////////////////////////////////////////////
// DrawVertical
void CXScrollBar::DrawVertical()
{
	TRACE(_T("in CXScrollBar::DrawVertical\n"));

	CClientDC dc(this);
	CMemDC memDC(&dc, &m_rectClient);

	CBrush brushFrame(FRAME_COLOR);

	CDC bitmapDC;
	bitmapDC.CreateCompatibleDC(&dc);
	CBitmap bitmap;

	// =====  draw Up arrow  =====

	VERIFY(bitmap.LoadBitmap(IDB_VERTICAL_SCROLLBAR_UPARROW));
	CBitmap* pOldBitmap = bitmapDC.SelectObject(&bitmap);

	// NOTE:  thumb and arrow bitmaps are assumed to be same width and height
	CRect rectUpArrow(m_rectClient.left, m_rectClient.top, 
		m_rectClient.right, m_rectClient.top + m_nBitmapHeight);

	memDC.StretchBlt(rectUpArrow.left, rectUpArrow.top, 
		rectUpArrow.Width(), rectUpArrow.Height(), 
		&bitmapDC, 0, 0, m_nBitmapWidth, m_nBitmapHeight, SRCCOPY);

	memDC.FrameRect(&rectUpArrow, &brushFrame);
	if (pOldBitmap)
	{
		bitmapDC.SelectObject(pOldBitmap);
	}

	if (bitmap.GetSafeHandle())
	{
		bitmap.DeleteObject();
	}

	pOldBitmap = NULL;

	int nChannelStart = m_rectClient.top + m_nBitmapHeight;
	int nChannelHeight = m_rectClient.Height() - 2*m_nBitmapHeight;

	// =====  draw channel  =====

	// save new thumb position
	TRACE(_T("m_nThumbTop=%d\n"), m_nThumbTop);
	m_rectThumb.left   = m_rectClient.left;
	m_rectThumb.right  = m_rectThumb.left + m_rectClient.Width();
	m_rectThumb.top    = m_rectClient.top + m_nThumbTop;
	m_rectThumb.bottom = m_rectThumb.top + m_nBitmapHeight;

	VERIFY(bitmap.LoadBitmap(IDB_VERTICAL_SCROLLBAR_CHANNEL));
	pOldBitmap = bitmapDC.SelectObject(&bitmap);

	CRect rectChannelDown(m_rectClient.left, m_rectThumb.top + m_nBitmapHeight/2, 
		m_rectClient.right, nChannelStart + nChannelHeight);

	memDC.StretchBlt(rectChannelDown.left+1, rectChannelDown.top, 
		rectChannelDown.Width()-1, rectChannelDown.Height(), 
		&bitmapDC, 0, 0, m_nBitmapWidth, 1, SRCCOPY);

	if (m_bChannelColor && m_bThumbColor)
	{
		// thumb has a color, so use same (lightened) color for channel
		CColor color;
		color.SetRGB(GetRValue(m_ThumbColor),
					 GetGValue(m_ThumbColor), 
					 GetBValue(m_ThumbColor));
		color.ToHLS();
		float fLuminance = color.GetLuminance();

		// use 80% L, 150% S for main color
		fLuminance = .80f;
		float fSaturation = color.GetSaturation();
		fSaturation = 0.5f * fSaturation;
		float fHue = color.GetHue();
		color.SetHLS(fHue, fLuminance, fSaturation);
		color.ToRGB();
		COLORREF rgb3 = RGB(color.GetRed(), color.GetGreen(), color.GetBlue());

		// use .87 L for second highlight color
		fLuminance = .87f;
		color.SetHLS(fHue, fLuminance, fSaturation);
		color.ToRGB();
		COLORREF rgb2 = RGB(color.GetRed(), color.GetGreen(), color.GetBlue());

		// use .92 L for first highlight color
		fLuminance = .92f;
		color.SetHLS(fHue, fLuminance, fSaturation);
		color.ToRGB();
		COLORREF rgb1 = RGB(color.GetRed(), color.GetGreen(), color.GetBlue());

		BITMAP bm;
		bitmap.GetBitmap(&bm);

		// set highlight colors
		bitmapDC.SetPixel(0, 0, rgb1);
		bitmapDC.SetPixel(1, 0, rgb2);

		// set main color
		for (int x = 2; x < (bm.bmWidth); x++)
		{
			bitmapDC.SetPixel(x, 0, rgb3);
		}
	}

	CRect rectChannelUp(m_rectClient.left, nChannelStart, 
		m_rectClient.right, m_rectThumb.top + m_nBitmapHeight/2);

	memDC.StretchBlt(rectChannelUp.left, rectChannelUp.top, 
		rectChannelUp.Width(), rectChannelUp.Height(), 
		&bitmapDC, 0, 0, m_nBitmapWidth, 1, SRCCOPY);

	if (pOldBitmap)
	{
		bitmapDC.SelectObject(pOldBitmap);
	}
	if (bitmap.GetSafeHandle())
	{
		bitmap.DeleteObject();
	}

	pOldBitmap = NULL;

	// =====  draw down arrow  =====

	VERIFY(bitmap.LoadBitmap(IDB_VERTICAL_SCROLLBAR_DOWNARROW));
	pOldBitmap = bitmapDC.SelectObject(&bitmap);

	CRect rectDownArrow(m_rectClient.left, m_rectClient.bottom - m_nBitmapHeight, 
		m_rectClient.right, m_rectClient.bottom);

	memDC.StretchBlt(rectDownArrow.left, rectDownArrow.top, 
		rectDownArrow.Width()-1, rectDownArrow.Height(), 
		&bitmapDC, 0, 0, m_nBitmapWidth, m_nBitmapHeight, SRCCOPY);
	memDC.FrameRect(&rectDownArrow, &brushFrame);

	if (pOldBitmap)
	{
		bitmapDC.SelectObject(pOldBitmap);
	}
	if (bitmap.GetSafeHandle())
	{
		bitmap.DeleteObject();
	}

	pOldBitmap = NULL;

	// If there is nothing to scroll then don't show the thumb
	if (m_nRange)
	{
		// =====  draw thumb  =====

		VERIFY(bitmap.LoadBitmap(m_bThumbColor ? 
			IDB_VERTICAL_SCROLLBAR_THUMB : 
			IDB_VERTICAL_SCROLLBAR_THUMB_NO_COLOR));
		pOldBitmap = bitmapDC.SelectObject(&bitmap);

		COLORREF rgbThumb = m_bThumbHover ? m_ThumbHoverColor : m_ThumbColor;
		COLORREF rgbPrev = 0;

		// add desired color to thumb
		for (int x = 0; x < m_nBitmapWidth; x++)
		{
			for (int y = 0; y < m_nBitmapHeight; y++)
			{
				COLORREF rgb = bitmapDC.GetPixel(x, y);
				switch (rgb)
				{
				case THUMB_MASK_COLOR:
					if (m_bThumbColor)
					{
						bitmapDC.SetPixel(x, y, rgbThumb);
					}
					break;

				case THUMB_GRIPPER_MASK_COLOR:
					bitmapDC.SetPixel(x, y, m_bThumbGripper ? 
						THUMB_GRIPPER_COLOR : rgbPrev);
					break;

				case THUMB_UP_TRANSPARENT_MASK_COLOR:
					bitmapDC.SetPixel(x, y, 
						memDC.GetPixel(x, nChannelStart));
					break;

				case THUMB_DOWN_TRANSPARENT_MASK_COLOR:
					bitmapDC.SetPixel(x, y, 
						memDC.GetPixel(x, nChannelStart+nChannelHeight-1));
					break;

				default:
					break;
				}
				rgbPrev = rgb;
			}
		}

		memDC.StretchBlt(m_rectThumb.left, m_rectThumb.top, 
			m_rectThumb.Width(), m_rectThumb.Height(), 
			&bitmapDC, 0, 0, m_nBitmapWidth, m_nBitmapHeight, SRCCOPY);

		if (pOldBitmap)
		{
			bitmapDC.SelectObject(pOldBitmap);
		}

		if (bitmap.GetSafeHandle())
		{
			bitmap.DeleteObject();
		}
		pOldBitmap = NULL;
	}
	else
	{
		m_rectThumb = CRect(-1,-1,-1,-1);
	}

	memDC.FrameRect(&m_rectClient, &brushFrame);
}