📄 mixerkeydef.cpp
字号:
// MixerKeyDef.cpp: implementation of the CMixerKeyDef class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include <sstream>
#include "MixerKeyDef.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMixerKeyDef::CMixerKeyDef(const char *szName,int iKeyPlus,int iKeyMinus,int iKeyMax,int iKeyMin)
: m_strName(szName),m_lstKeys(),m_uRefs(0),m_iId(0)
{
m_lstKeys.push_back(CKey(char(iKeyPlus),CCmdSeq(cmd::Plus,cmd::End)));
m_lstKeys.push_back(CKey(char(iKeyMinus),CCmdSeq(cmd::Minus,cmd::End)));
m_lstKeys.push_back(CKey(char(iKeyMax),CCmdSeq(cmd::Max,cmd::End)));
m_lstKeys.push_back(CKey(char(iKeyMin),CCmdSeq(cmd::Min,cmd::End)));
}
CMixerKeyDef::~CMixerKeyDef()
{
// for(int i=0;i<m_lstKeys.size();i++) {
// delete m_lstKeys[i];
// }
}
void CMixerKeyDef::Save(CMachineDataOutput * const pcOut)
{
pcOut->Write(m_strName.c_str());
int iNum=m_lstKeys.size();
pcOut->Write(iNum);
for(int i=0;i<iNum;i++) {
int iId=m_lstKeys[i].GetClassId();
pcOut->Write(iId);
m_lstKeys[i].Save(pcOut);
}
}
void CMixerKeyDef::Init(CMachineDataInput * const pcIn,unsigned uDataVersion)
{
char c='0';
stringstream stmName;
while(c != 0x0) {
pcIn->Read(c);
stmName << c;
}
m_strName=stmName.str();
int iNum;
pcIn->Read(iNum);
for(int i=0;i<iNum;i++) {
int iClassId;
pcIn->Read(iClassId);
switch(iClassId) {
case 1:
{
CKey cKey;
cKey.Init(pcIn,uDataVersion);
m_lstKeys.push_back(cKey);
InvalidateIterators();
}
break;
}
}
}
bool CMixerKeyDef::IsNameEqual(const string &s) const
{
const char *sz=s.c_str();
const char *sz1=m_strName.c_str();
int i=strcmp(sz,sz1);
return (i==0);
// return (m_strName.compare(s)>=0);
// return s==m_strName; should be this - doesnt work
}
const char *CMixerKeyDef::GetDisplayKey(cmd::TCmd c) const
{
for(int i=0;i<m_lstKeys.size();i++) {
if(m_lstKeys[i].GetFirstCmd() == c){
return m_lstKeys[i].GetDispKey();
}
}
return "";
}
string CMixerKeyDef::GetDisplayKeyAndErase(cmd::TCmd c)
{
for(TLstKeys::iterator ite=m_lstKeys.begin();ite < m_lstKeys.end(); ite++) {
if(ite->GetFirstCmd() == c){
string str=ite->GetDispKey();
m_lstKeys.erase(ite);
InvalidateIterators();
return str;
}
}
return "";
}
CKey *CMixerKeyDef::GetKeyClassByKey(TKey k)
{
for(int i=0;i<m_lstKeys.size();i++) {
if(m_lstKeys[i].GetVirtKey() == k)
return &m_lstKeys[i];
}
return NULL;
}
void CMixerKeyDef::DeleteKey(CKey *pKey)
{
for(TLstKeys::iterator ite=m_lstKeys.begin();ite < m_lstKeys.end(); ite++)
{
if(&(*ite) == pKey) {
m_lstKeys.erase(ite);
InvalidateIterators();
return;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -