virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
+ template <class Func>
+ void ForEachView(Func func)
+ {
+ for (POSITION pos = GetFirstViewPosition(); pos != nullptr; )
+ func(static_cast<CSampleView*>(GetNextView(pos)));
+ }
protected:
#include "SampleDoc.h"
#include "SampleView.h"
+#include "editcmd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
ON_COMMAND(ID_FILE_PRINT, CCrystalEditView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CCrystalEditView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CCrystalEditView::OnFilePrintPreview)
+ ON_COMMAND(ID_VIEW_SELMARGIN, OnSelMargin)
+ ON_COMMAND(ID_VIEW_WORDWRAP, OnWordWrap)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
SetFont(GetDocument()->m_lf);
SetColorContext(GetDocument()->m_pSyntaxColors);
SetMarkersContext(GetDocument()->m_pMarkers);
- SetWordWrapping(true);
}
void CSampleView::OnContextMenu(CWnd* pWnd, CPoint point)
{
AfxMessageBox(_T("Build your own context menu!"));
}
+
+void CSampleView::OnSelMargin()
+{
+ GetDocument()->ForEachView([](CSampleView* pView) {
+ pView->SetSelectionMargin(!pView->GetSelectionMargin());
+ });
+}
+
+void CSampleView::OnWordWrap()
+{
+ GetDocument()->ForEachView([](CSampleView* pView) {
+ pView->SetWordWrapping(!pView->GetWordWrapping());
+ });
+}