184 lines
4.7 KiB
C++
184 lines
4.7 KiB
C++
// drawobj.h - interface for CDrawObj and derivatives
|
|
//
|
|
// This file is a part of the XTREME TOOLKIT PRO MFC class library.
|
|
// (c)1998-2008 Codejock Software, All Rights Reserved.
|
|
//
|
|
// THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
|
|
// RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
|
|
// CONSENT OF CODEJOCK SOFTWARE.
|
|
//
|
|
// THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
|
|
// IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
|
|
// YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
|
|
// SINGLE COMPUTER.
|
|
//
|
|
// CONTACT INFORMATION:
|
|
// support@codejock.com
|
|
// http://www.codejock.com
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef __DRAWOBJ_H__
|
|
#define __DRAWOBJ_H__
|
|
|
|
class CDrawView;
|
|
class CDrawDoc;
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDrawObj - base class for all 'drawable objects'
|
|
|
|
class CDrawObj : public CObject
|
|
{
|
|
protected:
|
|
DECLARE_SERIAL(CDrawObj);
|
|
CDrawObj();
|
|
|
|
// Constructors
|
|
public:
|
|
CDrawObj(const CRect& position);
|
|
|
|
// Attributes
|
|
CRect m_position;
|
|
CDrawDoc* m_pDocument;
|
|
|
|
virtual int GetHandleCount();
|
|
virtual CPoint GetHandle(int nHandle);
|
|
CRect GetHandleRect(int nHandleID, CDrawView* pView);
|
|
virtual HCURSOR GetHandleCursor(int nHandle);
|
|
virtual void SetLineColor(COLORREF color);
|
|
virtual void SetFillColor(COLORREF color);
|
|
|
|
// Operations
|
|
virtual void Draw(CDC* pDC);
|
|
enum TrackerState { normal, selected, active };
|
|
virtual void DrawTracker(CDC* pDC, TrackerState state);
|
|
virtual void MoveTo(const CRect& positon, CDrawView* pView = NULL);
|
|
virtual int HitTest(CPoint point, CDrawView* pView, BOOL bSelected);
|
|
virtual BOOL Intersects(const CRect& rect);
|
|
virtual void MoveHandleTo(int nHandle, CPoint point, CDrawView* pView = NULL);
|
|
virtual void OnOpen(CDrawView* pView);
|
|
virtual void OnEditProperties();
|
|
virtual CDrawObj* Clone(CDrawDoc* pDoc = NULL);
|
|
virtual void Remove();
|
|
void Invalidate();
|
|
|
|
// Implementation
|
|
public:
|
|
virtual ~CDrawObj();
|
|
virtual void Serialize(CArchive& ar);
|
|
#ifdef _DEBUG
|
|
void AssertValid();
|
|
#endif
|
|
|
|
// implementation data
|
|
BOOL m_bPen;
|
|
LOGPEN m_logpen;
|
|
BOOL m_bBrush;
|
|
LOGBRUSH m_logbrush;
|
|
};
|
|
|
|
// special 'list' class for this application (requires afxtempl.h)
|
|
class CDrawObjList : public CTypedPtrList<CObList, CDrawObj*>
|
|
{
|
|
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
// specialized draw objects
|
|
|
|
class CDrawRect : public CDrawObj
|
|
{
|
|
protected:
|
|
DECLARE_SERIAL(CDrawRect);
|
|
CDrawRect();
|
|
|
|
public:
|
|
CDrawRect(const CRect& position);
|
|
|
|
// Implementation
|
|
public:
|
|
virtual void Serialize(CArchive& ar);
|
|
virtual void Draw(CDC* pDC);
|
|
virtual int GetHandleCount();
|
|
virtual CPoint GetHandle(int nHandle);
|
|
virtual HCURSOR GetHandleCursor(int nHandle);
|
|
virtual void MoveHandleTo(int nHandle, CPoint point, CDrawView* pView = NULL);
|
|
virtual BOOL Intersects(const CRect& rect);
|
|
virtual CDrawObj* Clone(CDrawDoc* pDoc);
|
|
|
|
protected:
|
|
enum Shape { rectangle, roundRectangle, ellipse, line };
|
|
Shape m_nShape;
|
|
CPoint m_roundness; // for roundRect corners
|
|
|
|
friend class CRectTool;
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
class CDrawPoly;
|
|
|
|
class CDrawPoly : public CDrawObj
|
|
{
|
|
protected:
|
|
DECLARE_SERIAL(CDrawPoly);
|
|
CDrawPoly();
|
|
|
|
public:
|
|
CDrawPoly(const CRect& position);
|
|
|
|
// Operations
|
|
void AddPoint(const CPoint& point, CDrawView* pView = NULL);
|
|
BOOL RecalcBounds(CDrawView* pView = NULL);
|
|
|
|
// Implementation
|
|
public:
|
|
virtual ~CDrawPoly();
|
|
virtual void Serialize(CArchive& ar);
|
|
virtual void Draw(CDC* pDC);
|
|
virtual void MoveTo(const CRect& position, CDrawView* pView = NULL);
|
|
virtual int GetHandleCount();
|
|
virtual CPoint GetHandle(int nHandle);
|
|
virtual HCURSOR GetHandleCursor(int nHandle);
|
|
virtual void MoveHandleTo(int nHandle, CPoint point, CDrawView* pView = NULL);
|
|
virtual BOOL Intersects(const CRect& rect);
|
|
virtual CDrawObj* Clone(CDrawDoc* pDoc);
|
|
|
|
protected:
|
|
int m_nPoints;
|
|
int m_nAllocPoints;
|
|
CPoint* m_points;
|
|
CDrawPoly* m_pDrawObj;
|
|
|
|
friend class CPolyTool;
|
|
};
|
|
|
|
class CDrawItem; // COleClientItem derived class
|
|
|
|
class CDrawOleObj : public CDrawObj
|
|
{
|
|
protected:
|
|
DECLARE_SERIAL(CDrawOleObj);
|
|
CDrawOleObj();
|
|
|
|
public:
|
|
CDrawOleObj(const CRect& position);
|
|
|
|
// Implementation
|
|
public:
|
|
virtual void Serialize(CArchive& ar);
|
|
virtual void Draw(CDC* pDC);
|
|
virtual CDrawObj* Clone(CDrawDoc* pDoc);
|
|
virtual void OnOpen(CDrawView* pView);
|
|
virtual void MoveTo(const CRect& positon, CDrawView* pView = NULL);
|
|
virtual void OnEditProperties();
|
|
virtual void Remove();
|
|
virtual ~CDrawOleObj();
|
|
|
|
static BOOL c_bShowItems;
|
|
|
|
CDrawItem* m_pClientItem;
|
|
CSize m_extent; // current extent is tracked separate from scaled position
|
|
};
|
|
|
|
#endif // __DRAWOBJ_H__
|