00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined(AFX_CTRLLIBRARYTREE_H__F092090F_D43A_4F3D_A584_8AE441A95945__INCLUDED_)
00023 #define AFX_CTRLLIBRARYTREE_H__F092090F_D43A_4F3D_A584_8AE441A95945__INCLUDED_
00024
00025 #pragma once
00026
00027 class CLibraryTreeItem;
00028 class CCoolTipCtrl;
00029 class CLibraryFolder;
00030 class CAlbumFolder;
00031
00032
00033 class CLibraryTreeCtrl : public CWnd
00034 {
00035
00036 public:
00037 CLibraryTreeCtrl();
00038 virtual ~CLibraryTreeCtrl();
00039
00040 DECLARE_DYNAMIC(CLibraryTreeCtrl)
00041
00042
00043 protected:
00044 CLibraryTreeItem* m_pRoot;
00045 int m_nTotal;
00046 int m_nVisible;
00047 int m_nScroll;
00048 protected:
00049 int m_nSelected;
00050 CLibraryTreeItem* m_pSelFirst;
00051 CLibraryTreeItem* m_pSelLast;
00052 CLibraryTreeItem* m_pFocus;
00053 protected:
00054 BOOL m_bDrag;
00055 CPoint m_ptDrag;
00056 CLibraryTreeItem* m_pDropItem;
00057 protected:
00058 DWORD m_nCleanCookie;
00059 CCoolTipCtrl* m_pTip;
00060
00061
00062 public:
00063 void SetToolTip(CCoolTipCtrl* pTip);
00064 void Clear();
00065 BOOL Expand(CLibraryTreeItem* pItem, TRISTATE bExpand = TS_TRUE, BOOL bInvalidate = TRUE);
00066 BOOL Select(CLibraryTreeItem* pItem, TRISTATE bSelect = TS_TRUE, BOOL bInvalidate = TRUE);
00067 BOOL SelectAll(CLibraryTreeItem* pParent = NULL, BOOL bInvalidate = TRUE);
00068 BOOL DeselectAll(CLibraryTreeItem* pExcept = NULL, CLibraryTreeItem* pParent = NULL, BOOL bInvalidate = TRUE);
00069 BOOL Highlight(CLibraryTreeItem* pItem);
00070 int GetSelectedCount() const;
00071 CLibraryTreeItem* GetFirstSelected() const;
00072 CLibraryTreeItem* GetLastSelected() const;
00073 CLibraryTreeItem* HitTest(const POINT& point, RECT* pRect = NULL) const;
00074 BOOL GetRect(CLibraryTreeItem* pItem, RECT* pRect);
00075 CLibraryTreeItem* GetFolderItem(LPVOID pSearch, CLibraryTreeItem* pParent = NULL);
00076 protected:
00077 void UpdateScroll();
00078 void ScrollBy(int nDelta);
00079 void ScrollTo(int nPosition);
00080 void Paint(CDC& dc, CRect& rcClient, CPoint& pt, CLibraryTreeItem* pItem);
00081 CLibraryTreeItem* HitTest(CRect& rcClient, CPoint& pt, CLibraryTreeItem* pItem, const POINT& point, RECT* pRect) const;
00082 BOOL GetRect(CPoint& pt, CLibraryTreeItem* pItem, CLibraryTreeItem* pFind, RECT* pRect);
00083 BOOL CleanItems(CLibraryTreeItem* pItem, DWORD nCookie, BOOL bVisible);
00084 BOOL CollapseRecursive(CLibraryTreeItem* pItem);
00085 void NotifySelection();
00086 void StartDragging(CPoint& ptMouse);
00087 CImageList* CreateDragImage(const CPoint& ptMouse);
00088
00089
00090 public:
00091
00092 public:
00093 virtual BOOL Create(CWnd* pParentWnd);
00094
00095
00096
00097 protected:
00098
00099 afx_msg void OnSize(UINT nType, int cx, int cy);
00100 afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
00101 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
00102 afx_msg void OnPaint();
00103 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
00104 afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
00105 afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
00106 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
00107 afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
00108 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
00109 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
00110
00111
00112 DECLARE_MESSAGE_MAP()
00113
00114 };
00115
00116
00117 class CLibraryTreeItem
00118 {
00119
00120 public:
00121 CLibraryTreeItem(CLibraryTreeItem* pParent = NULL);
00122 virtual ~CLibraryTreeItem();
00123
00124
00125 public:
00126 CLibraryTreeItem* m_pParent;
00127 CLibraryTreeItem** m_pList;
00128 int m_nCount;
00129 int m_nBuffer;
00130 CLibraryTreeItem* m_pSelPrev;
00131 CLibraryTreeItem* m_pSelNext;
00132 DWORD m_nCleanCookie;
00133 public:
00134 BOOL m_bExpanded;
00135 BOOL m_bSelected;
00136 BOOL m_bContract1;
00137 BOOL m_bContract2;
00138 public:
00139 CLibraryFolder* m_pPhysical;
00140 CAlbumFolder* m_pVirtual;
00141 DWORD m_nCookie;
00142 CString m_sText;
00143 BOOL m_bBold;
00144 BOOL m_bShared;
00145 BOOL m_bCollection;
00146 int m_nIcon16;
00147
00148
00149 public:
00150 CLibraryTreeItem* Add(LPCTSTR pszName);
00151 void Delete();
00152 void Delete(CLibraryTreeItem* pItem);
00153 void Delete(int nItem);
00154 void Clear();
00155 BOOL IsVisible() const;
00156 int GetChildCount() const;
00157 void Paint(CDC& dc, CRect& rc, BOOL bTarget, COLORREF crBack = CLR_NONE) const;
00158 int GetFileList(CLibraryList* pList, BOOL bRecursive = FALSE) const;
00159
00160 };
00161
00162
00163
00164 #define IDC_LIBRARY_TREE 131
00165 #define LTN_SELCHANGED 101
00166
00167 #endif // !defined(AFX_CTRLLIBRARYTREE_H__F092090F_D43A_4F3D_A584_8AE441A95945__INCLUDED_)