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

对话框与窗口

开发平台:

Visual C++

  1. // TearOffPopupsView.cpp : implementation of the CTearOffPopupsView class
  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 "TearOffPopups.h"
  22. #include "TearOffPopupsDoc.h"
  23. #include "CntrItem.h"
  24. #include "TearOffPopupsView.h"
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CTearOffPopupsView
  32. IMPLEMENT_DYNCREATE(CTearOffPopupsView, CRichEditView)
  33. BEGIN_MESSAGE_MAP(CTearOffPopupsView, CRichEditView)
  34. //{{AFX_MSG_MAP(CTearOffPopupsView)
  35. // NOTE - the ClassWizard will add and remove mapping macros here.
  36. //    DO NOT EDIT what you see in these blocks of generated code!
  37. ON_WM_DESTROY()
  38. //}}AFX_MSG_MAP
  39. // Standard printing commands
  40. ON_COMMAND(ID_FILE_PRINT, CRichEditView::OnFilePrint)
  41. ON_COMMAND(ID_FILE_PRINT_DIRECT, CRichEditView::OnFilePrint)
  42. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRichEditView::OnFilePrintPreview)
  43. ON_COMMAND(ID_FORMAT_STYLE_BOLD, OnCharBold)
  44. ON_UPDATE_COMMAND_UI(ID_FORMAT_STYLE_BOLD, OnUpdateCharBold)
  45. ON_COMMAND(ID_FORMAT_STYLE_ITALIC, OnCharItalic)
  46. ON_UPDATE_COMMAND_UI(ID_FORMAT_STYLE_ITALIC, OnUpdateCharItalic)
  47. ON_COMMAND(ID_FORMAT_STYLE_UNDERLINE, OnCharUnderline)
  48. ON_UPDATE_COMMAND_UI(ID_FORMAT_STYLE_UNDERLINE, OnUpdateCharUnderline)
  49. ON_UPDATE_COMMAND_UI(XTP_IDS_AUTOMATIC, OnUpdateTextAuto)
  50. ON_COMMAND(XTP_IDS_AUTOMATIC, OnTextAuto)
  51. ON_COMMAND(XTP_IDS_MORE_COLORS, OnTextMore)
  52. ON_COMMAND(ID_BUTTON_TEXT, OnButtonText)
  53. ON_UPDATE_COMMAND_UI(ID_BUTTON_TEXT, OnUpdateText)
  54. ON_XTP_EXECUTE(ID_SELECTOR_TEXT, OnSelectorText)
  55. ON_UPDATE_COMMAND_UI(ID_SELECTOR_TEXT, OnUpdateSelectorText)
  56. END_MESSAGE_MAP()
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CTearOffPopupsView construction/destruction
  59. CTearOffPopupsView::CTearOffPopupsView()
  60. {
  61. m_clrText = RGB(255, 0, 0);
  62. }
  63. CTearOffPopupsView::~CTearOffPopupsView()
  64. {
  65. }
  66. BOOL CTearOffPopupsView::PreCreateWindow(CREATESTRUCT& cs)
  67. {
  68. // TODO: Modify the Window class or styles here by modifying
  69. //  the CREATESTRUCT cs
  70. return CRichEditView::PreCreateWindow(cs);
  71. }
  72. void CTearOffPopupsView::OnInitialUpdate()
  73. {
  74. CRichEditView::OnInitialUpdate();
  75. // Set the printing margins (720 twips = 1/2 inch).
  76. SetMargins(CRect(720, 720, 720, 720));
  77. }
  78. /////////////////////////////////////////////////////////////////////////////
  79. // CTearOffPopupsView printing
  80. BOOL CTearOffPopupsView::OnPreparePrinting(CPrintInfo* pInfo)
  81. {
  82. // default preparation
  83. return DoPreparePrinting(pInfo);
  84. }
  85. void CTearOffPopupsView::OnDestroy()
  86. {
  87. // Deactivate the item on destruction; this is important
  88. // when a splitter view is being used.
  89. CRichEditView::OnDestroy();
  90. }
  91. /////////////////////////////////////////////////////////////////////////////
  92. // CTearOffPopupsView diagnostics
  93. #ifdef _DEBUG
  94. void CTearOffPopupsView::AssertValid() const
  95. {
  96. CRichEditView::AssertValid();
  97. }
  98. void CTearOffPopupsView::Dump(CDumpContext& dc) const
  99. {
  100. CRichEditView::Dump(dc);
  101. }
  102. CTearOffPopupsDoc* CTearOffPopupsView::GetDocument() // non-debug version is inline
  103. {
  104. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTearOffPopupsDoc)));
  105. return (CTearOffPopupsDoc*)m_pDocument;
  106. }
  107. #endif //_DEBUG
  108. /////////////////////////////////////////////////////////////////////////////
  109. // CTearOffPopupsView message handlers
  110. void CTearOffPopupsView::OnTextAuto()
  111. {
  112. CHARFORMAT& cfm = GetCharFormatSelection( );
  113. cfm.dwMask |= CFM_COLOR;
  114. cfm.dwEffects |= CFE_AUTOCOLOR ;
  115. GetRichEditCtrl().SetSelectionCharFormat(cfm);
  116. }
  117. void CTearOffPopupsView::OnUpdateTextAuto(CCmdUI* pCmd)
  118. {
  119. CHARFORMAT& cfm = GetCharFormatSelection( );
  120. pCmd->SetCheck(cfm.dwEffects & CFE_AUTOCOLOR? TRUE: FALSE);
  121. }
  122. void CTearOffPopupsView::OnTextMore()
  123. {
  124. CColorDialog cd(m_clrText);
  125. if (cd.DoModal())
  126. {
  127. m_clrText = cd.GetColor();
  128. OnButtonText();
  129. }
  130. }
  131. void CTearOffPopupsView::OnButtonText()
  132. {
  133. CHARFORMAT& cfm = GetCharFormatSelection( );
  134. cfm.dwMask |= CFM_COLOR;
  135. cfm.dwEffects &= ~CFE_AUTOCOLOR ;
  136. cfm.crTextColor = m_clrText;
  137. GetRichEditCtrl().SetSelectionCharFormat(cfm);
  138. }
  139. void CTearOffPopupsView::OnUpdateText(CCmdUI* pCmd)
  140. {
  141. CXTPCommandBar* pToolBar = (CXTPToolBar*)pCmd->m_pOther;
  142. if (pToolBar)
  143. {
  144. CXTPControlPopupColor* pPopup = (CXTPControlPopupColor*)pToolBar->GetControls()->GetAt(pCmd->m_nIndex);
  145. pPopup->SetColor(m_clrText);
  146. }
  147. pCmd->Enable(TRUE);
  148. }
  149. void CTearOffPopupsView::OnSelectorText(NMHDR* pNMHDR, LRESULT* pResult)
  150. {
  151. NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR;
  152. CXTPControlColorSelector* pControl = (CXTPControlColorSelector*)tagNMCONTROL->pControl;
  153. m_clrText = pControl->GetColor();
  154. OnButtonText();
  155. *pResult = 1;
  156. }
  157. void CTearOffPopupsView::OnUpdateSelectorText(CCmdUI* pCmd)
  158. {
  159. CXTPCommandBar* pToolBar = (CXTPToolBar*)pCmd->m_pOther;
  160. if (pToolBar)
  161. {
  162. CHARFORMAT& cfm = GetCharFormatSelection( );
  163. CXTPControlColorSelector* pSelector = (CXTPControlColorSelector*)pToolBar->GetControls()->GetAt(pCmd->m_nIndex);
  164. pSelector->SetColor(cfm.dwEffects & CFE_AUTOCOLOR? -1: cfm.crTextColor);
  165. }
  166. pCmd->Enable(TRUE);
  167. }