Скачиваний:
7
Добавлен:
01.05.2014
Размер:
1.66 Кб
Скачать
#ifndef Elements_h
#define Elements_h

#include "Hashable.h"

#include <iostream>
using namespace std;

// Generic element class
class CElement: virtual public CObject, virtual public Hashable
{
	private:
	    static unsigned long int count;

		static unsigned long int total;

		const unsigned long int id;

	protected:
		COLORREF m_Color;								// Color of an element

		CRect m_EnclosingRect;							// Rectangle enclosing an element

		CRect m_keyRectangle;

		int m_Pen;										// Pen width

	public:
		virtual ~CElement(){						// Virtual destructor
			count--;
			cout << "destroy Shape#" << id << endl; 
		}                      

		virtual void Draw(CDC* pDC, CElement* pElement=0, string key = "") {}

		virtual void setColor(COLORREF aColor);

		virtual COLORREF getColor();

		virtual void Move(CSize& aSize) {}			// Move an element

		CRect GetBoundRect();						// Get the bounding rectangle for an element

		virtual ostream& print(ostream& os) const = 0;
		
		friend ostream& operator<<(ostream& os, const CElement* o) {
			return o->print(os);
		}

		friend ostream& operator<<(ostream& os, const CElement& o) {
			return o.print(os);
		}

		virtual CArchive& save(CArchive& ar);

		virtual CArchive& load(CArchive& ar);

		unsigned long int getObjectId() const{
			return id;
		}

		static unsigned long int getNumberOfObjects(){ //const
			return count;
		}

		CElement(): id(++total){									// Default constructor
			count++;
			cout << "create Shape#" << id << endl;  		
		}      
		
		CRect drawKey(CDC* pDC, string text);

		CRect getKeyRectangle();
};

#endif
Соседние файлы в папке OLEApp