00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #pragma once
00023
00024 class CBrowseTreeItem;
00025 class CG2Packet;
00026 class CXMLElement;
00027 class CSchema;
00028
00029
00030 class CBrowseTreeCtrl : public CWnd
00031 {
00032
00033 public:
00034 CBrowseTreeCtrl();
00035 virtual ~CBrowseTreeCtrl();
00036
00037 DECLARE_DYNAMIC(CBrowseTreeCtrl)
00038
00039
00040 protected:
00041 CCriticalSection m_csRoot;
00042 CBrowseTreeItem* m_pRoot;
00043 int m_nTotal;
00044 int m_nVisible;
00045 int m_nScroll;
00046 protected:
00047 int m_nSelected;
00048 CBrowseTreeItem* m_pSelFirst;
00049 CBrowseTreeItem* m_pSelLast;
00050 CBrowseTreeItem* m_pFocus;
00051 protected:
00052 DWORD m_nCleanCookie;
00053
00054
00055 public:
00056 virtual BOOL Create(CWnd* pParentWnd);
00057 void Clear(BOOL bGUI = TRUE);
00058 BOOL Expand(CBrowseTreeItem* pItem, TRISTATE bExpand = TS_TRUE, BOOL bInvalidate = TRUE);
00059 BOOL Select(CBrowseTreeItem* pItem, TRISTATE bSelect = TS_TRUE, BOOL bInvalidate = TRUE);
00060 BOOL DeselectAll(CBrowseTreeItem* pExcept = NULL, CBrowseTreeItem* pParent = NULL, BOOL bInvalidate = TRUE);
00061 BOOL Highlight(CBrowseTreeItem* pItem);
00062 int GetSelectedCount() const;
00063 CBrowseTreeItem* GetFirstSelected() const;
00064 CBrowseTreeItem* GetLastSelected() const;
00065 CBrowseTreeItem* HitTest(const POINT& point, RECT* pRect = NULL) const;
00066 BOOL GetRect(CBrowseTreeItem* pItem, RECT* pRect);
00067 void OnTreePacket(CG2Packet* pPacket);
00068 protected:
00069 void UpdateScroll();
00070 void ScrollBy(int nDelta);
00071 void ScrollTo(int nPosition);
00072 void Paint(CDC& dc, CRect& rcClient, CPoint& pt, CBrowseTreeItem* pItem);
00073 CBrowseTreeItem* HitTest(CRect& rcClient, CPoint& pt, CBrowseTreeItem* pItem, const POINT& point, RECT* pRect) const;
00074 BOOL GetRect(CPoint& pt, CBrowseTreeItem* pItem, CBrowseTreeItem* pFind, RECT* pRect);
00075 BOOL CleanItems(CBrowseTreeItem* pItem, DWORD nCookie, BOOL bVisible);
00076 BOOL CollapseRecursive(CBrowseTreeItem* pItem);
00077 void NotifySelection();
00078 void OnTreePacket(CG2Packet* pPacket, DWORD nFinish, CBrowseTreeItem* pItem);
00079
00080
00081 public:
00082 inline CSyncObject* SyncRoot()
00083 {
00084 return &m_csRoot;
00085 }
00086
00087
00088 protected:
00089 DECLARE_MESSAGE_MAP()
00090 afx_msg void OnSize(UINT nType, int cx, int cy);
00091 afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
00092 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
00093 afx_msg void OnPaint();
00094 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
00095 afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
00096 afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
00097 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
00098 afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
00099 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
00100 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
00101
00102 };
00103
00104
00105 class CBrowseTreeItem
00106 {
00107
00108 public:
00109 CBrowseTreeItem(CBrowseTreeItem* pParent = NULL);
00110 virtual ~CBrowseTreeItem();
00111
00112
00113 public:
00114 CBrowseTreeItem* m_pParent;
00115 CBrowseTreeItem** m_pList;
00116 int m_nCount;
00117 int m_nBuffer;
00118 CBrowseTreeItem* m_pSelPrev;
00119 CBrowseTreeItem* m_pSelNext;
00120 DWORD m_nCleanCookie;
00121 public:
00122 BOOL m_bExpanded;
00123 BOOL m_bSelected;
00124 BOOL m_bContract1;
00125 BOOL m_bContract2;
00126 public:
00127 DWORD m_nCookie;
00128 CString m_sText;
00129 BOOL m_bBold;
00130 int m_nIcon16;
00131 public:
00132 CSchema* m_pSchema;
00133 DWORD* m_pFiles;
00134 DWORD m_nFiles;
00135
00136
00137 public:
00138 CBrowseTreeItem* Add(LPCTSTR pszName);
00139 CBrowseTreeItem* Add(CBrowseTreeItem* pNewItem);
00140 void Delete();
00141 void Delete(CBrowseTreeItem* pItem);
00142 void Delete(int nItem);
00143 void Clear();
00144 BOOL IsVisible() const;
00145 int GetChildCount() const;
00146 void Paint(CDC& dc, CRect& rc, BOOL bTarget, COLORREF crBack = CLR_NONE) const;
00147 void AddXML(CXMLElement* pXML);
00148
00149 };
00150
00151 #define IDC_BROWSE_TREE 125
00152 #define BTN_SELCHANGED 101