// INKS.h : main header file for the INKS application
//
#pragma once
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#ifndef __AFXWIN_H__
	#error "include 'stdafx.h' before including this file for PCH"
#endif

#include "resource.h"       // main symbols
#include "ElementContainer.h"
class CChildFrame;
class CINKSDoc;
class CINKSView;
class CMainFrame;
class CTreeItem;

typedef CTypedPtrList<CPtrList,CDocument*> DocumentList; 

class CINKSApp : public CWinApp
{
public:
	CINKSApp();
	~CINKSApp();
	virtual BOOL InitInstance();
	//void OpenFile(CString strPath, CString strTitle, CString strOrigin, int nType, bool bInProject);
	void OpenFile(CString strPath, CTreeItem *pItem);
	void SetProjectDirty(bool bDirty) {m_bProjectDirty = bDirty;}
	void CreateNewElement(int nType);
	void BringToTop(CDocument *pDoc);
	CDocument* GetActiveDocument();
	BOOL SaveAllModified();
	bool DeleteScheme();
	void CreateNewProject();
	void CreateProjectDirectories(CString strProjectPath);
	void CreateNewScheme(CTreeItem *pParent);
	void CreateNewBlock(CTreeItem *pParent);

private:
	void CloseAllDocuments(BOOL bEndSession);
	int ExitInstance();
	//void OnAppExit();
	BOOL CloseAllDocumentsCommand();
	void GetAllDocuments(DocumentList &Docs);

	CDocument* OpenDocumentFile(LPCTSTR lpszFileName);
	CDocument* CreateDocView(CString strFilename, CString strTitle, BOOL bViewVisible);
	bool DirectoryExists(CString strDirPath);
	bool FileExists(CString strFile);

	void CreateTagPath();

public:
	CElementContainer *m_pElementCont;
	ULONG_PTR m_gdiplusToken;
	CMainFrame* m_pMainFrame;
	CINKSDoc *m_pOpenedProjectDoc;
	CString m_strAppPath;
	bool m_bAppExit;

private:
	bool m_bProjectDirty;
	CMultiDocTemplate* pDocTemplate;
	QGdiPlus m_GdiPlus;
	DECLARE_MESSAGE_MAP()

public:
	afx_msg void OnAppAbout();
	afx_msg void OnParseAllGates();
	afx_msg void OnParseAllBlocks();
	afx_msg void OnProjectClose();
	afx_msg void OnProjectNew();
	afx_msg void OnProjectOpen();
	afx_msg void AddNewScheme();
public:
	afx_msg void OnAppExit();
};

extern CINKSApp theApp;