// Commands.h : header file
// COPYRIGHT (C) 1999-2000 by Mike Melnikov zmike@andnow.ru
//
#if !defined(AFX_COMMANDS_H__9E2BD958_202C_11D3_B5C4_0020AFDD89D7__INCLUDED_)
#define AFX_COMMANDS_H__9E2BD958_202C_11D3_B5C4_0020AFDD89D7__INCLUDED_
#include "UsefulManagersTypes.h"
#include "resource.h"
#include <ObjModel\addguid.h>
#include <ObjModel\appguid.h>
#include <ObjModel\bldguid.h>
#include <ObjModel\textguid.h>
#include <ObjModel\dbgguid.h>
#include "tags\entry.h"
#include "NestorThreads.h"
#include "Run.h"
#include <list>
using namespace std;
class CDlgMgr;
class RegularExpression;
class CCommands;
struct ReadParams : public RunParams
{
ReadParams (HANDLE h) : RunParams(h){}
void addText(const TCHAR* str);
void open(char* str) { }
};
class CRun : public Run
{
public:
private:
void MakeParams()
{
params[0] = new ReadParams(m_hChildStdoutRdDup);
params[1] = new ReadParams(m_hChildErrorRdDup);
}
};
struct ATL_NO_VTABLE CFileItem
{
void Touch() {m_timeLast = CTime::GetCurrentTime();}
CFileItem(LPCTSTR szDir,LPCTSTR szFile):m_Dir(szDir),m_File(szFile){Touch();}
CString m_File;
CTime m_timeLast;
CString m_Dir;
};
class LockState
{
public:
LockState(IApplication* pApplication);
virtual ~LockState();
static bool CanDo() {return refcount==0;}
protected:
static int refcount;
IApplication* m_pApplication;
};
class BuildThread : public Thread
{
public:
BuildThread() : Thread(true,THREAD_PRIORITY_LOWEST,false),ce_tou(false){}
bool ce_tou;
protected:
virtual void run();
};
class ConnectionCwnd : public CWnd
{
public:
LONG DoConnection(WPARAM wparam , LPARAM /* lparam */);
DECLARE_MESSAGE_MAP()
};
class MyCwnd : public CWnd
{
public:
MyCwnd() :/* m_bIsSubclassed(0),m_Saved_hWnd(0),*/m_timerID(111){}
protected:
int m_timerID;
void OnActivateApp( BOOL bActive, HTASK hTask );
void OnDestroy();
void PreSubclassWindow();
void OnEnable(BOOL bEnable);
void OnNcPaint();
DECLARE_MESSAGE_MAP()
};
class ATL_NO_VTABLE CCommands :
public IDSAddIn,
public IDispatchImpl<ICommands, &IID_ICommands, &LIBID_Findclass>,
public IDispatchImpl<IApplicationEvents, &IID_IApplicationEvents, &LIBID_Findclass>,
public CComObjectRoot,
public CComCoClass<CCommands, &CLSID_Commands>
{
public:
DECLARE_REGISTRY(CCommands, "UsefulManagers","UsefulManagers Add-in", IDS_FINDCLASS_DESCRIPTION,THREADFLAGS_BOTH)
protected:
IApplication* m_pApplication;
public:
CCommands();
~CCommands();
IApplication* GetApplication() { return m_pApplication; }
static CCommands* Get() {return g_CCommands;}
BEGIN_COM_MAP(CCommands)
COM_INTERFACE_ENTRY(IDSAddIn)
COM_INTERFACE_ENTRY(ICommands)
COM_INTERFACE_ENTRY_IID(IID_IApplicationEvents, IApplicationEvents)
END_COM_MAP()
DECLARE_NOT_AGGREGATABLE(CCommands)
protected:
// bookmarks
void SetBookMarks();
void AddBookMarks();
public:
void SetBookmark(int line = -1);
void ClearBookmark(CString s, int line);
protected:
DWORD m_dwAdvise;
public:
// IApplicationEvents methods
STDMETHOD(BeforeApplicationShutDown)(THIS);
STDMETHOD(BeforeBuildStart)(THIS);
STDMETHOD(BuildFinish)(THIS_ long nNumErrors, long nNumWarnings);
STDMETHOD(DocumentOpen)(THIS_ IDispatch * theDocument);
STDMETHOD(BeforeDocumentClose)(THIS_ IDispatch * theDocument);
STDMETHOD(DocumentSave)(THIS_ IDispatch * theDocument);
STDMETHOD(NewDocument)(THIS_ IDispatch * theDocument);
STDMETHOD(WindowActivate)(THIS_ IDispatch * theWindow);
STDMETHOD(WindowDeactivate)(THIS_ IDispatch * theWindow);
STDMETHOD(WorkspaceOpen)(THIS);
STDMETHOD(WorkspaceClose)(THIS);
STDMETHOD(NewWorkspace)(THIS);
// ICommands methods
public:
void SimpleOpenDoc(LPCTSTR fileName,int lines);
void GoToLine(int lines);
void selectTagByName(LPCTSTR name);
void RefreshBookMarks();
protected:
STDMETHODIMP OpenFile(LPCTSTR filename);
STDMETHODIMP Findclass(bool addHeader);
int findTag(ClassItem& item,RegularExpression& className);
int findTag(VecClassItem& vect,RegularExpression& className);
bool selectTagByFile();
bool selectTagByFile(HTREEITEM hParent);
void selectTagByName(HTREEITEM hParent,LPCTSTR nName);
void AddHeader(CString fileName,int lines);
public:
static CString DSWPath;
static CString CurrentWorkSpace;
static CString CurrentSession;
void DoUpdateInfo(bool force);
void ClearVectors();
//ini file
public:
static int getValue(LPCTSTR cvalue,int defaultValue,LPCTSTR topic = _T("Configure"));
static CString getValue(LPCTSTR cvalue,LPCTSTR defaultValue,LPCTSTR topic = _T("Configure"));
static void setValue(LPCTSTR cvalue,int newValue,LPCTSTR topic = _T("Configure"));
static void setValue(LPCTSTR cvalue,LPCTSTR newValue,LPCTSTR topic = _T("Configure"));
public:
void FindDoc(LPCTSTR szFile, CComPtr<IGenericDocument>& pDoc, bool fOkToOpen = true,LPCTSTR docType = _T("Auto"));
void OpenDoc(LPCTSTR szDoc, IGenericDocument **ppDoc = NULL);
void CloseDoc(LPCTSTR szDoc);
void SetInfo(CComQIPtr<IGenericDocument, &IID_IGenericDocument>&, bool fDoExtras = true);
CFileItem* findFileItem(CComQIPtr<IGenericDocument, &IID_IGenericDocument>& pDocument);
public:
void FileSaveAll();
public:
HRESULT GetActive(CComQIPtr<IGenericDocument, &IID_IGenericDocument>& pDocActive);
HRESULT GetDocuments(CComQIPtr<IDocuments, &IID_IDocuments>& pDocuments);
HRESULT GetSelection(CComQIPtr<ITextSelection, &IID_ITextSelection>& pSel);
long GetCurrentLine();
CString GetCurrentFile();
void OnNewExclude(const char* str,bool isBeforeClass);
public:
list<CFileItem*> m_dirList;
public:
CRun m_run;
public:
void NeedToDestroy(CDlgMgr* dlg);
protected:
enum Dlgs
{
_dlgWindows,
_dlgBookMarks,
_dlgTags,
_dlgFav,
_dlgSess,
_dlgFileTags,
_dlgCount,
};
CDlgMgr* m_dlgs[_dlgCount];
void toggleDialog(CDlgMgr* newDlg,CCommands::Dlgs d,int id);
void refresh(CCommands::Dlgs d);
public:
STDMETHOD(Favorites)();
STDMETHOD(TagsManager)();
STDMETHOD(Options)();
STDMETHOD(FindAndAddHeader)();
STDMETHOD(WindowsManager)();
STDMETHOD(ToggleFiles)();
STDMETHOD(FindClass)();
STDMETHOD(SessionManager)();
STDMETHOD(BuildRun)();
STDMETHOD(UpdateInfo)();
STDMETHOD(ShowFileTags)();
STDMETHOD(PushMark)();
STDMETHOD(PopMark)();
STDMETHOD(Bookmarks)();
// auto save
void Subclass();
void Unsubclass();
MyCwnd m_wnd;
public:
CWnd* GetDevOrMyWnd();
protected:
CWnd* GetDevWnd();
public:
STDMETHOD(OnConnection)(THIS_ IApplication* pApp, VARIANT_BOOL bFirstTime,long dwCookie, VARIANT_BOOL* OnConnection);
STDMETHOD(OnDisconnection)(THIS_ VARIANT_BOOL bLastTime);
public:
DWORD GetCookie() { return m_dwCookie;}
protected:
DWORD m_dwCookie;
protected:
ClassItem* foundTag;
HTREEITEM selected;
short sline;
short nline;
public:
WORD nFile;
protected:
//Timer m_outputTittle;
BuildThread gBuild;
void AddMFCExcludeTags();
private:
static CCommands* g_CCommands;
private:
ConnectionCwnd m_connectionCwnd;
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_COMMANDS_H__9E2BD958_202C_11D3_B5C4_0020AFDD89D7__INCLUDED)