#include <common/brush.hpp>
#include <common/purebmp.hpp>
#include <common/resbmp.hpp>

Brush::Brush(PureBitmap &pureBitmap)
: mhBrush(0)
{
  if(!pureBitmap.isOkay())return;
  mhBrush=::CreatePatternBrush(pureBitmap);
}

Brush::Brush(ResBitmap &resBitmap)
: mhBrush(0)
{
  if(!resBitmap.isOkay())return;
	mhBrush=::CreateDIBPatternBrushPt((BITMAPINFO*)(char*)(ResData<char>&)resBitmap,DIB_RGB_COLORS);
}

bool Brush::createPatternBrush(PureBitmap &pureBitmap)
{
  destroy();
	if(!pureBitmap.isOkay())return FALSE;
	mhBrush=::CreatePatternBrush(pureBitmap.getBitmap());
	return isOkay();
}

bool Brush::createHatchBrush(HatchStyle hatchStyle,const RGBColor &color)
{
  destroy();
	mBrushColor=color;
	mhBrush=::CreateHatchBrush(int(hatchStyle),color.getCOLORREF());
	return isOkay();
}



