#ifndef _COMMON_BITMAPDATA_HPP_
#define _COMMON_BITMAPDATA_HPP_
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
#ifndef _COMMON_TYPES_HPP_
#include <common/types.hpp>
#endif

class BitmapData
{
public:
	typedef enum Disposition{Keep,Delete};
	BitmapData(void);
	~BitmapData();
	Disposition getInfoType(void)const;
  Disposition getDataType(void)const;
	UHUGE *reserveData(LONG sizeData);
	BITMAPINFO *reserveInfo(LONG sizeInfo=0,WORD numColors=0);
  WORD setData(HGLOBAL hGlobalData,UHUGE *lpBitmapData);
	WORD setData(UHUGE *lpBitmapData);
	WORD setInfo(BITMAPINFO FAR *lpBitmapInfo);
	HGLOBAL getInfoHnd(void)const;
  HGLOBAL getDataHnd(void)const;
	BITMAPINFO *getInfoPtr(void)const;
	UHUGE *getDataPtr(void)const;
	WORD isOkay(void)const;
private:
	void cleanupData(void);
  void cleanupInfo(void);
	HGLOBAL mhGlobalBitmapData;
	HGLOBAL mhGlobalBitmapInfo;
	UHUGE *mlpBitmapData;
	BITMAPINFO *mlpBitmapInfo;
	Disposition mInfoDisposition;
  Disposition mDataDisposition;
};

inline
BitmapData::BitmapData(void)
: mhGlobalBitmapData(0), mhGlobalBitmapInfo(0), mlpBitmapData(0), mlpBitmapInfo(0),
  mInfoDisposition(Delete), mDataDisposition(Delete)
{
}

inline
BitmapData::~BitmapData()
{
	cleanupData();
  cleanupInfo();
}

inline
BITMAPINFO *BitmapData::getInfoPtr(void)const
{
  return mlpBitmapInfo;
}

inline
UHUGE *BitmapData::getDataPtr(void)const
{
	return mlpBitmapData;
}

inline
HGLOBAL BitmapData::getInfoHnd(void)const
{
  return mhGlobalBitmapInfo;
}

inline
HGLOBAL BitmapData::getDataHnd(void)const
{
  return mhGlobalBitmapData;
}

inline
WORD BitmapData::isOkay(void)const
{
  return (mlpBitmapData&&mlpBitmapInfo); 
}

inline
BitmapData::Disposition BitmapData::getInfoType(void)const
{
  return mInfoDisposition;
}

inline
BitmapData::Disposition BitmapData::getDataType(void)const
{
  return mDataDisposition;
}
#endif
