Leaked source code of windows server 2003
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.

218 lines
5.0 KiB

  1. // ChildFrm.cpp : implementation of the CChildFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "ncbrowse.h"
  5. #include "ChildFrm.h"
  6. #include "LeftView.h"
  7. #include "NCEditView.h"
  8. #include "ncbrowseView.h"
  9. #include <afxext.h>
  10. #include "SplitterView.h"
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CChildFrame
  18. IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
  19. BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
  20. //{{AFX_MSG_MAP(CChildFrame)
  21. // NOTE - the ClassWizard will add and remove mapping macros here.
  22. // DO NOT EDIT what you see in these blocks of generated code !
  23. //}}AFX_MSG_MAP
  24. ON_UPDATE_COMMAND_UI_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnUpdateViewStyles)
  25. ON_COMMAND_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnViewStyle)
  26. END_MESSAGE_MAP()
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CChildFrame construction/destruction
  29. CChildFrame::CChildFrame()
  30. {
  31. // TODO: add member initialization code here
  32. }
  33. CChildFrame::~CChildFrame()
  34. {
  35. }
  36. BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
  37. CCreateContext* pContext)
  38. {
  39. // create splitter window
  40. if (!m_wndSplitterTB.CreateStatic(this, 2, 1))
  41. return FALSE;
  42. if (!m_wndSplitterTB.CreateView(0, 0, RUNTIME_CLASS(CSplitterView), CSize(500, 250), pContext) ||
  43. !m_wndSplitterTB.CreateView(1, 0, RUNTIME_CLASS(CNCEditView), CSize(200, 250), pContext) )
  44. {
  45. m_wndSplitterTB.DestroyWindow();
  46. return FALSE;
  47. }
  48. return TRUE;
  49. }
  50. BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
  51. {
  52. // TODO: Modify the Window class or styles here by modifying
  53. // the CREATESTRUCT cs
  54. if( !CMDIChildWnd::PreCreateWindow(cs) )
  55. return FALSE;
  56. return TRUE;
  57. }
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CChildFrame diagnostics
  60. #ifdef _DEBUG
  61. void CChildFrame::AssertValid() const
  62. {
  63. CMDIChildWnd::AssertValid();
  64. }
  65. void CChildFrame::Dump(CDumpContext& dc) const
  66. {
  67. CMDIChildWnd::Dump(dc);
  68. }
  69. #endif //_DEBUG
  70. /////////////////////////////////////////////////////////////////////////////
  71. // CChildFrame message handlers
  72. CNcbrowseView* CChildFrame::GetRightPane()
  73. {
  74. CWnd* pWnd = m_wndSplitterTB.GetPane(0, 0);
  75. CSplitterView* pSplitterView = DYNAMIC_DOWNCAST(CSplitterView, pWnd);
  76. CWnd* pWndSplitter = pSplitterView->m_wndSplitterLR.GetPane(0, 1);
  77. CNcbrowseView* pView = DYNAMIC_DOWNCAST(CNcbrowseView, pWndSplitter);
  78. return pView;
  79. }
  80. CNCEditView* CChildFrame::GetLowerPane()
  81. {
  82. CWnd* pWnd = m_wndSplitterTB.GetPane(1, 0);
  83. CNCEditView* pView = DYNAMIC_DOWNCAST(CNCEditView, pWnd);
  84. return pView;
  85. }
  86. void CChildFrame::OnUpdateViewStyles(CCmdUI* pCmdUI)
  87. {
  88. // TODO: customize or extend this code to handle choices on the
  89. // View menu.
  90. CNcbrowseView* pView = GetRightPane();
  91. // if the right-hand pane hasn't been created or isn't a view,
  92. // disable commands in our range
  93. if (pView == NULL)
  94. pCmdUI->Enable(FALSE);
  95. else
  96. {
  97. DWORD dwStyle = pView->GetStyle() & LVS_TYPEMASK;
  98. // if the command is ID_VIEW_LINEUP, only enable command
  99. // when we're in LVS_ICON or LVS_SMALLICON mode
  100. if (pCmdUI->m_nID == ID_VIEW_LINEUP)
  101. {
  102. if (dwStyle == LVS_ICON || dwStyle == LVS_SMALLICON)
  103. pCmdUI->Enable();
  104. else
  105. pCmdUI->Enable(FALSE);
  106. }
  107. else
  108. {
  109. // otherwise, use dots to reflect the style of the view
  110. pCmdUI->Enable();
  111. BOOL bChecked = FALSE;
  112. switch (pCmdUI->m_nID)
  113. {
  114. case ID_VIEW_DETAILS:
  115. bChecked = (dwStyle == LVS_REPORT);
  116. break;
  117. case ID_VIEW_SMALLICON:
  118. bChecked = (dwStyle == LVS_SMALLICON);
  119. break;
  120. case ID_VIEW_LARGEICON:
  121. bChecked = (dwStyle == LVS_ICON);
  122. break;
  123. case ID_VIEW_LIST:
  124. bChecked = (dwStyle == LVS_LIST);
  125. break;
  126. default:
  127. bChecked = FALSE;
  128. break;
  129. }
  130. pCmdUI->SetRadio(bChecked ? 1 : 0);
  131. }
  132. }
  133. }
  134. void CChildFrame::OnViewStyle(UINT nCommandID)
  135. {
  136. // TODO: customize or extend this code to handle choices on the
  137. // View menu.
  138. CNcbrowseView* pView = GetRightPane();
  139. // if the right-hand pane has been created and is a CNcbrowseView,
  140. // process the menu commands...
  141. if (pView != NULL)
  142. {
  143. DWORD dwStyle = -1;
  144. switch (nCommandID)
  145. {
  146. case ID_VIEW_LINEUP:
  147. {
  148. // ask the list control to snap to grid
  149. CListCtrl& refListCtrl = pView->GetListCtrl();
  150. refListCtrl.Arrange(LVA_SNAPTOGRID);
  151. }
  152. break;
  153. // other commands change the style on the list control
  154. case ID_VIEW_DETAILS:
  155. dwStyle = LVS_REPORT;
  156. break;
  157. case ID_VIEW_SMALLICON:
  158. dwStyle = LVS_SMALLICON;
  159. break;
  160. case ID_VIEW_LARGEICON:
  161. dwStyle = LVS_ICON;
  162. break;
  163. case ID_VIEW_LIST:
  164. dwStyle = LVS_LIST;
  165. break;
  166. }
  167. // change the style; window will repaint automatically
  168. if (dwStyle != -1)
  169. pView->ModifyStyle(LVS_TYPEMASK, dwStyle);
  170. }
  171. }