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.

356 lines
8.8 KiB

  1. /*******************************************************************************
  2. *
  3. * appview.cpp
  4. *
  5. * implementation of the CApplicationView 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\appview.cpp $
  13. *
  14. * Rev 1.3 16 Feb 1998 16:00:26 donm
  15. * modifications to support pICAsso extension
  16. *
  17. * Rev 1.2 03 Nov 1997 15:20:32 donm
  18. * update
  19. *
  20. * Rev 1.1 22 Oct 1997 21:06:22 donm
  21. * update
  22. *
  23. * Rev 1.0 16 Oct 1997 14:00:06 donm
  24. * Initial revision.
  25. *
  26. *******************************************************************************/
  27. #include "stdafx.h"
  28. #include "resource.h"
  29. #include "appview.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: CApplicationView
  38. //
  39. IMPLEMENT_DYNCREATE(CApplicationView, CView)
  40. BEGIN_MESSAGE_MAP(CApplicationView, CView)
  41. //{{AFX_MSG_MAP(CApplicationView)
  42. ON_WM_SIZE()
  43. ON_WM_CREATE()
  44. //}}AFX_MSG_MAP
  45. ON_NOTIFY(TCN_SELCHANGE, 0, OnTabSelChange)
  46. ON_MESSAGE(WM_ADMIN_UPDATE_WINSTATIONS, OnAdminUpdateWinStations)
  47. ON_MESSAGE(WM_ADMIN_UPDATE_SERVER_INFO, OnAdminUpdateServerInfo)
  48. ON_MESSAGE(WM_EXT_ADD_APP_SERVER, OnExtAddAppServer)
  49. ON_MESSAGE(WM_EXT_REMOVE_APP_SERVER, OnExtRemoveAppServer)
  50. ON_MESSAGE(WM_EXT_APP_CHANGED, OnExtAppChanged)
  51. END_MESSAGE_MAP()
  52. PageDef CApplicationView::pages[NUMBER_OF_APP_PAGES] = {
  53. { NULL, RUNTIME_CLASS( CApplicationServersPage ), IDS_TAB_SERVERS, PAGE_APP_SERVERS, NULL },
  54. { NULL, RUNTIME_CLASS( CApplicationUsersPage ), IDS_TAB_USERS, PAGE_APP_USERS, NULL },
  55. { NULL, RUNTIME_CLASS( CApplicationInfoPage ), IDS_TAB_INFO, PAGE_APP_INFO, NULL }
  56. };
  57. ///////////////////////
  58. // F'N: CApplicationView ctor
  59. //
  60. CApplicationView::CApplicationView()
  61. {
  62. m_pTabs = NULL;
  63. m_pTabFont = NULL;
  64. m_pApplication = NULL;
  65. m_CurrPage = PAGE_APP_SERVERS;
  66. } // end CApplicationView ctor
  67. ///////////////////////
  68. // F'N: CApplicationView dtor
  69. //
  70. CApplicationView::~CApplicationView()
  71. {
  72. if(m_pTabs) delete m_pTabs;
  73. if(m_pTabFont) delete m_pTabFont;
  74. } // end CApplicationView dtor
  75. #ifdef _DEBUG
  76. ///////////////////////////////
  77. // F'N: CApplicationView::AssertValid
  78. //
  79. void CApplicationView::AssertValid() const
  80. {
  81. CView::AssertValid();
  82. } // end CApplicationView::AssertValid
  83. ////////////////////////
  84. // F'N: CApplicationView::Dump
  85. //
  86. void CApplicationView::Dump(CDumpContext& dc) const
  87. {
  88. CView::Dump(dc);
  89. } // end CApplicationView::Dump
  90. #endif //_DEBUG
  91. ////////////////////////////
  92. // F'N: CApplicationView::OnCreate
  93. //
  94. int CApplicationView::OnCreate(LPCREATESTRUCT lpCreateStruct)
  95. {
  96. if (CView::OnCreate(lpCreateStruct) == -1)
  97. return -1;
  98. return 0;
  99. } // end CApplicationView::OnCreate
  100. ///////////////////////////////////
  101. // F'N: CApplicationView::OnInitialUpdate
  102. //
  103. // - pointers to the pages of the sheet are obtained
  104. //
  105. void CApplicationView::OnInitialUpdate()
  106. {
  107. // create the tab control
  108. m_pTabs = new CTabCtrl;
  109. if(!m_pTabs) return;
  110. m_pTabs->Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP, CRect(0,0,0,0), this, 0);
  111. m_pTabFont = new CFont;
  112. if(m_pTabFont) {
  113. m_pTabFont->CreateStockObject(DEFAULT_GUI_FONT);
  114. m_pTabs->SetFont(m_pTabFont, TRUE);
  115. }
  116. TCHAR szTemp[40];
  117. CString tabString;
  118. int index = 0;
  119. for(int i = 0; i < NUMBER_OF_APP_PAGES; i++) {
  120. // If the page is shown under Picasso only and we're not running
  121. // under Picasso, skip to the next one
  122. if((pages[i].flags & PF_PICASSO_ONLY) && !((CWinAdminApp*)AfxGetApp())->IsPicasso()) continue;
  123. if(!(pages[i].flags & PF_NO_TAB)) {
  124. tabString.LoadString(pages[i].tabStringID);
  125. wcscpy(szTemp,tabString);
  126. AddTab(index, szTemp);
  127. index++;
  128. }
  129. pages[i].m_pPage = (CAdminPage*)pages[i].m_pRuntimeClass->CreateObject();
  130. pages[i].m_pPage->Create(NULL, NULL, WS_CHILD, CRect(0, 0, 0, 0), this, i, NULL);
  131. GetDocument()->AddView(pages[i].m_pPage);
  132. }
  133. m_pTabs->SetCurSel(0);
  134. m_CurrPage = PAGE_APP_SERVERS;
  135. OnChangePage(NULL, NULL);
  136. } // end CApplicationView::OnInitialUpdate
  137. //////////////////////////
  138. // F'N: CApplicationView::OnSize
  139. //
  140. // - size the pages to fill the entire view
  141. //
  142. void CApplicationView::OnSize(UINT nType, int cx, int cy)
  143. {
  144. RECT rect;
  145. GetClientRect(&rect);
  146. if(m_pTabs->GetSafeHwnd()) { // make sure the tabs object is valid
  147. m_pTabs->MoveWindow(&rect, TRUE); // size the tabs
  148. // for the next part (sizing of pages), we might want to add a member var
  149. // that keeps track of which page/tab is current... this way we could
  150. // only actually do a redraw (MoveWindow second parm == TRUE) for the
  151. // guy who is currently visible--DJM
  152. // we want to size the pages, too
  153. m_pTabs->AdjustRect(FALSE, &rect);
  154. for(int i = 0; i < NUMBER_OF_APP_PAGES; i++) {
  155. if(pages[i].m_pPage && pages[i].m_pPage->GetSafeHwnd())
  156. pages[i].m_pPage->MoveWindow(&rect, TRUE);
  157. }
  158. }
  159. } // end CApplicationView::OnSize
  160. //////////////////////////
  161. // F'N: CApplicationView::OnDraw
  162. //
  163. // - the CApplicationView and it's pages draw themselves, so there isn't anything
  164. // to do here...
  165. //
  166. void CApplicationView::OnDraw(CDC* pDC)
  167. {
  168. CDocument* pDoc = GetDocument();
  169. // TODO: add draw code here
  170. } // end CApplicationView::OnDraw
  171. /////////////////////////
  172. // F'N: CApplicationView::Reset
  173. //
  174. // - 'resets' the view by taking a pointer to a CPublishedApp object and filling in
  175. // the various property pages with info appropriate to that Application
  176. //
  177. void CApplicationView::Reset(void *pApplication)
  178. {
  179. ASSERT(pApplication);
  180. m_pApplication = (CPublishedApp*)pApplication;
  181. for(int i = 0; i < NUMBER_OF_APP_PAGES; i++) {
  182. if(pages[i].m_pPage)
  183. pages[i].m_pPage->Reset(pApplication);
  184. }
  185. ((CWinAdminDoc*)GetDocument())->SetCurrentPage(m_CurrPage);
  186. } // end CApplicationView::Reset
  187. //////////////////////////
  188. // F'N: CApplicationView::AddTab
  189. //
  190. void CApplicationView::AddTab(int index, TCHAR* text)
  191. {
  192. TC_ITEM tc;
  193. tc.mask = TCIF_TEXT;
  194. tc.pszText = text;
  195. m_pTabs->InsertItem(index, &tc);
  196. } // end CApplicationView::AddTab
  197. ////////////////////////////////
  198. // F'N: CApplicationView::OnChangePage
  199. //
  200. // - changes to a new Application page based on currently selected tab
  201. // - OnChangePage needs to force recalculation of scroll bars!!!--DJM
  202. //
  203. LRESULT CApplicationView::OnChangePage(WPARAM wParam, LPARAM lParam)
  204. {
  205. // find out which tab is now selected
  206. int index = m_pTabs->GetCurSel();
  207. // hide the current page
  208. pages[m_CurrPage].m_pPage->ModifyStyle(WS_VISIBLE, WS_DISABLED);
  209. m_CurrPage = index;
  210. ((CWinAdminDoc*)GetDocument())->SetCurrentPage(m_CurrPage);
  211. // show the new page
  212. pages[index].m_pPage->ModifyStyle(WS_DISABLED, WS_VISIBLE);
  213. pages[index].m_pPage->ScrollToPosition(CPoint(0,0));
  214. pages[index].m_pPage->Invalidate();
  215. pages[index].m_pPage->SetFocus();
  216. return 0;
  217. } // end CApplicationView::OnChangeview
  218. //////////////////////////
  219. // F'N: CApplicationView::OnTabSelChange
  220. //
  221. void CApplicationView::OnTabSelChange(NMHDR* pNMHDR, LRESULT* pResult)
  222. {
  223. OnChangePage(NULL, NULL);
  224. *pResult = 0;
  225. } // end CApplicationView::OnTabSelChange
  226. ////////////////////////////////
  227. // F'N: CApplicationView::OnAdminUpdateWinStations
  228. //
  229. //
  230. LRESULT CApplicationView::OnAdminUpdateWinStations(WPARAM wParam, LPARAM lParam)
  231. {
  232. ((CApplicationUsersPage*)pages[PAGE_APP_USERS].m_pPage)->UpdateWinStations((CServer*)lParam);
  233. return 0;
  234. } // end CApplicationView::OnAdminUpdateWinStations
  235. ////////////////////////////////
  236. // F'N: CApplicationView::OnAdminUpdateServerInfo
  237. //
  238. //
  239. LRESULT CApplicationView::OnAdminUpdateServerInfo(WPARAM wParam, LPARAM lParam)
  240. {
  241. ((CApplicationServersPage*)pages[PAGE_APP_SERVERS].m_pPage)->UpdateServer((CServer*)lParam);
  242. return 0;
  243. } // end CApplicationView::OnAdminUpdateWinStations
  244. ////////////////////////////////
  245. // F'N: CApplicationView::OnExtAddAppServer
  246. //
  247. //
  248. LRESULT CApplicationView::OnExtAddAppServer(WPARAM wParam, LPARAM lParam)
  249. {
  250. if(m_pApplication == (CPublishedApp*)((ExtAddTreeNode*)wParam)->pParent) {
  251. ((CApplicationServersPage*)pages[PAGE_APP_SERVERS].m_pPage)->AddServer((CAppServer*)lParam);
  252. }
  253. return 0;
  254. } // end CApplicationView::OnExtAddAppServer
  255. ////////////////////////////////
  256. // F'N: CApplicationView::OnExtRemoveAppServer
  257. //
  258. //
  259. LRESULT CApplicationView::OnExtRemoveAppServer(WPARAM wParam, LPARAM lParam)
  260. {
  261. if(m_pApplication == (CPublishedApp*)wParam) {
  262. ((CApplicationServersPage*)pages[PAGE_APP_SERVERS].m_pPage)->RemoveServer((CAppServer*)lParam);
  263. }
  264. return 0;
  265. } // end CApplicationView::OnExtAppChanged
  266. ////////////////////////////////
  267. // F'N: CApplicationView::OnExtAppChanged
  268. //
  269. //
  270. LRESULT CApplicationView::OnExtAppChanged(WPARAM wParam, LPARAM lParam)
  271. {
  272. if(m_pApplication == (CPublishedApp*)lParam) {
  273. ((CApplicationInfoPage*)pages[PAGE_APP_INFO].m_pPage)->Reset((CPublishedApp*)lParam);
  274. }
  275. return 0;
  276. } // end CApplicationView::OnExtAppChanged