/** * @file XTPSyntaxEditView.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(__XTPSYNTAXEDITSYNTAXEDITVIEW_H__) # define __XTPSYNTAXEDITSYNTAXEDITVIEW_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPSyntaxEditFindReplaceDlg; /** @cond */ namespace XTPSyntaxEditLexAnalyser /** @endcond */ { class CXTPSyntaxEditLexParser; } /** * @brief * Describes printing options for the Calendar control. * @details * Use this class when you want to programmatically customize printing * options for the Calendar control. * * See each property description to examine which customization options * are available. * @see * CXTPPrintOptions */ class _XTP_EXT_CLASS CXTPSyntaxEditViewPrintOptions : public CXTPPrintOptions { /** @cond */ DECLARE_DYNAMIC(CXTPSyntaxEditViewPrintOptions) /** @endcond */ public: /** * @brief * Default constructor. */ CXTPSyntaxEditViewPrintOptions(); protected: # ifdef _XTP_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPSyntaxEditViewPrintOptions); /** @endcond */ # endif }; /** * @brief * This class represents a View portion of the Edit Control. It extends * the functionality provided by the CView class from MFC's document-view * model implementation. The CXTPSyntaxEditView class works together with * CXTPSyntaxEditDoc and provides facilities for it to be displayed on * a screen or printed on a printer. * @see * CXTPSyntaxEditDoc */ class _XTP_EXT_CLASS CXTPSyntaxEditView : public CView { /** @cond */ friend class CXTPSyntaxEditDoc; DECLARE_DYNCREATE(CXTPSyntaxEditView) /** @endcond */ protected: /** * @brief * Protected object constructor. Used by dynamic creation. */ CXTPSyntaxEditView(); /** * @brief * Destroys a CXTPSyntaxEditView() object, handles cleanup and * de-allocation. */ virtual ~CXTPSyntaxEditView(); public: /** * @brief * Sets the font for the edit control. * @param pLogFont [in] Pointer to a LOGFONT structure. * @param bUpdateReg [in] TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. */ void SetFontIndirect(LOGFONT* pLogFont, BOOL bUpdateReg = FALSE); /** * @brief * Enables/disables line numbering. * @param bEnable [in] TRUE to enable line numbering, * FALSE to disable line numbering. */ void SetLineNumbers(BOOL bEnable); /** * @brief * Determines if the horizontal scrollbar is enabled. * @return * TRUE if the horizontal scrollbar is enabled, otherwise FALSE. */ BOOL GetHorzScrollBar() const; /** * @brief * Determines if the vertical scrollbar is enabled. * @return * TRUE if the vertical scrollbar is enabled, otherwise FALSE. */ BOOL GetVertScrollBar() const; /** * @brief * Enables/disables the horizontal and vertical scrollbars. * @param bHorz [in] TRUE to enable the horizontal scrollbar, * FALSE to disable the horizontal scrollbar. * @param bVert [in] TRUE to enable the vertical scrollbar, * FALSE to disable the vertical scrollbar. * @param bUpdateReg [in] TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @param bRecalcLayout [in] TRUE to recalculate the layout, * FALSE otherwise. * @return * TRUE if the scrollbars were updated, otherwise FALSE. */ BOOL SetScrollBars(BOOL bHorz, BOOL bVert, BOOL bUpdateReg = FALSE, BOOL bRecalcLayout = TRUE); /** * @brief * Enables/disables the gutter. * @param bEnable [in] TRUE to enable the gutter, * FALSE to disable the gutter. */ void SetSelMargin(BOOL bEnable); /** * @brief * Enables/disables auto-indent. * @param bEnable [in] TRUE to enable auto-indent, * FALSE to disable auto-indent. */ void SetAutoIndent(BOOL bEnable); /** * @brief * Enables/disables syntax colorization. * @param bEnable [in] TRUE to enable syntax colorization, * FALSE to disable syntax colorization. */ void SetSyntaxColor(BOOL bEnable); /** * @brief * Updates all active sibling views. */ void UpdateAllViews(); /** * @brief * Sets the view ready for redraw. */ void SetDirty(); /** * @brief * Gets the smart edit control. * @return * A reference to the smart edit control. */ CXTPSyntaxEditCtrl& GetEditCtrl(); const CXTPSyntaxEditCtrl& GetEditCtrl() const; /** * @brief * Sets the smart edit control. * @param pControl Pointer to the smart edit control to be set. * @details * The default edit control window will be destroyed. * InternalRelease will be called for the external control object * in the view object destructor. * @see * GetEditCtrl */ virtual void SetEditCtrl(CXTPSyntaxEditCtrl* pControl); /** * @brief * Gets the buffer manager of the smart edit control. * @return * A pointer to the buffer manager of the smart edit control. */ CXTPSyntaxEditBufferManager* GetEditBuffer() const; /** * @brief * Gets the associated configuration manager. * @return * A pointer to the associated configuration manager. */ CXTPSyntaxEditConfigurationManager* GetLexConfigurationManager() const; /** * @brief * Refreshes the whole document and recalculates the scrollbar. */ void Refresh(); /** * @brief * Sets the top row. * @param iRow [in] Row to be set. * @return * TRUE if successful, otherwise FALSE. */ BOOL SetTopRow(int iRow); /** * @brief * Gets the top row. * @return * The identifier of the top row. */ int GetTopRow() const; /** * @brief * Updates sibling views while in split mode. * @param pSender [in] Pointer to a sender object (or NULL). * @param dwUpdate [in] View update flags. */ void UpdateScrollPos(CView* pSender, DWORD dwUpdate = XTP_EDIT_UPDATE_ALL); /** * @brief * Gets the document. * @return * A pointer to the document. */ CXTPSyntaxEditDoc* GetDocument() const; /** * @brief * Gets the edit buffer manager. * @return * A pointer to the edit buffer manager. * @see * CXTPSyntaxEditBufferManager */ CXTPSyntaxEditBufferManager* GetDataManager() const; /** * @brief * Gets the associated lexical parser. * @return * A pointer to the associated lexical parser. */ XTPSyntaxEditLexAnalyser::CXTPSyntaxEditLexParser* GetLexParser() const; /** * @brief * Gets the attached Find/Replace dialog. * @return * A pointer to the attached Find/Replace dialog. */ virtual CXTPSyntaxEditFindReplaceDlg* GetFindReplaceDlg(); /** * @brief * Gets the document title. * @return * The document title. */ virtual CString GetPageTitle(); /** * @brief * Gets the print options of this view. * @return * A pointer to the print options of this view. */ CXTPSyntaxEditViewPrintOptions* GetPrintOptions() const; /** @cond */ public: virtual void OnInitialUpdate(); virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo = NULL); virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point); virtual void OnDragLeave(); virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point); virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point); protected: afx_msg void OnPaint(); virtual void OnDraw(CDC* pDC); /**< overridden to draw this view */ virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo); virtual BOOL PaginateTo(CDC* pDC, CPrintInfo* pInfo); virtual BOOL PreCreateWindow(CREATESTRUCT& cs); virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView); virtual void OnDropFiles(HDROP hDropInfo); virtual void OnUpdate(CView* pSender, LPARAM lHint = 0L, CObject* pHint = NULL); /** @endcond */ protected: /** * @brief * This function is the default handler for the XTP_EDIT_NM_EDITCHANGING message * which is sent before editing is applied. * @param pNMHDR [in] Pointer to a NMHDR structure. * @param pResult [out] Pointer to a LRESULT value. * TRUE to cancel editing, * FALSE to allow editing. * @return * TRUE if the message was handled successfully, otherwise FALSE. * @see * OnEditChanged, XTP_EDIT_NM_EDITCHANGING, XTP_EDIT_NM_EDITCHANGED */ virtual BOOL OnEditChanging(NMHDR* pNMHDR, LRESULT* pResult); /** * @brief * This function is the default handler for the XTP_EDIT_NM_EDITCHANGED message * which is sent when editing is applied. * @param pNMHDR [in] Pointer to an XTP_EDIT_NMHDR_EDITCHANGED structure. * @param pResult This parameter is unused for this handler. * @return * TRUE if the message was handled successfully, otherwise FALSE. * @see * XTP_EDIT_NM_EDITCHANGING, XTP_EDIT_NM_EDITCHANGED, * XTP_EDIT_NMHDR_EDITCHANGED */ virtual BOOL OnEditChanged(NMHDR* pNMHDR, LRESULT* pResult); /** * @brief * This function is the default handler for the XTP_EDIT_NM_SETDOCMODIFIED message * which is sent when the modified state of the document (edit control) is changed. * @param pNMHDR [in] Pointer to an XTP_EDIT_NMHDR_DOCMODIFIED structure. * @param pResult This parameter is unused for this handler. * @return * TRUE if the message was handled successfully, otherwise FALSE. * @see * XTP_EDIT_NM_SETDOCMODIFIED, XTP_EDIT_NMHDR_DOCMODIFIED */ virtual BOOL OnSetDocModified(NMHDR* pNMHDR, LRESULT* pResult); /** * @brief * This function is the default handler for the XTP_EDIT_NM_DRAWBOOKMARK message * which is sent before the bookmark is drawn. * @param pNMHDR [in] Pointer to an XTP_EDIT_SENMBOOKMARK structure. * @param pResult [out] Pointer to a LRESULT value. * TRUE to cancel default processing (bookmark drawing), * FALSE to allow default processing. * @return * TRUE if the message was handled successfully, otherwise FALSE. * @see * XTP_EDIT_NM_DRAWBOOKMARK, XTP_EDIT_SENMBOOKMARK */ virtual BOOL OnDrawBookmark(NMHDR* pNMHDR, LRESULT* pResult); /** * @brief * This function is the default handler for the XTP_EDIT_NM_ROWCOLCHANGED message * which is sent before the current row or column is changed. * @param pNMHDR [in] Pointer to an XTP_EDIT_NMHDR_ROWCOLCHANGED structure. * @param pResult This parameter is unused for this handler. * @return * TRUE if the message was handled successfully, otherwise FALSE. * @see * XTP_EDIT_NM_ROWCOLCHANGED, XTP_EDIT_NMHDR_ROWCOLCHANGED */ virtual BOOL OnRowColChanged(NMHDR* pNMHDR, LRESULT* pResult); /** * @brief * This function is the default handler for the XTP_EDIT_NM_UPDATESCROLLPOS message * which is sent before the scroll bar position is changed. * @param pNMHDR [in] Pointer to an XTP_EDIT_NM_UPDATESCROLLPOS structure. * @param pResult This parameter is unused for this handler. * @return * TRUE if the message was handled successfully, otherwise FALSE. * @see * XTP_EDIT_NM_UPDATESCROLLPOS */ virtual BOOL OnUpdateScrollPos(NMHDR* pNMHDR, LRESULT* pResult); /** * @brief * This function is the default handler for the XTP_EDIT_NM_ENABLESCROLLBAR message * which is sent before the scroll bar state is changed. * @param pNMHDR [in] Pointer to an XTP_EDIT_NMHDR_ENABLESCROLLBAR structure. * @param pResult This parameter is unused for this handler. * @return * TRUE if the message was handled successfully, otherwise FALSE. * @see * XTP_EDIT_NM_ENABLESCROLLBAR */ virtual BOOL OnEnableScrollBar(NMHDR* pNMHDR, LRESULT* pResult); /** * @brief * This function is the default handler for the XTP_EDIT_NM_INSERTKEY message * which is sent when the 'Ins' (VK_INSERT) key is down (insert mode changed). * @param pNMHDR [in] Pointer to a NMHDR structure. * @param pResult This parameter is unused for this handler. * @return * TRUE if the message was handled successfully, otherwise FALSE. * @see * XTP_EDIT_NM_INSERTKEY */ virtual BOOL OnInsertKey(NMHDR* pNMHDR, LRESULT* pResult); /** * @brief * This function is the default handler for the XTP_EDIT_NM_SELINIT message * which is sent when the selection is reset. * @param pNMHDR [in] Pointer to a NMHDR structure. * @param pResult This parameter is unused for this handler. * @return * TRUE if the message was handled successfully, otherwise FALSE. * @see * XTP_EDIT_NM_SELINIT */ virtual BOOL OnSelInit(NMHDR* pNMHDR, LRESULT* pResult); /** * @brief * This function is the default handler for the XTP_EDIT_NM_STARTOLEDRAG message * which is sent when OLE dragging is started. * @param pNMHDR [in] Pointer to a NMHDR structure. * @param pResult This parameter is unused for this handler. * @return * TRUE if the message was handled successfully, otherwise FALSE. * @see * XTP_EDIT_NM_STARTOLEDRAG */ virtual BOOL OnStartOleDrag(NMHDR* pNMHDR, LRESULT* pResult); /** * @brief * This function is the default handler for the XTP_EDIT_NM_MARGINCLICKED message * which is sent when the left mouse button is clicked on the bookmarks area. * @param pNMHDR [in] Pointer to an XTP_EDIT_NMHDR_MARGINCLICKED structure. * @param pResult [out] Pointer to a LRESULT value. * TRUE to cancel default processing (breakpoint set/reset), * FALSE to allow default processing. * @return * TRUE if the message was handled successfully, otherwise FALSE. * @see * XTP_EDIT_NM_MARGINCLICKED, XTP_EDIT_NMHDR_MARGINCLICKED */ virtual BOOL OnMarginClicked(NMHDR* pNMHDR, LRESULT* pResult); /** * @brief * This function is the default handler for the XTP_EDIT_NM_PARSEEVENT message * which is sent when a parser event occurs. * @param pNMHDR [in] Pointer to an XTP_EDIT_NMHDR_PARSEEVENT structure. * @param pResult This parameter is unused for this handler. * @return * TRUE if the message was handled successfully, otherwise FALSE. * @see * XTP_EDIT_NM_PARSEEVENT, XTP_EDIT_NMHDR_PARSEEVENT */ virtual BOOL OnParseEvent(NMHDR* pNMHDR, LRESULT* pResult); protected: # ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; # endif /** * @brief * Overwrite this method to customize read-only file handling. * @return * TRUE if a read-only file can be changed, otherwise FALSE. */ virtual BOOL CanChangeReadonlyFile(); /** @cond */ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); afx_msg void OnSetFocus(CWnd* pOldWnd); afx_msg void OnEditUndo(); afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI); afx_msg void OnEditRedo(); afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI); afx_msg void OnEditCut(); afx_msg void OnUpdateEditCut(CCmdUI* pCmdUI); afx_msg void OnEditCopy(); afx_msg void OnUpdateEditCopy(CCmdUI* pCmdUI); afx_msg void OnEditPaste(); afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI); afx_msg void OnEditDelete(); afx_msg void OnUpdateEditDelete(CCmdUI* pCmdUI); afx_msg void OnEditSelectAll(); afx_msg void OnUpdateEditSelectAll(CCmdUI* pCmdUI); afx_msg void OnEditFind(); afx_msg void OnUpdateEditFind(CCmdUI* pCmdUI); afx_msg void OnEditReplace(); afx_msg void OnUpdateEditReplace(CCmdUI* pCmdUI); afx_msg void OnEditRepeat(); afx_msg void OnUpdateEditRepeat(CCmdUI* pCmdUI); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnFilePageSetup(); afx_msg void OnUpdateKeyIndicator(CCmdUI* pCmdUI); virtual void _EditFindReplace(BOOL bReplaceDlg); DECLARE_MESSAGE_MAP() /** @endcond */ protected: /** * @brief * This method is called to apply an update to all sibling views. * @param pNMHDR_EC [in] Pointer to the parameters header. * @param bTextChanged [in] TRUE if document text was changed, FALSE otherwise. */ void UpdateSiblings(XTP_EDIT_NMHDR_EDITCHANGED* pNMHDR_EC = NULL, BOOL bTextChanged = TRUE); /** * @brief * This method is called when a sibling view must be updated. * @param pSender [in] Source to be updated from. * @param dwUpdate [in] Type of update. Allowed values are: * XTP_EDIT_UPDATE_HORZ, XTP_EDIT_UPDATE_VERT, XTP_EDIT_UPDATE_DIAG. * See Also * CXTPSyntaxEditView */ void UpdateSiblingScrollPos(CXTPSyntaxEditView* pSender, DWORD dwUpdate); /** * @brief * Gets the view of a specified pane of the splitter. * @param nRow [in] Row of the splitter frame. * @param nCol [in] Column of the splitter frame. * @return * A pointer to the view of the specified pane of the splitter. * @see * CXTPSyntaxEditView */ CXTPSyntaxEditView* GetSplitterView(int nRow, int nCol); /** * @brief * Starts OLE drag. */ void StartOleDrag(); LOGFONT m_lfPrevFont; /**< Temporarily stores editor font. */ int m_nPrevTopRow; /**< Temporarily stores previous top row. */ protected: int m_nParserThreadPriority_WhenActive; /**< Parser priority (active state). */ int m_nParserThreadPriority_WhenInactive; /**< Parser priority (inactive state). */ BOOL m_bDraggingOver; /**< TRUE if dragover is going on, FALSE otherwise. */ BOOL m_bDraggingStartedHere; /**< TRUE if dragging is started in this view, FALSE otherwise. */ BOOL m_bScrollBars; /**< Whether to create control with own scrollbars, or let to manage scrolling for parent window. */ static CXTPSyntaxEditView* ms_pTargetView; /**< Target view pointer to be filled in by drag-drop routine. */ static BOOL ms_bDroppedHere; /**< TRUE if text is dropped in this view, FALSE otherwise */ static POINT ms_ptDropPos; /**< Drop mouse position. */ static DWORD_PTR ms_dwSignature; /**< Signature used during drag-drop operation. */ BOOL m_bOleDragging; /**< TRUE if OLE dragging is enabled, FALSE otherwise. */ BOOL m_bFilesDragging; /**< TRUE when dragging files, FALSE otherwise. */ COleDropTarget m_dropTarget; /**< OLE drop target. */ CSize m_szPage; /**< Page size for printing or preview. */ int m_iTopRow; /**< Top row for display. */ CWnd* m_pParentWnd; CXTPSyntaxEditCtrl* m_pEditCtrl; /**< Edit control instance. */ static CXTPSyntaxEditFindReplaceDlg* m_pFindReplaceDlg; /**< Pointer to find or replace dialog. */ BOOL m_bOnSizeRunning; /**< TRUE if the OnSize message handler is in progress, FALSE otherwise. */ CXTPSyntaxEditViewPrintOptions* m_pPrintOptions; /**< Printing options. */ CUIntArray m_aPageStart; /**< Printed page start row indexes. */ public: BOOL m_bPrintDirect; /**< TRUE if the Print Dialog is bypassed. FALSE by default. */ BOOL m_bResizeControlWithView; /**< FALSE if the attached Calendar control will not be resized with the view. TRUE by default. */ }; ///////////////////////////////////////////////////////////////////////////// AFX_INLINE CXTPSyntaxEditBufferManager* CXTPSyntaxEditView::GetEditBuffer() const { return GetEditCtrl().GetEditBuffer(); } AFX_INLINE CXTPSyntaxEditConfigurationManager* CXTPSyntaxEditView::GetLexConfigurationManager() const { return GetEditCtrl().GetLexConfigurationManager(); } AFX_INLINE CXTPSyntaxEditViewPrintOptions* CXTPSyntaxEditView::GetPrintOptions() const { return m_pPrintOptions; } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPSYNTAXEDITSYNTAXEDITVIEW_H__) /** @endcond */