#ifndef _COMMON_BRUSH_HPP_
#define _COMMON_BRUSH_HPP_
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
#ifndef _COMMON_GDIOBJ_HPP_
#include <common/gdiobj.hpp>
#endif
#ifndef _COMMON_RGBCOLOR_HPP_
#include <common/rgbcolor.hpp>
#endif

class PureBitmap;
class ResBitmap;

class Brush
{
public:
  enum HatchStyle{HDiag=HS_BDIAGONAL,HCross=HS_CROSS,HDiagCross=HS_DIAGCROSS,HFDiag=HS_FDIAGONAL,HHoriz=HS_HORIZONTAL,HVert=HS_VERTICAL};
  Brush(void);
	Brush(RGBColor rgbColor);
	Brush(int red,int green,int blue);
	Brush(PureBitmap &pureBitmap);
	Brush(ResBitmap &resBitmap); 
	virtual ~Brush();
  operator GDIObj(void);
  bool createBrush(const RGBColor &rgbColor);
	bool createNullBrush(void);
	bool createPatternBrush(PureBitmap &pureBitmap);
	bool createHatchBrush(HatchStyle hatchStyle,const RGBColor &rgbColor);
	bool isOkay(void)const;
	HBRUSH getBrush(void)const;
	const RGBColor &getColor(void)const;
private:
	Brush(const Brush &someBrush);
	Brush &operator=(const Brush &someBrush);
	void destroy(void);
  HBRUSH mhBrush;
	RGBColor mBrushColor;
};

inline
Brush::Brush(void)
: mhBrush(0)
{
}

inline
Brush::Brush(const Brush &/*someBrush*/)
: mhBrush(0)
{  // private implementation
}

inline
Brush::Brush(int red,int green,int blue)
: mhBrush(0)
{
  mhBrush=::CreateSolidBrush((COLORREF)RGBColor(red,green,blue));
}

inline
Brush::Brush(RGBColor rgbColor)
: mhBrush(0)
{
  mBrushColor=rgbColor;
  mhBrush=::CreateSolidBrush((COLORREF)rgbColor);  
}

inline
Brush::~Brush()
{
  destroy();
}

inline
Brush &Brush::operator=(const Brush &/*someBrush*/)
{  // private implementation
  return *this;
}

inline
Brush::operator GDIObj(void)
{
  return (GDIObj)mhBrush;
}

inline
void Brush::destroy(void)
{
  if(mhBrush){::DeleteObject(mhBrush);mhBrush=0;}
}

inline
bool Brush::createBrush(const RGBColor &rgbColor)
{
  destroy();
	mBrushColor=rgbColor;
  mhBrush=::CreateSolidBrush((COLORREF)rgbColor);  
	return isOkay();
}

inline
bool Brush::createNullBrush(void)
{
  destroy();
	mhBrush=(HBRUSH)::GetStockObject(NULL_BRUSH);
	return isOkay();
}

inline
const RGBColor &Brush::getColor(void)const
{
  return mBrushColor;
}

inline
HBRUSH Brush::getBrush(void)const
{
  return mhBrush;
}

inline
bool Brush::isOkay(void)const
{
  return (mhBrush?TRUE:FALSE);
}
#endif

