Files
Work/vst/GainEdit.cpp
2024-08-07 09:16:27 -04:00

141 lines
4.1 KiB
C++

#include <common/StringBuffer.hpp>
#include <common/window.hpp>
#include <common/purehdc.hpp>
#include <vst/GainEdit.hpp>
char GainEditor::szClassName[]={"GainControl"};
int GainEditor::smUseCount=0;
GainEditor::GainEditor(AudioEffect *effect)
: AEffEditor(effect), mWheelController(::GetModuleHandle("GainEdit"))
{
mResBitmap=::new ResBitmap("MAIN",::GetModuleHandle("GainEdit"));
mResBitmap.disposition(PointerDisposition::Delete);
mRect.left=0;
mRect.top=0;
mRect.right=mResBitmap->width()-1;
mRect.bottom=mResBitmap->height()-1;
mPaintHandler.setCallback(this,&GainEditor::paintHandler);
mCreateHandler.setCallback(this,&GainEditor::createHandler);
mGainWindow.insertHandler(VectorHandler::PaintHandler,&mPaintHandler);
mGainWindow.insertHandler(VectorHandler::CreateHandler,&mCreateHandler);
effect->setEditor(this);
}
GainEditor::~GainEditor()
{
mGainWindow.removeHandler(VectorHandler::PaintHandler,&mPaintHandler);
mGainWindow.removeHandler(VectorHandler::CreateHandler,&mCreateHandler);
mGainWindow.destroy();
}
long GainEditor::getRect(ERect **eRect)
{
*eRect=&mRect;
return true;
}
long GainEditor::open(void *ptr)
{
smUseCount++;
mpSystemWindow=(HWND)ptr;
registerClass();
createWindow();
return true;
}
void GainEditor::close()
{
mGainWindow.destroy();
smUseCount--;
if(0==smUseCount)::UnregisterClass(szClassName,mGainWindow.processInstance());
}
void GainEditor::idle()
{
AEffEditor::idle();
}
void GainEditor::update(void)
{
//SendMessage (delayFader, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) effect->getParameter (kDelay)
//SendMessage (feedbackFader, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) effect->getParameter(kFeedBack));
//SendMessage (volumeFader, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) effect->getParameter (kOut));
}
void GainEditor::setValue(void* fader, int value)
{
message("setValue");
//if (fader == delayFader)
//effect->setParameterAutomated (kDelay, (float)value / 100.f);
//else if (fader == feedbackFader)
//effect->setParameterAutomated (kFeedBack, (float)value / 100.f);
//else if (fader == volumeFader)
//effect->setParameterAutomated (kOut, (float)value / 100.f);
}
void GainEditor::registerClass()
{
WNDCLASS wndClass;
if(::GetClassInfo(mGainWindow.processInstance(),szClassName,(WNDCLASS FAR*)&wndClass))return;
wndClass.style =CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS|CS_OWNDC;
wndClass.lpfnWndProc =(WNDPROC)GUIWindow::WndProc;
wndClass.cbClsExtra =0;
wndClass.cbWndExtra =sizeof(GainEditor*);
wndClass.hInstance =mGainWindow.processInstance();
wndClass.hIcon =0;
wndClass.hCursor =0;
wndClass.hbrBackground =(HBRUSH)::GetSysColorBrush(COLOR_BTNFACE);
wndClass.lpszMenuName =0;
wndClass.lpszClassName =szClassName;
::RegisterClass(&wndClass);
}
void GainEditor::createWindow()
{
mGainWindow.createWindow(0,szClassName,"Window",WS_CHILD|WS_VISIBLE,Rect(0,0,mResBitmap->width(),mResBitmap->height()),mpSystemWindow,0,mGainWindow.processInstance(),&mGainWindow);
mGainWindow.show(SW_SHOW);
mGainWindow.update();
}
CallbackData::ReturnType GainEditor::createHandler(CallbackData &someCallbackData)
{
PureDevice pureDevice(mGainWindow);
mDIBitmap=::new DIB24();
mDIBitmap.disposition(PointerDisposition::Delete);
mDIBitmap->create(mResBitmap->width(),mResBitmap->height(),pureDevice);
mDIBitmap->copyBits(*mResBitmap);
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType GainEditor::paintHandler(CallbackData &someCallbackData)
{
PureDevice pureDevice(mGainWindow);
// mResBitmap->getPalette().usePalette(pureDevice,true);
mDIBitmap->bitBlt(pureDevice,Rect(0,0,mGainWindow.width(),mGainWindow.height()),Point());
mWheelController.drawImage(pureDevice,Point(0,0),0);
// mResBitmap->getPalette().usePalette(pureDevice,false);
return (CallbackData::ReturnType)FALSE;
}
void GainEditor::message(String message)
{
::MessageBox(0,"GainEditor",message.str(),MB_OK);
}
// ******************************************************************************************************************
GainEdit::GainEdit(AudioMasterCallback audioMaster)
: Gain(audioMaster)
{
setUniqueID('GNed');
editor=new GainEditor(this);
// if(!editor)oome=true;
}
GainEdit::~GainEdit()
{
}