// Copyright (C) 1991 - 1999 Rational Software Corporation
#if defined (_MSC_VER) && (_MSC_VER >= 1000)
#pragma once
#endif
#ifndef _INC_CCANVAS_3C1AF7BF0378_INCLUDED
#define _INC_CCANVAS_3C1AF7BF0378_INCLUDED
#define CANVAS_GDI 0
#define CANVAS_DDRAW 1
#include "canvasimpl.h"
//����ʵ����
//##ModelId=3C1AF7BF0378
class AFX_EXT_CLASS CCanvas
{
public:
HRESULT Create(CWnd *pWnd, UINT uID, int Width, int Height, int BPP);
CCanvas(CWnd *pWnd, UINT uID, int Width, int Height, int BPP = 0);
HRESULT Blt(CCanvas *pcanvas, LPRECT pDestRect,LPRECT pSrcRect);
HRESULT Release();
CCanvas(){};
HRESULT LoadBitmap(const char *szFilename);
CCanvas(CWnd* pWnd, UINT uID=CANVAS_DDRAW){Create(pWnd, uID);};
~CCanvas();
//Create
//PURPOSE: ʵ������������
//##ModelId=3C1AF7BF0379
HRESULT Create(CWnd* pWnd, UINT uID);
//���Ƶ�
//##ModelId=3C1AF7BF037E
HRESULT PutPixel(int X, int Y, DWORD Col);
//ȡ��ָ�������ɫ
//##ModelId=3C1AF7BF0382
DWORD GetPixel(int X, int Y);
//Rect
//PURPOSE: ���ƾ���
//RETURNS: 0 or > - �ɹ�
//< 0 - ʧ��
//##ModelId=3C1AF7BF0385
HRESULT Rect(int X1, int Y1, int X2, int Y2, DWORD Col);
//NAME: FillRect
//PURPOSE: ����������
//RETURNS: 0 or > - �ɹ�
//< 0 - ʧ��
//##ModelId=3C1AF7BF038B
HRESULT FillRect(int X1, int Y1, int X2, int Y2, DWORD Col);
//NAME: Line
//PURPOSE: ����ֱ��.
//RETURNS: 0 or > - �ɹ�
//< 0 - ʧ��
//##ModelId=3C1AF7BF0391
HRESULT Line(int X1, int Y1, int X2, int Y2, DWORD Col);
//NAME: Circle
//PURPOSE: ����Բ��
//RETURNS: 0 or > - �ɹ�
//< 0 - ʧ��
//##ModelId=3C1AF7BF0397
HRESULT Circle(int X, int Y, int Radius, DWORD Col);
//NAME: FillCircle
//PURPOSE: ����һ��������
//RETURNS: 0 or > - �ɹ�
//< 0 - ʧ��
//##ModelId=3C1AF7BF039C
HRESULT FillCircle(int X, int Y, int Radius, DWORD Col);
//NAME: RoundedRect
//PURPOSE: ����Բ�Ǿ���
//RETURNS: 0 or > - �ɹ�
//< 0 - ʧ��
//##ModelId=3C1AF7BF03A1
HRESULT RoundedRect(int X1, int Y1, int X2, int Y2, int Radius, DWORD Col);
//NAME: Fill
//PURPOSE: ��ָ����ɫ��䱳��
//RETURNS: 0 or > - �ɹ�
//< 0 - ʧ��
//##ModelId=3C1AF7BF03A8
HRESULT Fill(DWORD FillColor);
//////////////////////////////////////////////////////////
//////////////////////////
//NAME: TextXY
//
//PURPOSE: Draws the text specified by pString at
//position X,Y in colour Col.
//The text background is transparent.
//
//INPUT: x - X location of start of the string
//y - Y location of start of the string
//col - color to draw in.
//pString - the text string to be drawn
//
//RETURNS: 0 or > - successful
//< 0 - failed
//
//////////////////////////////////////////////////////////
//////////////////////////
//##ModelId=3C1AF7BF03AA
HRESULT TextOut(int x, int y, COLORREF col, LPCTSTR pString);
//////////////////////////////////////////////////////////
//////////////////////////
//NAME: DrawText
//
//PURPOSE: Draw word wrapped text on a device context
//inside a user defined
//RECT with formatting dimensions.
//
//INPUT: pString - the text string to be drawn
//col - color to draw in.
//pRect - bounding rect that the text will be drawn
//within
//
//RETURNS: 0 or > - successful
//< 0 - failed
//
//////////////////////////////////////////////////////////
//////////////////////////
//##ModelId=3C1AF7BF03AF
HRESULT DrawText(LPCSTR pString, COLORREF col, LPRECT pRect);
//////////////////////////////////////////////////////////
//////////////////////////
//NAME: SaveAsBMP
//
//PURPOSE:
//
//INPUT: none
//
//RETURNS: 0 or > - successful
//< 0 - failed
//
//////////////////////////////////////////////////////////
//////////////////////////
//##ModelId=3C1AF7BF03B3
HRESULT SaveAsBMP(const char* szFilename);
//////////////////////////////////////////////////////////
//////////////////////////
//NAME: ValidateBlt
//
//PURPOSE: Used to clip both the source and destination
//rectangles against their
//associated surface's m_ClipRect. The source or
//destination values
//will be adjusted to comply with the clipping rectangles.
//
//INPUT: lpCDXS - pointer to the destination surface
//lDestX - X location on the destination surface
//lDestY - Y location on the destination surface
//srcRect - rectangle descipbing the source block of
//pixels to be drawn
//
//RETURNS: TRUE - proceed with the draw operation
//FALSE - after clipping there is nothing to draw, exit
//draw operation.
//
//////////////////////////////////////////////////////////
//////////////////////////
//##ModelId=3C1AF7BF03B5
BOOL Blt(LPRECT pDestRect, LPRECT pSrcRect, CONST VOID *lpBits, CONST BITMAPINFO *lpBitsInfo);
//////////////////////////////////////////////////////////
//////////////////////////
//NAME: ClipRect
//
//PURPOSE: Clips a rectangle specified by Rect to the
//member variable m_clipRect
//
//INPUT: Rect - rectangle descirbing the block of pixels
//to be drawn
//
//RETURNS: TRUE - proceed with the draw operation
//FALSE - after clipping there is nothing to draw, exit
//draw operation.
//
//////////////////////////////////////////////////////////
//////////////////////////
//##ModelId=3C1AF7BF03BA
BOOL ClipRect(RECT* Rect);
//////////////////////////////////////////////////////////
//////////////////////////
//NAME: Restore
//
//PURPOSE: Restores the DirectDrawSurface and bitmap if
//lost. Called internally
//if a Draw function fails. It will also attempt to
//reload the bitmap
//if m_FileName is not NULL.
//
//INPUT: none
//
//RETURNS: 0 or > - successful
//< 0 - failed
//
//////////////////////////////////////////////////////////
//////////////////////////
//##ModelId=3C1AF7BF03BC
HRESULT Restore();
//NAME: SetFont
//
//PURPOSE: Selects the the currently chosen font from
//ChangeFont into the DC
//obtained by calling GetDC().
//
//INPUT: none
//
//RETURNS: 0 or > - successful
//< 0 - failed
//
//////////////////////////////////////////////////////////
//////////////////////////
//##ModelId=3C1AF7BF03C2
HRESULT SetFont(LPCTSTR FontName, int Width, int Height, int Attributes = FW_NORMAL);
//////////////////////////////////////////////////////////
//////////////////////////
//NAME: Lock
//
//PURPOSE: Locks the surface and provides direct access
//to the display memory.
//
//INPUT: none
//
//RETURNS: m_LockCount - successful
//< 0 - failed
//
//NOTE: Remember to call UnLock when you have finished
//drawing to the display
//memory. This method will properly restore any lost
//surfaces when called.
//
//////////////////////////////////////////////////////////
//////////////////////////
//##ModelId=3C1AF7BF03C3
HRESULT Lock();
//////////////////////////////////////////////////////////
//////////////////////////
//NAME: UnLock
//
//PURPOSE: UnLocks the surface and prevents access to
//display memory.
//
//INPUT: none
//
//RETURNS: m_LockCount - successful
//< 0 - failed
//
//NOTE: Should be called after you have finished with a
//Lock function. This
//method will properly restore any lost surfaces when
//called.
//
//////////////////////////////////////////////////////////
//////////////////////////
//##ModelId=3C1AF7BF03C4
HRESULT UnLock();
//////////////////////////////////////////////////////////
//////////////////////////
//NAME: GetDC
//
//PURPOSE: Retieves a handle of the display device
//context (DC) and stores it in
//the m_DC data member. The device context is used in GDI
//functions to
//draw to the screen.
//
//INPUT: none
//
//RETURNS: 0 or > - successful
//< 0 - failed
//
//NOTE: Remember to call ReleaseDC when you are finished
//with your GDI functions.
//
//////////////////////////////////////////////////////////
//////////////////////////
//##ModelId=3C1AF7BF03C5
HDC GetDC();
//////////////////////////////////////////////////////////
//////////////////////////
//NAME: ReleaseDC
//
//PURPOSE: Releases the device context. Should be called
//after you have finished
//with a GetDC function.
//
//INPUT: none
//
//RETURNS: 0 or > - successful
//< 0 - failed
//
//NOTE: Should be called after you have finished with a
//GetDC function.
//
//////////////////////////////////////////////////////////
//////////////////////////
//##ModelId=3C1AF7BF03C6
HRESULT ReleaseDC();
//##ModelId=3C1AF7BF03C7
int GetWidth();
//##ModelId=3C1AF7BF03C8
int GetHeight();
//##ModelId=3C1AF7BF03C9
void* GetSurfacePointer();
//##ModelId=3C1AF7BF03CA
LPRECT GetClipRect();
//////////////////////////////////////////////////////////
//////////////////////////
//NAME: SetClipRect
//
//PURPOSE: Set m_clipRect to the passed in RECT values
//
//INPUT: clipRect - RECT strcture that contains the new
//clipping rect values
//
//RETURNS: nothing
//
//NOTE: The clipping rect cannot be large then the
//current screen size
//
//////////////////////////////////////////////////////////
//////////////////////////
//##ModelId=3C1AF7BF03CB
void SetClipRect(LPRECT clipRect);
//////////////////////////////////////////////////////////
//////////////////////////
//NAME: GetFontName
//
//PURPOSE: Returns the font name
//
//INPUT: name - pointer to a string to hold the font
//name. This should be at
//least 256 bytes
//
//RETURNS: char pointer that was passed in. Useful if
//you want to inline the code
//
//////////////////////////////////////////////////////////
//////////////////////////
//##ModelId=3C1AF7BF03CD
char* GetFontName(char* name);
//////////////////////////////////////////////////////////
//////////////////////////
//NAME: GetSurfaceDescriptor
//
//PURPOSE:
//
//INPUT: lpddsd -
//
//RETURNS: nothing
//
//////////////////////////////////////////////////////////
//////////////////////////
//##ModelId=3C1AF7BF03CF
void GetSurfaceDescriptor(LPDDSURFACEDESC2 lpddsd);
//##ModelId=3C1AF7BF03D1
LPDIRECTDRAWSURFACE7 GetDDS();
//##ModelId=3C1AF7BF03D2
LRESULT Refresh(LPRECT pRect);
private:
//������ȣ�������Ϊ��λ��
//##ModelId=3C1AF7BF03D4
int m_nWidth;
//�����߶ȣ�������Ϊ��λ��
//##ModelId=3C1AF7BF03D5
int m_nHeight;
//��������
//##ModelId=3C1AF7BF03D6
char m_szFontName[256];
//##ModelId=3C1AF7FA02C9
CCanvasImpl* m_pImpl;
};
#endif /* _INC_CCANVAS_3C1AF7BF0378_INCLUDED */