Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

239 lines
7.0 KiB

  1. // tedit.h : interface of the CTedit class
  2. //
  3. // This class takes text entry from the user.
  4. // It is derived from the CEdit class
  5. //
  6. #ifndef __TEDIT_H__
  7. #define __TEDIT_H__
  8. // default position for text box
  9. #define INITX 10
  10. #define INITY 10
  11. #define INITCX 100
  12. #define INITCY 50
  13. #define MIN_CHARS_DISPLAY_SIZE 5 // minimum size is 5 chars with the default font
  14. #define WM_MOVING 0x0216
  15. //#define EM_POSFROMCHAR 0x00D6
  16. //#define EM_CHARFROMPOS 0x00D7
  17. #define IS_DBCS_CHARSET( charset ) ( (charset == GB2312_CHARSET) || \
  18. (charset == SHIFTJIS_CHARSET) || \
  19. (charset == HANGEUL_CHARSET) || \
  20. (charset == CHINESEBIG5_CHARSET) )
  21. class CTedit;
  22. class CTfont;
  23. typedef enum
  24. {
  25. eEBOX_CHANGE,
  26. eFONT_CHANGE,
  27. eSIZE_MOVE_CHANGE,
  28. eNO_CHANGE
  29. } eLASTACTION;
  30. /******************************************************************************/
  31. class CAttrEdit : public CEdit
  32. {
  33. public:
  34. BOOL m_bBackgroundTransparent;
  35. UINT m_uiLastChar[2];
  36. CRect m_rectUpdate;
  37. CTedit* m_pParentWnd;
  38. CString m_strResult;
  39. HKL m_hKL;
  40. BOOL m_bMouseDown;
  41. HCURSOR m_hHCursor;
  42. HCURSOR m_hVCursor;
  43. HCURSOR m_hOldCursor;
  44. CRect m_rectFmt;
  45. int m_iPrevStart;
  46. int m_iTabPos;
  47. BOOL m_bResizeOnly; // when IME composition will
  48. // force a resize
  49. CAttrEdit::CAttrEdit();
  50. DECLARE_DYNCREATE( CAttrEdit )
  51. protected: // create from serialization only
  52. //{{AFX_MSG(CAttrEdit)
  53. afx_msg void OnPaint();
  54. afx_msg BOOL OnEraseBkgnd ( CDC* pDC );
  55. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  56. afx_msg void OnChar (UINT nChar, UINT nRepCnt, UINT nFlags);
  57. afx_msg LRESULT OnImeChar ( WPARAM wParam, LPARAM lParam );
  58. afx_msg LRESULT OnImeComposition ( WPARAM wParam, LPARAM lParam );
  59. afx_msg LRESULT OnInputLangChange ( WPARAM wParam, LPARAM lParam );
  60. afx_msg void OnKillFocus ( CWnd* pNewWnd );
  61. afx_msg UINT OnNcHitTest ( CPoint point );
  62. afx_msg void OnSetFocus ( CWnd* pOldWnd );
  63. afx_msg void OnSize ( UINT nType, int cx, int cy );
  64. afx_msg void OnLButtonDblClk ( UINT nFlags, CPoint point );
  65. afx_msg void OnLButtonDown ( UINT nFlags, CPoint point );
  66. afx_msg void OnMouseMove ( UINT nFlags, CPoint point );
  67. afx_msg void OnLButtonUp ( UINT nFlags, CPoint point );
  68. afx_msg void OnKeyDown ( UINT nChar, UINT nRepCnt, UINT nFlags);
  69. afx_msg LRESULT OnSysTimer ( WPARAM wParam, LPARAM lParam );
  70. //}}AFX_MSG
  71. DECLARE_MESSAGE_MAP()
  72. void SetHCursorShape ( void );
  73. void SetVCursorShape ( void );
  74. void UpdateSel ( void );
  75. void UpdateInput ( void );
  76. void SetStartSelect ( void );
  77. void SetCaretPosition ( BOOL bPrev, CPoint *ptMouse, int iPrevStart );
  78. void SetCaretShape ( void );
  79. void SetFmtRect ( void );
  80. void Repaint ( void );
  81. void TabTextOut ( CDC *pDC, int nCharIndex, int x, int y,
  82. LPCTSTR lpStr, int nCount, BOOL bSelect );
  83. friend class CTedit;
  84. };
  85. /******************************************************************************/
  86. class CTedit : public CWnd
  87. {
  88. friend class CTfont;
  89. private:
  90. CAttrEdit m_cEdit;
  91. CTfont* m_pcTfont;
  92. eLASTACTION m_eLastAction;
  93. BOOL m_bBackgroundTransparent;
  94. BOOL m_bCleanupBKBrush;
  95. BOOL m_bStarting;
  96. BOOL m_bPasting;
  97. BOOL m_bExpand;
  98. BOOL m_bChanged;
  99. UINT m_uiHitArea;
  100. COLORREF m_crFGColor;
  101. COLORREF m_crBKColor;
  102. CRect m_cRectOldPos;
  103. CRect m_cRectWindow;
  104. CSize m_SizeMinimum;
  105. public:
  106. CImgWnd* m_pImgWnd;
  107. CBrush m_hbrBkColor;
  108. BOOL m_bRefresh;
  109. int m_iLineHeight;
  110. BOOL m_bVertEdit;
  111. BOOL m_bAssocIMC;
  112. HIMC m_hIMCEdit;
  113. HIMC m_hIMCFace;
  114. HIMC m_hIMCSize;
  115. HWND m_hWndFace;
  116. HWND m_hWndSize;
  117. CTedit::CTedit();
  118. DECLARE_DYNCREATE( CTedit )
  119. afx_msg void OnEnMaxText();
  120. protected:
  121. //{{AFX_MSG(CTedit)
  122. afx_msg void OnAttrEditEnChange(void);
  123. afx_msg void OnSize( UINT nType, int cx, int cy );
  124. afx_msg void OnMove( int x, int y );
  125. afx_msg void OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI );
  126. afx_msg HBRUSH OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor );
  127. afx_msg void OnNcCalcSize( BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp );
  128. afx_msg void OnNcPaint();
  129. afx_msg UINT OnNcHitTest( CPoint point );
  130. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  131. afx_msg void OnTextPlain();
  132. afx_msg void OnTextBold();
  133. afx_msg void OnTextItalic();
  134. afx_msg void OnTextUnderline();
  135. afx_msg void OnTextSelectfont();
  136. afx_msg void OnTextSelectpointsize();
  137. afx_msg void OnEditCut();
  138. afx_msg void OnEditCopy();
  139. afx_msg void OnEditPaste();
  140. afx_msg void OnTextDelete();
  141. afx_msg void OnTextSelectall();
  142. afx_msg void OnTextUndo();
  143. afx_msg void OnTextPlace();
  144. afx_msg void OnTextTexttool();
  145. afx_msg void OnUpdateTextPlain(CMenu *pcMenu);
  146. afx_msg void OnUpdateTextBold(CMenu *pcMenu);
  147. afx_msg void OnUpdateTextItalic(CMenu *pcMenu);
  148. afx_msg void OnUpdateTextUnderline(CMenu *pcMenu);
  149. afx_msg void OnUpdateTextTexttool(CMenu *pcMenu);
  150. afx_msg void OnDestroy();
  151. //}}AFX_MSG
  152. afx_msg void OnEnUpdate();
  153. afx_msg LRESULT OnMoving( WPARAM, LPARAM lprc );
  154. DECLARE_MESSAGE_MAP()
  155. virtual void PostNcDestroy();
  156. CSize GetDefaultMinSize( void );
  157. public:
  158. virtual CTedit::~CTedit();
  159. virtual BOOL PreCreateWindow( CREATESTRUCT& cs );
  160. BOOL Create( CImgWnd* pParentWnd,
  161. COLORREF crefForeground,
  162. COLORREF crefBackground,
  163. CRect& rectTextPos,
  164. BOOL bBackTransparent = TRUE );
  165. void OnAttrEditFontChange( void );
  166. void RefreshWindow ( CRect* prect = NULL, BOOL bErase = TRUE );
  167. void SetTextColor ( COLORREF crColor );
  168. void SetBackColor ( COLORREF crColor );
  169. void SetTransparentMode ( BOOL bTransparent );
  170. void Undo ();
  171. void ShowFontPalette ( int nCmdShow );
  172. BOOL IsFontPaletteVisible( void );
  173. void ShowFontToolbar ( BOOL bActivate = FALSE );
  174. void HideFontToolbar ( void );
  175. BOOL IsModified ( void ) { return m_bChanged; }
  176. void GetBitmap ( CDC* pDC, CRect* prectImg );
  177. CAttrEdit* GetEditWindow ( void ) { return &m_cEdit; }
  178. HIMC DisableIme( HWND hWnd );
  179. void EnableIme( HWND hWnd, HIMC hIMC );
  180. BOOL IsCUAS();
  181. };
  182. #endif // __TEDIT_H__