#pragma once
#include "commonobject.h"
#include "Wire.h"
class CNode :
	public CCommonObject
{
private:
	CCommonObject *m_pLeft;
	CCommonObject *m_pTop;
	CCommonObject *m_pRight;
	CCommonObject *m_pBottom;
	CList<CCommonObject *> m_NonRectObjects;
	CPoint		   m_Position;
	Brush			*m_pBrush;
	CCommonObject *m_pAttachedObject;

public:
	bool IsDirectionFree(int dir);
	CCommonObject* ConnectHitTest(CPoint point, int &nNumber);
	Gdiplus::Rect *GetBounds();
	void OutScreen(Gdiplus::Graphics &g);
	CPoint GetPoint()
	{
		return m_Position;
	}
	CCommonObject *GetAttachedObject()
	{
		return m_pAttachedObject;
	}
	void ConnectWire(CWire *wire, int direction);
	void DisconnectWire(CWire *wire);
	void AttachObject(CCommonObject *obj, int freeDir);
	void MoveDelta(int dx, int dy);
	vector<CWire *> GetWires();
	CNode(){};
	CNode(CPoint position);
	~CNode(void);
	bool bOut;
private:
	void MakeBoundingRect();
};
