UIRichEdit.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. #ifndef __UIRICHEDIT_H__
  2. #define __UIRICHEDIT_H__
  3. #pragma once
  4. namespace DuiLib {
  5. class CTxtWinHost;
  6. class UILIB_API CRichEditUI : public CContainerUI, public IMessageFilterUI
  7. {
  8. DECLARE_DUICONTROL(CRichEditUI)
  9. public:
  10. CRichEditUI();
  11. ~CRichEditUI();
  12. LPCTSTR GetClass() const;
  13. LPVOID GetInterface(LPCTSTR pstrName);
  14. UINT GetControlFlags() const;
  15. void SetEnabled(bool bEnabled);
  16. bool IsMultiLine();
  17. void SetMultiLine(bool bMultiLine);
  18. bool IsWantTab();
  19. void SetWantTab(bool bWantTab = true);
  20. bool IsWantReturn();
  21. void SetWantReturn(bool bWantReturn = true);
  22. bool IsWantCtrlReturn();
  23. void SetWantCtrlReturn(bool bWantCtrlReturn = true);
  24. bool IsTransparent();
  25. void SetTransparent(bool bTransparent = true);
  26. bool IsRich();
  27. void SetRich(bool bRich = true);
  28. bool IsReadOnly();
  29. void SetReadOnly(bool bReadOnly = true);
  30. bool IsWordWrap();
  31. void SetWordWrap(bool bWordWrap = true);
  32. int GetFont();
  33. void SetFont(int index);
  34. void SetFont(LPCTSTR pStrFontName, int nSize, bool bBold, bool bUnderline, bool bItalic);
  35. LONG GetWinStyle();
  36. void SetWinStyle(LONG lStyle);
  37. DWORD GetTextColor();
  38. void SetTextColor(DWORD dwTextColor);
  39. int GetLimitText();
  40. void SetLimitText(int iChars);
  41. long GetTextLength(DWORD dwFlags = GTL_DEFAULT) const;
  42. CDuiString GetText() const;
  43. void SetText(LPCTSTR pstrText);
  44. bool IsModify() const;
  45. void SetModify(bool bModified = true) const;
  46. void GetSel(CHARRANGE &cr) const;
  47. void GetSel(long& nStartChar, long& nEndChar) const;
  48. int SetSel(CHARRANGE &cr);
  49. int SetSel(long nStartChar, long nEndChar);
  50. void ReplaceSel(LPCTSTR lpszNewText, bool bCanUndo);
  51. void ReplaceSelW(LPCWSTR lpszNewText, bool bCanUndo = false);
  52. CDuiString GetSelText() const;
  53. int SetSelAll();
  54. int SetSelNone();
  55. WORD GetSelectionType() const;
  56. bool GetZoom(int& nNum, int& nDen) const;
  57. bool SetZoom(int nNum, int nDen);
  58. bool SetZoomOff();
  59. bool GetAutoURLDetect() const;
  60. bool SetAutoURLDetect(bool bAutoDetect = true);
  61. DWORD GetEventMask() const;
  62. DWORD SetEventMask(DWORD dwEventMask);
  63. CDuiString GetTextRange(long nStartChar, long nEndChar) const;
  64. void HideSelection(bool bHide = true, bool bChangeStyle = false);
  65. void ScrollCaret();
  66. int InsertText(long nInsertAfterChar, LPCTSTR lpstrText, bool bCanUndo = false);
  67. int AppendText(LPCTSTR lpstrText, bool bCanUndo = false);
  68. DWORD GetDefaultCharFormat(CHARFORMAT2 &cf) const;
  69. bool SetDefaultCharFormat(CHARFORMAT2 &cf);
  70. DWORD GetSelectionCharFormat(CHARFORMAT2 &cf) const;
  71. bool SetSelectionCharFormat(CHARFORMAT2 &cf);
  72. bool SetWordCharFormat(CHARFORMAT2 &cf);
  73. DWORD GetParaFormat(PARAFORMAT2 &pf) const;
  74. bool SetParaFormat(PARAFORMAT2 &pf);
  75. bool CanUndo();
  76. bool CanRedo();
  77. bool CanPaste();
  78. bool Redo();
  79. bool Undo();
  80. void Clear();
  81. void Copy();
  82. void Cut();
  83. void Paste();
  84. int GetLineCount() const;
  85. CDuiString GetLine(int nIndex, int nMaxLength) const;
  86. int LineIndex(int nLine = -1) const;
  87. int LineLength(int nLine = -1) const;
  88. bool LineScroll(int nLines, int nChars = 0);
  89. CDuiPoint GetCharPos(long lChar) const;
  90. long LineFromChar(long nIndex) const;
  91. CDuiPoint PosFromChar(UINT nChar) const;
  92. int CharFromPos(CDuiPoint pt) const;
  93. void EmptyUndoBuffer();
  94. UINT SetUndoLimit(UINT nLimit);
  95. long StreamIn(int nFormat, EDITSTREAM &es);
  96. long StreamOut(int nFormat, EDITSTREAM &es);
  97. void SetAccumulateDBCMode(bool bDBCMode);
  98. bool IsAccumulateDBCMode();
  99. RECT GetTextPadding() const;
  100. void SetTextPadding(RECT rc);
  101. LPCTSTR GetNormalImage();
  102. void SetNormalImage(LPCTSTR pStrImage);
  103. LPCTSTR GetHotImage();
  104. void SetHotImage(LPCTSTR pStrImage);
  105. LPCTSTR GetFocusedImage();
  106. void SetFocusedImage(LPCTSTR pStrImage);
  107. LPCTSTR GetDisabledImage();
  108. void SetDisabledImage(LPCTSTR pStrImage);
  109. void PaintStatusImage(HDC hDC);
  110. void SetTipValue(LPCTSTR pStrTipValue);
  111. LPCTSTR GetTipValue();
  112. void SetTipValueColor(LPCTSTR pStrColor);
  113. DWORD GetTipValueColor();
  114. void SetTipValueAlign(UINT uAlign);
  115. UINT GetTipValueAlign();
  116. void DoInit();
  117. bool SetDropAcceptFile(bool bAccept);
  118. // 注意:TxSendMessage和SendMessage是有区别的,TxSendMessage没有multibyte和unicode自动转换的功能,
  119. // 而richedit2.0内部是以unicode实现的,在multibyte程序中,必须自己处理unicode到multibyte的转换
  120. virtual HRESULT TxSendMessage(UINT msg, WPARAM wparam, LPARAM lparam, LRESULT *plresult) const;
  121. IDropTarget* GetTxDropTarget();
  122. virtual bool OnTxViewChanged();
  123. virtual void OnTxNotify(DWORD iNotify, void *pv);
  124. CDuiSize GetNaturalSize(LONG width, LONG height);
  125. void SetScrollPos(SIZE szPos, bool bMsg = true);
  126. void LineUp();
  127. void LineDown();
  128. void PageUp();
  129. void PageDown();
  130. void HomeUp();
  131. void EndDown();
  132. void LineLeft();
  133. void LineRight();
  134. void PageLeft();
  135. void PageRight();
  136. void HomeLeft();
  137. void EndRight();
  138. SIZE EstimateSize(SIZE szAvailable);
  139. void SetPos(RECT rc, bool bNeedInvalidate = true);
  140. void Move(SIZE szOffset, bool bNeedInvalidate = true);
  141. void DoEvent(TEventUI& event);
  142. bool DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);
  143. void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
  144. LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
  145. protected:
  146. enum {
  147. DEFAULT_TIMERID = 20,
  148. };
  149. CTxtWinHost* m_pTwh;
  150. bool m_bVScrollBarFixing;
  151. bool m_bWantTab;
  152. bool m_bWantReturn;
  153. bool m_bWantCtrlReturn;
  154. bool m_bTransparent;
  155. bool m_bRich;
  156. bool m_bReadOnly;
  157. bool m_bWordWrap;
  158. DWORD m_dwTextColor;
  159. int m_iFont;
  160. int m_iLimitText;
  161. LONG m_lTwhStyle;
  162. bool m_bDrawCaret;
  163. bool m_bInited;
  164. bool m_fAccumulateDBC ; // TRUE - need to cumulate ytes from 2 WM_CHAR msgs
  165. // we are in this mode when we receive VK_PROCESSKEY
  166. UINT m_chLeadByte; // use when we are in _fAccumulateDBC mode
  167. RECT m_rcTextPadding;
  168. UINT m_uButtonState;
  169. CDuiString m_sNormalImage;
  170. CDuiString m_sHotImage;
  171. CDuiString m_sFocusedImage;
  172. CDuiString m_sDisabledImage;
  173. CDuiString m_sTipValue;
  174. DWORD m_dwTipValueColor;
  175. UINT m_uTipValueAlign;
  176. };
  177. } // namespace DuiLib
  178. #endif // __UIRICHEDIT_H__