Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

515 lines
12 KiB

  1. /*******************************************************************************
  2. *
  3. * ltpane.cpp
  4. *
  5. * implementation of the CLeftPane class
  6. *
  7. * copyright notice: Copyright 1997, Citrix Systems Inc.
  8. * Copyright (c) 1998 - 1999 Microsoft Corporation
  9. *
  10. * $Author: donm $ Don Messerli
  11. *
  12. * $Log: N:\nt\private\utils\citrix\winutils\tsadmin\VCS\ltpane.cpp $
  13. *
  14. * Rev 1.4 19 Feb 1998 17:40:48 donm
  15. * removed latest extension DLL support
  16. *
  17. * Rev 1.2 19 Jan 1998 16:47:48 donm
  18. * new ui behavior for domains and servers
  19. *
  20. * Rev 1.1 03 Nov 1997 15:24:40 donm
  21. * added Domains
  22. *
  23. * Rev 1.0 13 Oct 1997 22:33:18 donm
  24. * Initial revision.
  25. *
  26. *******************************************************************************/
  27. #include "stdafx.h"
  28. #include "winadmin.h"
  29. #include "ltpane.h"
  30. #include "admindoc.h"
  31. #ifdef _DEBUG
  32. #define new DEBUG_NEW
  33. #undef THIS_FILE
  34. static char THIS_FILE[] = __FILE__;
  35. #endif
  36. ////////////////////////////
  37. // MESSAGE MAP: CLeftPane
  38. //
  39. IMPLEMENT_DYNCREATE(CLeftPane, CView)
  40. BEGIN_MESSAGE_MAP(CLeftPane, CView)
  41. //{{AFX_MSG_MAP(CLeftPane)
  42. ON_MESSAGE(WM_ADMIN_EXPANDALL, OnExpandAll)
  43. ON_MESSAGE(WM_ADMIN_COLLAPSEALL, OnCollapseAll)
  44. ON_MESSAGE(WM_ADMIN_COLLAPSETOSERVERS, OnCollapseToServers)
  45. ON_MESSAGE(WM_ADMIN_COLLAPSETODOMAINS, OnCollapseToDomains)
  46. ON_MESSAGE(WM_ADMIN_ADD_SERVER, OnAdminAddServer)
  47. ON_MESSAGE(WM_ADMIN_REMOVE_SERVER, OnAdminRemoveServer)
  48. ON_MESSAGE(WM_ADMIN_UPDATE_SERVER, OnAdminUpdateServer)
  49. ON_MESSAGE(WM_ADMIN_ADD_WINSTATION, OnAdminAddWinStation)
  50. ON_MESSAGE(WM_ADMIN_UPDATE_WINSTATION, OnAdminUpdateWinStation)
  51. ON_MESSAGE(WM_ADMIN_REMOVE_WINSTATION, OnAdminRemoveWinStation)
  52. ON_MESSAGE(WM_ADMIN_UPDATE_DOMAIN, OnAdminUpdateDomain)
  53. ON_MESSAGE(WM_ADMIN_ADD_DOMAIN, OnAdminAddDomain)
  54. ON_MESSAGE(WM_EXT_ADD_APPLICATION, OnExtAddApplication)
  55. ON_MESSAGE(WM_EXT_ADD_APP_SERVER, OnExtAddAppServer)
  56. ON_MESSAGE(WM_EXT_REMOVE_APP_SERVER, OnExtRemoveAppServer)
  57. ON_MESSAGE(WM_ADMIN_VIEWS_READY, OnAdminViewsReady)
  58. ON_NOTIFY(TCN_SELCHANGE, IDC_TREE_TABS, OnTabSelChange)
  59. ON_WM_SIZE()
  60. //}}AFX_MSG_MAP
  61. END_MESSAGE_MAP()
  62. /////////////////////////
  63. // F'N: CLeftPane cto
  64. //
  65. // - the view pointers are initially set to NULL
  66. //
  67. CLeftPane::CLeftPane()
  68. {
  69. m_pTabs = NULL;
  70. m_pTabFont = NULL;
  71. m_pServerTreeView = NULL;
  72. m_pAppTreeView = NULL;
  73. m_CurrTreeViewType = TREEVIEW_SERVERS;
  74. m_CurrTreeView = (CView*)m_pServerTreeView;
  75. } // end CLeftPane ctor
  76. ////////////////////////////
  77. // CLeftPane::OnDraw
  78. //
  79. void CLeftPane::OnDraw(CDC* pDC)
  80. {
  81. } // end CLeftPane::OnDraw
  82. /////////////////////////
  83. // CLeftPane dtor
  84. //
  85. CLeftPane::~CLeftPane()
  86. {
  87. if(m_pTabs) delete m_pTabs;
  88. if(m_pTabFont) delete m_pTabFont;
  89. } // end CLeftPane dtor
  90. #ifdef _DEBUG
  91. /////////////////////////////////
  92. // CLeftPane::AssertValid
  93. //
  94. void CLeftPane::AssertValid() const
  95. {
  96. CView::AssertValid();
  97. } // end CLeftPane::AssertValid
  98. //////////////////////////
  99. // CLeftPane::Dump
  100. //
  101. void CLeftPane::Dump(CDumpContext& dc) const
  102. {
  103. CView::Dump(dc);
  104. } // end CLeftPane::Dump
  105. #endif //_DEBUG
  106. /////////////////////////////////////
  107. // CLeftPane::OnInitialUpdate
  108. //
  109. // - each of the tree view objects is created
  110. // - the CTreeView object is initially the 'active' view in the left pane
  111. //
  112. void CLeftPane::OnInitialUpdate()
  113. {
  114. CView::OnInitialUpdate();
  115. CFrameWnd* pMainWnd = (CFrameWnd*)AfxGetMainWnd();
  116. CWinAdminDoc* pDoc = (CWinAdminDoc*)pMainWnd->GetActiveDocument();
  117. // create the Tabs
  118. m_pTabs = new CTreeTabCtrl;
  119. if(!m_pTabs) return;
  120. m_pTabs->Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP | TCS_BOTTOM | TCS_FORCEICONLEFT |TCS_FOCUSNEVER, CRect(0,0,0,0), this, IDC_TREE_TABS);
  121. m_pTabFont = new CFont;
  122. if(m_pTabFont) {
  123. m_pTabFont->CreateStockObject(DEFAULT_GUI_FONT);
  124. m_pTabs->SetFont(m_pTabFont, TRUE);
  125. }
  126. BuildImageList();
  127. TCHAR szTemp[40];
  128. CString tabString;
  129. tabString.LoadString(IDS_TAB_SERVERS);
  130. wcscpy(szTemp,tabString);
  131. TC_ITEM tc;
  132. tc.mask = TCIF_TEXT | TCIF_IMAGE;
  133. tc.pszText = szTemp;
  134. tc.iImage = m_idxServer;
  135. m_pTabs->InsertItem(0, &tc);
  136. tabString.LoadString(IDS_PUBLISHED_APPS); // should create a string for this tab (with spaces_
  137. wcscpy(szTemp,tabString);
  138. tc.pszText = szTemp;
  139. tc.iImage = m_idxApps;
  140. m_pTabs->InsertItem(1, &tc);
  141. m_pTabs->SetCurSel(0); // set the 'Servers' tab as the current one
  142. m_pServerTreeView = new CAdminTreeView();
  143. if(m_pServerTreeView) m_pServerTreeView->Create(NULL, NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, CRect(0, 0, 0, 0), m_pTabs, 0);
  144. m_pAppTreeView = new CAppTreeView();
  145. if(m_pAppTreeView) m_pAppTreeView->Create(NULL, NULL, WS_CHILD | WS_BORDER, CRect(0, 0, 0, 0), m_pTabs, 1);
  146. m_CurrTreeViewType = TREEVIEW_SERVERS;
  147. m_CurrTreeView = m_pServerTreeView;
  148. pDoc->AddView(m_pServerTreeView);
  149. pDoc->AddView(m_pAppTreeView);
  150. pDoc->UpdateAllViews(NULL);
  151. } // end CLeftPane::OnInitialUpdate
  152. /////////////////////////////////////
  153. // CLeftPane::BuildImageList
  154. //
  155. // - calls m_imageList.Create(..) to create the image list
  156. // - calls AddIconToImageList(..) to add the icons themselves and save
  157. // off their indices
  158. // - attaches the image list to the CTabCtrl
  159. //
  160. void CLeftPane::BuildImageList()
  161. {
  162. m_ImageList.Create(16, 16, TRUE, 2, 0);
  163. m_idxServer = AddIconToImageList(IDI_SERVER);
  164. m_idxApps = AddIconToImageList(IDI_APPS);
  165. m_pTabs->SetImageList(&m_ImageList);
  166. } // end CLeftPane::BuildImageList
  167. /////////////////////////////////////////
  168. // CLeftPane::AddIconToImageList
  169. //
  170. // - loads the appropriate icon, adds it to m_ImageList, and returns
  171. // the newly-added icon's index in the image list
  172. //
  173. int CLeftPane::AddIconToImageList(int iconID)
  174. {
  175. HICON hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(iconID));
  176. return m_ImageList.Add(hIcon);
  177. } // end CLeftPane::AddIconToImageList
  178. /////////////////////////////////////////
  179. // CLeftPane::OnTabSelChange
  180. //
  181. void CLeftPane::OnTabSelChange(NMHDR* pNMHDR, LRESULT* pResult)
  182. {
  183. // find out which tab is now selected
  184. int index = m_pTabs->GetCurSel();
  185. DWORD_PTR node;
  186. // switch to the appropriate tree
  187. switch(index) {
  188. case 0:
  189. // bring 'Servers' to the top
  190. m_pServerTreeView->ModifyStyle(WS_DISABLED, WS_VISIBLE);
  191. // hide the others
  192. m_pAppTreeView->ModifyStyle(WS_VISIBLE, WS_DISABLED);
  193. m_CurrTreeViewType = TREEVIEW_SERVERS;
  194. m_CurrTreeView = m_pServerTreeView;
  195. m_pServerTreeView->Invalidate();
  196. m_pServerTreeView->SetFocus();
  197. node = m_pServerTreeView->GetCurrentNode();
  198. break;
  199. case 1:
  200. // bring 'Published Applications' to the top
  201. m_pAppTreeView->ModifyStyle(WS_DISABLED, WS_VISIBLE);
  202. // hide the others
  203. m_pServerTreeView->ModifyStyle(WS_VISIBLE, WS_DISABLED);
  204. m_CurrTreeViewType = TREEVIEW_APPS;
  205. m_CurrTreeView = m_pAppTreeView;
  206. m_pAppTreeView->Invalidate();
  207. m_pAppTreeView->SetFocus();
  208. node = m_pAppTreeView->GetCurrentNode();
  209. break;
  210. }
  211. // Tell the document that the current item in the tree has changed
  212. ((CWinAdminDoc*)GetDocument())->SetCurrentView(VIEW_CHANGING);
  213. ((CWinAdminDoc*)GetDocument())->SetTreeCurrent(((CTreeNode*)node)->GetTreeObject(), ((CTreeNode*)node)->GetNodeType());
  214. CFrameWnd* pMainWnd = (CFrameWnd*)AfxGetMainWnd();
  215. // FALSE signifies that this was not caused by a mouse click on a tree item
  216. pMainWnd->PostMessage(WM_ADMIN_CHANGEVIEW, FALSE, node);
  217. *pResult = 0;
  218. } // end CLeftPane::OnTabSelChange
  219. ////////////////////////////
  220. // CLeftPane::OnSize
  221. //
  222. // - currently all views are sized to fit the view, whether they are 'active'
  223. // or not... this may change to sizing only the view that is 'active' if
  224. // it significantly impacts performance
  225. //
  226. void CLeftPane::OnSize(UINT nType, int cx, int cy)
  227. {
  228. RECT rect;
  229. GetClientRect(&rect);
  230. if(m_pTabs)
  231. if(m_pTabs->GetSafeHwnd())
  232. m_pTabs->MoveWindow(&rect, TRUE);
  233. CView::OnSize(nType, cx, cy);
  234. } // end CLeftPane::OnSize
  235. LRESULT CLeftPane::OnExpandAll(WPARAM wParam, LPARAM lParam)
  236. {
  237. // Send to the currently visible tree
  238. m_CurrTreeView->SendMessage(WM_ADMIN_EXPANDALL, wParam, lParam);
  239. return 0;
  240. }
  241. } // end CLeftPane::OnExpandAll
  242. ////////////////////////////
  243. // CLeftPane::OnCollapseAll
  244. //
  245. LRESULT CLeftPane::OnCollapseAll(WPARAM wParam, LPARAM lParam)
  246. {
  247. // Send to the currently visible tree
  248. m_CurrTreeView->SendMessage(WM_ADMIN_COLLAPSEALL, wParam, lParam);
  249. return 0;
  250. } // end CLeftPane::OnCollapseAll
  251. ////////////////////////////
  252. // CLeftPane::OnCollapseToServers
  253. //
  254. LRESULT CLeftPane::OnCollapseToServers(WPARAM wParam, LPARAM lParam)
  255. {
  256. // Send to the currently visible tree
  257. m_CurrTreeView->SendMessage(WM_ADMIN_COLLAPSETOSERVERS, wParam, lParam);
  258. return 0;
  259. } // end CLeftPane::OnCollapseToServers
  260. ////////////////////////////
  261. // CLeftPane::OnCollapseToDomains
  262. //
  263. LRESULT CLeftPane::OnCollapseToDomains(WPARAM wParam, LPARAM lParam)
  264. {
  265. m_pServerTreeView->SendMessage(WM_ADMIN_COLLAPSETODOMAINS, wParam, lParam);
  266. return 0;
  267. } // end CLeftPane::OnCollapseToDomains
  268. ////////////////////////////
  269. // CLeftPane::OnCollapseToApplications
  270. //
  271. LRESULT CLeftPane::OnCollapseToApplications(WPARAM wParam, LPARAM lParam)
  272. {
  273. if(m_pAppTreeView)
  274. m_pAppTreeView->SendMessage(WM_ADMIN_COLLAPSETODOMAINS, wParam, lParam);
  275. return 0;
  276. } // end CLeftPane::OnCollapseToApplications
  277. LRESULT CLeftPane::OnAdminAddServer(WPARAM wParam, LPARAM lParam)
  278. {
  279. m_pServerTreeView->SendMessage(WM_ADMIN_ADD_SERVER, wParam, lParam);
  280. return 0;
  281. }
  282. LRESULT CLeftPane::OnAdminRemoveServer(WPARAM wParam, LPARAM lParam)
  283. {
  284. m_pServerTreeView->SendMessage(WM_ADMIN_REMOVE_SERVER, wParam, lParam);
  285. return 0;
  286. }
  287. LRESULT CLeftPane::OnAdminUpdateServer(WPARAM wParam, LPARAM lParam)
  288. {
  289. m_pServerTreeView->SendMessage(WM_ADMIN_UPDATE_SERVER, wParam, lParam);
  290. return 0;
  291. }
  292. ////////////////////////////
  293. // CLeftPane::OnAdminAddWinStation
  294. //
  295. LRESULT CLeftPane::OnAdminAddWinStation(WPARAM wParam, LPARAM lParam)
  296. {
  297. m_pServerTreeView->SendMessage(WM_ADMIN_ADD_WINSTATION, wParam, lParam);
  298. return 0;
  299. } // end CLeftPane::OnAdminAddWinStation
  300. ////////////////////////////
  301. // CLeftPane::OnAdminUpdateWinStation
  302. //
  303. LRESULT CLeftPane::OnAdminUpdateWinStation(WPARAM wParam, LPARAM lParam)
  304. {
  305. m_pServerTreeView->SendMessage(WM_ADMIN_UPDATE_WINSTATION, wParam, lParam);
  306. return 0;
  307. } // end CLeftPane::OnAdminUpdateWinStation
  308. ////////////////////////////
  309. // CLeftPane::OnAdminRemoveWinStation
  310. //
  311. LRESULT CLeftPane::OnAdminRemoveWinStation(WPARAM wParam, LPARAM lParam)
  312. {
  313. m_pServerTreeView->SendMessage(WM_ADMIN_REMOVE_WINSTATION, wParam, lParam);
  314. return 0;
  315. } // end CLeftPane::OnAdminRemoveWinStation
  316. ////////////////////////////
  317. // CLeftPane::OnAdminUpdateDomain
  318. //
  319. LRESULT CLeftPane::OnAdminUpdateDomain(WPARAM wParam, LPARAM lParam)
  320. {
  321. m_pServerTreeView->SendMessage(WM_ADMIN_UPDATE_DOMAIN, wParam, lParam);
  322. return 0;
  323. } // end CLeftPane::OnAdminUpdateDomain
  324. ////////////////////////////
  325. // CLeftPane::OnAdminAddDomain
  326. //
  327. LRESULT CLeftPane::OnAdminAddDomain(WPARAM wParam, LPARAM lParam)
  328. {
  329. ASSERT(lParam);
  330. return m_pServerTreeView->SendMessage(WM_ADMIN_ADD_DOMAIN, wParam, lParam);
  331. } // end CLeftPane::OnAdminAddDomain
  332. LRESULT CLeftPane::OnExtAddApplication(WPARAM wParam, LPARAM lParam)
  333. {
  334. m_pAppTreeView->SendMessage(WM_EXT_ADD_APPLICATION, wParam, lParam);
  335. return 0;
  336. }
  337. LRESULT CLeftPane::OnExtAddAppServer(WPARAM wParam, LPARAM lParam)
  338. {
  339. m_pAppTreeView->SendMessage(WM_EXT_ADD_APP_SERVER, wParam, lParam);
  340. return 0;
  341. }
  342. CTreeTabCtrl::CTreeTabCtrl()
  343. {
  344. }
  345. CTreeTabCtrl::~CTreeTabCtrl()
  346. {
  347. }
  348. BEGIN_MESSAGE_MAP(CTreeTabCtrl, CTabCtrl)
  349. //{{AFX_MSG_MAP(CTreeTabCtrl)
  350. ON_WM_SIZE()
  351. // ON_NOTIFY_REFLECT(TCN_SELCHANGE, OnSelchange)
  352. //}}AFX_MSG_MAP
  353. END_MESSAGE_MAP()
  354. void CTreeTabCtrl::Initialize()
  355. {
  356. }
  357. void CTreeTabCtrl::OnSize(UINT nType, int cx, int cy)
  358. {
  359. CTabCtrl::OnSize(nType, cx, cy);
  360. CRect rcTabCtrl(0,0,cx,cy);
  361. AdjustRect(FALSE,&rcTabCtrl);
  362. CWnd* pWnd = GetDlgItem(0);
  363. if(pWnd) {
  364. pWnd->MoveWindow(&rcTabCtrl);
  365. }
  366. pWnd = GetDlgItem(1);
  367. if(pWnd) {
  368. pWnd->MoveWindow(&rcTabCtrl);
  369. }
  370. }
  371. #ifdef _DEBUG
  372. void CTreeTabCtrl::AssertValid() const
  373. {
  374. }
  375. void CTreeTabCtrl::Dump(CDumpContext& dc) const
  376. {
  377. }
  378. #endif
  379. void CTreeTabCtrl::OnDraw(CDC* pDC)
  380. {
  381. }