#if !defined(AFX_LTRITEMTREEWND_H__6E4108A6_4C37_4F9A_AAD7_5A486AAC442A__INCLUDED_)
#define AFX_LTRITEMTREEWND_H__6E4108A6_4C37_4F9A_AAD7_5A486AAC442A__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ltrItemTreeWnd.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CltrItemTreeWnd window
struct cltrItemNode
{
cltrItemNode(const cxaParseElement* _papeElem = NULL)
: clrBorder(0),
clrBackground(RGB(0xcc,0xcc,0xcc)),
clrForeground(RGB(0xaa,0xaa,0xaa)),
fIsNode(true),nX(0),nY(0),nWidth(0),
papeElem(_papeElem)
{};
cltrItemNode(const std::tstring& _text, const cxaParseElement* _papeElem = NULL)
: clrBorder(0),
clrBackground(RGB(0xcc,0xcc,0xcc)),
clrForeground(RGB(0xaa,0xaa,0xaa)),
text(_text),
fIsNode(true),nX(0),nY(0),nWidth(0),
papeElem(_papeElem)
{};
virtual ~cltrItemNode()
{};
bool fIsNode;
COLORREF clrBorder;
COLORREF clrBackground;
COLORREF clrForeground;
std::tstring text;
int nX,nY,nWidth;
const cxaParseElement *papeElem;
};
struct cltrItemBranch : public cltrItemNode,
public std::vector<cltrItemNode*>
{
cltrItemBranch(const cxaParseElement* _papeElem = NULL)
: cltrItemNode(_papeElem),
fIsExpanded(false)
{ fIsNode = false; };
cltrItemBranch(std::tstring _text, const cxaParseElement* _papeElem = NULL)
: fIsExpanded(false),
cltrItemNode(_text,_papeElem)
{ fIsNode = false; };
virtual ~cltrItemBranch()
{
const_iterator it;
for(it=begin();it!=end();it++)
delete (*it);
};
bool fIsExpanded;
};
struct cltrItemCoordMap
{
typedef std::map< int, cltrItemNode* > innermap_type;
typedef std::map< int, innermap_type > coordmap_type;
coordmap_type mapCoords;
void reset() { mapCoords.clear(); };
void insert(int x,int y, cltrItemNode* pltrItem)
{
coordmap_type::iterator it0;
innermap_type::iterator it1;
it0 = mapCoords.find(x);
if(it0==mapCoords.end())
{
mapCoords.insert( std::make_pair(x,innermap_type() ) );
it0 = mapCoords.find(x);
}
it1 = it0->second.find(y);
if(it1==it0->second.end())
it0->second.insert( std::make_pair(y,pltrItem) );
else
ASSERT(FALSE);
};
cltrItemNode* find(int x,int y)
{
coordmap_type::iterator it0;
innermap_type::iterator it1;
it0 = mapCoords.find(x);
if(it0==mapCoords.end())
return NULL;
it1 = it0->second.find(y);
if(it1==it0->second.end())
return NULL;
return it1->second;
};
};
class CltrItemTreeWnd : public CWnd
{
// Construction
public:
CltrItemTreeWnd(cxtPackage *pPkg);
// Attributes
public:
cxtPackage* m_pPkg;
CFont m_Font;
double m_fZoomFactor;
int m_nLRMargin, m_nTBMargin;
int m_nBaseWidth, m_nCenterOffsX;
int m_nBaseHeight, m_nCenterOffsY;
cltrItemBranch* m_pltrTree;
cltrItemNode* m_pltrHilite;
cltrItemNode* m_pltrContext;
HICON m_icZoom, m_icUnzoom;
cltrItemCoordMap m_mapItems;
// Operations
public:
void SetTree(cltrItemBranch *pltrTree);
COLORREF ColorSlide(COLORREF clr1, COLORREF clr2, int nNom, int nDenom) const;
void CalculateItemRect(int x, int y, int nWidth, CRect& rcBounds);
cltrItemNode* FindItemFromCoords(int x, int y);
void CalculateDims(const cltrItemBranch& ltrBranch, int* pnWidth, int *pnHeight) const;
void RecalcViewLayout();
void ScrollHandler(bool fHorz, UINT nSBCode, UINT nPos);
enum eviewstatus
{
vs_visible,
vs_top,
vs_side,
vs_bottom
};
eviewstatus DrawItem(CDC *pDC, bool fInsert, int nHilite, int nX, int nY, cltrItemNode* pltrItem, int nWidth=1);
int DrawBranch(CDC *pDC, bool fInsert, int nHilite, int nX, int nY, cltrItemBranch& ltrBranch);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CltrItemTreeWnd)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CltrItemTreeWnd();
// Generated message map functions
protected:
//{{AFX_MSG(CltrItemTreeWnd)
afx_msg void OnPaint();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnTimer(UINT_PTR nIDEvent);
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
afx_msg void OnLtrcontextShowProps();
afx_msg void OnUpdateLtrcontextCollapseItem(CCmdUI* pCmdUI);
afx_msg void OnUpdateLtrcontextExpandItem(CCmdUI* pCmdUI);
afx_msg void OnLtrcontextExpandItem();
afx_msg void OnLtrcontextCollapseItem();
afx_msg void OnLtrcontextShowRawTokenStream();
afx_msg void OnUpdateLtrcontextShowProps(CCmdUI* pCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_LTRITEMTREEWND_H__6E4108A6_4C37_4F9A_AAD7_5A486AAC442A__INCLUDED_)