-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathArenaBar.cpp
156 lines (127 loc) · 3.69 KB
/
ArenaBar.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*************************************************************************************************\
*
* Filename: ArenaBar.cpp
* Purpose: Implement CArenaBar class
* Version: 1.0
* Author: Gavin Clayton
*
* Last Updated: 29/08/2002
*
* Copyright 2002. Gavin Clayton. All Rights Reserved.
*
*
* If changes are made by you to this code, please log them below:
*
*
\*************************************************************************************************/
#include "stdafx.h"
#include "daggerfall explorer.h"
#include "ArenaBar.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CArenaBar
CArenaBar::CArenaBar()
{
// Initialise
m_bIsCreated = FALSE;
m_oaNodeProperties.SetLength( 100, 100 );
}
CArenaBar::~CArenaBar()
{
}
BEGIN_MESSAGE_MAP(CArenaBar, baseCViewBar)
//{{AFX_MSG_MAP(CArenaBar)
ON_WM_CREATE()
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//
// void Purge()
// Delete all nodes from the Arena tree
//
void CArenaBar::Purge()
{
// Purge tree control items
m_ctrlArenaTree.DeleteAllItems();
// Purge node properties database
m_oaNodeProperties.DeleteAll();
}/* Purge */
//
// HTREEITEM InsertNode( HTREEITEM hParent, LPCSTR pszText, LPARAM nt, int iImage = NI_FOLDER, int iSelectedImage = NI_FOLDEROPEN, LPCSTR pszFile = NULL )
// Adds a node to the Arena tree
// Return: Handle to new node
//
HTREEITEM CArenaBar::InsertNode( HTREEITEM hParent, LPCSTR pszText, LPARAM nt, int iImage/*=NI_FOLDER*/, int iSelectedImage/*=NI_FOLDEROPEN*/, LPCSTR pszFile/*=NULL*/ )
{
HPOLYOBJ hNode;
HTREEITEM hItem = NULL;
TVINSERTSTRUCT tvi;
// Create a properties object
hNode = m_oaNodeProperties.New();
if ( hNode == HSTOPERR )
return NULL;
// Create tree node
tvi.hParent = hParent;
tvi.hInsertAfter = TVI_LAST;
tvi.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvi.item.pszText = (char*)pszText;
tvi.item.lParam = hNode;
tvi.item.iImage = iImage;
tvi.item.iSelectedImage = iSelectedImage;
hItem = m_ctrlArenaTree.InsertItem( &tvi );
if ( !hItem )
{
m_oaNodeProperties.Delete( hNode );
return NULL;
}
// Set properties
m_oaNodeProperties[hNode].nt = nt;
m_oaNodeProperties[hNode].hThis = hItem;
m_oaNodeProperties[hNode].hParent = hParent;
m_oaNodeProperties[hNode].strText = pszText;
if ( pszFile ) m_oaNodeProperties[hNode].strFile = pszFile;
return hItem;
}/* InsertNode */
/////////////////////////////////////////////////////////////////////////////
// CArenaBar message handlers
int CArenaBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (baseCViewBar::OnCreate(lpCreateStruct) == -1)
return -1;
// Create list control
if ( !m_ctrlArenaTree.Create( WS_VISIBLE|WS_CHILD|WS_EX_CLIENTEDGE|
TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
CRect(0,0,0,0), this, IDC_ARENA_TREE ) )
return -1;
// Create image list
if ( !m_ilArenaTree.Create( IDB_ARENA_TREE_BITMAP, 16, 1, RGB(0,0,255) ) ) return FALSE;
m_ctrlArenaTree.SetImageList( &m_ilArenaTree, TVSIL_NORMAL );
// Set created flag
m_bIsCreated = TRUE;
return 0;
}
void CArenaBar::OnSize(UINT nType, int cx, int cy)
{
baseCViewBar::OnSize(nType, cx, cy);
// Size child control
if ( m_bIsCreated ) {
CRect rct;
GetClientRect( rct );
m_ctrlArenaTree.MoveWindow( rct );
}
}
BOOL CArenaBar::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
// Route messages to parent application
int idCtrl = (int)wParam;
LPNMHDR pnmh = (LPNMHDR)lParam;
CDaggerfallExplorerApp *pApp = (CDaggerfallExplorerApp*)::AfxGetApp();
if ( pApp ) {
pApp->HandleChildMessage( pnmh );
}
return baseCViewBar::OnNotify(wParam, lParam, pResult);
}