#include "customgui_bitmapbutton.h"
#include "c4d_string.h"
#include "c4d_gui.h"


BitmapButtonLib *lib_bitmapbutton = NULL;


static BitmapButtonLib *CheckPrefsLib(LONG offset)
{
	return (BitmapButtonLib*)CheckLib(CUSTOMGUI_BITMAPBUTTON,offset,(C4DLibrary**)&lib_bitmapbutton);
}

Bool BitmapButtonCustomGui::SetImage(BaseBitmap *bmp,Bool copybmp,Bool secondstate)
{
	BitmapButtonLib *lib = CheckPrefsLib(LIBOFFSET(BitmapButtonLib,SetImageA));
	if (!lib || !lib->SetImageA) return FALSE;

	return (((iBitmapButtonCustomGui*)this)->*(lib->SetImageA))(bmp,copybmp,secondstate);
}

Bool BitmapButtonCustomGui::SetImage(const Filename &name,Bool secondstate)
{
	BitmapButtonLib *lib = CheckPrefsLib(LIBOFFSET(BitmapButtonLib,SetImageA));
	if (!lib || !lib->SetImageB) return FALSE;

	return (((iBitmapButtonCustomGui*)this)->*(lib->SetImageB))(name,secondstate);
}

void BitmapButtonCustomGui::SetToggleState(Bool set)
{
	BitmapButtonLib *lib = CheckPrefsLib(LIBOFFSET(BitmapButtonLib,SetToggleState));
	if (!lib || !lib->SetToggleState) return;

	(((iBitmapButtonCustomGui*)this)->*(lib->SetToggleState))(set);
}

void BitmapButtonCustomGui::SetDragArray(AtomArray *array)
{
	BitmapButtonLib *lib = CheckPrefsLib(LIBOFFSET(BitmapButtonLib,SetDragArray));
	if (!lib || !lib->SetDragArray) return;

	(((iBitmapButtonCustomGui*)this)->*(lib->SetDragArray))(array);
}

