// Canvas.h: interface for the CCanvas class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CANVAS_H__31413FAA_DC0C_4694_AF72_F7B77FEA8316__INCLUDED_)
#define AFX_CANVAS_H__31413FAA_DC0C_4694_AF72_F7B77FEA8316__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "common.h"
#include <OLECTL.H>
/**********
������ô��Ϊ�����еĻ�ͼ����һ������ľ�����Ļ��
��������ʾ������ͼ��ֻ�����������Ļ�ϵ�һ���֣�Ҳ
����һ��View,�������attached_dc��ô�Ͱ����DC����
��ǰ��View, �������attached_dc��ô��this->hdc����
��ǰ��view.
**********/
class CCanvas{
public:
HWND hparent;
HDC hdc;
HBITMAP hbitmap,old_hbitmap;
HPEN hpen,old_pen;
HBRUSH hbrush,old_brush;
HFONT hfont,old_font;
int offx,offy;
int left,top,width,height;
bool is_attached_hdc;
public:
int SetBrush(UINT style,COLORREF color,LONG hatch);
int UpdateParent();
int SetTransparentBkMode();
int AttachDC(HDC hdc);
COLORREF GetPixel(int x,int y);
int SetStockFont(int fnObject);
int SetFont(LOGFONT *logfont);
int SetTextColor(COLORREF color);
int SetTextBkColor(COLORREF color);
int SetPen(int fnPenStyle,int nWidth,COLORREF crColor);
int SetHatchBrush(int fnStyle,COLORREF clrref);
int SetSolidBrush(COLORREF clrref);
int TextOut(int x,int y,char *str);
int TextOutF(int x,int y,char *szFormat, ...);
int TextOutEx(int x,int y,RECT &r,char *str);
int FillRect(int l,int t,int w,int h);
int DrawRect(COLORREF color);
int DrawRect(int l,int t,int w,int h,COLORREF color);
int DrawRect(int l,int t,int w,int h);
int LoadBitMap(DWORD bmp_id);
int LineTo(int x,int y);
int CCanvas::Ellipse(int l,int t,int r,int b);
int Arc(int nLeftRect,int nTopRect,int nRightRect,int nBottomRect,int nXRadial1,int nYRadial1,int nXRadial2,int nYRadial2);
int MoveTo(int x,int y);
int DrawToScreen();
int Clear();
int StretchToDC(HDC hdc_des,int width,int height);
int SaveBmp(char *fn);
int SetX(int x);
int SetY(int y);
int DrawTextEx(char *str,RECT r,UINT dwDTFormat,LPDRAWTEXTPARAMS lpDTParams);
int SetPixel(int x,int y,COLORREF color);
int Copy(HDC hdc_src);
int Paste(HDC hdc_des);
int SetParent(HWND hp);
int SetPos(int l,int t);
int SetSize(int w,int h);
int CreateCompatibleDC(HDC hdc);
CCanvas();
virtual ~CCanvas();
int Init();
int Destroy();
int Copy(CCanvas *p);
int Comp(CCanvas *p);
int Print();
int InitBasic();
};
/////////////////////////////////////////////
class CDiBMP{
public:
BITMAPFILEHEADER * pbmfh ;
int width;
int height;
public:
int DibLoadImage (PTSTR pstrFileName);
int Paste(HDC hdc_des);
CDiBMP();
virtual ~CDiBMP();
int Init();
int Destroy();
int InitBasic();
};
/////////////////////////////////////////////
//CoInitialize() and CoUninitialize() must
//be called before use CJpeg
/////////////////////////////////////////////
class CJepg{
public:
IStream * pStream;
IPicture * pPicture;
HGLOBAL hmem;
HDC i_hdc;
public:
int SetIDC(HDC hdc);
int Draw(int x,int y);
int Draw(int x,int y,int w,int h);
int Draw(RECT r);
int GetHeight();
int GetWidth();
int LoadFromFile(char *fn);
CJepg();
virtual ~CJepg();
int Init();
int Destroy();
int InitBasic();
};
/////////////////////////////////////////////
#endif // !defined(AFX_CANVAS_H__31413FAA_DC0C_4694_AF72_F7B77FEA8316__INCLUDED_)