예제 #1
0
LRESULT FProgress::OnMouseButton(UINT message, WPARAM, LPARAM lParam, BOOL&)
{
	if (message == WM_LBUTTONDOWN)
	{
		POINT pt = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
		FRect rClient; 
		GetClientRect(&rClient);
		int AvailPx = (int)GetAvail(rClient.Width());
		if (pt.x < AvailPx)
		{
			if (m_hWnd != GetCapture())
			{
				SetCapture();
				m_dwFlags|=FPROGRESS_MOUSEDOWN; 

				SetCurrentFromMax((double)pt.x, (double)rClient.Width()); 
				
				InvalidateRect(NULL, TRUE); 
				SendMessage(GetParent(), WM_HSCROLL, MAKEWPARAM(GetMenu(), TB_THUMBPOSITION), (LPARAM)m_hWnd);
				m_LastMousePt = pt; 
			}
		}
	}
	else
		if (message == WM_LBUTTONUP)
		{
			m_LastMousePt.x = m_LastMousePt.y = 0; 
			ReleaseCapture(); 
			m_dwFlags&=~FPROGRESS_MOUSEDOWN; 
		}
		return 0; 
}
예제 #2
0
LRESULT FProgress::OnMouseMove(UINT, WPARAM, LPARAM lParam, BOOL&)
{
	POINT pt = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
	FRect rClient; 

	GetClientRect(&rClient);
	int AvailPx = (int)GetAvail(rClient.Width());

	if (pt.x <= AvailPx)
		m_CurCursorIndex = 1;	//Hand
	else
		m_CurCursorIndex = 0;	//Arrow

	if (m_dwFlags & FPROGRESS_MOUSEDOWN)
	{
		if (pt.x > rClient.Width())
			pt.x = rClient.Width(); 

		SetCurrentFromMax((double)pt.x, (double)rClient.Width());
		InvalidateRect(NULL, TRUE); 
		SendMessage(GetParent(), WM_HSCROLL, MAKEWPARAM(GetMenu(), TB_THUMBPOSITION), (LPARAM)m_hWnd);
	}

	return 0; 
}
예제 #3
0
void FProgress::DrawMeter(CDC& dc, FRect& rcPaint)
{

	//fill the unavailable 
	int nLines = rcPaint.Width() / (gLineDistance + gPenWidth) + 1; 

	int nAvailLines = (int)GetAvail((double)nLines) ;
	int nCurrLines  = (int)GetCurrent((double)nLines);
	
	assert(nAvailLines >= nCurrLines);

	int x = rcPaint.left; 
	int y = rcPaint.top; 

	dc.MoveTo(x, y); 

	int lh = rcPaint.Height() - 0; 
	int mh = lh; 

	int nPenIndex = 2; 
	dc.SelectPen(m_Pens[nPenIndex]); 
	dword dwStyle = GetWindowLong(GWL_STYLE); 

	for (int k = 0; k < nLines; k++)
	{
		if (k == nCurrLines)
		{
			if (k < nAvailLines)
				dc.SelectPen(m_Pens[1]);	
			else
				dc.SelectPen(m_Pens[0]);
			if (dwStyle & PROG_LARGER_CURRENT)
			{
				lh = lh / 2; 
				y += lh / 2; 
				dc.MoveTo(x, y);  
			}
		}
		else if (k == nAvailLines)
		{
			dc.SelectPen(m_Pens[0]); 
		}

		if (dwStyle & PROG_GROWING)
		{
			double dblNow = (double)k / (double)nLines; 
			lh = (int)(mh * dblNow); 
			y = mh - lh; 
			dc.MoveTo(x, y); 
		}

		dc.LineTo(x, y + lh);
		x += gLineDistance; 
		x += gPenWidth;
		dc.MoveTo(x, y); 
	}
}
예제 #4
0
파일: sndbuf2.cpp 프로젝트: pololei/m88
// ---------------------------------------------------------------------------
//	バッファから音を貰う
//
int SoundBuffer2::Get(Sample* dest, int samples)
{
	CriticalSection::Lock lock(cs);
	if (!buffer)
		return 0;

	for (int s=samples; s>0; )
	{
		int xsize = Min(s, buffersize - read);
		
		int avail = GetAvail();

		// 供給不足なら追加
		if (xsize <= avail || fillwhenempty)
		{
			if (xsize > avail)
				FillMain(xsize - avail);
			memcpy(dest, buffer + read * ch, xsize * ch * sizeof(Sample));
			dest += xsize * ch;
			read += xsize;
		}
		else
		{
			if (avail > 0)
			{
				memcpy(dest, buffer + read * ch, avail * ch * sizeof(Sample));
				dest += avail * ch;
				read += avail;
			}
			memset(dest, 0, (xsize - avail) * ch * sizeof(Sample));
			dest += (xsize - avail) * ch;
		}
		
		s -= xsize;
		if (read >= buffersize)
			read -= buffersize;
	}
	return samples;
}
예제 #5
0
파일: sndbuf2.cpp 프로젝트: pololei/m88
int SoundBuffer2::FillMain(int samples)
{
	// リングバッファの空きを計算
	int free = buffersize - GetAvail();

	if (!fillwhenempty && (samples > free-1))
	{
		int skip = Min(samples-free+1, buffersize-free);
		free += skip;
		read += skip;
		if (read > buffersize)
			read -= buffersize;
	}
	
	// 書きこむべきデータ量を計算
	samples = Min(samples, free-1);
	if (samples > 0)
	{
		// 書きこむ
		if (buffersize - write >= samples)
		{
			// 一度で書ける場合
			source->Get(buffer + write * ch, samples);
		}
		else
		{
			// 2度に分けて書く場合
			source->Get(buffer + write * ch, buffersize - write);
			source->Get(buffer, samples - (buffersize - write));
		}
		write += samples;
		if (write >= buffersize)
			write -= buffersize;
	}
	return samples;
}
예제 #6
0
파일: sndbuf2.cpp 프로젝트: pololei/m88
// ---------------------------------------------------------------------------
//	バッファが空か,空に近い状態か?
//
bool SoundBuffer2::IsEmpty()
{
	return GetAvail() == 0;
}