-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExplorer.cpp
124 lines (97 loc) · 3.08 KB
/
Explorer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Explorer.cpp : implementation file
//
#include "stdafx.h"
#include "MODVIEW32.h"
#include "Explorer.h"
#include "MODVIEW32Doc.h"
#include "MODVIEW32View.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExplorer
IMPLEMENT_DYNCREATE(CExplorer, CListView)
CExplorer::CExplorer()
{
DoEventhandling=TRUE;
}
CExplorer::~CExplorer()
{
}
BEGIN_MESSAGE_MAP(CExplorer, CTreeView)
//{{AFX_MSG_MAP(CExplorer)
ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnSelchanged)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExplorer drawing
void CExplorer::OnDraw(CDC* pDC)
{
CDocument* pDoc=GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CExplorer diagnostics
#ifdef _DEBUG
void CExplorer::AssertValid() const
{
CTreeView::AssertValid();
}
void CExplorer::Dump(CDumpContext& dc) const
{
CTreeView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CExplorer message handlers
void CExplorer::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
if(DoEventhandling)
{
//GetTreeCtrl().ModifyStyle(0, TVS_SHOWSELALWAYS | TVS_FULLROWSELECT | TVS_HASLINES | TVS_HASLINES);
HTREEITEM itm=GetTreeCtrl().GetSelectedItem();
ASSERT(itm!=NULL);
if (!itm) return;
CString name=GetTreeCtrl().GetItemText(itm);
CMainFrame *viewFrame=static_cast<CMainFrame*>(GetParentFrame());
CMODVIEW32View *view=(CMODVIEW32View *)viewFrame->GetActiveView();
//CMODVIEW32Doc *viewDoc=(CMODVIEW32Doc *)view->GetDocument();
CMODVIEW32Doc *viewDoc=(CMODVIEW32Doc *)viewFrame->GetDocument();
if (viewDoc->m_Game == GAME_FS) {
name=name+".pof";
viewFrame->m_ZoomLevel=1.0;
viewDoc->m_ErrorCode=viewDoc->FS_LoadVPContent(name);
}
}
*pResult=0;
}
BOOL CExplorer::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
BOOL ret=CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
GetTreeCtrl().ModifyStyle(0, TVS_SHOWSELALWAYS | TVS_FULLROWSELECT | TVS_HASLINES | TVS_HASBUTTONS);
return ret;
}
// GetNextItem - Get next item as if outline was completely expanded
// Returns - The item immediately below the reference item
// hItem - The reference item
HTREEITEM CExplorer::GetNextItem(HTREEITEM hItem)
{
HTREEITEM hti;
if(GetTreeCtrl().ItemHasChildren(hItem))
return GetTreeCtrl().GetChildItem(hItem); // return first child
else
{
// return next sibling item
// Go up the tree to find a parent's sibling if needed.
while((hti=GetTreeCtrl().GetNextSiblingItem(hItem))==NULL)
{
if((hItem=GetTreeCtrl().GetParentItem(hItem))==NULL)
return NULL;
}
}
return hti;
}