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.

309 lines
8.0 KiB

  1. #include "MainForm.h"
  2. #include "LeftView.h"
  3. #include "RightTopView.h"
  4. #include "RightBottomView.h"
  5. #include "resource.h"
  6. IMPLEMENT_DYNCREATE( MainForm, CFrameWnd )
  7. BEGIN_MESSAGE_MAP( MainForm, CFrameWnd )
  8. ON_WM_CREATE()
  9. END_MESSAGE_MAP()
  10. MainForm::MainForm()
  11. {
  12. m_bAutoMenuEnable = FALSE;
  13. }
  14. int
  15. MainForm::OnCreate( LPCREATESTRUCT lpCreateStruct )
  16. {
  17. static const unsigned int indicator = ID_SEPARATOR;
  18. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  19. return -1;
  20. statusBar.Create( this );
  21. statusBar.SetIndicators( &indicator, 1 );
  22. #if 0
  23. if ( !toolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  24. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC)
  25. ||
  26. !toolBar.LoadToolBar(IDR_MAINFRAME) )
  27. return -1;
  28. #endif
  29. return 0;
  30. }
  31. BOOL MainForm::PreCreateWindow(CREATESTRUCT& cs)
  32. {
  33. if( !CFrameWnd::PreCreateWindow(cs) )
  34. return FALSE;
  35. // The following will prevent the "-" getting added to the window title
  36. cs.style &= ~FWS_ADDTOTITLE;
  37. return TRUE;
  38. }
  39. BOOL
  40. MainForm::OnCreateClient( LPCREATESTRUCT lpcs, CCreateContext* pContext )
  41. {
  42. #if 0
  43. // create the splitter window.
  44. // it is really a splitter within a splitter
  45. // ---------------------------------
  46. // | | List |
  47. // | | |
  48. // | | |
  49. // | Tree | |
  50. // | -----------------------|
  51. // | | Edit |
  52. // | | |
  53. // | | |
  54. // ---------------------------------
  55. // left pane is a treeview control
  56. // right pane is another splitter with listview control
  57. // and editview control.
  58. splitterWindow.CreateStatic( this, 1, 2 );
  59. // create left hand tree view.
  60. splitterWindow.CreateView( 0,
  61. 0,
  62. RUNTIME_CLASS( LeftView ),
  63. CSize( 300, 300 ),
  64. pContext );
  65. // create nested splitter.
  66. splitterWindow2.CreateStatic( &splitterWindow, 2, 1,
  67. WS_CHILD | WS_VISIBLE | WS_BORDER,
  68. splitterWindow.IdFromRowCol( 0, 1 )
  69. );
  70. splitterWindow2.CreateView( 0,
  71. 0,
  72. RUNTIME_CLASS( RightTopView ),
  73. CSize( 100, 400 ),
  74. pContext );
  75. splitterWindow2.CreateView( 1,
  76. 0,
  77. RUNTIME_CLASS( RightBottomView ),
  78. CSize( 100, 200 ),
  79. pContext );
  80. return TRUE;
  81. #else
  82. // create the splitter window.
  83. // it is really a splitter within a splitter
  84. // ---------------------------------
  85. // | | List |
  86. // | | |
  87. // | Tree | |
  88. // | | |
  89. // |-------------------------------|
  90. // | Edit |
  91. // | |
  92. // | |
  93. // ---------------------------------
  94. // left pane is a treeview control
  95. // right pane is another splitter with listview control
  96. // and bottom is editview control.
  97. splitterWindow.CreateStatic( this, 2, 1 );
  98. // create nested splitter.
  99. splitterWindow2.CreateStatic( &splitterWindow, 1, 2,
  100. WS_CHILD | WS_VISIBLE | WS_BORDER,
  101. splitterWindow.IdFromRowCol( 0, 0 )
  102. );
  103. splitterWindow2.CreateView( 0,
  104. 0,
  105. RUNTIME_CLASS( LeftView ),
  106. CSize( 0, 0 ),
  107. pContext );
  108. splitterWindow2.CreateView( 0,
  109. 1,
  110. RUNTIME_CLASS( RightTopView ),
  111. CSize( 0, 0 ),
  112. pContext );
  113. // create bottom text view
  114. splitterWindow.CreateView( 1,
  115. 0,
  116. RUNTIME_CLASS( RightBottomView ),
  117. CSize( 0, 0 ),
  118. pContext );
  119. // go for 30-70 split column split
  120. // and 60-40 row split.
  121. CRect rect;
  122. GetWindowRect( &rect );
  123. splitterWindow2.SetColumnInfo( 0, rect.Width() * 0.3, 10 );
  124. splitterWindow2.SetColumnInfo( 1, rect.Width() * 0.6, 10 );
  125. splitterWindow2.RecalcLayout();
  126. splitterWindow.SetRowInfo( 0, rect.Height() * 0.6, 10 );
  127. splitterWindow.SetRowInfo( 1, rect.Height() * 0.4, 10 );
  128. splitterWindow.RecalcLayout();
  129. return TRUE;
  130. #endif
  131. }
  132. void
  133. MainForm::clusterMenuClicked( CCmdUI* pCmdUI )
  134. {
  135. return;
  136. // find out what is present selection
  137. // whether cluster, world or host.
  138. // disable all menu items if current selection
  139. // not cluster level, else enable.
  140. //
  141. CTreeView* treeView = (CTreeView * ) splitterWindow2.GetPane( 0, 0 );
  142. // Find the item from TreeCtrl which has been selected.
  143. HTREEITEM hdlSelItem = treeView->GetTreeCtrl().GetSelectedItem();
  144. TVITEM selItem;
  145. selItem.hItem = hdlSelItem;
  146. selItem.mask = TVIF_IMAGE ;
  147. treeView->GetTreeCtrl().GetItem( &selItem );
  148. int level;
  149. switch( selItem.iImage )
  150. {
  151. case 0: // this is world level.
  152. level = 0;
  153. break;
  154. case 1: // this is some cluster
  155. level = 1;
  156. break;
  157. default: // this has to be host.
  158. level = 2;
  159. break;
  160. }
  161. if( level == 1 )
  162. {
  163. pCmdUI->m_pMenu->EnableMenuItem(
  164. ID_CLUSTER_ADD_HOST,
  165. MF_BYCOMMAND | MF_ENABLED );
  166. pCmdUI->m_pMenu->EnableMenuItem(
  167. ID_CLUSTER_REMOVE,
  168. MF_BYCOMMAND | MF_ENABLED );
  169. pCmdUI->m_pMenu->EnableMenuItem(
  170. ID_CLUSTER_PROPERTIES,
  171. MF_BYCOMMAND | MF_ENABLED );
  172. pCmdUI->m_pMenu->EnableMenuItem(
  173. ID_CLUSTER_UNMANAGE,
  174. MF_BYCOMMAND | MF_ENABLED );
  175. }
  176. else
  177. {
  178. pCmdUI->m_pMenu->EnableMenuItem(
  179. ID_CLUSTER_ADD_HOST,
  180. MF_BYCOMMAND | MF_GRAYED | MF_DISABLED );
  181. pCmdUI->m_pMenu->EnableMenuItem(
  182. ID_CLUSTER_REMOVE,
  183. MF_BYCOMMAND | MF_GRAYED | MF_DISABLED );
  184. pCmdUI->m_pMenu->EnableMenuItem(
  185. ID_CLUSTER_PROPERTIES,
  186. MF_BYCOMMAND | MF_GRAYED | MF_DISABLED );
  187. pCmdUI->m_pMenu->EnableMenuItem(
  188. ID_CLUSTER_UNMANAGE,
  189. MF_BYCOMMAND | MF_GRAYED | MF_DISABLED );
  190. }
  191. this->DrawMenuBar();
  192. }
  193. void
  194. MainForm::hostMenuClicked( CCmdUI* pCmdUI )
  195. {
  196. return;
  197. // find out what is present selection
  198. // whether cluster, world or host.
  199. // disable all menu items if current selection
  200. // not host level, else enable.
  201. //
  202. CTreeView* treeView = (CTreeView * ) splitterWindow2.GetPane( 0, 0 );
  203. // Find the item from TreeCtrl which has been selected.
  204. HTREEITEM hdlSelItem = treeView->GetTreeCtrl().GetSelectedItem();
  205. TVITEM selItem;
  206. selItem.hItem = hdlSelItem;
  207. selItem.mask = TVIF_IMAGE ;
  208. treeView->GetTreeCtrl().GetItem( &selItem );
  209. int level;
  210. switch( selItem.iImage )
  211. {
  212. case 0: // this is world level.
  213. level = 0;
  214. break;
  215. case 1: // this is some cluster
  216. level = 1;
  217. break;
  218. default: // this has to be host.
  219. level = 2;
  220. break;
  221. }
  222. if( level == 2 )
  223. {
  224. pCmdUI->m_pMenu->EnableMenuItem(
  225. pCmdUI->m_nID,
  226. // ID_HOST_REMOVE,
  227. MF_BYCOMMAND | MF_ENABLED );
  228. }
  229. else
  230. {
  231. pCmdUI->m_pMenu->EnableMenuItem(
  232. pCmdUI->m_nID,
  233. MF_BYCOMMAND | MF_GRAYED | MF_DISABLED );
  234. }
  235. this->DrawMenuBar();
  236. }