| 1 |
// ElephantDoc.h : interface of the CElephantDoc class |
|---|
| 2 |
// |
|---|
| 3 |
///////////////////////////////////////////////////////////////////////////// |
|---|
| 4 |
|
|---|
| 5 |
#if !defined(AFX_ELEPHANTDOC_H__9DBCBBCC_EBF4_4724_A31A_B7839632499A__INCLUDED_) |
|---|
| 6 |
#define AFX_ELEPHANTDOC_H__9DBCBBCC_EBF4_4724_A31A_B7839632499A__INCLUDED_ |
|---|
| 7 |
|
|---|
| 8 |
#if _MSC_VER > 1000 |
|---|
| 9 |
#pragma once |
|---|
| 10 |
#endif // _MSC_VER > 1000 |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
class CElephantDoc : public CScintillaDoc |
|---|
| 14 |
{ |
|---|
| 15 |
protected: // create from serialization only |
|---|
| 16 |
CElephantDoc(); |
|---|
| 17 |
DECLARE_DYNCREATE(CElephantDoc) |
|---|
| 18 |
|
|---|
| 19 |
// Attributes |
|---|
| 20 |
public: |
|---|
| 21 |
|
|---|
| 22 |
// Operations |
|---|
| 23 |
public: |
|---|
| 24 |
bool ScintillaOpen(LPCTSTR lpszPathName); |
|---|
| 25 |
bool ScintillaSave(LPCTSTR lpszPathName); |
|---|
| 26 |
void FileModified() ; |
|---|
| 27 |
void Reload(); |
|---|
| 28 |
CScintillaCtrl& GetCtrl(); |
|---|
| 29 |
afx_msg void OnFileSaveSavefile(); |
|---|
| 30 |
// Overrides |
|---|
| 31 |
// ClassWizard generated virtual function overrides |
|---|
| 32 |
//{{AFX_VIRTUAL(CElephantDoc) |
|---|
| 33 |
public: |
|---|
| 34 |
virtual void Serialize(CArchive& ar); |
|---|
| 35 |
virtual BOOL OnOpenDocument(LPCTSTR lpszPathName); |
|---|
| 36 |
virtual BOOL OnSaveDocument(LPCTSTR lpszPathName); |
|---|
| 37 |
virtual void OnCloseDocument(); |
|---|
| 38 |
protected: |
|---|
| 39 |
virtual BOOL SaveModified(); |
|---|
| 40 |
//}}AFX_VIRTUAL |
|---|
| 41 |
|
|---|
| 42 |
BOOL PromptSave(); |
|---|
| 43 |
|
|---|
| 44 |
// Implementation |
|---|
| 45 |
public: |
|---|
| 46 |
virtual ~CElephantDoc(); |
|---|
| 47 |
#ifdef _DEBUG |
|---|
| 48 |
virtual void AssertValid() const; |
|---|
| 49 |
virtual void Dump(CDumpContext& dc) const; |
|---|
| 50 |
#endif |
|---|
| 51 |
|
|---|
| 52 |
protected: |
|---|
| 53 |
|
|---|
| 54 |
// Generated message map functions |
|---|
| 55 |
protected: |
|---|
| 56 |
//{{AFX_MSG(CElephantDoc) |
|---|
| 57 |
afx_msg void OnFileSaveAs(); |
|---|
| 58 |
//}}AFX_MSG |
|---|
| 59 |
DECLARE_MESSAGE_MAP() |
|---|
| 60 |
}; |
|---|
| 61 |
|
|---|
| 62 |
struct LastView { |
|---|
| 63 |
|
|---|
| 64 |
LastView() {} |
|---|
| 65 |
LastView(CElephantDoc* m, int c ) : me(m),cursor(c) {} |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
int cursor; |
|---|
| 69 |
CElephantDoc* me; |
|---|
| 70 |
}; |
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
class RecentViews { |
|---|
| 74 |
public: |
|---|
| 75 |
deque<LastView> backViews; |
|---|
| 76 |
deque<LastView> forwardViews; |
|---|
| 77 |
CElephantDoc* lastAdded; |
|---|
| 78 |
|
|---|
| 79 |
public: |
|---|
| 80 |
|
|---|
| 81 |
void Clear() { |
|---|
| 82 |
backViews.clear(); |
|---|
| 83 |
forwardViews.clear(); |
|---|
| 84 |
} |
|---|
| 85 |
|
|---|
| 86 |
void Add ( LastView& lv ) ; |
|---|
| 87 |
|
|---|
| 88 |
void Remove(LastView& lv) ; |
|---|
| 89 |
|
|---|
| 90 |
LastView Back() { |
|---|
| 91 |
// pop off top element |
|---|
| 92 |
LastView x; |
|---|
| 93 |
|
|---|
| 94 |
if ( backViews.size() ) { |
|---|
| 95 |
x = backViews[0]; |
|---|
| 96 |
backViews.pop_front(); |
|---|
| 97 |
forwardViews.push_front(x); |
|---|
| 98 |
} |
|---|
| 99 |
else return LastView(0,0 ); |
|---|
| 100 |
|
|---|
| 101 |
return x; |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
LastView Forward() { |
|---|
| 105 |
|
|---|
| 106 |
LastView x; |
|---|
| 107 |
|
|---|
| 108 |
if ( forwardViews.size() ) { |
|---|
| 109 |
x = forwardViews[0]; |
|---|
| 110 |
forwardViews.pop_front(); |
|---|
| 111 |
backViews.push_front(x); |
|---|
| 112 |
|
|---|
| 113 |
} |
|---|
| 114 |
else return LastView(0,0 ); |
|---|
| 115 |
|
|---|
| 116 |
return x; |
|---|
| 117 |
} |
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
}; |
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
///////////////////////////////////////////////////////////////////////////// |
|---|
| 124 |
|
|---|
| 125 |
//{{AFX_INSERT_LOCATION}} |
|---|
| 126 |
// Microsoft Visual C++ will insert additional declarations immediately before the previous line. |
|---|
| 127 |
|
|---|
| 128 |
#endif // !defined(AFX_ELEPHANTDOC_H__9DBCBBCC_EBF4_4724_A31A_B7839632499A__INCLUDED_) |
|---|