Files
Work/guitar/FretViewWnd.cpp
2024-08-07 09:16:27 -04:00

165 lines
4.8 KiB
C++

#include <guitar/FretViewWnd.hpp>
#include <guitar/GUIFretboard.hpp>
#include <guitar/guitar.hpp>
#include <guitar/TabEntry.hpp>
#include <guitar/GlobalDefs.hpp>
#include <midiseq/midiout.hpp>
#include <statbar/statbarx.hpp>
#include <common/file.hpp>
FretViewWindow::FretViewWindow(void)
{
mCreateHandler.setCallback(this,&FretViewWindow::createHandler);
mSizeHandler.setCallback(this,&FretViewWindow::sizeHandler);
mPaintHandler.setCallback(this,&FretViewWindow::paintHandler);
mHorizontalScrollHandler.setCallback(this,&FretViewWindow::horizontalScrollHandler);
mVerticalScrollHandler.setCallback(this,&FretViewWindow::verticalScrollHandler);
mLeftButtonDownHandler.setCallback(this,&FretViewWindow::leftButtonDownHandler);
mCloseHandler.setCallback(this,&FretViewWindow::closeHandler);
MDIWindow::insertHandler(VectorHandler::CreateHandler,&mCreateHandler);
MDIWindow::insertHandler(VectorHandler::SizeHandler,&mSizeHandler);
MDIWindow::insertHandler(VectorHandler::PaintHandler,&mPaintHandler);
MDIWindow::insertHandler(VectorHandler::VerticalScrollHandler,&mVerticalScrollHandler);
MDIWindow::insertHandler(VectorHandler::HorizontalScrollHandler,&mHorizontalScrollHandler);
MDIWindow::insertHandler(VectorHandler::LeftButtonDownHandler,&mLeftButtonDownHandler);
MDIWindow::insertHandler(VectorHandler::CloseHandler,&mCloseHandler);
}
FretViewWindow::~FretViewWindow()
{
MDIWindow::removeHandler(VectorHandler::CreateHandler,&mCreateHandler);
MDIWindow::removeHandler(VectorHandler::SizeHandler,&mSizeHandler);
MDIWindow::removeHandler(VectorHandler::PaintHandler,&mPaintHandler);
MDIWindow::removeHandler(VectorHandler::VerticalScrollHandler,&mVerticalScrollHandler);
MDIWindow::removeHandler(VectorHandler::HorizontalScrollHandler,&mHorizontalScrollHandler);
MDIWindow::removeHandler(VectorHandler::LeftButtonDownHandler,&mLeftButtonDownHandler);
MDIWindow::removeHandler(VectorHandler::CloseHandler,&mCloseHandler);
}
CallbackData::ReturnType FretViewWindow::closeHandler(CallbackData &someCallbackData)
{
return true;
}
CallbackData::ReturnType FretViewWindow::createHandler(CallbackData &someCallbackData)
{
setTitle("Fretboard");
mGUIFretboard=::new GUIFretboard(*this);
mGUIFretboard.disposition(PointerDisposition::Delete);
return FALSE;
}
CallbackData::ReturnType FretViewWindow::sizeHandler(CallbackData &someCallbackData)
{
return false;
}
CallbackData::ReturnType FretViewWindow::paintHandler(CallbackData &someCallbackData)
{
PaintInformation *pPaintInfo=(PaintInformation*)someCallbackData.lParam();
PureDevice &pureDevice=(PureDevice&)*pPaintInfo;
mGUIFretboard->draw(pureDevice);
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType FretViewWindow::verticalScrollHandler(CallbackData &someCallbackData)
{
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType FretViewWindow::horizontalScrollHandler(CallbackData &someCallbackData)
{
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType FretViewWindow::leftButtonDownHandler(CallbackData &someCallbackData)
{
return (CallbackData::ReturnType)FALSE;
}
void FretViewWindow::setTitle(const String &strTitle)
{
String strCaption;
String strString;
windowText(strCaption);
strString=strCaption;
strCaption=strCaption.betweenString(0,' ');
if(strCaption.isNull())strCaption=strString;
strCaption+=String(" - [")+strTitle+String("]");
setCaption(strCaption);
}
String FretViewWindow::getTitle(void)const
{
String strCaption;
windowText(strCaption);
return strCaption.betweenString('[',']');
}
void FretViewWindow::setNote(const TabEntry &entry,bool clear,bool play)
{
mGUIFretboard->setNote(entry,clear,play);
}
void FretViewWindow::setNote(const Music::Chord &chord,bool play)
{
mGUIFretboard->setNote(chord,play);
}
void FretViewWindow::setNote(const Note &note,bool clear,bool play)
{
mGUIFretboard->setNote(note,clear,play);
}
void FretViewWindow::setNote(const Scale &scale,bool play)
{
mGUIFretboard->setNote(scale,play);
}
void FretViewWindow::setNote(const FrettedNotes &frettedNotes,bool play)
{
mGUIFretboard->setNote(frettedNotes,play);
}
void FretViewWindow::clearNotes(void)
{
mGUIFretboard->clearNotes();
}
void FretViewWindow::showAllPositions(void)
{
mGUIFretboard->showAllPositions();
}
void FretViewWindow::cut(void)
{
mGUIFretboard->cut();
}
void FretViewWindow::copy(void)
{
mGUIFretboard->copy();
}
void FretViewWindow::paste(void)
{
mGUIFretboard->paste();
}
// *** virtuals
void FretViewWindow::preRegister(WNDCLASS &wndClass)
{
wndClass.style|=CS_SAVEBITS|CS_OWNDC;
wndClass.hbrBackground=(HBRUSH)::GetStockObject(WHITE_BRUSH);
}
void FretViewWindow::preCreate(MDICREATESTRUCT &createStruct)
{
createStruct.style=WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_VISIBLE|WS_CHILD|WS_CAPTION|WS_SIZEBOX|WS_MINIMIZEBOX|WS_THICKFRAME|WS_MINIMIZEBOX|WS_OVERLAPPED|WS_BORDER|WS_SYSMENU;
}