This commit was manufactured by cvs2svn to create branch 'captive'.
[reactos.git] / subsys / system / explorer / Seashell / SeaShellExt / UITreeView.cpp
1 //*******************************************************************************
2 // COPYRIGHT NOTES
3 // ---------------
4 // You may use this source code, compile or redistribute it as part of your application 
5 // for free. You cannot redistribute it as a part of a software development 
6 // library without the agreement of the author. If the sources are 
7 // distributed along with the application, you should leave the original 
8 // copyright notes in the source code without any changes.
9 // This code can be used WITHOUT ANY WARRANTIES at your own risk.
10 // 
11 // For the latest updates to this code, check this site:
12 // http://www.masmex.com 
13 // after Sept 2000
14 // 
15 // Copyright(C) 2000 Philip Oldaker <email: philip@masmex.com>
16 //*******************************************************************************
17
18 // TabClientView.cpp : implementation file
19 //
20
21 #include "stdafx.h"
22 #include "UITreeView.h"
23 #include "UIMessages.h"
24
25 #ifdef _DEBUG
26 #define new DEBUG_NEW
27 #undef THIS_FILE
28 static char THIS_FILE[] = __FILE__;
29 #endif
30
31 /////////////////////////////////////////////////////////////////////////////
32 // CUITreeView
33
34 IMPLEMENT_DYNAMIC(CUITreeView, CView)
35
36 CUITreeView::CUITreeView(UINT nID) : m_nID(nID), m_pTreeCtrl(NULL)
37 {
38         m_Style = WS_VISIBLE | /*WS_BORDER |*/ WS_CHILD | LVS_REPORT;
39 }
40
41 CUITreeView::~CUITreeView()
42 {
43         delete m_pTreeCtrl;
44 }
45
46 CUITreeCtrl &CUITreeView::GetTreeCtrl()
47 {
48         ASSERT(m_pTreeCtrl);
49         return *m_pTreeCtrl;
50 }
51
52 void CUITreeView::CreateTreeCtrl()
53 {
54         m_pTreeCtrl = new CUITreeCtrl;
55 }
56
57 void CUITreeView::SelectionChanged(const CRefresh &Refresh)
58 {
59 }
60
61 BEGIN_MESSAGE_MAP(CUITreeView, CView)
62         //{{AFX_MSG_MAP(CUITreeView)
63         ON_WM_CREATE()
64         ON_WM_SETFOCUS()
65         ON_WM_SIZE()
66         //}}AFX_MSG_MAP
67         ON_MESSAGE(WM_APP_UPDATE_ALL_VIEWS, OnAppUpdateAllViews)
68 END_MESSAGE_MAP()
69
70 /////////////////////////////////////////////////////////////////////////////
71 // CUITreeView drawing
72
73 void CUITreeView::OnDraw(CDC* pDC)
74 {
75         CDocument* pDoc = GetDocument();
76         // TODO: add draw code here
77 }
78
79 /////////////////////////////////////////////////////////////////////////////
80 // CUITreeView diagnostics
81
82 #ifdef _DEBUG
83 void CUITreeView::AssertValid() const
84 {
85         CView::AssertValid();
86 }
87
88 void CUITreeView::Dump(CDumpContext& dc) const
89 {
90         CView::Dump(dc);
91 }
92 #endif //_DEBUG
93
94 /////////////////////////////////////////////////////////////////////////////
95 // CUITreeView message handlers
96
97 int CUITreeView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
98 {
99         if (CView::OnCreate(lpCreateStruct) == -1)
100                 return -1;
101
102         CreateTreeCtrl();
103
104         if (GetTreeCtrl().Create(m_Style,CRect(0,0,0,0),this,m_nID) == -1)
105                 return -1;
106
107         return 0;
108 }
109
110 BOOL CUITreeView::PreCreateWindow(CREATESTRUCT& cs) 
111 {
112         // TODO: Add your specialized code here and/or call the base class
113         cs.lpszClass = AfxRegisterWndClass(
114                                   CS_DBLCLKS,                       
115                                   NULL,                             
116                                   NULL,                             
117                                   NULL); 
118         ASSERT(cs.lpszClass);
119         BOOL ret = CView::PreCreateWindow(cs);
120         cs.dwExStyle |= WS_EX_CLIENTEDGE;
121         return ret;
122 }
123
124 void CUITreeView::OnSetFocus(CWnd* pOldWnd) 
125 {
126         CView::OnSetFocus(pOldWnd);
127         
128         // TODO: Add your message handler code here
129         GetTreeCtrl().SetFocus();       
130 }
131
132 void CUITreeView::OnSize(UINT nType, int cx, int cy) 
133 {
134         CView::OnSize(nType, cx, cy);
135
136         // TODO: Add your message handler code here
137         if (GetTreeCtrl().GetSafeHwnd())
138                 GetTreeCtrl().MoveWindow(0,0,cx,cy);    
139 }
140
141 LRESULT CUITreeView::OnAppUpdateAllViews( WPARAM wParam, LPARAM lParam )
142 {
143         ASSERT(wParam);
144         GetDocument()->UpdateAllViews(NULL,wParam,(CObject*)lParam);
145         return 1L;
146 }
147
148 void CUITreeView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
149 {
150         // TODO: Add your specialized code here and/or call the base class
151         if (lHint == HINT_TREE_SEL_CHANGED)
152         {
153                 ASSERT(pHint);
154                 ASSERT_KINDOF(CRefresh,pHint);
155                 CRefresh *pRefresh = (CRefresh*)pHint;
156                 SelectionChanged(*pRefresh);
157         }       
158 }
159