HeaderFooterView.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:29k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // HeaderFooterView.cpp : implementation file
  2. //
  3. // This file is a part of the XTREME TOOLKIT PRO MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "reportsample.h"
  22. #include "HeaderFooterView.h"
  23. #include "ReportSampleView.h"
  24. #include "TaskListView.h"
  25. #if _MSC_VER >= 1200 // MFC 6.0
  26. #include <afxdtctl.h>       // MFC support for Internet Explorer 4 Common Controls
  27. #endif
  28. #ifdef _DEBUG
  29. #define new DEBUG_NEW
  30. #undef THIS_FILE
  31. static char THIS_FILE[] = __FILE__;
  32. #endif
  33. #if _MSC_VER >= 1200 // MFC 6.0
  34. //////////////////////////////////////////////////////////////////////////
  35. class CMonthCalCtrlEx2 : public CMonthCalCtrl
  36. {
  37. public:
  38. BOOL GoModal(const CPoint& pt, CWnd* pParentWnd, COleDateTime& rdtDate);
  39. protected:
  40. afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  41. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  42. afx_msg void OnSelChange(NMHDR* pNMHdr, LRESULT* pResult);
  43. DECLARE_MESSAGE_MAP()
  44. };
  45. BEGIN_MESSAGE_MAP(CMonthCalCtrlEx2, CMonthCalCtrl)
  46. ON_WM_LBUTTONDOWN()
  47. ON_WM_KEYDOWN()
  48. ON_NOTIFY_REFLECT(MCN_SELECT, OnSelChange)
  49. END_MESSAGE_MAP()
  50. #endif
  51. //////////////////////////////////////////////////////////////////////////
  52. // CHeaderFooterFrame
  53. BEGIN_MESSAGE_MAP(CHeaderFooterFrame, CFrameWnd)
  54. //{{AFX_MSG_MAP(CHeaderFooterFrame)
  55. // NOTE - the ClassWizard will add and remove mapping macros here.
  56. //    DO NOT EDIT what you see in these blocks of generated code !
  57. ON_WM_CREATE()
  58. ON_WM_DESTROY()
  59. //}}AFX_MSG_MAP    
  60. END_MESSAGE_MAP()
  61. static UINT indicators[] =
  62. {
  63. ID_SEPARATOR,           // status line indicator
  64. ID_INDICATOR_CAPS,
  65. ID_INDICATOR_NUM,
  66. ID_INDICATOR_SCRL,
  67. };
  68. #define COLUMN_TYPE             0
  69. #define COLUMN_IMPORTANCE       1
  70. #define COLUMN_ATTACHMENT       2
  71. #define COLUMN_STATUS           3
  72. #define COLUMN_SUBJECT          4
  73. #define COLUMN_DUE_DATE         5
  74. #define COLUMN_COMPLETE         6
  75. #define COLUMN_CATEGORIES       7
  76. int CHeaderFooterFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  77. {
  78. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  79. return -1;
  80. if (!m_wndStatusBar.Create(this) ||
  81. !m_wndStatusBar.SetIndicators(indicators,
  82.   sizeof(indicators)/sizeof(UINT)))
  83. {
  84. TRACE0("Failed to create status barn");
  85. return -1;      // fail to create
  86. }
  87. if (!InitCommandBars())
  88. return -1;
  89. CXTPCommandBars* pCommandBars = GetCommandBars();
  90. pCommandBars->SetMenu(_T("Menu Bar"), IDR_HEADERFOOTER);
  91. return 0;
  92. }
  93. void CHeaderFooterFrame::OnDestroy()
  94. {
  95. ((CReportSampleView*)m_pOwnerView)->m_pHeaderFooterFrame = NULL;
  96. CFrameWnd::OnDestroy();
  97. }
  98. /////////////////////////////////////////////////////////////////////////////
  99. // CHeaderFooterView
  100. IMPLEMENT_DYNCREATE(CHeaderFooterView, CXTPReportView)
  101. CHeaderFooterView::CHeaderFooterView()
  102. {
  103. }
  104. CHeaderFooterView::~CHeaderFooterView()
  105. {
  106. }
  107. BEGIN_MESSAGE_MAP(CHeaderFooterView, CXTPReportView)
  108. //{{AFX_MSG_MAP(CHeaderFooterView)
  109. ON_WM_CREATE()
  110. ON_COMMAND(ID_REPORTCONTROL_SHOWHEADERRECORDS, OnShowHeaderRecords)
  111. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_SHOWHEADERRECORDS, OnUpdateShowHeaderRecords)
  112. ON_COMMAND(ID_REPORTCONTROL_HEADERRECORDS_EDIT, OnHeaderRecordsAllowEdit)
  113. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_HEADERRECORDS_EDIT, OnUpdateHeaderRecordsAllowEdit)
  114. ON_COMMAND(ID_REPORTCONTROL_SHOWFOOTERRECORDS, OnShowFooterRecords)
  115. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_SHOWFOOTERRECORDS, OnUpdateShowFooterRecords)
  116. ON_COMMAND(ID_REPORTCONTROL_FOOTERRECORDS_EDIT, OnFooterRecordsAllowEdit)
  117. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_FOOTERRECORDS_EDIT, OnUpdateFooterRecordsAllowEdit)
  118. ON_COMMAND(ID_REPORTCONTROL_PIN_FOOTER, OnPinFooterRows)
  119. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_PIN_FOOTER, OnUpdatePinFooterRows)
  120. ON_COMMAND(ID_REPORTCONTROL_DRAW_GRID_EMPTY, OnDrawGridForEmpty)
  121. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_DRAW_GRID_EMPTY, OnUpdateDrawGridForEmpty)
  122. ON_COMMAND(ID_REPORTCONTROL_MOVEINHEADER, OnMoveInHeader)
  123. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_MOVEINHEADER, OnUpdateMoveInHeader)
  124. ON_COMMAND(ID_REPORTCONTROL_MOVEINFOOTER, OnMoveInFooter)
  125. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_MOVEINFOOTER, OnUpdateMoveInFooter)
  126. ON_COMMAND(ID_REPORTCONTROL_HDIV_THIN, OnHeaderDividerStyleThin)
  127. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_HDIV_THIN, OnUpdateHeaderDividerStyleThin)
  128. ON_COMMAND(ID_REPORTCONTROL_HDIV_BOLD, OnHeaderDividerStyleBold)
  129. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_HDIV_BOLD, OnUpdateHeaderDividerStyleBold)
  130. ON_COMMAND(ID_REPORTCONTROL_HDIV_SHADE, OnHeaderDividerStyleShade)
  131. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_HDIV_SHADE, OnUpdateHeaderDividerStyleShade)
  132. ON_COMMAND(ID_REPORTCONTROL_HDIV_NONE, OnHeaderDividerStyleNone)
  133. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_HDIV_NONE, OnUpdateHeaderDividerStyleNone)
  134. ON_COMMAND(ID_REPORTCONTROL_HDIV_OUTLOOK, OnHeaderDividerStyleOutlook)
  135. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_HDIV_OUTLOOK, OnUpdateHeaderDividerStyleOutlook)
  136. ON_COMMAND(ID_REPORTCONTROL_FDIV_THIN, OnFooterDividerStyleThin)
  137. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_FDIV_THIN, OnUpdateFooterDividerStyleThin)
  138. ON_COMMAND(ID_REPORTCONTROL_FDIV_BOLD, OnFooterDividerStyleBold)
  139. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_FDIV_BOLD, OnUpdateFooterDividerStyleBold)
  140. ON_COMMAND(ID_REPORTCONTROL_FDIV_SHADE, OnFooterDividerStyleShade)
  141. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_FDIV_SHADE, OnUpdateFooterDividerStyleShade)
  142. ON_COMMAND(ID_REPORTCONTROL_FDIV_NONE, OnFooterDividerStyleNone)
  143. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_FDIV_NONE, OnUpdateFooterDividerStyleNone)
  144. ON_COMMAND(ID_REPORTCONTROL_FDIV_OUTLOOK, OnFooterDividerStyleOutlook)
  145. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_FDIV_OUTLOOK, OnUpdateFooterDividerStyleOutlook)
  146. ON_COMMAND(ID_REPORTCONTROL_COLUMNS_SHADED, OnColumnsStyleShaded)
  147. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_COLUMNS_SHADED, OnUpdateColumnsStyleShaded)
  148. ON_COMMAND(ID_REPORTCONTROL_COLUMNS_FLAT, OnColumnsStyleFlat)
  149. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_COLUMNS_FLAT, OnUpdateColumnsStyleFlat)
  150. ON_COMMAND(ID_REPORTCONTROL_COLUMNS_EXPLORER, OnColumnsStyleExplorer)
  151. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_COLUMNS_EXPLORER, OnUpdateColumnsStyleExplorer)
  152. ON_COMMAND(ID_REPORTCONTROL_COLUMNS_OFFICE2003, OnColumnsStyleOffice2003)
  153. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_COLUMNS_OFFICE2003, OnUpdateColumnsStyleOffice2003)
  154. //}}AFX_MSG_MAP
  155. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  156. ON_NOTIFY(XTP_NM_REPORT_INPLACEBUTTONDOWN, XTP_ID_REPORT_CONTROL, OnReportButtonClick)
  157. END_MESSAGE_MAP()
  158. /////////////////////////////////////////////////////////////////////////////
  159. // CHeaderFooterView drawing
  160. /////////////////////////////////////////////////////////////////////////////
  161. // CHeaderFooterView diagnostics
  162. #ifdef _DEBUG
  163. void CHeaderFooterView::AssertValid() const
  164. {
  165. CView::AssertValid();
  166. }
  167. void CHeaderFooterView::Dump(CDumpContext& dc) const
  168. {
  169. CView::Dump(dc);
  170. }
  171. #endif //_DEBUG
  172. /////////////////////////////////////////////////////////////////////////////
  173. // CHeaderFooterView message handlers
  174. int CHeaderFooterView::OnCreate(LPCREATESTRUCT lpCreateStruct)
  175. {
  176. if (CXTPReportView::OnCreate(lpCreateStruct) == -1)
  177. return -1;
  178. CXTPReportControl& wndReport = GetReportCtrl();
  179. wndReport.GetImageManager()->SetIcons(IDB_BMREPORT, 0, 0, CSize(16, 16));
  180. wndReport.AddColumn(new CXTPReportColumn(COLUMN_TYPE, _T("Type"), 18, FALSE, 0));
  181. CXTPReportColumn* pColumnImportance = wndReport.AddColumn(new CXTPReportColumn(COLUMN_IMPORTANCE, _T("Importants"), 18, FALSE, 1));
  182. wndReport.AddColumn(new CXTPReportColumn(COLUMN_ATTACHMENT, _T("Attachments"), 18, FALSE, 7));
  183. CXTPReportColumn* pColumnStatus = wndReport.AddColumn(new CXTPReportColumn(COLUMN_STATUS, _T("Status"), 100));
  184. wndReport.AddColumn(new CXTPReportColumn(COLUMN_SUBJECT, _T("Subject"), 200));
  185. CXTPReportColumn* pColumnDueDate = wndReport.AddColumn(new CXTPReportColumn(COLUMN_DUE_DATE, _T("Due Date"), 100));
  186. wndReport.AddColumn(new CXTPReportColumn(COLUMN_COMPLETE, _T("% Complete"), 100));
  187. wndReport.AddColumn(new CXTPReportColumn(COLUMN_CATEGORIES, _T("Categories"), 80));
  188. pColumnStatus->GetEditOptions()->AddConstraint(_T("Not Started"), taskStatusNotStarted);
  189. pColumnStatus->GetEditOptions()->AddConstraint(_T("In Progress"), taskStatusInProgress);
  190. pColumnStatus->GetEditOptions()->AddConstraint(_T("Completed"), taskStatusCompleted);
  191. pColumnStatus->GetEditOptions()->AddConstraint(_T("Waiting on someone else"), taskStatusWaiting);
  192. pColumnStatus->GetEditOptions()->AddConstraint(_T("Deferred"), taskStatusDeferred);
  193. pColumnStatus->GetEditOptions()->m_bConstraintEdit = TRUE;
  194. pColumnStatus->GetEditOptions()->m_bAllowEdit = TRUE;
  195. pColumnStatus->GetEditOptions()->AddComboButton();
  196. pColumnImportance->GetEditOptions()->AddConstraint(_T("Low"), taskImportanceLow);
  197. pColumnImportance->GetEditOptions()->AddConstraint(_T("Normal"), taskImportanceNormal);
  198. pColumnImportance->GetEditOptions()->AddConstraint(_T("High"), taskImportanceHigh);
  199. pColumnImportance->GetEditOptions()->m_bAllowEdit = FALSE;
  200. pColumnImportance->GetEditOptions()->AddComboButton();
  201. pColumnDueDate->GetEditOptions()->AddComboButton();
  202. COleDateTime dtNone;
  203. COleDateTime dtNow = COleDateTime::GetCurrentTime();
  204. wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceNormal, TRUE, taskStatusInProgress, _T("Support Email: About tooltips"), dtNone, 70, _T("")));
  205. wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceNormal, TRUE, taskStatusNotStarted, _T("Support Email: Docking Pane ToggleDocking"), dtNone, 0, _T("")));
  206. wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceHigh, TRUE, taskStatusNotStarted, _T("Feature Request: New Event for CommandBars"), dtNow, 0, _T("")));
  207. wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceHigh, TRUE, taskStatusCompleted, _T("Support Email: Help Taskpanel And ShortcutBar"), dtNow, 100, _T("")));
  208. wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceNormal, FALSE, taskStatusCompleted, _T("Support Email: RE: Docking Pane Window Overlapping Issues"), dtNow, 100, _T("")));
  209. wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceNormal, FALSE, taskStatusCompleted, _T("Support Email: CXTPPropertyGridItem"), dtNone, 100, _T("")));
  210. wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceNormal, TRUE, taskStatusCompleted, _T("Support Email: Toolbar Oddity"), dtNone, 100, _T("")));
  211. wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceNormal, TRUE, taskStatusCompleted, _T("Support Email: CXTPTabControl"), dtNone, 100, _T("")));
  212. wndReport.AddRecord(new CTaskRecord(FALSE, taskImportanceNormal, TRUE, taskStatusInProgress, _T("Support Email: Menus go wrong if another form has topmost setting"), dtNone, 10, _T("")));
  213. wndReport.AddRecord(new CTaskRecord(FALSE, taskImportanceNormal, TRUE, taskStatusInProgress, _T("Support Email: Update Xtreme Suite from 8.6 to 8.7"), dtNone, 0, _T("")));
  214. wndReport.AddRecord(new CTaskRecord(TRUE, taskImportanceLow, TRUE, taskStatusInProgress, _T("Support Email: Bug in Tree-View on Label Edit"), dtNone, 0, _T("")));
  215. // Fixed rows
  216. wndReport.GetHeaderRecords()->Add(new CTaskRecord(TRUE, taskImportanceNormal, TRUE, taskStatusInProgress, _T("Header record 1"), dtNone, 0, _T("")));
  217. wndReport.GetHeaderRecords()->Add(new CTaskRecord(TRUE, taskImportanceNormal, TRUE, taskStatusInProgress, _T("Header record 2"), dtNone, 0, _T("")));
  218. wndReport.GetFooterRecords()->Add(new CTaskRecord(TRUE, taskImportanceNormal, TRUE, taskStatusInProgress, _T("Footer record 1"), dtNone, 100, _T("")));
  219. wndReport.GetFooterRecords()->Add(new CTaskRecord(TRUE, taskImportanceNormal, TRUE, taskStatusInProgress, _T("Footer record 2"), dtNone, 100, _T("")));
  220. // Fixed rows appearance
  221. wndReport.ShowHeaderRows(TRUE);
  222. wndReport.ShowFooterRows(TRUE);
  223. wndReport.PinFooterRows(FALSE);
  224. wndReport.GetPaintManager()->SetHeaderRowsDividerStyle(xtpReportFixedRowsDividerNone);
  225. wndReport.GetPaintManager()->SetFooterRowsDividerStyle(xtpReportFixedRowsDividerNone);
  226. wndReport.GetPaintManager()->m_clrHeaderRowsDivider = RGB(255,0,0);
  227. wndReport.GetPaintManager()->m_clrFooterRowsDivider = RGB(0,0,255);
  228. wndReport.GetPaintManager()->SetColumnStyle(xtpReportColumnFlat);
  229. wndReport.GetReportHeader()->AllowColumnRemove(FALSE);
  230. wndReport.AllowEdit(TRUE);
  231. wndReport.FocusSubItems(TRUE);
  232. wndReport.Populate();
  233. wndReport.GetPaintManager()->SetGridStyle(TRUE, xtpReportGridSolid);
  234. wndReport.SetFocus();
  235. return 0;
  236. }
  237. void CHeaderFooterView::OnShowHeaderRecords()
  238. {
  239. GetReportCtrl().ShowHeaderRows(!GetReportCtrl().IsHeaderRowsVisible());
  240. }
  241. void CHeaderFooterView::OnUpdateShowHeaderRecords(CCmdUI* pCmdUI)
  242. {
  243. pCmdUI->Enable(TRUE); 
  244. pCmdUI->SetCheck(GetReportCtrl().IsHeaderRowsVisible()); 
  245. }
  246. void CHeaderFooterView::OnShowFooterRecords()
  247. {
  248. GetReportCtrl().ShowFooterRows(!GetReportCtrl().IsFooterRowsVisible());
  249. }
  250. void CHeaderFooterView::OnUpdateShowFooterRecords(CCmdUI* pCmdUI)
  251. {
  252. pCmdUI->Enable(TRUE); 
  253. pCmdUI->SetCheck(GetReportCtrl().IsFooterRowsVisible()); 
  254. }
  255. void CHeaderFooterView::OnHeaderRecordsAllowEdit()
  256. {
  257. GetReportCtrl().HeaderRowsAllowEdit(!GetReportCtrl().IsHeaderRowsAllowEdit());
  258. }
  259. void CHeaderFooterView::OnUpdateHeaderRecordsAllowEdit(CCmdUI* pCmdUI)
  260. {
  261. pCmdUI->Enable(TRUE); 
  262. pCmdUI->SetCheck(GetReportCtrl().IsHeaderRowsAllowEdit()); 
  263. }
  264. void CHeaderFooterView::OnFooterRecordsAllowEdit()
  265. {
  266. GetReportCtrl().FooterRowsAllowEdit(!GetReportCtrl().IsFooterRowsAllowEdit());
  267. }
  268. void CHeaderFooterView::OnUpdateFooterRecordsAllowEdit(CCmdUI* pCmdUI)
  269. {
  270. pCmdUI->Enable(TRUE); 
  271. pCmdUI->SetCheck(GetReportCtrl().IsFooterRowsAllowEdit()); 
  272. }
  273. void CHeaderFooterView::OnPinFooterRows()
  274. {
  275. GetReportCtrl().PinFooterRows(!GetReportCtrl().IsFooterRowsPinned());
  276. GetReportCtrl().RedrawControl();
  277. }
  278. void CHeaderFooterView::OnUpdatePinFooterRows(CCmdUI* pCmdUI)
  279. {
  280. pCmdUI->Enable(TRUE); 
  281. pCmdUI->SetCheck(GetReportCtrl().IsFooterRowsPinned()); 
  282. }
  283. void CHeaderFooterView::OnDrawGridForEmpty()
  284. {
  285. GetReportCtrl().GetPaintManager()->SetDrawGridForEmptySpace(!GetReportCtrl().GetPaintManager()->IsDrawGridForEmptySpace());
  286. GetReportCtrl().RedrawControl();
  287. }
  288. void CHeaderFooterView::OnUpdateDrawGridForEmpty(CCmdUI* pCmdUI)
  289. {
  290. pCmdUI->Enable(TRUE); 
  291. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->IsDrawGridForEmptySpace());
  292. }
  293. void CHeaderFooterView::OnMoveInHeader()
  294. {
  295. GetReportCtrl().GetNavigator()->SetCurrentFocusInHeadersRows(!GetReportCtrl().GetNavigator()->GetCurrentFocusInHeadersRows());
  296. GetReportCtrl().RedrawControl();
  297. }
  298. void CHeaderFooterView::OnUpdateMoveInHeader(CCmdUI* pCmdUI)
  299. {
  300. pCmdUI->Enable(GetReportCtrl().IsHeaderRowsVisible()); 
  301. pCmdUI->SetCheck(GetReportCtrl().GetNavigator()->GetCurrentFocusInHeadersRows());
  302. }
  303. void CHeaderFooterView::OnMoveInFooter()
  304. {
  305. GetReportCtrl().GetNavigator()->SetCurrentFocusInFootersRows(!GetReportCtrl().GetNavigator()->GetCurrentFocusInFootersRows());
  306. GetReportCtrl().RedrawControl();
  307. }
  308. void CHeaderFooterView::OnUpdateMoveInFooter(CCmdUI* pCmdUI)
  309. {
  310. pCmdUI->Enable(GetReportCtrl().IsFooterRowsVisible()); 
  311. pCmdUI->SetCheck(GetReportCtrl().GetNavigator()->GetCurrentFocusInFootersRows());
  312. }
  313. // styles
  314. #define ONDIVIDER_STYLE(Where, Style)
  315. void CHeaderFooterView::On##Where##DividerStyle##Style()
  316. {
  317. GetReportCtrl().GetPaintManager()->Set##Where##RowsDividerStyle(xtpReportFixedRowsDivider##Style);
  318. GetReportCtrl().AdjustLayout();
  319. GetReportCtrl().RedrawControl();
  320. }
  321. void CHeaderFooterView::OnUpdate##Where##DividerStyle##Style(CCmdUI* pCmdUI)
  322. {
  323. pCmdUI->Enable(TRUE); 
  324. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->Get##Where##RowsDividerStyle() == xtpReportFixedRowsDivider##Style); 
  325. }
  326. ONDIVIDER_STYLE(Header, Thin)
  327. ONDIVIDER_STYLE(Header, Bold)
  328. ONDIVIDER_STYLE(Header, Shade)
  329. ONDIVIDER_STYLE(Header, None)
  330. ONDIVIDER_STYLE(Header, Outlook)
  331. ONDIVIDER_STYLE(Footer, Thin)
  332. ONDIVIDER_STYLE(Footer, Bold)
  333. ONDIVIDER_STYLE(Footer, Shade)
  334. ONDIVIDER_STYLE(Footer, None)
  335. ONDIVIDER_STYLE(Footer, Outlook)
  336. /*
  337. void CHeaderFooterView::OnHeaderDividerStyleThin()
  338. {
  339. GetReportCtrl().GetPaintManager()->SetHeaderRowsDividerStyle(xtpReportFixedRowsDividerThin);
  340. GetReportCtrl().AdjustLayout();
  341. GetReportCtrl().RedrawControl();
  342. }
  343. void CHeaderFooterView::OnUpdateHeaderDividerStyleThin(CCmdUI* pCmdUI)
  344. {
  345. pCmdUI->Enable(TRUE); 
  346. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->GetHeaderRowsDividerStyle() == xtpReportFixedRowsDividerThin); 
  347. }
  348. void CHeaderFooterView::OnHeaderDividerStyleBold()
  349. {
  350. GetReportCtrl().GetPaintManager()->SetHeaderRowsDividerStyle(xtpReportFixedRowsDividerBold);
  351. GetReportCtrl().AdjustLayout();
  352. GetReportCtrl().RedrawControl();
  353. }
  354. void CHeaderFooterView::OnUpdateHeaderDividerStyleBold(CCmdUI* pCmdUI)
  355. {
  356. pCmdUI->Enable(TRUE); 
  357. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->GetHeaderRowsDividerStyle() == xtpReportFixedRowsDividerBold); 
  358. }
  359. void CHeaderFooterView::OnHeaderDividerStyleShade()
  360. {
  361. GetReportCtrl().GetPaintManager()->SetHeaderRowsDividerStyle(xtpReportFixedRowsDividerShade);
  362. GetReportCtrl().AdjustLayout();
  363. GetReportCtrl().RedrawControl();
  364. }
  365. void CHeaderFooterView::OnUpdateHeaderDividerStyleShade(CCmdUI* pCmdUI)
  366. {
  367. pCmdUI->Enable(TRUE); 
  368. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->GetHeaderRowsDividerStyle() == xtpReportFixedRowsDividerShade); 
  369. }
  370. void CHeaderFooterView::OnHeaderDividerStyleNone()
  371. {
  372. GetReportCtrl().GetPaintManager()->SetHeaderRowsDividerStyle(xtpReportFixedRowsDividerNone);
  373. GetReportCtrl().AdjustLayout();
  374. GetReportCtrl().RedrawControl();
  375. }
  376. void CHeaderFooterView::OnUpdateHeaderDividerStyleNone(CCmdUI* pCmdUI)
  377. {
  378. pCmdUI->Enable(TRUE); 
  379. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->GetHeaderRowsDividerStyle() == xtpReportFixedRowsDividerNone); 
  380. }
  381. void CHeaderFooterView::OnHeaderDividerStyleOutlook()
  382. {
  383. GetReportCtrl().GetPaintManager()->SetHeaderRowsDividerStyle(xtpReportFixedRowsDividerOutlook);
  384. GetReportCtrl().AdjustLayout();
  385. GetReportCtrl().RedrawControl();
  386. }
  387. void CHeaderFooterView::OnUpdateHeaderDividerStyleOutlook(CCmdUI* pCmdUI)
  388. {
  389. pCmdUI->Enable(TRUE); 
  390. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->GetHeaderRowsDividerStyle() == xtpReportFixedRowsDividerOutlook); 
  391. }
  392. // footer rows style
  393. void CHeaderFooterView::OnFooterDividerStyleThin()
  394. {
  395. GetReportCtrl().GetPaintManager()->SetFooterRowsDividerStyle(xtpReportFixedRowsDividerThin);
  396. GetReportCtrl().AdjustLayout();
  397. GetReportCtrl().RedrawControl();
  398. }
  399. void CHeaderFooterView::OnUpdateFooterDividerStyleThin(CCmdUI* pCmdUI)
  400. {
  401. pCmdUI->Enable(TRUE); 
  402. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->GetFooterRowsDividerStyle() == xtpReportFixedRowsDividerThin); 
  403. }
  404. void CHeaderFooterView::OnFooterDividerStyleBold()
  405. {
  406. GetReportCtrl().GetPaintManager()->SetFooterRowsDividerStyle(xtpReportFixedRowsDividerBold);
  407. GetReportCtrl().AdjustLayout();
  408. GetReportCtrl().RedrawControl();
  409. }
  410. void CHeaderFooterView::OnUpdateFooterDividerStyleBold(CCmdUI* pCmdUI)
  411. {
  412. pCmdUI->Enable(TRUE); 
  413. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->GetFooterRowsDividerStyle() == xtpReportFixedRowsDividerBold); 
  414. }
  415. void CHeaderFooterView::OnFooterDividerStyleShade()
  416. {
  417. GetReportCtrl().GetPaintManager()->SetFooterRowsDividerStyle(xtpReportFixedRowsDividerShade);
  418. GetReportCtrl().AdjustLayout();
  419. GetReportCtrl().RedrawControl();
  420. }
  421. void CHeaderFooterView::OnUpdateFooterDividerStyleShade(CCmdUI* pCmdUI)
  422. {
  423. pCmdUI->Enable(TRUE); 
  424. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->GetFooterRowsDividerStyle() == xtpReportFixedRowsDividerShade); 
  425. }
  426. void CHeaderFooterView::OnFooterDividerStyleNone()
  427. {
  428. GetReportCtrl().GetPaintManager()->SetFooterRowsDividerStyle(xtpReportFixedRowsDividerNone);
  429. GetReportCtrl().AdjustLayout();
  430. GetReportCtrl().RedrawControl();
  431. }
  432. void CHeaderFooterView::OnUpdateFooterDividerStyleNone(CCmdUI* pCmdUI)
  433. {
  434. pCmdUI->Enable(TRUE); 
  435. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->GetFooterRowsDividerStyle() == xtpReportFixedRowsDividerNone); 
  436. }
  437. void CHeaderFooterView::OnFooterDividerStyleOutlook()
  438. {
  439. GetReportCtrl().GetPaintManager()->SetFooterRowsDividerStyle(xtpReportFixedRowsDividerOutlook);
  440. GetReportCtrl().AdjustLayout();
  441. GetReportCtrl().RedrawControl();
  442. }
  443. void CHeaderFooterView::OnUpdateFooterDividerStyleOutlook(CCmdUI* pCmdUI)
  444. {
  445. pCmdUI->Enable(TRUE); 
  446. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->GetFooterRowsDividerStyle() == xtpReportFixedRowsDividerOutlook); 
  447. }
  448. */
  449. // columns style
  450. #define CONCOLUMN_STYLE(Style)
  451. void CHeaderFooterView::OnColumnsStyle##Style()
  452. {
  453. GetReportCtrl().GetPaintManager()->SetColumnStyle(xtpReportColumn##Style);
  454. GetReportCtrl().AdjustLayout();
  455. GetReportCtrl().RedrawControl();
  456. }
  457. void CHeaderFooterView::OnUpdateColumnsStyle##Style(CCmdUI* pCmdUI)
  458. {
  459. pCmdUI->Enable(TRUE); 
  460. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->GetColumnStyle() == xtpReportColumn##Style); 
  461. }
  462. CONCOLUMN_STYLE(Flat)
  463. CONCOLUMN_STYLE(Explorer)
  464. CONCOLUMN_STYLE(Shaded)
  465. CONCOLUMN_STYLE(Office2003)
  466. /*
  467. void CHeaderFooterView::OnColumnsStyleFlat()
  468. {
  469. GetReportCtrl().GetPaintManager()->m_columnStyle = xtpReportColumnFlat;
  470. GetReportCtrl().AdjustLayout();
  471. GetReportCtrl().RedrawControl();
  472. }
  473. void CHeaderFooterView::OnUpdateColumnsStyleFlat(CCmdUI* pCmdUI)
  474. {
  475. pCmdUI->Enable(TRUE); 
  476. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->m_columnStyle == xtpReportColumnFlat); 
  477. }
  478. void CHeaderFooterView::OnColumnsStyleExplorer()
  479. {
  480. GetReportCtrl().GetPaintManager()->m_columnStyle = xtpReportColumnExplorer;
  481. GetReportCtrl().AdjustLayout();
  482. GetReportCtrl().RedrawControl();
  483. }
  484. void CHeaderFooterView::OnUpdateColumnsStyleExplorer(CCmdUI* pCmdUI)
  485. {
  486. pCmdUI->Enable(TRUE); 
  487. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->m_columnStyle == xtpReportColumnExplorer); 
  488. }
  489. void CHeaderFooterView::OnColumnsStyleShaded()
  490. {
  491. GetReportCtrl().GetPaintManager()->m_columnStyle = xtpReportColumnShaded;
  492. GetReportCtrl().AdjustLayout();
  493. GetReportCtrl().RedrawControl();
  494. }
  495. void CHeaderFooterView::OnUpdateColumnsStyleShaded(CCmdUI* pCmdUI)
  496. {
  497. pCmdUI->Enable(TRUE); 
  498. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->m_columnStyle == xtpReportColumnShaded); 
  499. }
  500. void CHeaderFooterView::OnColumnsStyleOffice2003()
  501. {
  502. GetReportCtrl().GetPaintManager()->m_columnStyle = xtpReportColumnOffice2003;
  503. GetReportCtrl().AdjustLayout();
  504. GetReportCtrl().RedrawControl();
  505. }
  506. void CHeaderFooterView::OnUpdateColumnsStyleOffice2003(CCmdUI* pCmdUI)
  507. {
  508. pCmdUI->Enable(TRUE); 
  509. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->m_columnStyle == xtpReportColumnOffice2003); 
  510. }
  511. */
  512. //
  513. void CHeaderFooterView::OnAddTask() 
  514. {
  515. CTaskRecord* pRecord = (CTaskRecord*)GetReportCtrl().AddRecord(new CTaskRecord(TRUE, taskImportanceNormal, FALSE, taskStatusNotStarted, _T(""), COleDateTime(), 0, _T("")));
  516. GetReportCtrl().Populate();
  517. CXTPReportRow* pRow = GetReportCtrl().GetRows()->Find(pRecord);
  518. if (pRow)
  519. {
  520. XTP_REPORTRECORDITEM_ARGS itemArgs(&GetReportCtrl(), pRow, GetReportCtrl().GetColumns()->Find(COLUMN_SUBJECT));
  521. GetReportCtrl().EditItem(&itemArgs);
  522. }
  523. }
  524. void CHeaderFooterView::OnReportButtonClick(NMHDR * pNotifyStruct, LRESULT* pResult)
  525. {
  526.     XTP_NM_REPORTINPLACEBUTTON* pItemNotify = (XTP_NM_REPORTINPLACEBUTTON*) pNotifyStruct;
  527.     ASSERT(pItemNotify->pButton);
  528. if (!pItemNotify->pButton->pColumn || pItemNotify->pButton->pColumn->GetItemIndex() != COLUMN_DUE_DATE)
  529. return;
  530. CRect rcRow = pItemNotify->pButton->pRow->GetRect();
  531. CRect rcCol = pItemNotify->pButton->pColumn->GetRect();
  532. CRect rcItem = rcRow;
  533. rcItem.left = rcCol.left;
  534. rcItem.right = rcCol.right;
  535. CXTPReportRecordItemDateTime* pItemDateTime = DYNAMIC_DOWNCAST(CXTPReportRecordItemDateTime, pItemNotify->pItem);
  536. if (!pItemDateTime) {
  537. ASSERT(FALSE);
  538. return;
  539. }
  540. COleDateTime dtDateValue = pItemDateTime->GetValue();
  541. if (dtDateValue.GetStatus() != COleDateTime::valid || dtDateValue == 0) 
  542. {
  543. dtDateValue = COleDateTime::GetCurrentTime();
  544. #ifdef _XTP_INCLUDE_CALENDAR
  545. dtDateValue = CXTPCalendarUtils::ResetTime(dtDateValue);
  546. #endif
  547. }
  548. CXTPReportControl* pControl = pItemNotify->pButton->pControl;
  549. BOOL bResult = -1; // -1 means that XTP DatePicker is not supported in this build.
  550. //#define DBG_DATE_PICKERS
  551. #ifdef DBG_DATE_PICKERS
  552. static int s_nRotator = 0;
  553. s_nRotator++;
  554. if(s_nRotator % 2 == 0)
  555. #endif
  556. bResult = Show_XTPDatePicker(pControl, rcItem, dtDateValue);
  557. if(bResult < 0) {
  558. bResult = Show_MFCDatePicker(pControl, rcItem, dtDateValue);
  559. }
  560. if(!bResult) {
  561. return;
  562. }
  563. CString strNewVal = dtDateValue.Format();
  564. //pItemNotify->pButton->pControl->GetInplaceEdit()->SetWindowText(strNewVal);
  565. pItemNotify->pItem->OnEditChanged(NULL, strNewVal);
  566. // uncomment to end editing after pop-up date picker closed.
  567. //pItemNotify->pButton->pControl->EditItem(NULL);
  568. pItemNotify->pButton->pControl->RedrawControl();
  569. *pResult = (LRESULT)TRUE;
  570. }
  571. BOOL CHeaderFooterView::Show_XTPDatePicker(CXTPReportControl* pControl, 
  572. const CRect& rcItem,
  573. COleDateTime& rdtDate)
  574. {
  575. #ifdef _XTP_INCLUDE_CALENDAR
  576. CXTPDatePickerControl wndDatePicker;
  577. if(!wndDatePicker.GetSelectedDays()) {
  578. ASSERT(FALSE);
  579. return FALSE;
  580. }
  581. wndDatePicker.SetMaxSelCount(1);
  582. wndDatePicker.GetSelectedDays()->Select(rdtDate);
  583. wndDatePicker.EnsureVisible(rdtDate);
  584. CRect rcSize;
  585. if(!wndDatePicker.GetMinReqRect(&rcSize, 1, 1) ) {
  586. ASSERT(FALSE);
  587. return FALSE;
  588. }
  589. rcSize.InflateRect(5, 5);
  590. CRect rcPopUp = rcItem;
  591. pControl->ClientToScreen(&rcPopUp);
  592. rcPopUp.right = rcPopUp.left + rcSize.Width();
  593. rcPopUp.top = rcPopUp.bottom;
  594. rcPopUp.bottom = rcPopUp.bottom + rcSize.Height();
  595. BOOL bResult = wndDatePicker.GoModal(rcPopUp, pControl);
  596. if(bResult) 
  597. {
  598. int nSelCount = wndDatePicker.GetSelectedDays()->GetSelectedBlocksCount();
  599. if(nSelCount) 
  600. {
  601. rdtDate = (DATE)wndDatePicker.GetSelectedDays()->GetSelectedBlock(0).nDateBegin;
  602. }
  603. }
  604. return bResult;
  605. #else 
  606. return -1; 
  607. #endif
  608. }
  609. BOOL CHeaderFooterView::Show_MFCDatePicker(CXTPReportControl* pControl, 
  610. const CRect& rcItem,
  611. COleDateTime& rdtDate)
  612. {
  613. #if _MSC_VER >= 1200 // MFC 6.0
  614. CMonthCalCtrlEx2 wndMFCDatePicker;
  615. CPoint pt(rcItem.left, rcItem.bottom);
  616. pControl->ClientToScreen(&pt);
  617. BOOL bResult = wndMFCDatePicker.GoModal(pt, pControl, rdtDate);
  618. return bResult;
  619. #else
  620. return FALSE;
  621. #endif
  622. }
  623. #if _MSC_VER >= 1200 // MFC 6.0
  624. #ifndef AfxDeferRegisterClass
  625. #define AfxDeferRegisterClass(fClass) AfxEndDeferRegisterClass(fClass)
  626. BOOL AFXAPI AfxEndDeferRegisterClass(LONG fToRegister);
  627. #define AFX_WNDCOMMCTL_DATE_REG 0x20000
  628. #endif
  629. BOOL CMonthCalCtrlEx2::GoModal(const CPoint& pt, CWnd* pParentWnd, 
  630.   COleDateTime& rdtDate)
  631. {
  632. if (::IsWindow(m_hWnd)) {
  633. ASSERT(FALSE);
  634. return FALSE;
  635. }
  636. VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTL_DATE_REG));
  637. CRect rcRect(pt.x, pt.y, 0, 0);
  638. BOOL bCreate = CreateEx(WS_EX_TOPMOST|WS_EX_DLGMODALFRAME, 
  639. MONTHCAL_CLASS, NULL, 
  640. WS_POPUP, rcRect, pParentWnd, 0);
  641. ASSERT(bCreate);
  642. if(!bCreate) {
  643. return FALSE;
  644. }
  645. CRect rect;
  646. if (GetMinReqRect(rect))
  647. {
  648. rect.InflateRect(5, 5);
  649. DWORD dwFlags = SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOMOVE | SWP_NOACTIVATE;
  650. SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(), dwFlags);
  651. }
  652. else 
  653. {
  654. ASSERT(FALSE);
  655. DestroyWindow();
  656. return FALSE;
  657. }
  658. SetCurSel(rdtDate);
  659. // Enable this window
  660. EnableWindow(TRUE);
  661. CWnd* pFocusWnd = SetFocus();
  662. SetCapture();
  663. ShowWindow(SW_SHOWNA);
  664. m_nFlags |= WF_CONTINUEMODAL;
  665. int nResult = m_nModalResult;
  666. if (ContinueModal())
  667. {
  668. // enter modal loop
  669. DWORD dwFlags = MLF_SHOWONIDLE;
  670. if (GetStyle() & DS_NOIDLEMSG)
  671. dwFlags |= MLF_NOIDLEMSG;
  672. nResult = RunModalLoop(dwFlags);
  673. }
  674. ReleaseCapture();
  675. SYSTEMTIME sysTime;
  676. ::ZeroMemory(&sysTime, sizeof(sysTime));
  677. BOOL bSelResult = GetCurSel(&sysTime);
  678. if (bSelResult) {
  679. rdtDate = COleDateTime(sysTime.wYear, sysTime.wMonth, sysTime.wDay, 0, 0, 0);
  680. }
  681. DestroyWindow();
  682. if (pFocusWnd && ::IsWindow(pFocusWnd->GetSafeHwnd()))
  683. pFocusWnd->SetFocus();
  684. return (nResult == IDOK) && bSelResult;
  685. }
  686. void CMonthCalCtrlEx2::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
  687. {
  688. if (nChar == VK_RETURN || nChar == VK_ESCAPE)
  689. {
  690. EndModalLoop(nChar == VK_RETURN ? IDOK : IDCANCEL);
  691. return;
  692. }
  693. CMonthCalCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
  694. }
  695. void CMonthCalCtrlEx2::OnLButtonDown(UINT nFlags, CPoint point)
  696. {
  697. CRect rcClient;
  698. GetClientRect(&rcClient);
  699. if (!rcClient.PtInRect(point))
  700. {
  701. EndModalLoop(IDOK);
  702. return;
  703. }
  704. CMonthCalCtrl::OnLButtonDown(nFlags, point);
  705. }
  706. void CMonthCalCtrlEx2::OnSelChange(NMHDR* /*pNMHdr*/, LRESULT* /*pResult*/)
  707. {
  708. EndModalLoop(IDOK);
  709. }
  710. #endif