/***************************************************************
 * Name:      wxCairo.h
 * Purpose:   Defines Application Frame
 * Author:    Igor I (info@tiptopcity.com)
 * Created:   2010-11-14
 * Copyright: Igor I (tiptopcity.com)
 * License:   http://wikipedia.org/wiki/LGPL
 **************************************************************/

#ifndef _WX_CAIRO_H_
#define _WX_CAIRO_H_

//#include <wx/wx.h>
#include <cairo/cairo.h>
#include <string>

class wxCairo
{
private:
	int m_width,m_height; //Размер буфера
	cairo_t* m_cr;
	cairo_surface_t* m_surface;
	cairo_format_t m_format;

	void setBit(unsigned char *mas, const unsigned char pos, bool val);
public:
	unsigned int glId; //Идентификатор GL материала
	unsigned char* m_buffer; //Рисунок RGBA

	wxCairo();
	~wxCairo();
	cairo_t* getCairo() { return m_cr; };
	unsigned char* CreateBuffer(int w,int h); //Создаст буфер если изменились его размеры
	bool Init();
	bool Test();
	//void Draw(wxPaintDC& dc); //Вывести на экран
	void Fill();
	void Stroke(); //Обводка

	void MoveTo(double x, double y);
	void LineTo(double x, double y);
	void SetLineWidth(double width);
	void SetSourceRGBA(double red, double green, double blue, double alpha);
	void SetSourceRGB(double red, double green, double blue);
	void Rectangle (double x, double y, double width, double height);
	void Clip();
	void ResetClip();

	void ShowText(std::wstring& utf8);
	void ShowTextCenter(std::wstring& utf8,int xStart,int xEnd,int y);
	void ShowTextBR(std::wstring& str, int xStart, int xEnd, int y);
	void ShowTextCenterBR(std::wstring& str, int xStart, int xEnd, int y);
	void setFontface(const char *family, cairo_font_slant_t slant, cairo_font_weight_t  weight);
	void setFontface(std::string family, bool slant, bool weight);
	void setFontSize(double size);
	double getTextWidth(std::wstring& str);
	double getTextHeight(std::wstring& str);

	void toBitArray(unsigned char* bitArray);
	void seveToPNG(std::string filePath);
};

#endif
