⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 colorslidwin.cpp

📁 miXo is a buzz machine (www.buzzmachines.com) - a plugin for the freely available jeskola buzz track
💻 CPP
字号:
// ColorSlidWin.cpp: implementation of the CColorSlidWin class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "mixer.h"
#include <assert.h>
#include <math.h>
#include "ColorSlidWin.h"
#include "ColGen.h"
#include "Col.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CColorSlidWin::CColorSlidWin(const char *sz,CColGen *pCol) 
: CSlidWin(sz,pCol),m_fVal(-1.0),m_bUpdate(true),m_iColDiv(16),
m_cSlidMon(sz,pCol),
m_bMonitor(true),
m_bGray(false),m_pcColGen(pCol)
{
}
CColorSlidWin::~CColorSlidWin()
{
	m_cSlidMon.DeInit();
}
void CColorSlidWin::DeInit()
{
	m_cSlidMon.DeInit();
	CAbWin::DeInit();
}
bool CColorSlidWin::SetValue(float f)
{
	if(fabs(m_fVal-f) > 0.001) 
	{
		m_fVal=f;
		m_bUpdate=true;
		return true;
	}
	return false;
}
bool CColorSlidWin::DoUpdate()
{
	bool bRet=false;
	if(m_bUpdate) {
		InvalidateRect(GetWndHandle(),NULL,FALSE);	//TRUE
		m_bUpdate=false;
		bRet=true;
	}
	if(m_bMonitor) {
		if(m_cSlidMon.DoUpdate())
			bRet=true;
	}
	return bRet;
}
bool CColorSlidWin::OnWMPaint(HDC) 
{	
	assert(m_pcColGen);
	RECT r;
	if((GetUpdateRect(GetWndHandle(),&r,FALSE) == FALSE) && !m_bUpdate)	//TRUE
		return false;
//	if((m_fVal < 0.001) && (m_fSmVal < 0.001))
//		return false;
	::GetClientRect(GetWndHandle(),&r);
	PAINTSTRUCT pntstrc;
	BeginPaint(GetWndHandle(),&pntstrc);
	{
		CCol cCol(pntstrc.hdc);
		int iOrigHt=r.bottom;
		int iNewHt=int((float(iOrigHt)*m_fVal));
		if(iNewHt > iOrigHt)
			iNewHt=iOrigHt;
		//int iDiff=iOrigHt-iNewHt;
		float fColDivHt=float(iOrigHt)/float(m_iColDiv);
		//	float fColOff=(255.0f/float(m_iColDiv))*3.0;
		COLORREF uCol;
		m_pcColGen->Init(m_iColDiv,iOrigHt);
		float fGrayOff=130.0f/float(m_iColDiv);
		int iGray;
		int iBot=r.bottom;
		int iTop=iBot-fColDivHt;
		int iLeft=0;
		int iRight=r.right;
		for(int i=0;i<m_iColDiv;i++) {
			if(m_bGray) {
				iGray=(int(fGrayOff*(m_iColDiv-i)))-105;
				iGray=100-iGray;
				if(iGray < 0)
					iGray=0;
				uCol=RGB(iGray,iGray,iGray);
			}
			else
			{
				uCol=m_pcColGen->Next(i);
			}
			cCol.ChangePen(PS_SOLID,0,uCol);
			cCol.ChangeBrush(uCol);
			if(iNewHt >= fColDivHt) {
				Rectangle(pntstrc.hdc,iLeft,iTop,iRight,iBot);
			}else{
				if(iNewHt < 0) {
//					cCol.ChangePen(PS_SOLID,0,uCol,false);
//					cCol.ChangeBrush(uCol,false);
					break;
				}
				uCol=m_pcColGen->GetBg();
				Rectangle(pntstrc.hdc,iLeft,iBot-iNewHt,iRight,iBot);
				cCol.ChangePen(PS_SOLID,0,uCol);
				cCol.ChangeBrush(uCol);
				Rectangle(pntstrc.hdc,0,0,iRight,iBot-iNewHt);
				
			}
			iBot-=fColDivHt;
			iTop-=fColDivHt;
			iNewHt-=fColDivHt;
		}
	}
/*
	if(m_bMonitor) {
		int iPenWd=r.right/4;
		uCol=m_pcColGen->GetMon();
		ChangeBrush(pntstrc.hdc,uCol);
		ChangePen(pntstrc.hdc,PS_SOLID,0,uCol);
		iNewHt=float(r.bottom)*m_fSmVal;
		Rectangle(pntstrc.hdc,r.right-iPenWd,r.bottom-iNewHt,r.right,r.bottom);
	}
	ChangePen(pntstrc.hdc,PS_SOLID,0l,false);
	ChangeBrush(pntstrc.hdc,0l,false);
*/
	EndPaint(GetWndHandle(),&pntstrc);
	return true;
}
void CColorSlidWin::PostCreate()
{
	CAbWin::PostCreate();
	RECT r;
	::GetClientRect(GetWndHandle(),&r);
	int iWd=r.right-r.left;
//	m_cSlidMon.SetBgBrush(0);
	m_cSlidMon.Init(GetWndHandle());
	m_cSlidMon.SetWindowClientRect(CWinRect((iWd-iWd/4),0,iWd,r.bottom));
	m_cSlidMon.Create();
	m_cSlidMon.SetBgBrush(::CreateSolidBrush(RGB(0,0,0)));
}

/*
LRESULT CColorSlidWin::WindowProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	switch(uMsg) {
	case WM_LBUTTONUP:
		{
//			int xPos = LOWORD(lParam);  
//			OutputDebugString("called");
			int yPos = HIWORD(lParam);
			m_fVal=float(GetWindowRect().Y1()-yPos)/float(GetWindowRect().Y1());
			SendMessage(GetParHandle(),WM_USER,0x2,0l);
		}
		return FALSE;
	}
	return CAbWin::WindowProc(hWnd,uMsg,wParam,lParam);
}
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -