#ifndef OUT_H_
#define OUT_H_

#include "dib.h"

class COut
{
public:
	bool isScrolling;
	int rowNum;
//	int colNum;
	int scrollRows;
	int scrollCols;
	int clipFlag; //0 clip,1 no clip,2 no clip but return
public:
	int x; //当前的输出位置的x坐标
	int y; //当前的输出位置的y坐标
	int xstart; //输出起始点的x坐标
	int ystart; //输出起始点的y坐标
	int space; //空格的宽度
	int rowHeight; //行高，可用来设置行之间的间距
	int charWidth; //单个字符占据的宽度
	int precious; //小数的精度
	CRect displayArea;
	CDC *pDC;
	CFont *font,*oldFont;
	int textBkMode,oldTextBkMode;
	COLORREF textColor,oldTextColor;
	COLORREF textBkColor,oldTextBkColor;
	void setTextBkColor(COLORREF bkColor);
	void setTextBkMode(int mode);
	void setTextColor(COLORREF textColor);
	//////////////////////////////////////////////////
	void setDC(CDC *pDC); //初始化调用（必需！）
	void setDisplayArea(CRect rect); //设置显示的方形区域（单行长度超出后自动折回）
	void setStart(int x,int y);
	//设置显示的初始位置,相对于displayArea
	void endl(); //回车换行
	void setFont(int size,CString type);
	void clearScrollPos();
	void clearBackground(COLORREF color);
	void setSpaceWidth(int width); //空格宽度（以字符宽度为单位）
	void clip(int flag); ////0 clip,1 no clip,2 no clip but return
	//////////////////////////////////////////////////
	void scrollRight(int colomn = 1);
	void scrollLeft(int colomn = 1);
	void scrollDown(int rows = 1);
	void scrollUp(int rows = 1);
	void scrollRow(int rows = 1, int direction = -1); //滚动屏幕:-1上滚1下滚
	void scrollPixel(int pixels = 1,int direction = -1); 
	///////////////////////////////////////////////////
	void drawLineInRect(CString str);
	void removeSubStr(CString &sourceStr,CString subStr);
	void replaceSubStr(CString &sourceStr,CString subStrOut,CString subStrIn);
	void getCutPisition(CString &subStr,int &n,CString &sourceStr);
	CString getInnerStrIter(CString beginStr,CString endStr,int &ifSuccess);
	void removeInnerStr(CString &s,CString begin,CString end);//删除s中以begin和end为定界符的子字符串。
public:
	CDIBitmap bmp;
	CDIBitmap bkBmp;
public:
	void drawLineInRectIncludeBmp(CString &s);
	CString beginStr,endStr;//图片文件名的分割标记
	CString beginStr1,endStr1;
	CString beginStr2,endStr2;

	void LoadBmp(CString s);
	void SetBmpColor(COLORREF bkColor,COLORREF forColor);
	COLORREF bmpBkColor;//设定图片的背景色
	COLORREF bmpForColor;//设定图片的前景色
	void SupportBmp(bool b = true,int flag = 1);// 支持图片输出
	bool isDrawBmp;
	void DrawBmp();
	long bufferPos;
	CString buffer;
public:
	///////////////////////////////////////////////////
	COut& operator << (int num);
	COut& operator << (unsigned int num);
	COut& operator << (long num);
	COut& operator << (float num);
	COut& operator << (double num);
	COut& operator << (char str);
	COut& operator << (char *pStr);
	COut& operator << (CString str);
	inline COut& operator << (COut& (*f)(COut&)) //支持cout<<endl;形式的回车换行
	{
		f(*this); //(*f)(*this);
		return *this;
	}
	COut();
	~COut();
};

inline COut& endl(COut& out)
{
	out.endl();
	return out;
}

#endif

