AeBankAsset.c++ 2.74 KB
#include <assert.h>
#include <Vk/VkApp.h>

#include "AeBankFile.h"
#include "AeAsset.h"
#include "bankfileIcon.xbm"
#include "bankIcon.xbm"


Pixmap AeBankFileAsset::fIcon = NULL;
Pixmap AeBankAsset::fIcon = NULL;


AeBankFileAsset::AeBankFileAsset (AeBankFile * file)
    : AeContainerAsset (file->GetFileName (), kBankFileType)
{
    fFile = file;
    fRevision = 0;

    if (!fIcon)
    {
	fIcon = XCreateBitmapFromData (theApplication->display (),
				       DefaultRootWindow (theApplication->display ()),
				       (char *)bankfileIcon_bits,
				       bankfileIcon_width,
				       bankfileIcon_height);
    }
}


AeBankFileAsset::AeBankFileAsset (const char * name)
    : AeContainerAsset (name, kBankFileType)
{
    fFile = NULL;
    fRevision = 0;
}


AeBankFileAsset::~AeBankFileAsset (void)
{
    if (fFile)
	delete fFile;
}


void
AeBankFileAsset::GetClassName (char * name)
{
    strcpy (name, "bankfile");
}


char *
AeBankFileAsset::GetDirProc (AeAsset * asset)
{
    assert (asset != NULL);
    AeBankFile * file = ((AeBankFileAsset *)asset)->GetFile ();

    if (file)

	return (char *)file->GetDirName ();

    return "--";
}


int
AeBankFileAsset::GetRevisionProc (AeAsset * asset)
{
    assert (asset != NULL);
    return ((AeBankFileAsset *)asset)->GetRevision ();
}


/////////////////////////////////////////////////////////


AeBankAsset::AeBankAsset (const char * name, int sampleRate, AeInstAsset *percussion)
    : AeContainerAsset (name, kBankType)
{
    fSampleRate = sampleRate;
    fPercussion = percussion;

    if (!fIcon)
    {
	fIcon = XCreateBitmapFromData (theApplication->display (),
				       DefaultRootWindow (theApplication->display ()),
				       (char *)bankIcon_bits,
				       bankIcon_width,
				       bankIcon_height);
    }
}


AeBankAsset::~AeBankAsset (void)
{
    if (fPercussion)
	fPercussion->RemoveParent (this);
}


void
AeBankAsset::GetClassName (char * name)
{
    strcpy (name, "bank");
}


void
AeBankAsset::SetPercussion (AeInstAsset * percussion)
{
    if (fPercussion)
	fPercussion->RemoveParent (this);

    fPercussion = percussion;

    if (fPercussion)
	fPercussion->AppendParent (this);
}


int
AeBankAsset::GetSampleRateProc (AeAsset * asset)
{
    assert (asset != NULL);
    return ((AeBankAsset *)asset)->GetSampleRate ();
}


AeAsset *
AeBankAsset::GetPercussionProc (AeAsset * asset)
{
    assert (asset != NULL);
    return (AeAsset *)((AeBankAsset *)asset)->GetPercussion ();
}


void
AeBankAsset::SetSampleRateProc (AeAsset * asset, int sampleRate)
{
    assert (asset != NULL);
    ((AeBankAsset *)asset)->SetSampleRate (sampleRate);
}


void
AeBankAsset::SetPercussionProc (AeAsset * asset, AeAsset * percussion)
{
    assert (asset != NULL);
    ((AeBankAsset *)asset)->SetPercussion ((AeInstAsset *)percussion);
}