/** * @file XTPSyntaxEditCtrl.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(__XTPSYNTAXEDITSYNTAXEDITCTRL_H__) # define __XTPSYNTAXEDITSYNTAXEDITCTRL_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** @cond */ typedef CMap CXTPSyntaxEditRowColorMap; /** @endcond */ // forwards class CXTPNotifySink; class CXTPSyntaxEditBufferManager; class CXTPSyntaxEditConfigurationManager; class CXTPSyntaxEditToolTipCtrl; class CXTPSyntaxEditAutoCompleteWnd; class CXTPSyntaxEditLineMarksManager; class CXTPSyntaxEditDrawTextProcessor; class CXTPSyntaxEditSelection; typedef CList CXTPSyntaxEditTextBlockList; typedef LPCTSTR XTP_EDIT_LINEMARKTYPE; struct XTP_EDIT_LMPARAM; /** * @brief * Shared Options of SyntaxEdit. */ class _XTP_EXT_CLASS CXTPSyntaxEditOptions : public CXTPCmdTarget { public: CXTPSyntaxEditOptions(); protected: BOOL m_bSyntaxColor; /**< TRUE if syntax colorization is enabled, FALSE if disabled. */ BOOL m_bAutoIndent; /**< TRUE if auto-indentation is enabled, FALSE if disabled. */ BOOL m_bSelMargin; /**< TRUE if selection margin is enabled, FALSE if disabled. */ BOOL m_bLineNumbers; /**< TRUE if line numbers are to be printed, FALSE otherwise. */ BOOL m_bWideCaret; /**< Stored Overwrite Caret Style: Thin or Thick. */ BOOL m_bTabWithSpace; /**< TRUE if tabs are replaced with spaces, FALSE otherwise. */ BOOL m_bVirtualSpace; /**< TRUE if virtual space is enabled (i.e. the cursor can be placed anywhere after the line end), otherwise FALSE. */ BOOL m_bDrawNodes; /**< TRUE if collapsible nodes signs are printed, otherwise FALSE. */ BOOL m_bEnableWhiteSpace; /**< TRUE if white space is shown, otherwise FALSE. */ BOOL m_bReadOnly; /**< TRUE if in read-only mode, otherwise FALSE. */ BOOL m_bViewOnly; /**< TRUE if in view-only mode, otherwise FALSE. */ BOOL m_bHideCaret; /**< TRUE if the caret is hidden, otherwise FALSE. */ BOOL m_bEnableEditAccelerators; /**< TRUE if the accelerators for the Cut, Copy, Paste, Undo, Redo, and Select All operations are enabled, FALSE if disabled. */ CXTPSyntaxEditRowColorMap m_mapRowBkColor; /**< Map for row back colors. */ CXTPSyntaxEditRowColorMap m_mapRowForeColor; /**< Map for row colors. */ friend class CXTPSyntaxEditCtrl; }; /** * @brief * This class is the main CWnd-based editor class. It is a rectangular * child window in which the user can enter and edit text. * @details * The control is also capable of enhancing text coloring for a number * of specific input file types (e.g. C/C++ source files, HTML files, etc.). * The user can create and customize their own text files schemes * (they are independent of source files). * The control contains the main configuration file, which can contain * references to specific configuration files. By default, this file * is placed in the same folder as the application executable and * is called EditControl.ini. * The main configuration file contains 2 blocks with references to * input file lexicographic schemes in a specific format (see below) * and color themes for the editor, which could be applied to the * control editing any file type. The format of the main configuration * file is as follows: *
 * [Schemas]
 * FileType1=SchemaFileName1.schclass
 * FileType2=SchemaFileName2.schclass
 * ...
 *
 * [Themes]
 * ThemeName1=ThemeFileName1.ini
 * ThemeName2=ThemeFileName2.ini
 * ...
 * 
*/ class _XTP_EXT_CLASS CXTPSyntaxEditCtrl : public CWnd { DECLARE_DYNAMIC(CXTPSyntaxEditCtrl) friend class CXTPSyntaxEditAutoCompleteWnd; friend class CXTPSyntaxEditView; friend class CXTPSyntaxEditCommand; friend class CXTPSyntaxEditPaintManager; friend class CXTPSyntaxEditSelection; friend class CSyntaxEditCtrl; /**< for ActiveX implementation */ friend class CSyntaxEditBaseCtrl; class CImmWrapper; public: /** * @brief * Default object constructor. */ CXTPSyntaxEditCtrl(); /** * @brief * Destroys a CXTPSyntaxEditCtrl object, handles cleanup and de-allocation. */ virtual ~CXTPSyntaxEditCtrl(); public: /** * @brief * Determines if line numbering is enabled/disabled. * @return * TRUE if line numbering is enabled, * FALSE if line numbering is disabled. */ BOOL GetLineNumbers() const; /** * @brief * Enables/disables line numbering. * @param bLineNumbers [in] TRUE to enable line numbering, * FALSE to disable line numbering. * @param bUpdateReg [in] TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return True to enable line numbering, False to disable */ BOOL SetLineNumbers(BOOL bLineNumbers, BOOL bUpdateReg = FALSE); /** * @brief * Determines if the collapsible nodes area is enabled/disabled. * @return * TRUE if the collapsible nodes area is enabled, * FALSE if the collapsible nodes area is disabled. */ BOOL GetCollapsibleNodes() const; /** * @brief * Enables/disables the collapsible nodes area. * @param bDrawNodes [in] TRUE to enable the collapsible nodes area, * FALSE to disable the collapsible nodes area. * @param bUpdateReg [in] TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. */ void SetCollapsibleNodes(BOOL bDrawNodes, BOOL bUpdateReg = FALSE); /** * @brief * Replaces all tabs with blank spaces. * @return * TRUE if successful, otherwise FALSE. */ BOOL UnTabifySelection(); /** * @brief * Replaces all blank spaces with tabs. * @return * TRUE if successful, otherwise FALSE. */ BOOL TabifySelection(); /** * @brief * Converts the selected text to lowercase. * @return * TRUE if successful, otherwise FALSE. */ BOOL LowercaseSelection(); /** * @brief * Converts the selected text to uppercase. * @return * TRUE if successful, otherwise FALSE. */ BOOL UppercaseSelection(); /** * @brief * Gets the current selection. * @return * A reference to the current selection. * @see * CXTPSyntaxEditSelection */ CXTPSyntaxEditSelection& GetSelection(); /** * @brief * Gets the auto-complete pop-up window. * @return * A pointer to the auto-complete pop-up window. * @see * CXTPSyntaxEditAutoCompleteWnd */ CXTPSyntaxEditAutoCompleteWnd* GetAutoCompleteWnd() const; /** * @brief * Gets the number of rows that can be printed per page when * using the current settings. * @return * The number of rows that can be printed per page when * using the current settings. */ int GetRowPerPage() const; /** * @brief * Determines if a specified row is visible. * @param iRow [in] Document row number to be tested. * @return * TRUE if the specified row is visible, otherwise FALSE. */ BOOL IsRowVisible(int iRow) const; /** * @brief * Sets right mouse button for dragging. * @param bRightButtonDrag [in] Boolean state flag of right button drag mode. * @details * Mainly used by CXTPSyntaxEditView for setting right button * drag mode. If parameter is TRUE function sets right button for * dragging, otherwise dragging mode is disabled for right mouse * button. * @see * void CancelRightButtonDrag(), BOOL IsRightButtonDrag() */ void SetRightButtonDrag(BOOL bRightButtonDrag = TRUE); /** * @brief * Enables/disables scrollbars. * @param bHorzSBar [in] TRUE to enable the horizontal scrollbar, * FALSE to disable the horizontal scrollbar. * @param bVertSBar [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. * @return * TRUE if the scrollbars were updated, otherwise FALSE. */ BOOL SetScrollBars(BOOL bHorzSBar, BOOL bVertSBar, BOOL bUpdateReg = FALSE); /** * @brief * Determines if the horizontal scrollbar is enabled/disabled. * @return * TRUE if the horizontal scrollbar is enabled, * FALSE if the horizontal scrollbar is disabled. */ BOOL GetHorzScrollBar() const; /** * @brief * Determines if the vertical scrollbar is enabled/disabled. * @return * TRUE if the vertical scrollbar is enabled, * FALSE if the vertical scrollbar is disabled. */ BOOL GetVertScrollBar() const; /** * @brief * Enables/disables the gutter. * @param bSelMargin [in] TRUE to enable the gutter, * FALSE to disable the gutter. * @param bUpdateReg [in] TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @details * The gutter is not visible if it is disabled. * @return * TRUE if the operation was successful, otherwise FALSE. * @see * GetSelMargin */ BOOL SetSelMargin(BOOL bSelMargin, BOOL bUpdateReg = FALSE); /** * @brief * Determines if the gutter is enabled/disabled. * @return * TRUE if the gutter is enabled, * FALSE if the gutter is disabled. * @see * SetSelMargin */ BOOL GetSelMargin() const; /** * @brief * Enables/disables syntax colorization. * @param bSyntaxColor [in] TRUE to enable syntax colorization, * FALSE to disable syntax colorization. * @param bUpdateReg [in] TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return * TRUE if the operation was successful, otherwise FALSE. * @see * GetSyntaxColor */ BOOL SetSyntaxColor(BOOL bSyntaxColor, BOOL bUpdateReg = FALSE); /** * @brief * Determines if syntax colorization is enabled/disabled. * @return * TRUE if syntax colorization is enabled, otherwise FALSE. * @see * SetSyntaxColor */ BOOL GetSyntaxColor() const; /** * @brief * Enables/disables auto-indentation. * @param bAutoIndent [in] TRUE to enable auto-indentation, * FALSE to disable auto-indentation. * @param bUpdateReg [in] TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return * TRUE if the operation was successful, otherwise FALSE. * @see * GetAutoIndent */ BOOL SetAutoIndent(BOOL bAutoIndent, BOOL bUpdateReg = FALSE); /** * @brief * Determines if auto-indentation is enabled/disabled. * @return * TRUE if auto-indentation is enabled, * FALSE if auto-indentation is disabled. * @see * SetAutoIndent */ BOOL GetAutoIndent() const; /** * @brief * Sets the tab size. * @param nTabSize [in] Tab size to be set (should be between 2 to 10). * @param bUpdateReg [in] TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return * TRUE if the operation was successful, otherwise FALSE. * @see * GetTabSize */ BOOL SetTabSize(int nTabSize, BOOL bUpdateReg = FALSE); /** * @brief * Gets the tab size. * @return * The tab size. * @see * SetTabSize */ int GetTabSize() const; /** * @brief * Determines if replacing tabs with spaces is enabled/disabled. * @return * TRUE if replacing tabs with spaces is enabled, * FALSE if replacing tabs with spaces is disabled. * @see * SetTabWithSpace */ BOOL GetTabWithSpace() const; /** * @brief * Enables/disables replacing tabs with spaces. * @param bTabWithSpace [in] TRUE to enable replacing tabs with spaces, * FALSE to disable replacing tabs with spaces. * @param bUpdateReg [in] TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return * TRUE if the operation was successful, otherwise FALSE. * @see * GetTabWithSpace */ BOOL SetTabWithSpace(BOOL bTabWithSpace, BOOL bUpdateReg = FALSE); /** * @brief * Sets the text color foreground for a specified row in the colors cache. * @param nRow [in] Row identifier. * @param clrFront [in] Text color foreground to be set. * @see * GetRowColor */ void SetRowColor(int nRow, COLORREF clrFront); /** * @brief * Gets the text color foreground of a specified row in the colors cache. * @param nRow [in] Row identifier. * @return * The text color foreground of the specified row in the colors cache. * @see * SetRowColor */ virtual COLORREF GetRowColor(int nRow) const; /** * @brief * Sets the background color of a specified row in the colors cache. * @param nRow [in] Row identifier. * @param crBack [in] Background color to be set. * @see * GetRowBkColor */ void SetRowBkColor(int nRow, COLORREF crBack); /** * @brief * Gets the background color of a specified row in the colors cache. * @param nRow [in] Row identifier. * @return * The background color of the specified row in the colors cache. * @see * SetRowBkColor */ virtual COLORREF GetRowBkColor(int nRow) const; /** * @brief * Determines if showing white space is enabled/disabled. * @return * TRUE if showing white space is enabled, * FALSE if showing white space is disabled. * @see * EnableWhiteSpace */ BOOL IsEnabledWhiteSpace() const; /** * @brief * Enables/disables showing white space. * @param bShow [in] TRUE to enable showing white space, * FALSE to disable showing white space. * @see * IsEnabledWhiteSpace */ void EnableWhiteSpace(BOOL bShow = TRUE); /** * @brief * Determines if virtual space mode is enabled/disabled. * @return * TRUE if virtual space mode is enabled, * FALSE if virtual space mode is disabled. * @see * EnableVirtualSpace */ BOOL IsEnabledVirtualSpace() const; /** * @brief * Enables/disables virtual space mode. * @param bEnable [in] TRUE to enable virtual space mode, * FALSE to disable virtual space mode. * @param bUpdateReg [in] TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @see * IsEnabledWhiteSpace */ void EnableVirtualSpace(BOOL bEnable, BOOL bUpdateReg = FALSE); /** * @brief * Determines if mouse right button drag is enabled/disabled. * @return * TRUE if mouse right button drag is enabled, * FALSE if mouse right button drag is disabled. * @see * SetRightButtonDrag, CancelRightButtonDrag */ BOOL IsRightButtonDrag() const; /** * @brief * Disables mouse right button drag. * @see * SetRightButtonDrag, IsRightButtonDrag, CXTPSyntaxEditView */ void CancelRightButtonDrag(); /** * @brief * Displays the default context menu. * @details * This member function calls OnContextMenu. * @see * OnContextMenu */ void ShowDefaultContextMenu(); /** * @brief * Handles the drop operation within the same edit buffer. * @param bCopy [in] TRUE if drag is to copy, * FALSE to specify a move. */ void HandleDrop(BOOL bCopy); /** * @brief * Moves to a specified row. * @param iRow [in] Row index. * @param bSelectRow [in] TRUE to select row, FALSE otherwise. */ void GoToRow(int iRow, BOOL bSelectRow = FALSE); /** * @brief * Replaces the selected text with specified text. * @param szNewText [in] Text to be used to replace the selected text. * @return * TRUE if the selected text was replaced, otherwise FALSE. */ BOOL ReplaceSel(LPCTSTR szNewText); /** * @brief * Replaces all occurrences of szFindText with szReplaceText. * @param szFindText [in] Pointer to the text to find. * @param szReplaceText [in] Pointer to the text to be replaced. * @param bMatchWholeWord [in] TRUE to match whole word, FALSE otherwise. * @param bMatchCase [in] TRUE to match case, FALSE otherwise. * @return * The number of found matches. */ int ReplaceAll(LPCTSTR szFindText, LPCTSTR szReplaceText, BOOL bMatchWholeWord, BOOL bMatchCase); /** * @brief * Gets the selected text. * @param strText [out] Reference to a CString object to receive * the selected text. * @return * The number of characters in the selected text. */ int GetSelectionText(CString& strText); /** * @brief * Sets the drop position. * @param iRow [in] Row of the drop position. * @param iCol [in] Column of the drop position. * @see * CXTPSyntaxEditView */ void SetDropPos(int iRow, int iCol); /** * @brief * Gets the absolute column position. * @return * The absolute column position. */ int GetCurAbsCol() const; /** * @brief * Gets the handle of the selection buffer in global memory for * a specified clipboard format (either CF_TEXT or CF_UNICODETEXT). * @param nFormat [in] Clipboard format (either CF_TEXT or CF_UNICODETEXT). * @details * This method is used mainly in OLE drag drop operations. * @return * The handle of the selection buffer in global memory for * the specified clipboard format (either CF_TEXT or CF_UNICODETEXT). */ HGLOBAL GetSelectionBuffer(UINT nFormat); /** * @brief * Enables/disables OLE drag drop mode. * @param bEnableDrag [in] TRUE to enable OLE drag drop mode, * FALSE to disable OLE drag drop mode. */ void EnableOleDrag(BOOL bEnableDrag = TRUE); /** * @brief * Validates and sets the row column to a valid one. * @param nRow [in] Document row to be validated. * @param nCol [in, out] Column to be validated. * @param nAbsCol [in, out] Absolute column to be validated. */ void ValidateCol(const int nRow, int& nCol, int& nAbsCol); /** * @brief * Gets the row and column (not validated) at a specified point. * Use CalcValidDispCol for validation. * @param pt [in] Point in client coordinates. * @param pRow [out] Pointer to an int to receive * the calculated row. * @param pCol [out] Pointer to an int to receive * the calculated column. * @param pDispRow [out] Pointer to an int to receive * the visible row. * @param pDispCol [out] Pointer to an int to receive * the visible column. * @param bVirtualSpace [in] TRUE if virtual space is enabled, otherwise FALSE. * @return * TRUE if successful, otherwise FALSE. */ BOOL RowColFromPoint(CPoint pt, int* pRow, int* pCol, int* pDispRow = NULL, int* pDispCol = NULL, BOOL bVirtualSpace = -1); /** * @brief * Deletes a tab from the front of the selection. * @return * TRUE if successful, otherwise FALSE. */ BOOL DecreaseIndent(); /** * @brief * Inserts a tab to the front of the selection. * @return * TRUE if successful, otherwise FALSE. */ BOOL IncreaseIndent(); /** * @brief * Either deletes all lines in the selection or a specified line * in the case that no selection exists. * @param iForceDeleteRow [in] Line to delete in the case that * no selection exists. */ void DeleteSelectedLines(int iForceDeleteRow); /** * @brief * Shows/hides the horizontal scrollbar. * @param bShow [in] TRUE to show the horizontal scrollbar, * FALSE to hide the horizontal scrollbar. * The default value for this parameter is TRUE. */ void ShowHScrollBar(BOOL bShow = TRUE); /** * @brief * Copies or moves text after dragging. * @param bCopy [in] TRUE to copy text, FALSE to move text. */ void CopyOrMoveText(BOOL bCopy); /** * @brief * Finds specified text. * @param szText [in] Pointer to the text to be found. * @param bMatchWholeWord [in] TRUE to find text matching the whole word, * FALSE otherwise. * @param bMatchCase [in] TRUE to find text matching the case, * FALSE otherwise. * @param bSearchDown [in] TRUE to search downward, * FALSE otherwise. * @param bRedraw [in] TRUE to redraw the control, * FALSE otherwise. * The default value of this parameter is TRUE. * @param nStartRow [in] Row number to start search. Set this * parameter to -1 to start from the current row. * @param nStartCol [in] Column number to start search. Set this * parameter to -1 to start from the current column. * @return * TRUE if the text was found, otherwise FALSE. */ BOOL Find(LPCTSTR szText, BOOL bMatchWholeWord, BOOL bMatchCase, BOOL bSearchDown, BOOL bRedraw = TRUE, int nStartRow = -1, int nStartCol = -1); /** * @brief * Selects the text bounded by a specified rectangle area. * @param nRow1 Start row of the text. * @param nDispCol1 Start visible column (character) of the text. * @param nRow2 End row of the text. * @param nDispCol2 End visible column (character) of the text. * @param bRedraw TRUE to redraw the control, * FALSE otherwise. * The default value of this parameter is TRUE. * @return * TRUE if the text was found, otherwise FALSE. */ BOOL Select(int nRow1, int nDispCol1, int nRow2, int nDispCol2, BOOL bRedraw = TRUE); /** * @brief * Deselects the previously selected rectangle area. * @see * SetCurSel */ void Unselect(); /** * @brief * Copies the control settings from a specified control. * @param src Reference to a CXTPSyntaxEditCtrl object to copy from. * @return * A reference to this CXTPSyntaxEditCtrl object. */ const CXTPSyntaxEditCtrl& operator=(const CXTPSyntaxEditCtrl& src); /** * @brief * Restores the cursor. * @details * This method is mainly used when changing the font. */ void RestoreCursor(); /** * @brief * Enables/disables overwrite mode. * @param bOverwriteMode [in] TRUE to enable overwrite mode, * FALSE to disable overwrite mode. */ void SetOverwriteMode(BOOL bOverwriteMode); /** * @brief * Sets the caret for overwrite mode. * @param bWideCaret [in] TRUE to set thin caret for overwrite mode, * FALSE to set wide caret for overwrite mode. * @param bUpdateReg [in] TRUE to update this setting in the registry, FALSE otherwise. * By default, this parameter is FALSE. * @return * TRUE if the operation was successful, otherwise FALSE. */ BOOL SetWideCaret(BOOL bWideCaret, BOOL bUpdateReg = FALSE); /** * @brief * Determines if thin caret is set for overwrite mode. * @return * TRUE if thin caret is set for overwrite mode, * FALSE if wide caret is set for overwrite mode. */ BOOL GetWideCaret() const; /** * @brief * Determines if the caret is hidden/visible. * @return * TRUE if the caret is hidden, FALSE if the caret is visible. */ BOOL IsHideCaret() const; /** * @brief * Hides/shows the caret. * @param bHide TRUE to hide the caret, FALSE to show the caret. * @details * It may be useful to hide the caret in read-only mode. */ void SetHideCaret(BOOL bHide); /** * @brief * Selects the word at a specified point. * @param point [in] Point. */ void SelectWord(CPoint point); /** * @brief * Sets the current caret position to a specified row and column. * @param nTextRow [in] Row number for the current caret position. * @param nDispCol [in] Column number for the current caret position. * @param bRowColNotify [in] TRUE to send an XTP_EDIT_NM_ROWCOLCHANGED * notification, FALSE otherwise. * @param bEnsureVisible [in] TRUE to ensure the visibility of the specified * row and column, FALSE otherwise. */ void SetCurCaretPos(int nTextRow, int nDispCol, BOOL bRowColNotify = TRUE, BOOL bEnsureVisible = TRUE); /** * @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 * Gets the associated paint manager. * @return * A pointer to the associated paint manager. */ CXTPSyntaxEditPaintManager* GetPaintManager() const; /** * @brief * Sets the associated paint manager. * @param pPaintManager [in] Pointer to a CXTPSyntaxEditPaintManager object. */ virtual void SetPaintManager(CXTPSyntaxEditPaintManager* pPaintManager); /** * @brief * Gets the draw text processor. * @return * A pointer to the draw text processor. */ CXTPSyntaxEditDrawTextProcessor& GetDrawTextProcessor(); /** * @brief * Inserts either a string or a vertical text block at a specified row and column. * @param szText [in] Pointer to the string to be inserted. * @param iRow [in] Row identifier. * @param iCol [in] Column identifier. * @param bDeleteSelection [in] TRUE to delete the selected text at insertion, * FALSE otherwise. * The default value for this parameter is TRUE. */ void InsertString(LPCTSTR szText, int iRow, int iCol, BOOL bDeleteSelection = TRUE); /** * @brief * Inserts either a string or a vertical text block at a specified row and column. * @param szText [in] Pointer to the string to be inserted. * @param iRow [in] Row identifier. * @param iCol [in] Column identifier. * @param bDeleteSelection [in] TRUE to delete the selected text at insertion, * FALSE otherwise. * The default value for this parameter is TRUE. */ void InsertTextBlock(LPCTSTR szText, int iRow, int iCol, BOOL bDeleteSelection = TRUE); /** * @brief * Gets the name of the main configuration file. * @return * The name of the main configuration file. * @see * CXTPSyntaxEditCtrl::SetConfigFile */ CString GetConfigFile() const; /** * @brief * Gets the path of the executable file module. * @return * The path of the executable file module. */ static CString AFX_CDECL GetModulePath(); /** * @brief * Sets the the path to the main configuration file. * @param szPath [in] Path to be set. * @param bConfigFileMode [in] Flag for configuration file mode. * @details * The configuration will be reloaded. * @return * TRUE if the path was found, otherwise FALSE. * @see * CXTPSyntaxEditCtrl::GetConfigFile */ BOOL SetConfigFile(LPCTSTR szPath, BOOL bConfigFileMode = TRUE); /** * @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(LPLOGFONT pLogfont, BOOL bUpdateReg = FALSE); /** * @brief * Sets the current cursor position to a specified row and column. * @param nTextRow [in] Row to be set in document coordinates. * @param nDispCol [in] Column to be set in document coordinates. * @param bRemainSelected [in] TRUE for the selected text to remain selected, * FALSE for the selected text to be deselected. * @param bForceVisible [in] TRUE to ensure the visibility of the specified * row and column, FALSE otherwise. * @see * GetCurCol, GetCurRow */ void SetCurPos(int nTextRow, int nDispCol, BOOL bRemainSelected = FALSE, BOOL bForceVisible = TRUE); /** * @brief * Gets the current column. * @return * The identifier of the current column. */ int GetCurCol() const; /** * @brief * Gets the current row. * @return * The identifier of the current row. */ int GetCurRow() const; /** * @brief * Gets the number of rows in the current document. * @return * The number of rows in the current document. */ int GetRowCount() const; /** * @brief * Selects all text. */ void SelectAll(); /** * @brief * Draws the edit control client area. * @param pDC [in] Pointer to a CDC object. * @param rcRect [in] Reference to a CRect object. * @see * PrintPage */ virtual void Draw(CDC* pDC, const CRect& rcRect); /** * @brief * Prints the edit control page. * @param pDC [in] Pointer to a CDC object. * @param rcRect [in] Reference to a CRect object. * @param nFlags [in] Additional printing options. The following are supported: * DT_CALCRECT, DT_SINGLELINE, DT_WORDBREAK * @details * The top row is used as the first page line. * @return * The number of printed rows. * @see * Draw */ virtual int PrintPage(CDC* pDC, const CRect& rcRect, int nFlags = 0); /** * @brief * Calculates the rectangles of the edit control regions. * @param prcBookMarks [out] Pointer to a CRect object to receive * the bookmarks area rectangle. * The value of this parameter may be NULL. * @param prcLineNum [out] Pointer to a CRect object to receive * the line numbers area rectangle. * The value of this parameter may be NULL. * @param prcNodes [out] Pointer to a CRect object to receive * the line nodes area rectangle. * The value of this parameter may be NULL. * @param prcText [out] Pointer to a CRect object to receive * the text area rectangle. * The value of this parameter may be NULL. * @param prcClient [in] Pointer to a CRect object containing the base edit * control rectangle to be used to calculate the other * rectangles. Set the value of this parameter to NULL * to use the edit control's window client rectangle. * @details * Empty rectangles will be returned for invisible/disabled regions. * @return * The rectangle used to calculate the other rectangles. */ virtual CRect CalcEditRects(CRect* prcBookMarks = NULL, CRect* prcLineNum = NULL, CRect* prcNodes = NULL, CRect* prcText = NULL, const CRect* prcClient = NULL) const; /** * @brief * Determines if the selection exists. * @return * TRUE if the selection exists, otherwise FALSE. */ BOOL IsSelectionExist() const; /** * @brief * Pastes from the clipboard to the document. */ void Paste(); /** * @brief * Copies the selected text to the clipboard. */ void Copy(); /** * @brief * Copies the selected text to the clipboard and * deletes the selected text from the document. */ void Cut(); /** * @brief * Determines if it is possible to perform the redo action. * @return * TRUE if it is possible to perform the redo action, otherwise FALSE. * @see * Redo */ BOOL CanRedo() const; /** * @brief * Determines if it is possible to perform the undo action. * @return * TRUE if it is possible to perform the undo action, otherwise FALSE. * @see * Undo */ BOOL CanUndo() const; /** * @brief * Performs a redo operation. * @param nActionsCount [in] Number of actions to redo simultaneously. * @return * TRUE if successful, otherwise FALSE. * @see * CanRedo */ BOOL Redo(int nActionsCount = 1); /** * @brief * Performs a undo operation. * @param nActionsCount [in] Number of actions to undo simultaneously. * @return * TRUE if successful, otherwise FALSE. * @see * CanUndo */ BOOL Undo(int nActionsCount = 1); /** * @brief * Gets the list of text for undo operations. * @return * A reference to the list of text for undo operations. */ const CStringList& GetUndoTextList(); /** * @brief * Gets the list of text for redo operations. * @return * A reference to the list of text for redo operations. */ const CStringList& GetRedoTextList(); /** * @brief * Deletes the character at a specified location. * @param iRow [in] Row identifier in document coordinates. * @param iCol [in] Column identifier in document coordinates. * @param pos [in] Position qualifier. * @return * TRUE if successful, otherwise FALSE. * @see * XTPSyntaxEditDeletePos enum. */ BOOL DeleteChar(int iRow, int iCol, XTPSyntaxEditDeletePos pos); /** * @brief * Deletes a specified range of text. * @param iRowFrom [in] Start row in document coordinates. * @param iColFrom [in] Start column in document coordinates. * @param iRowTo [in] End row in document coordinates. * @param iColTo [in] End column in document coordinates. * @param nFlags [in] Mode flag. Possible values are: * smfRedraw, smfForceRedraw, smfTextAsBlock. * @return * TRUE if successful, otherwise FALSE. * @see * XTPSyntaxEditFlags */ BOOL DeleteBuffer(int iRowFrom, int iColFrom, int iRowTo, int iColTo, int nFlags = 0); /** * @brief * Deletes the currently selected text. * @return * TRUE if successful, otherwise FALSE. */ BOOL DeleteSelection(); /** * @brief * Gets the editor text. * @param nMaxLen [in] Maximum text length to get (in TCHARs). * Set this parameter to -1 to get all text. * The default value for this parameter is -1. * @details * CWnd::GetWindowText can also be used to get the editor text. * @return * The first function returns the editor text if successful, * otherwise an empty string. * The second function returns TRUE if successful, * otherwise FALSE. * @see * SetText, CWnd::SetWindowText */ CString GetText(int nMaxLen = -1) const; /** * @brief * Gets the editor text. * @param nMaxLen [in] Maximum text length to get (in TCHARs). * Set this parameter to -1 to get all text. * The default value for this parameter is -1. * @param memFile [out] Reference to a CMemFile object to receive the text. * @details * CWnd::GetWindowText can also be used to get the editor text. * @return * The first function returns the editor text if successful, * otherwise an empty string. * The second function returns TRUE if successful, * otherwise FALSE. * @see * SetText, CWnd::SetWindowText */ BOOL GetText(CMemFile& memFile, int nMaxLen = -1) const; /** * @brief * Sets the editor text. * @param pcszText [in] Pointer to the editor text to be set. * @details * CWnd::SetWindowText can also be used to set the editor text. * @see * GetText, CWnd::GetWindowText */ void SetText(LPCTSTR pcszText); /** * @brief * Sets the top row of the visible window. * @param iRow [in] Identifier of the row to be set. * @see * GetTopRow */ void SetTopRow(int iRow); /** * @brief * Gets the identifier of the top row of the visible window. * @return * The identifier of the top row of the visible window. * @see * SetTopRow */ int GetTopRow() const; /** * @brief * Recalculates and sets the scroll bars and other related areas * depending on the text size and current position. */ void RecalcScrollBars(); /** * @brief * Repositions and resizes control bars in the client area of a window. * @param nIDFirst [in] Indentifer of the first in a range of control bars * to reposition and resize. * @param nIDLast [in] Identifier of the last in a range of control bars * to reposition and resize. * @param nIDLeftOver [in] Identifier of the pane to fill the rest of * the client area. * @param nFlag [in] This parameter can be one of the following values: * CWnd::reposDefault: Performs the layout of * the control bars. lpRectParam * is not used and can be NULL. * CWnd::reposQuery: The layout of the control bars * is not done. Instead, lpRectParam * is initialized with the size of * the client area as if the layout * had actually been done. * CWnd::reposExtra: Adds the values of lpRectParam * to the client area of nIDLast * and also performs the layout. * @param lpRectParam [in] Pointer to a RECT structure. The usage of this * structure depends on the value of nFlag. * @param lpRectClient [in] Pointer to a RECT structure containing the available * client area. If NULL, then the window's client area * will be used. * @param bStretch [in] TRUE to stretch the bar to the size of the frame, * FALSE otherwise. * @details * The nIDFirst and nIDLast parameters define a range of control bar * identifiers to be repositioned in the client area. * * The nIDLeftOver parameter specifies the identifier of the child window * (normally the view) which is repositioned and resized to fill the rest * of the client area that is not filled by control bars. */ void RepositionBars(UINT nIDFirst, UINT nIDLast, UINT nIDLeftOver, UINT nFlag = CWnd::reposDefault, LPRECT lpRectParam = NULL, LPCRECT lpRectClient = NULL, BOOL bStretch = TRUE); /** * @brief * Retrieves a pointer to a specified sibling scroll bar. * @param nBar [in] Type of scrollbar to be retrieved. * This parameter can be one of the following values: * SB_HORZ: Horizontal scroll bar. * SB_VERT: Vertical scrollbar. * @details * This member function does not operate on scroll bars created * when the WS_HSCROLL or WS_VSTROLL bits are set during the creation * of a window. * * The CWnd implementation of this method simply returns NULL. * * Derived classes, such as CView, implement the described functionality. * @return * A pointer to the specified sibling scroll bar, otherwise NULL. */ virtual CScrollBar* GetScrollBarCtrl(int nBar) const; /** * @brief * Enables/disables the scroll bar. * @param nBar [in] Scroll bar identifier. * @param bEnable [in] TRUE to enable the scroll bar, * FALSE to disable the scroll bar. * @details * If the window has a sibling scroll bar control, then that * scroll bar is used, otherwise the window's own scroll bar is used. * @see * ShowScrollBar */ void EnableScrollBarCtrl(int nBar, BOOL bEnable = TRUE); /** * @brief * Shows/hides a specified scroll bar. * @param nBar [in] Specifies if the scroll bar is a control or a part of * a window's non-client area. If the scroll bar is * a part of the non-client area, then the value of this * parameter also indicates if the scroll bar is positioned * horizontally, vertically, or both. * The value of this parameter must be one of the following: * SB_BOTH: Specifies the horizontal and vertical * scroll bars of the window. * SB_HORZ: Specifies that the window is a horizontal * scroll bar. * SB_VERT: Specifies that the window is a vertical * scroll bar. * @param bShow [in] TRUE to show the scroll bar, FALSE to hide the scroll bar. * @details * An application should not call ShowScrollBar to hide a scroll bar * while processing a scroll bar notification message. * @see * EnableScrollBarCtrl */ void ShowScrollBar(UINT nBar, BOOL bShow = TRUE); /** * @brief * Sets the minimum and maximum position values for a specified scroll bar. * @param nBar [in] Specifies the scrollbar to be set. * The value of this parameter must be one of the following: * SB_HORZ: Sets the range of the horizontal * scroll bar of the window. * SB_VERT: Sets the range of the vertical * scroll bar of the window. * @param nMinPos [in] Specifies the minimum scrolling position. * @param nMaxPos [in] Specifies the maximum scrolling position. * @param bRedraw [in] TRUE to redraw the scrollbar, FALSE otherwise. * @details * This method can also be used to hide or show standard scroll bars. * * An application should not call this function to hide a scroll bar * while processing a scroll-bar notification message. * * If the call to SetScrollRange immediately follows a call to the * SetScrollPos member function, the bRedraw parameter in the * SetScrollPos member function should be set to 0 to prevent the * scroll bar from being drawn twice. * * The default range for a standard scroll bar is 0 through 100. * The default range for a scroll bar control is empty (both the * nMinPos and nMaxPos values are 0). * * The difference between the values specified by nMinPos and nMaxPos * must not be greater than INT_MAX. */ void SetScrollRange(int nBar, int nMinPos, int nMaxPos, BOOL bRedraw = TRUE); /** * @brief * Sets the current position of a specified scroll box and, if requested, * redraws the scroll bar to reflect the new position of the scroll box. * @param nBar [in] Specifies the scroll bar to be set. * The value of this parameter must be one of the following: * SB_HORZ: Sets the position of the scroll box in * the horizontal scroll bar of the window. * SB_VERT: Sets the position of the scroll box in * the vertical scroll bar of the window. * @param nPos [in] Specifies the new position of the scroll box. The value * of this parameter must be within the scrolling range. * @param bRedraw [in] TRUE to redraw the scroll bar, FALSE otherwise. * @details * Setting bRedraw to FALSE is useful whenever the scroll bar will * be redrawn by a subsequent call to another function. * @return * The previous position of the scroll box. */ int SetScrollPos(int nBar, int nPos, BOOL bRedraw = TRUE); /** * @brief * Sets the information that the SCROLLINFO structure maintains * about a specified scroll bar. * @param nBar [in] Specifies the scroll bar to be set. * The value of this parameter must be one of the following: * SB_HORZ: Sets the position of the scroll box in * the horizontal scroll bar of the window. * SB_VERT: Sets the position of the scroll box in * the vertical scroll bar of the window. * @param lpScrollInfo [in] Pointer to a SCROLLINFO structure. * @param bRedraw [in] TRUE to redraw the scroll bar, FALSE otherwise. * @details * You must provide the values required by the SCROLLINFO structure * parameters, including the flag values. * * The SCROLLINFO structure contains information about a scroll bar, * including the minimum and maximum scrolling positions, the page * size, and the position of the scroll box (the thumb). See the * SCROLLINFO structure topic in the Platform SDK for more information * about changing the structure defaults. * @return * TRUE if successful, otherwise FALSE. * @see * GetScrollInfo, GetScrollLimit */ BOOL SetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE); /** * @brief * Retrieves the scroll limit of a specified scroll bar. * @param nBar [in] Specified the type of scroll bar. * The value of this parameter must be one of the following: * SB_HORZ: Retrieves the scroll limit of * the horizontal scroll bar. * SB_VERT: Retrieves the scroll limit of * the vertical scroll bar. * @return * The scroll limit of the specified scrollbar. */ int GetScrollLimit(int nBar); /** * @brief * Retrieves the information of a specified scroll bar. * @param nBar [in] Specifies if the scroll bar is a control or a part of * a window's non-client area. If the scroll bar is * a part of the non-client area, then the value of this * parameter also indicates if the scroll bar is positioned * horizontally, vertically, or both. * The value of this parameter must be one of the following: * SB_CTL: Contains the parameters for a scroll bar * control. The m_hWnd data member must be * the handle of the scroll bar control. * SB_HORZ: Specifies that the window is a horizontal * scroll bar. * SB_VERT: Specifies that the window is a vertical * scroll bar. * @param lpScrollInfo [out] Pointer to a SCROLLINFO structure. See the Platform SDK * for more information about this structure. * @param nMask [in] Specifies the scroll bar parameters to retrieve. * The default specifies a combination of SIF_PAGE, * SIF_POS, SIF_TRACKPOS, and SIF_RANGE. See SCROLLINFO * for more information on the nMask values. * @details * Call this member function to retrieve the information that the * SCROLLINFO structure maintains about a scroll bar. * GetScrollInfo enables applications to use 32-bit scroll positions. * * The SCROLLINFO structure contains information about a scroll bar, * including the minimum and maximum scrolling positions, the page * size, and the position of the scroll box (the thumb). See the * SCROLLINFO structure topic in the Platform SDK for more information * about changing the structure defaults. * * The MFC Windows message handlers that indicate scroll-bar position, * CWnd::OnHScroll and CWnd::OnVScroll, provide only 16 bits of position * data. GetScrollInfo and SetScrollInfo provide 32 bits of scroll-bar * position data. Thus, an application can call GetScrollInfo while * processing either CWnd::OnHScroll or CWnd::OnVScroll to obtain 32-bit * scroll-bar position data. * @return * TRUE if the message retrieved any values, otherwise FALSE. * @see * SetScrollInfo */ BOOL GetScrollInfo(int nBar, LPSCROLLINFO lpScrollInfo, UINT nMask = SIF_ALL); /** * @brief * Scrolls the specified client area with additional features. * @param dx [in] Specifies the amount, in device units, of horizontal scrolling. * This parameter must have a negative value to scroll to the left. * @param dy [in] Specifies the amount, in device units, of vertical scrolling. * This parameter must have a negative value to scroll up. * @param lpRectScroll [in] Points to a RECT structure that specifies the portion * of the client area to be scrolled. If this parameter * is NULL, the entire client area is scrolled. * @param lpRectClip [in] Points to a RECT structure that specifies the clipping * rectangle to scroll. This structure takes precedence * over the rectangle pointed to by lpRectScroll. Only * bits inside this rectangle are scrolled. Bits outside * this rectangle are not affected even if they are in * the lpRectScroll rectangle. If this parameter is NULL, * no clipping is performed on the scroll rectangle. * @param prgnUpdate [in] Identifies the region that is modified to hold the * region invalidated by scrolling. This parameter * may be NULL. * @param lpRectUpdate [out] Points to a RECT structure that will receive the * boundaries of the rectangle invalidated by scrolling. * This parameter may be NULL. * @param flags [in] Can have one of the following values: * SW_ERASE: When specified with SW_INVALIDATE, * erases the newly invalidated region by * sending a WM_ERASEBKGND message to the * window. * SW_INVALIDATE: Invalidates the region identified * by prgnUpdate after scrolling. * SW_SCROLLCHILDREN: Scrolls all child windows that * intersect the rectangle pointed * to by lpRectScroll by the number * of pixels specified in dx and dy. * Windows sends a WM_MOVE message to * all child windows that intersect * lpRectScroll, even if they do not * move. The caret is repositioned when * a child window is scrolled and the * cursor rectangle intersects the * scroll rectangle. * @return * If the function succeeds, then the return value is * SIMPLEREGION (rectangular invalidated region), * COMPLEXREGION (nonrectangular invalidated region; overlapping rectangles), * or NULLREGION (no invalidated region). * * If the function fails, then the return value is ERROR. * To get extended error information, call GetLastError. */ int ScrollWindowEx(int dx, int dy, LPCRECT lpRectScroll, LPCRECT lpRectClip, CRgn* prgnUpdate, LPRECT lpRectUpdate, UINT flags); /** * @brief * Scrolls the specified client area. * @param xAmount [in] Specifies the amount, in device units, of horizontal * scrolling. This parameter must be a negative value * to scroll to the left. * @param yAmount [in] Specifies the amount, in device units, of vertical * scrolling. This parameter must be a negative value * to scroll up. * @param lpRect [in] Points to a CRect object or RECT structure that * specifies the portion of the client area to be scrolled. * If lpRect is NULL, the entire client area is scrolled. * The caret is repositioned if the cursor rectangle * intersects the scroll rectangle. * @param lpClipRect [in] Points to a CRect object or RECT structure that * specifies the clipping rectangle to scroll. * Only bits inside this rectangle are scrolled. * Bits outside this rectangle are not affected * even if they are in the lpRect rectangle. * If lpClipRect is NULL, no clipping is performed * on the scroll rectangle. */ void ScrollWindow(int xAmount, int yAmount, LPCRECT lpRect = NULL, LPCRECT lpClipRect = NULL); /** * @brief * Gets the range of a specified scroll bar. * @param nBar [in] Specifies the scrollbar to examine. * The value of this parameter must be one of the following: * * SB_HORZ Retrieves the position of * the horizontal scroll bar. * * SB_VERT Retrieves the position of * the vertical scroll bar. * * @param lpMinPos [in] Pointer to an int to receive the minimum position. * @param lpMaxPos [in] Pointer to an int to receive the maximum position. */ void GetScrollRange(int nBar, LPINT lpMinPos, LPINT lpMaxPos) const; /** * @brief * Gets the position of a specified scroll box. * @param nBar [in] Specifies the scrollbar to examine. * The value of this parameter must be one of the following: * * SB_HORZ Retrieves the position of * the horizontal scroll bar. * * SB_VERT Retrieves the position of * the vertical scroll bar. * * @return * The position of the scroll box in the specified scroll bar if successful, * otherwise 0. */ int GetScrollPos(int nBar) const; /** * @brief * Scrolls the window by the specified offsets along the x- and y- axes. * @param yPos [in] Scroll vertically in rows. * @param xPos [in] Scroll Horizontally in columns. */ void Scroll(int xPos, int yPos); /** * @brief * Ensures the visibility of a specified row. * @param nTextRow [in] Row identifier in document coordinates. * @return * TRUE if successful, otherwise FALSE. */ BOOL EnsureVisibleRow(int nTextRow); /** * @brief * Ensures the visibility of a specified location. * @param nDispRow [in] Row identifier in display coordinates. * @param nDispCol [in] Column identifier in display coordinates. * @return * TRUE if successful, otherwise FALSE. */ BOOL EnsureVisibleCol(int nDispRow, int nDispCol); /** * @brief * Creates the window. * @param pParent [in] Pointer to the parent window (must not be NULL). * @param bHorzScroll [in] TRUE to use a horizontal scroll bar, FALSE otherwise. * @param bVertScroll [in] TRUE to use a vertical scroll bar, FALSE otherwise. * @param pBuffer [in] Pointer to the buffer for the control (used by splitter). * @param lpCS [in] Pointer to the create context of the window. * @param nID [in] Control identifier. * @return * TRUE if the window was created successfully, otherwise FALSE. */ BOOL Create(CWnd* pParent, BOOL bHorzScroll, BOOL bVertScroll, CXTPSyntaxEditBufferManager* pBuffer = NULL, CCreateContext* lpCS = NULL, UINT nID = 0); using CWnd::Create; /** * @brief * Adds/removes a breakpoint to/from a specified row. * @param nRow [in] Row identifier in document coordinates. * @details * If the row does not have a breakpoint, then * a breakpoint will be added. * If the row does have a breakpoint, then * the breakpoint will be removed. */ void AddRemoveBreakPoint(int nRow); /** * @brief * Adds/removes a bookmark to/from a specified row. * @param nRow [in] Row identifier in document coordinates. * @details * If the row does not have a bookmark, then * a bookmark will be added. * If the row does have a bookmark, then * a bookmark will be removed. */ void AddRemoveBookmark(int nRow); /** * @brief * Expands/collapses the block at a specified row. * @param nRow [in] Row identifier in document coordinates. * @details * If the block at the specified row is expanded, then * it will be collapsed. * If the block at the specified row is collapsed, then * it will be expanded. */ void CollapseExpandBlock(int nRow); /** * @brief * Removes the breakpoint from a specified row. * @param nRow [in] Row identifier in document coordinates. */ void DeleteBreakpoint(int nRow); /** * @brief * Removes the bookmark from a specified row. * @param nRow [in] Row identifier in document coordinates. */ void DeleteBookmark(int nRow); /** * @brief * Moves the current position to the previous bookmark. */ void PrevBookmark(); /** * @brief * Moves the current position to the next bookmark. */ void NextBookmark(); /** * @brief * Determines if the current document has breakpoints. * @return * TRUE if the current document has breakpoints, otherwise FALSE. */ BOOL HasBreakpoints() const; /** * @brief * Determines if the current document has bookmarks. * @return * TRUE if the current document has bookmarks, otherwise FALSE. */ BOOL HasBookmarks() const; /** * @brief * Determines if a specified row has a specified mark. * @param nRow [in] Row identifier in document coordinates. * @param lmType [in] Mark type identifier. * @param pParam [in] Pointer to XTP_EDIT_LMPARAM. * The default value for this parameter is NULL. * @return * TRUE if the specified row has the specified mark, otherwise FALSE. * @see * XTP_EDIT_LINEMARKTYPE, XTP_EDIT_LMPARAM */ BOOL HasRowMark(int nRow, const XTP_EDIT_LINEMARKTYPE& lmType, XTP_EDIT_LMPARAM* pParam = NULL) const; /** * @brief * Collapses all expanded collapsible nodes. * @see * ExpandAll */ void CollapseAll(); /** * @brief * Expands all collapsed nodes. * @see * CollapseAll */ void ExpandAll(); /** * @brief * Gets the array of available theme names. * @return * A reference to the array of available theme names. */ CStringArray& GetThemes(); /** * @brief * Applies a theme with a specified name to the editor. * @param strTheme [in] Name of the theme to be applied. */ void ApplyTheme(CString strTheme); /** * @brief * Gets the current theme name. * @return * The current theme name. */ CString GetCurrentTheme() const; /** * @brief * Refreshes the colors for the current document. * @details * Refreshing colors causes configuration files to be reread and * the current document to be reparsed. */ virtual void RefreshColors(); /** * @brief * Invalidates a specified row. * @param nRow [in] Row identifier in document coordinates. */ void InvalidateRow(int nRow); /** * @brief * Invalidates a specified set of rows. * @param nRowFrom [in] First row identifier in document coordinates. * @param nRowTo [in] Last row identifier in document coordinates. */ void InvalidateRows(int nRowFrom = -1, int nRowTo = -1); /** * @brief * Determines if a specified row is valid. * @param nDispRow [in] Row identifier in document coordinates. * @return * TRUE if the specified row is valid, otherwise FALSE. * @see * SetRowValid */ BOOL IsRowValid(int nDispRow) const; /** * @brief * Validates a specified row. * @param nDispRow [in] Row identifier in document coordinates. * @see * IsRowValid */ void SetRowValid(int nDispRow); /** * @brief * Determines if the edit control is actived/deactivated. * @return * TRUE if the edit control is actived, * FALSE if the edit control is deactivated. */ BOOL IsActive() const; /** * @brief * Activates/deactives the edit control. * @param bIsActive TRUE to activate the edit control, * FALSE to deactivate the edit control. */ virtual void SetActive(BOOL bIsActive); /** * @brief * Determines if scroll bars are created in the parent window. * @return * TRUE if scroll bars are created in the parent window, otherwise FALSE. */ BOOL IsCreateScrollbarOnParent() const; /** * @brief * Sets if scroll bars should be created in the parent window. * @param nSet TRUE to create scroll bars in the parent window, FALSE otherwise. */ void SetCreateScrollbarOnParent(BOOL nSet); /** * @brief * Determines if the document can be edited. * @return * TRUE if the document can be edited, otherwise FALSE. */ virtual BOOL CanEditDoc() const; /** * @brief * Gets if the editor is in read-only mode. * @return * TRUE if the editor is in read-only mode, otherwise FALSE. */ BOOL IsReadOnly() const; /** * @brief * Sets if the editor should be in read-only mode. * @param bReadOnly TRUE to set the editor to read-only mode, * FALSE otherwise. */ virtual void SetReadOnly(BOOL bReadOnly = TRUE); /** * @brief * Gets if the editor is in view-only mode. * @details * View-only mode is the same as read-only except with a normal background, * no cursor (caret), no selectable text, and no copy/paste. * @return * TRUE if the edit is in view-only mode, otherwise FALSE. */ BOOL IsViewOnly() const; /** * @brief * Sets if the editor should be in view-only mode. * @param bViewOnly TRUE to set the editor to view-only mode, * FALSE otherwise. * @details * View-only mode is the same as read-only except with a normal background, * no cursor (caret), no selectable text, and no copy/paste. */ void SetViewOnly(BOOL bViewOnly); /** * @brief * Determines if editor accelerators are enabled/disabled. * @details * Standard editor accelerators include: * Ctrl+C, Ctrl+V, Ctrl+X, Ctrl+Y, Ctrl+Z, Ctrl+Shift+Z, Ctrl+A, * Ctrl+Ins, Shift+Ins, Alt+Backspace. * @details * You can support any of these editing operations externally * by calling member functions. * * By default, this feature is disabled. * @return * TRUE if editor accelerators are enabled, * FALSE if editor accelerators are disabled. */ BOOL IsEnabledEditAccelerators() const; /** * @brief * Enables/disables editor accelerators. * @param bEnable TRUE to enable editor accelerators, * FALSE to disable editor accelerators. * @details * By default, this feature is disabled. */ void EnableEditAccelerators(BOOL bEnable); BOOL HasFocus() const; /** @cond */ public: virtual BOOL PreTranslateMessage(MSG* pMsg); virtual BOOL PreCreateWindow(CREATESTRUCT& cs); virtual void PreSubclassWindow(); virtual void OnFinalRelease(); virtual BOOL _InitEditControl(); virtual DWORD ProcessCollapsedRowsBeroreDraw(int nTextRow, int& rnSkipRowsCount); virtual BOOL _IsVirtualSpaceActive() const; virtual void _EnsureVisible(int nTextRow, int nDispCol); virtual BOOL SetValueInt(LPCTSTR lpszValue, int nNewValue, int& nRefValue, BOOL bUpdateReg); virtual BOOL SetValueBool(LPCTSTR lpszValue, BOOL bNewValue, BOOL& bRefValue, BOOL bUpdateReg); void SetInternalRowBkColor(int nRow, COLORREF crBack); void SetInternalRowColor(int nRow, COLORREF crText); protected: afx_msg void OnPaint(); afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnDestroy(); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnSetFocus(CWnd* pOldWnd); afx_msg BOOL OnNcActivate(BOOL bActive); afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message); afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); afx_msg void OnRButtonDown(UINT nFlags, CPoint point); afx_msg void OnRButtonUp(UINT nFlags, CPoint point); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); afx_msg void OnTimer(UINT_PTR nIDEvent); afx_msg void OnKillFocus(CWnd* pNewWnd); afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized); afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnGetText(WPARAM wBufferSize, LPARAM lpBuffer); afx_msg LRESULT OnGetTextLen(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnGetFont(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnSetFont(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnInputLanguage(WPARAM wParam, LPARAM lParam); afx_msg void OnDragCopy(); afx_msg void OnDragMove(); afx_msg UINT OnGetDlgCode(); DECLARE_MESSAGE_MAP() /** @endcond */ ///////////////////////////////////////////////////////////////// // Methods ///////////////////////////////////////////////////////////////// /** * @brief * Calculates the rectangle(s) for a collapsible node icon. * @param nDispRow [in] Window row identifier for which to print. * @param rcNode [out] Reference to a CRect object to receive * the node icon rectangle. * @param prcNodeFull [out] Pointer to a CRect object to receive * the full node area rectangle. */ void GetLineNodeRect(int nDispRow, CRect& rcNode, CRect* prcNodeFull = NULL) const; /** * @brief * Calculates the edit bar length. * @param pDC [in] Pointer to a device context. */ void CalculateEditbarLength(CDC* pDC = NULL); /** * @brief * Recalculates the scroll bars * depending on the text size and current position. */ void _RecalcScrollBars(); /** * @brief * Recalculates the maximum width of the horizontal scrollbar * depending on the visible text size. */ void _RecalcHScrollMaxWidth(); /** * @brief * Updates the IME status. */ void _UpdateIMEStatus(); /** * @brief * Adds tabs and spaces to specified text until it reaches * a specified display column. * @param rstrTextToIns [in, out] Reference to the text to be added to. * @param nDispCol [in] Identifier of the display column to reach. */ void FillTabs(CString& rstrTextToIns, int nDispCol); /** * @brief * Fills and/or calculates number of tabs or blank spaces required. * @param szText [in] Text to be inserted. * @param strTextToIns [out] Return string with all the indentation. * @param iNewRow [out] New row. * @param iNewCol [out] New absolute column. * @param iNewDispCol [out] New display column. * @param iEditRowFrom [out] Start row for XTP_EDIT_NM_EDITCHANGED. * @param iEditRowTo [out] End row for XTP_EDIT_NM_EDITCHANGED. * @param iChainActionCount [out] Chain action count for undo. * @return * TRUE if successful, otherwise FALSE. */ BOOL CreateInsertText(LPTSTR szText, CString& strTextToIns, int& iNewRow, int& iNewCol, int& iNewDispCol, int& iEditRowFrom, int& iEditRowTo, int& iChainActionCount); /** * @brief * Sends an XTP_EDIT_NM_EDITCHANGED notification with specified parameters. * @param iRowFrom [in] Start row identifier. * @param iRowTo [in] End row identifier. * @param nActions [in] Action mask. */ void NotifyEditChanged(int iRowFrom, int iRowTo, UINT nActions); /** * @brief * Sends a notification when the current text position is changed. * @param nRow [in] Row to be notified (in document coordinates). * @param nCol [in] Column to be notified. */ void NotifyCurRowCol(int nRow, int nCol) const; /** * @brief * Sends any notifications to the parent. * @param uCode [in] Notification code. * @return * The LRESULT value returned by the parent notification handler. */ virtual LRESULT NotifyParent(UINT uCode) const; /** * @brief * Sends any mouse notifications to the parent. * @param uCode [in] Mouse notification code (e.g. XTP_EDIT_NM_LBUTTONDOWN). * @param nFlags [in] Mouse event flags. * @param point [in] Reference to the mouse event cursor position. * @return * The LRESULT value returned by the parent notification handler. * @see * XTP_EDIT_NM_LBUTTONDOWN, XTP_EDIT_NM_LBUTTONDBLCLICK, XTP_EDIT_NM_LBUTTONUP, * XTP_EDIT_NM_RBUTTONDOWN, XTP_EDIT_NM_RBUTTONUP, XTP_EDIT_NM_MOUSEMOVE. */ virtual LRESULT NotifyMouseEvent(UINT uCode, UINT nFlags, const CPoint& point) const; /** * @brief * Notifies the parent that the user clicked in the bookmark area. * @param nRow [in] Document row. * @param nDispRow [in] Visible row. * @return * TRUE if the action was handled, otherwise FALSE. */ virtual BOOL NotifyMarginLBtnClick(int nRow, int nDispRow) const; /** * @brief * Initializes the selection of all sibling views. */ virtual void NotifySelInit() const; /** * @brief * Recalculates the horizontal scroll bar. */ void RecalcHorzScrollPos(); /** * @brief * Recalculates the vertical scroll bar. */ void RecalcVertScrollPos(); /** * @brief * Searches for the next/previous word position. * @param nFindWhat [in] XTP_EDIT_FINDWORD_NEXT to find the next word, * XTP_EDIT_FINDWORD_PREV to find the previous word. */ void FindWord(UINT nFindWhat); /** * @brief * Searches for the next/previous word position. * @param nFindWhat [in] XTP_EDIT_FINDWORD_NEXT to find the next word, * XTP_EDIT_FINDWORD_PREV to find the previous word. * @param nTextRow [in] Row identifier. * @param nCol [in] Column identifier (column is one-based). * @param rlcWordStart [out] Reference to an XTP_EDIT_LINECOL object * to receive the word start position. * @param rlcWordEnd [out] Reference to an XTP_EDIT_LINECOL object * to receive the word end position. * @param rbOverSpace [out] Reference to a BOOL to receive a value of * TRUE if the search began on a space character or * FALSE if the search began on a tab character. * @return * TRUE if the word was found, otherwise FALSE. */ BOOL FindWordEx(UINT nFindWhat, int nTextRow, int nCol, XTP_EDIT_LINECOL& rlcWordStart, XTP_EDIT_LINECOL& rlcWordEnd, BOOL& rbOverSpace); /** * @brief * Searches for the next/previous word position. * @param nFindWhat [in] XTP_EDIT_FINDWORD_NEXT to find the next word, * XTP_EDIT_FINDWORD_PREV to find the previous word. * @param lcPos_str [in] Text position (column is zero-based). * @param rlcWordStart [out] Reference to an XTP_EDIT_LINECOL object * to receive the word start position. * @param rlcWordEnd [out] Reference to an XTP_EDIT_LINECOL object * to receive the word end position. * @param rbOverSpace [out] Reference to a BOOL to receive a value of * TRUE if the search began on a space character or * FALSE if the search began on a tab character. * @return * TRUE if the word was found, otherwise FALSE. */ BOOL FindWordEx_str(UINT nFindWhat, XTP_EDIT_LINECOL lcPos_str, XTP_EDIT_LINECOL& rlcWordStart, XTP_EDIT_LINECOL& rlcWordEnd, BOOL& rbOverSpace); /** * @brief * Attempts to match text using the specified parameters. * @param nRow [in] Row to match for. * @param szLineText [in] Line text. * @param szMatchText [in] Text to be matched. * @param nStartPos [in] Start position. * @param bMatchWholeWord [in] TRUE to match whole words, * FALSE otherwise. * @param bMatchCase [in] TRUE to match case, * FALSE otherwise. * @param bSearchForward [in] TRUE to search forward, * FALSE otherwise. * @param bRedraw [in] TRUE to redraw the control after the search, * FALSE otherwise. * @return * TRUE if successful, otherwise FALSE. */ BOOL MatchText(int nRow, LPCTSTR szLineText, LPCTSTR szMatchText, int nStartPos, BOOL bMatchWholeWord, BOOL bMatchCase, BOOL bSearchForward, BOOL bRedraw = TRUE); /** * @brief * Gets the effective parent window. * @return * A pointer to the effective parent window. */ CWnd* GetEffectiveParent() const; /** * @brief * Calculate and returns the display column for another display column * specified in the iCol parameter. * @param szText [in] The text on which the calculation should be made. * @param iCol [in] The display column for which calculation is needed. * @return * The display column as integer value. */ int CalcValidDispCol(LPCTSTR szText, int iCol) const; /** * @brief * Calculates the absolute column for a specified display column. * @param szText [in] Text for calculation. * @param nDispCol [in] Display column position. * @return * The calculated absolute column. */ int CalcAbsCol(LPCTSTR szText, int nDispCol) const; /** * @brief * Calculates the display column for a specified absolute column. * @param szText [in] Text for calculation. * @param nActualCol [in] Absolute column position. * @return * The calculated display column. */ int CalcDispCol(LPCTSTR szText, int nActualCol) const; public: /** * @brief * Calculates the absolute column for a specified display column. * @param nTextRow [in] Row identifier. * @param nDispCol [in] Display column position. * @return * The calculated absolute column. */ int CalcAbsCol(int nTextRow, int nDispCol) const; /** * @brief * Calculates the display column for a specified absolute column. * @param nTextRow [in] Row identifier. * @param nActualCol [in] Absolute column position. * @return * The calculated display column. */ int CalcDispCol(int nTextRow, int nActualCol) const; /** * @brief * Gets a pointer to the line marks manager associated * with the current text buffer. * @return * A pointer to the line marks manager associated * with the current text buffer. */ CXTPSyntaxEditLineMarksManager* GetLineMarksManager() const; /** * @brief * Sets the text value for a specified row. * @param nRow [in] Row identifier. * @param pcszText [in] New row text. * @param bCanUndo [in] TRUE if this can be undone, FALSE otherwise. * @details * The parser is notified to reparse the changed text. */ void SetRowText(int nRow, LPCTSTR pcszText, BOOL bCanUndo); /** * @brief * Inserts a new row. * @param nRow [in] Row identifier to insert at. * @param pcszText [in] New row text. * @param bCanUndo [in] TRUE if this can be undone, FALSE otherwise. * @details * The parser is notified to reparse the changed text. */ void InsertRow(int nRow, LPCTSTR pcszText, BOOL bCanUndo); /** * @brief * Removes a specified row. * @param nRow [in] Row identifier. * @param bCanUndo [in] TRUE if this can be undone, otherwise FALSE. * @details * The parser is notified to reparse the changed text. */ void RemoveRow(int nRow, BOOL bCanUndo); /** * @brief * Gets the text colors of a specified row. * @param nTextRow [in] Row identifier. * @param nColFrom [in] Zero-based start column number. * @param nColTo [in] Zero-based end column number. * A value of -1 indicates the line end. * @param clrDefault [in] Constant reference to an XTP_EDIT_COLORVALUES structure * containing the default text colors. By default, * CXTPSyntaxEditPaintManager::m_clrValues is passed. * @param rBlocks [out] Pointer to a CXTPSyntaxEditTextBlockList object * to receive the text colors. * @details * The default implementation calls CXTPSyntaxEditLexTextSchema::GetRowColors. * You may override this method and create your own fast implementation * for the simple colors schemas. */ virtual void GetRowColors(int nTextRow, int nColFrom, int nColTo, const XTP_EDIT_COLORVALUES& clrDefault, CXTPSyntaxEditTextBlockList* rBlocks); /** * @brief * Gets the collapsable text blocks of a specified row. * @param nTextRow [in] Row identifier. * @param rArBlocks [out] Reference to a CXTPSyntaxEditRowsBlockArray object * to receive the collapsable text blocks. * @details * The default implementation calls CXTPSyntaxEditLexTextSchema::GetCollapsableBlocksInfo. * You may override this method and create your own fast implementation. */ virtual void GetCollapsableBlocksInfo(int nTextRow, CXTPSyntaxEditRowsBlockArray& rArBlocks) const; public: /** * @brief * Gets the text of a specified line. * @param nRow [in] Row identifier. * @param bAddCRLF [in] Specifies how to process the end of text lines. * The default value of this parameter is FALSE. * @param iCRLFStyle [in] Style of the end of text lines. * The default value of this parameter is -1. * @return * The text of the specified line. */ CString GetLineText(int nRow, BOOL bAddCRLF = FALSE, int iCRLFStyle = -1) const; /** * @brief * Gets the text of a specified line. * @param bAddCRLF [in] Specifies how to process the end of text lines. * The default value of this parameter is FALSE. * @param iCRLFStyle [in] Style of the end of text lines. * The default value of this parameter is -1. * @param strBuffer [out] Reference to the text buffer to receive * the text of the specified line. * @param nRow [in] Row identifier. */ void GetLineText(int nRow, CString& strBuffer, BOOL bAddCRLF = FALSE, int iCRLFStyle = -1) const; protected: /** * @brief * Expands the character set by putting spaces in the position of tabs. * @param pDC [in] Pointer to a CDC object. * @param pszChars [in] Text to be processed. * @param nCurPos [in] Current position in the line. * @param strBufer [in] Reference to the buffer for text * to be created after expansion. * @return * The length of the processed text after expansion. */ int ExpandChars(CDC* pDC, LPCTSTR pszChars, int nCurPos, CString& strBufer); /** * @brief * Calculates the collapsed text sign rectangle (like for [..]). * @param pDC [in] Pointer to a CDC object. * @param pCoDrawBlk [in] Pointer to an XTP_EDIT_COLLAPSEDBLOCK structure. * @param rcCoBlk [in, out] Reference to a rectangle with * a collapsed block text area. * The right border is updated by this function. * @see * XTP_EDIT_COLLAPSEDBLOCK */ void ProcessCollapsedText(CDC* pDC, XTP_EDIT_COLLAPSEDBLOCK* pCoDrawBlk, CRect& rcCoBlk); /** * @brief * Performs the same functionality as ProcessCollapsedText, * but has additional checks for input parameters. * @param pDC [in] Pointer to a CDC object. * @param pCoDrawBlk [in] Pointer to an XTP_EDIT_COLLAPSEDBLOCK structure. * @param txtBlk [in] Pointer to an XTP_EDIT_TEXTBLOCK structure. * @param rcCoBlk [in, out] Reference to a rectangle with * a collapsed block text area. * The right border is updated by this function. * @return * TRUE if the operation was successful, otherwise FALSE. * @see * XTP_EDIT_COLLAPSEDBLOCK, XTP_EDIT_TEXTBLOCK */ BOOL ProcessCollapsedTextEx(CDC* pDC, XTP_EDIT_COLLAPSEDBLOCK* pCoDrawBlk, const XTP_EDIT_TEXTBLOCK& txtBlk, CRect& rcCoBlk); /** * @brief * Gets the collapsed text of a specified collapsed block. * @param pCoDrawBlk [in] Pointer to an XTP_EDIT_COLLAPSEDBLOCK structure. * @param nMaxLinesCount [in] Maximum lines of text. * The default value of this parameter is 150. * @return * The collapsed text of the specified collapsed block. * @see * XTP_EDIT_COLLAPSEDBLOCK */ CString GetCollapsedText(XTP_EDIT_COLLAPSEDBLOCK* pCoDrawBlk, int nMaxLinesCount = 150) const; /** * @brief * Gets the collapsed block, if any, at a specified point. * @param ptMouse [in] Reference to the mouse coordinates * to check for a collapsed block. * @return * A pointer to the XTP_EDIT_COLLAPSEDBLOCK structure, if any, * at the specified point, otherwise NULL. * @see * XTP_EDIT_COLLAPSEDBLOCK */ XTP_EDIT_COLLAPSEDBLOCK* GetBlockFromPt(const CPoint& ptMouse) const; /** * @brief * Shows a tooltip with the collapsed text of the collapsed block * at a specified point. * @param ptMouse [in] Reference to the mouse coordinates * to check for a collapsed block. * @see * CXTPSyntaxEditToolTipCtrl, m_wndToolTip */ void ShowCollapsedToolTip(const CPoint& ptMouse); /** * @brief * Expands a collapsed block if it is double clicked. * @param ptMouse [in] Reference to the mouse coordinates * to check for a collapsed block. * @return * The number of rows that the collapsed block was expanded, * otherwise 0 if the collapsed block was not expanded. * @see * CXTPSyntaxEditToolTipCtrl */ int ProcessCollapsedBlockDblClick(const CPoint& ptMouse); /** * @brief * Updates sibling views while in split mode. * @param dwUpdate [in] View update flags. */ void UpdateScrollPos(DWORD dwUpdate = XTP_EDIT_UPDATE_ALL); /** * @brief * Sets the modification flag for the currently opened document. * @param bModified [in] TRUE to set the modification flag to modified, * FALSE otherwise. * The default value of this parameter is TRUE. */ void SetDocModified(BOOL bModified = TRUE); /** * @brief * Calculates the maximum width of specified text. * @param szText [in] Text for calculation. * @return * The maximum width of the specified text. */ int CalcMaximumWidth(LPCTSTR szText); /** * @brief * Gets the default configuration file path. * @return * The default configuration file path. */ CString GetDefaultCfgFilePath(); /** * @brief * Internal editing event handler. * @param nRow [in] Row identifier. * @param nCol [in] Column identifier. */ void OnBeforeEditChanged(int nRow, int nCol); /** * @brief * Internal editing event handler. * @param nRowFrom [in] Start row identifier. * @param nColFrom [in] Start column identifier. * @param nRowTo [in] End row identifier. * @param nColTo [in] End column identifier. * @param eEditAction [in] Action identifier. */ void OnEditChanged(int nRowFrom, int nColFrom, int nRowTo, int nColTo, int eEditAction); /** * @brief * Internal editing event handler. * @param LCFrom [in] Start coordinates. * @param LCTo [in] End coordinates. * @param eEditAction [in] Action identifier. * @see * XTP_EDIT_LINECOL */ void OnEditChanged(const XTP_EDIT_LINECOL& LCFrom, const XTP_EDIT_LINECOL& LCTo, int eEditAction); /** * @brief * Internal editing event handler. * @param code [in] Event code. * @param wParam [in] Event parameter 1. * @param lParam [in] Event parameter 2. * @see * XTP_NOTIFY_CODE */ void OnParseEvent(XTP_NOTIFY_CODE code, WPARAM wParam, LPARAM lParam); /** * @brief * Sends a WM_NOTIFY message with an XTP_EDIT_NM_PARSEEVENT code to the parent window. * @param code [in] Event code from the XTPSyntaxEditOnParseEvent enumeration. * @param wParam [in] Event parameter 1. * @param lParam [in] Event parameter 2. * @return * TRUE if the operation was successful, otherwise FALSE. * @see * XTPSyntaxEditOnParseEvent */ BOOL NotifyParseEvent(XTP_NOTIFY_CODE code, WPARAM wParam, LPARAM lParam); /** * @brief * Internal editing event handler. * @param code [in] Event code from the XTPSyntaxEditOnCfgChangedEvent enumeration. * @param wParam [in] Event parameter 1. * @param lParam [in] Event parameter 2. * @see * XTPSyntaxEditOnCfgChangedEvent */ void OnLexCfgWasChanged(XTP_NOTIFY_CODE code, WPARAM wParam, LPARAM lParam); /** * @brief * Gets the current document row. * @return * The identifier of the current document row. * @see * SetCurrentDocumentRow */ int GetCurrentDocumentRow() const; /** * @brief * Sets the current document row. * @param nRow [in] Row identifier. * @see * GetCurrentDocumentRow */ void SetCurrentDocumentRow(int nRow); /** * @brief * Gets the current visible row. * @return * The identifier of the current visible row. */ int GetCurrentVisibleRow(); /** * @brief * Calculates document row basing in visible row. * @param nVisibleRow [in] Visible row. * @return * Integer value of document row. * @see * GetCurrentVisibleRow */ int GetDocumentRow(int nVisibleRow); /** * @brief * Calculates document row basing in global visible row. * @param nStartDocumentRow [in] Start document row. * @param nRowDelta [in] Visible rows count. * @return * Integer value of document row. */ int CalculateDocumentRow(int nStartDocumentRow, int nRowDelta); /** * @brief * Calculates visible row basing in document row. * @param nDocumentRow [in] Document row. * @return * Integer value of visible row. */ int GetVisibleRow(int nDocumentRow); /** * @brief * Calculates global visible row basing in document row. * @param nStartDocumentRow [in] Start row. * @param nDocumentRow [in] Count of document rows. * @return * Integer value of global visible row. Returns 1 if value less than 1. * @see * CalculateVisibleRow_ */ int CalculateVisibleRow(int nStartDocumentRow, int nDocumentRow); /** * @brief * Calculates global visible row basing in document row. * @param nStartDocumentRow [in] Start row. * @param nDocumentRow [in] Count of document rows. * @return * Integer value of global visible row. Can return values less than 1 if * nStartDocumentRow bigger than nDocumentRow. * @see * CalculateVisibleRow */ int CalculateVisibleRow_(int nStartDocumentRow, int nDocumentRow); /** * @brief * Gets the maximum number of visible rows. * @param nMaxDocRow [in] Maximum document row up to which to calculate * the visible rows. If a value of -1 is passed, * then the visible rows will be calculated until * the end of the document. * The default value of this parameter is -1. * @return * The maximum number of visible rows. */ int GetVisibleRowsCount(int nMaxDocRow = -1); /** * @brief * Moves the current row up a specified number of rows. * @param nCount [in] Number of rows. * @return * The identifier of the current visible row. */ int MoveCurrentVisibleRowUp(int nCount); /** * @brief * Moves the current row down a specified number of rows. * @param nCount [in] Number of rows. * @return * The identifier of the current visible row. */ int MoveCurrentVisibleRowDown(int nCount); /** * @brief * Shifts the current row up a specified number of rows. * @param nCount [in] Number of rows. * @param bChangeCaret [in] Caret movement flag. * The default value of this parameter is FALSE. * @return * TRUE if the screen was changed, otherwise FALSE. */ BOOL ShiftCurrentVisibleRowUp(int nCount, BOOL bChangeCaret = FALSE); /** * @brief * Shifts the current row down a specified number of rows. * @param nCount [in] Number of rows. * @param bChangeCaret [in] Caret movement flag. * The default value of this parameter is FALSE. * @return * TRUE if the screen was changed, otherwise FALSE. */ BOOL ShiftCurrentVisibleRowDown(int nCount, BOOL bChangeCaret = FALSE); /** * @brief * Gets the length of a collapsed block. * @param nStartRow [in] Start row of the collapsed block. * @param rnLen [out] Reference to an int to receive * the length of the collapsed block. * @return * TRUE if successful, otherwise FALSE. */ BOOL GetCollapsedBlockLen(int nStartRow, int& rnLen) const; /** * @brief * Gets the row node type. * @param nRow [in] Row identifier. * @param dwType [out] Reference to a DWORD to receive * the row node type. * @return * TRUE if successful, otherwise FALSE. */ BOOL GetRowNodes(int nRow, DWORD& dwType) const; /** * @brief * Loads data into an auto-complete list. */ virtual void SetAutoCompleteList(); /** * @brief * Refreshes line marks depending on the change type. * @param pEditChanged [in] Pointer to an XTP_EDIT_NMHDR_EDITCHANGED structure. * @see * LPXTP_EDIT_NMHDR_EDITCHANGED */ virtual void RefreshLineMarks(XTP_EDIT_NMHDR_EDITCHANGED* pEditChanged); /** * @brief * Redraws line marks. */ virtual void RedrawLineMarks(); /** * @brief * Performs undo/redo operations and common control properties adjustment. * @param nActionsCount [in] Number of actions to undo/redo. * @param bUndoRedo [in] TRUE to perform undo operations, * FALSE to perform redo operations. * @return * TRUE if successful, otherwise FALSE. */ BOOL DoUndoRedo(int nActionsCount, BOOL bUndoRedo); /** * @brief * Changes the case of the selection. * @param bUpper [in] TRUE to change the selection case to upper, * FALSE to change the selection case to lower. * @return * TRUE if successful, otherwise FALSE. */ BOOL DoChangeSelectionCase(BOOL bUpper); /** * @brief * Changes the tabification of the selection. * @param bTabify [in] TRUE to change spaces to tabs, * FALSE to change tabs to spaces. * @return * TRUE if successful, otherwise FALSE. */ BOOL DoChangeSelectionTabify(BOOL bTabify); /** * @brief * Reads options from the registry. * @return * TRUE if successful, otherwise FALSE. */ BOOL GetRegValues(); /** * @brief * Internally updates drawing information * (e.g. each character position) in the draw text processor. * @param nTextRow Row identifier. * @details * This method draws the specified row on the memory device context. */ void UpdateRowInfoInternally(int nTextRow); /** * @brief * Determines the scroll direction for automatic scrolling * (when selecting by mouse). * @param pnCols [out] Pointer to an int to receive * the columns count to scroll. May be NULL. * @param pnRows [out] Pointer to an int to receive * the rows count to scroll. May be NULL. * @return * Flags from the CXTPSyntaxEditCtrl::XTPScrolDirection enumeration. */ virtual DWORD GetAutoscrollDirection(int* pnCols = NULL, int* pnRows = NULL); /** * @brief * Subtracts the selection size from a specified position. * @param lcDispPos Position. * @return * The subtracted position. */ XTP_EDIT_LINECOL _SubtractSelSizeFromPos(XTP_EDIT_LINECOL lcDispPos); /** * @brief * Sets variables for auto-indent. * @param nBaseDocRow [in] Text row to calculate auto-indent start. * @param nDispCol_prev [in] Previous display column (before enter pressed). */ virtual void DoAutoIndentIfNeed(int nBaseDocRow, int nDispCol_prev); /** * @brief * Notifies the parent window that the scroll bar state has changed. * @param dwScrollBar [in] Defines the scroll bar(s) to change state as * WS_HSCROLL and WS_VSCROLL flags. * @param dwState [in] Defines the scroll bar(s) state as * WS_HSCROLL and WS_VSCROLL flags. * @details * The default implementation sends an * XTP_EDIT_NM_ENABLESCROLLBAR notification to the parent. */ virtual void _EnableScrollBarNotify(DWORD dwScrollBar, DWORD dwState); virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point); virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point); private: void RedrawScrollBar(int nBar); void InvalidateAll(); protected: CXTPSyntaxEditOptions* m_pOptions; ///////////////////////////////////////////////////////////////////////// // Variables ///////////////////////////////////////////////////////////////////////// BOOL m_bVertScrollBarEnabled; BOOL m_bHorzScrollBarEnabled; CXTPSyntaxEditRowColorMap m_mapInternalRowBkColor; /**< Map for row back colors. */ CXTPSyntaxEditRowColorMap m_mapInternalRowForeColor; /**< Map for row colors. */ CXTPNotifySink* m_pSink; BOOL m_bVertScrollBar; /**< TRUE if vertical scrollbar is enabled. */ BOOL m_bHorzScrollBar; /**< TRUE if horizontal scrollbar is enabled. */ BOOL m_bScrolling; /**< TRUE if scrolling by mouse wheel. */ BOOL m_bCaseSensitive; /**< TRUE if case sensitive. */ BOOL m_bEnableOleDrag; /**< TRUE if OLE drag drop is enabled. */ BOOL m_bIsSmartIndent; /**< TRUE if smart indentation is enabled. */ BOOL m_bRightButtonDrag; /**< TRUE if the user is dragging through right button. */ BOOL m_bIsScrollingEndRow; /**< Maintains an internal logic to draw the last row which is partly visible */ BOOL m_bTokensLoaded; /**< TRUE if if tokens are loaded. */ BOOL m_bDroppable; /**< TRUE if the current position is droppable. */ BOOL m_bDragging; /**< TRUE if in dragging mode. */ BOOL m_bIsDragging; /**< TRUE if dragging, FALSE otherwise. */ BOOL m_bPageDirty; /**< TRUE if the whole page is dirty. */ BOOL m_bIsActive; /**< TRUE if the application is active. */ BOOL m_bFocused; /**< TRUE if focused. */ BOOL m_bCreateScrollbarOnParent; /**< TRUE if parent window scroll bars are used, otherwise FALSE. */ BOOL m_bAllowExpandCollapse; BOOL m_bActivateOnFocus; /**< Flag to activate control on focus set (like CXTPSyntaxEditView do). */ int m_nTopCalculatedRow; /**< Top row of the last range of rows that have scrollbars properly calculated. */ int m_nBottomCalculatedRow; /**< Bottom row of the last range of rows that have scrollbars properly calculated. */ int m_nEditbarLength; /**< Edit bar length including gutter and line number. */ int m_nMarginLength; /**< Margin length. */ int m_nLineNumLength; /**< Line numbers length. */ int m_nNodesWidth; /**< The width of the nodes signs. */ int m_nInsertTabCount; /**< Temporarily stores the number of tabs to be inserted for auto-indentation. */ int m_nInsertSpaceCount; /**< Temporarily stores the number of spaces to be inserted for auto-indentation. */ int m_nAutoIndentCol; /**< Contains the column for auto-indentation. */ int m_nTopRow; /**< Top row for display. */ int m_nCurrentDocumentRow; /**< Current row in the document. */ int m_nCurrentCol; /**< Current absolute column. */ int m_nDispCol; /**< Current display column. */ int m_nWheelScroll; /**< Lines to scroll on mouse wheel. */ int m_nAverageLineLen; /**< Average length of line. */ int m_nCollapsedTextRowsCount; /**< The total amount of collapsed blocks in the document. */ DWORD m_dwInsertPos; /**< Current insert position. */ DWORD m_dwLastRedrawTime; /**< Stores last redrawing time. */ # ifndef _UNICODE // DBCS Support (specially for IME) BYTE m_chPrevLeadByte; /**< For non-UNICODE version, IME sends double byte chars as 2 messages. This member keeps a lead byte until second byte receive to process them together. */ # endif CPoint m_ptDropPos; /**< Drop position. */ CPoint m_ptPrevMouse; /**< Mouse position of the previous tip showing. */ CBitmap m_bmpCache; /**< Current view cached picture. */ CXTPSyntaxEditSelection* m_pSelection; /**< Current selection. */ /** * @brief * This enum defines flags for auto-scroll direction. */ enum XTPScrolDirection { xtpLeft = 0x0001, /**< Defines left direction. */ xtpRight = 0x0010, /**< Defines right direction. */ xtpTop = 0x0100, /**< Defines top direction. */ xtpBottom = 0x1000, /**< Defines bottom direction. */ }; DWORD m_dwAutoScrollDirection; /**< Active auto-scroll direction. */ CXTPSyntaxEditBufferManager* m_pBuffer; /**< The buffer manager. */ CXTPSyntaxEditPaintManager* m_pPaintManeger; /**< The paint manager. */ CWnd* m_pParentWnd; /**< Pointer to the parent window. */ CUIntArray m_arCollapsedTextRows; /**< The array of rows with beginning of collapsed blocks. */ CXTPSyntaxEditToolTipCtrl* m_pToolTip; /**< Tooltip window for collapsed blocks text. */ CXTPSyntaxEditAutoCompleteWnd* m_pAutoComplete; /**< Auto-complete pop-up window. */ CString m_strDefaultCfgFilePath; /**< Configuration file full name. */ CString m_strSyntaxScheme; /**< The syntax scheme. */ CString m_strColorScheme; /**< The color scheme. */ int m_nHScrollMaxWidth; /**< Maximum horizontal scrollbar position. */ BOOL m_bWndCreateInProgress; /**< Internal flag to indicate that window creation is in progress. */ /** * @brief * Gets the screen schema cache. * @param nForRow Row index. * @return * A pointer to the screen schema cache. */ XTPSyntaxEditLexAnalyser::CXTPSyntaxEditLexTextBlock* GetOnScreenSch(int nForRow); /** * @brief * Clears the screen schema cache. * @param nRowFrom [in] Row index to clear the cache from. */ void ClearOnScreenSchCache(int nRowFrom); /** * @brief * Calculates the average line length between * specified starting and ending rows. * @param nRowStart [in] Row index to calculate from. * @param nRowEnd [in] Row index to calculate to. * @return * The average line length between the * specified starting and ending rows. */ virtual UINT CalcAveDataSize(int nRowStart, int nRowEnd); /** * @brief * Registers the window class if it has not already been registered. * @param hInstance Instance of the resource where the control is located. * @return * TRUE if the window class was successfully registered, otherwise FALSE. */ BOOL RegisterWindowClass(HINSTANCE hInstance = NULL); /** * @brief * CXTPSyntaxEditCtrl::CTextSearchCache */ class CTextSearchCache; CTextSearchCache* m_fcCollapsable; /**< Collapsible rows cache. */ CTextSearchCache* m_fcRowColors; /**< Row colors cache. */ class CScreenSearchBlock; class CScreenSearchCache; CScreenSearchCache* m_arOnScreenSchCache; /**< On-screen schema cache for this control. */ CByteArray m_arValidDispRows; /**< Array with indexes of valid displayed rows. */ /** * @brief * CXTPSyntaxEditCtrl::CAverageVal */ class CAverageVal { public: /** * @brief * Constructs a CAverageVal object. * * @param nDataSize Data size. */ CAverageVal(int nDataSize = 100); /** * @brief * Adds a value to the data collection. * * @param uVal Value to be added. */ void AddValue(UINT uVal); /** * @brief * Gets the average value the data in this object. * * @param uDefaultIfNoData Default value. * @return * The average value of the data in this object. */ UINT GetAverageValue(UINT uDefaultIfNoData = 0); protected: int m_nDataSize; /**< Data size. */ int m_nNextIndex; /**< Next index. */ CUIntArray m_arData; /**< Data collection. */ }; CAverageVal m_aveRedrawScreenTime; /**< Redraw screen time. */ CXTPSyntaxEditDrawTextProcessor* m_pDrawTextProcessor; /**< Pointer to the draw text processor. */ CImmWrapper* m_pImmWrapper; /**< Imm wrapper. */ BOOL m_bIMEsupported; /**< TRUE if IME is supported, FALSE otherwise. */ // for direct assignment (without SynaxEditControl files to read!) CString m_sIniSet; /**< String with default or passed type of rules, e.g. _T("[Schemes]\r\nCPP\r\n[Themes]\r\nDefault\r\nAlternative\r\n") */ BOOL m_bConfigFileMode; /**< TRUE if control read Config file with links to detailed setting (Syntax and Color schemes) FALSE if Syntax and Color schemes passed as strings using special functions */ CString m_sPassedIniSet; /**< String with passed type of rules, e.g. _T("[Schemes]\r\nVBS\r\n[Themes]\r\nDefault\r\nAlternative\r\n") */ public: BOOL m_bDisableRedraw; /**< If TRUE - control window is not redraw, it is draw last window content (draw cached bitmap). FALSE by default. */ BOOL m_bUseMonitor; /**< TRUE if control use special thread to synchronize syntax rules with files with Syntax and Color schemes FALSE if control works "off-line" */ /** * @brief * Gets the config file mode. * @return * A boolean value that specifies the current config file mode. */ BOOL IsConfigFileMode() { return m_bConfigFileMode; } /** * @brief * Gets the syntax scheme. * @return * A string containing the syntax scheme. */ CString GetSyntaxScheme() { return m_strSyntaxScheme; } /** * @brief * Gets the color scheme. * @return * A string containing the color scheme. */ CString GetColorScheme() { return m_strColorScheme; } CString m_sCustomTitle; // User-defined app title. Can also be used in Print Job as a unique identifier. /** * @brief * Sets the passed ini set. * @param sPassedIniSet Passed ini set to be set. */ void SetPassedIniSet(CString sPassedIniSet) { m_sPassedIniSet = sPassedIniSet; } /** * @brief * Sets the syntax and color schemes. * @param sSyntaxScheme String containing the syntax scheme. * @param sColorScheme String containing the color scheme. * @param bScheme Additional flag to call in-place editor. * @param bColors Additional flag to call in-place editor. */ void SetSyntaxAndColorScheme(CString sSyntaxScheme, CString sColorScheme, BOOL bScheme = FALSE, BOOL bColors = FALSE); /** * @brief * Reloads the syntax string mode. */ void ReloadSyntaxStringMode(); /** * @brief * Reloads the syntax config file mode. */ void ReloadSyntaxConfigFileMode(); }; ///////////////////////////////////////////////////////////////////////////// AFX_INLINE void CXTPSyntaxEditCtrl::InvalidateRow(int nDispRow) { InvalidateRows(nDispRow, nDispRow); } AFX_INLINE BOOL CXTPSyntaxEditCtrl::GetAutoIndent() const { return m_pOptions->m_bAutoIndent; } AFX_INLINE BOOL CXTPSyntaxEditCtrl::GetSyntaxColor() const { return m_pOptions->m_bSyntaxColor; } AFX_INLINE BOOL CXTPSyntaxEditCtrl::GetSelMargin() const { return m_pOptions->m_bSelMargin; } AFX_INLINE CXTPSyntaxEditBufferManager* CXTPSyntaxEditCtrl::GetEditBuffer() const { return m_pBuffer; } AFX_INLINE CXTPSyntaxEditPaintManager* CXTPSyntaxEditCtrl::GetPaintManager() const { return m_pPaintManeger; } AFX_INLINE BOOL CXTPSyntaxEditCtrl::GetHorzScrollBar() const { return m_bHorzScrollBar; } AFX_INLINE BOOL CXTPSyntaxEditCtrl::GetVertScrollBar() const { return m_bVertScrollBar; } AFX_INLINE BOOL CXTPSyntaxEditCtrl::IsActive() const { return m_bIsActive; } AFX_INLINE BOOL CXTPSyntaxEditCtrl::IsCreateScrollbarOnParent() const { return m_bCreateScrollbarOnParent; } AFX_INLINE void CXTPSyntaxEditCtrl::SetCreateScrollbarOnParent(BOOL bSet) { m_bCreateScrollbarOnParent = bSet; } AFX_INLINE BOOL CXTPSyntaxEditCtrl::IsEnabledVirtualSpace() const { return m_pOptions->m_bVirtualSpace; } AFX_INLINE CXTPSyntaxEditAutoCompleteWnd* CXTPSyntaxEditCtrl::GetAutoCompleteWnd() const { return m_pAutoComplete; } AFX_INLINE BOOL CXTPSyntaxEditCtrl::IsReadOnly() const { return m_pOptions->m_bReadOnly; } AFX_INLINE BOOL CXTPSyntaxEditCtrl::GetLineNumbers() const { return m_pOptions->m_bLineNumbers; } AFX_INLINE void CXTPSyntaxEditCtrl::SetReadOnly(BOOL bReadOnly) { m_pOptions->m_bReadOnly = bReadOnly; InvalidateAll(); } AFX_INLINE BOOL CXTPSyntaxEditCtrl::IsViewOnly() const { return m_pOptions->m_bViewOnly; } AFX_INLINE void CXTPSyntaxEditCtrl::SetViewOnly(BOOL bViewOnly) { m_pOptions->m_bViewOnly = bViewOnly; m_pOptions->m_bReadOnly = bViewOnly; m_pOptions->m_bHideCaret = bViewOnly; InvalidateAll(); } AFX_INLINE BOOL CXTPSyntaxEditCtrl::HasFocus() const { return m_bFocused; } AFX_INLINE BOOL CXTPSyntaxEditCtrl::IsHideCaret() const { return m_pOptions->m_bHideCaret; } AFX_INLINE void CXTPSyntaxEditCtrl::SetHideCaret(BOOL bHide) { m_pOptions->m_bHideCaret = bHide; if (m_hWnd) Invalidate(FALSE); } AFX_INLINE BOOL CXTPSyntaxEditCtrl::GetCollapsibleNodes() const { return m_pOptions->m_bDrawNodes; } AFX_INLINE BOOL CXTPSyntaxEditCtrl::IsEnabledEditAccelerators() const { return m_pOptions->m_bEnableEditAccelerators; } AFX_INLINE void CXTPSyntaxEditCtrl::EnableEditAccelerators(BOOL bEnable) { m_pOptions->m_bEnableEditAccelerators = bEnable; } /** @cond */ AFX_INLINE BOOL CXTPSyntaxEditCtrl::_IsVirtualSpaceActive() const { BOOL bVirtualSpace = IsEnabledVirtualSpace(); return bVirtualSpace; } /** @endcond */ AFX_INLINE BOOL CXTPSyntaxEditCtrl::IsEnabledWhiteSpace() const { return m_pOptions->m_bEnableWhiteSpace; } AFX_INLINE BOOL CXTPSyntaxEditCtrl::GetTabWithSpace() const { return m_pOptions->m_bTabWithSpace; } AFX_INLINE int CXTPSyntaxEditCtrl::GetTopRow() const { return m_nTopRow; } AFX_INLINE BOOL CXTPSyntaxEditCtrl::IsRightButtonDrag() const { return m_bRightButtonDrag; } AFX_INLINE void CXTPSyntaxEditCtrl::CancelRightButtonDrag() { m_bRightButtonDrag = FALSE; } AFX_INLINE void CXTPSyntaxEditCtrl::SetRightButtonDrag(BOOL bRightButtonDrag) { m_bRightButtonDrag = bRightButtonDrag; } AFX_INLINE int CXTPSyntaxEditCtrl::GetCurCol() const { return m_nDispCol; } AFX_INLINE int CXTPSyntaxEditCtrl::GetCurAbsCol() const { return m_nCurrentCol; } ///////////////////////////////////////////////////////////////////////////// // CXTPSyntaxEditStringDlg dialog class _XTP_EXT_CLASS CXTPSyntaxEditStringDlg : public CDialog { /** @cond */ DECLARE_DYNAMIC(CXTPSyntaxEditStringDlg) /** @endcond */ public: CXTPSyntaxEditStringDlg(CWnd* pParent = NULL); /**< Standard constructor. */ virtual ~CXTPSyntaxEditStringDlg(); CString m_Syntax; protected: virtual void DoDataExchange(CDataExchange* pDX); /**< DDX/DDV support. */ DECLARE_MESSAGE_MAP() virtual void OnOK(); public: virtual INT_PTR DoModal(); virtual BOOL OnInitDialog(); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnEditCut(); afx_msg void OnEditCopy(); afx_msg void OnEditClear(); afx_msg void OnEditPaste(); afx_msg void OnEditUndo(); afx_msg void OnEditSelectAll(); CEdit m_edit; }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPSYNTAXEDITSYNTAXEDITCTRL_H__) /** @endcond */