Leaked source code of windows server 2003
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.

187 lines
4.8 KiB

  1. //
  2. // TXTED.HPP
  3. // Text Object Editor
  4. //
  5. // Copyright Microsoft 1998-
  6. //
  7. #ifndef __TXTED_HPP_
  8. #define __TXTED_HPP_
  9. #define MIN_IME_WINDOW 30
  10. #define MIN_FITBOX_CHARS 6
  11. class WbTextEditor;
  12. /////////////////////////////////////////////////////////////////////////////
  13. // WbTextBox window
  14. class WbTextBox
  15. {
  16. public:
  17. WbTextBox(WbTextEditor * pEditor);
  18. ~WbTextBox();
  19. BOOL Create(HWND hwndParent);
  20. BOOL FitBox( void );
  21. void AutoCaretScroll( void );
  22. int GetMaxCharHeight( void );
  23. int GetMaxCharWidth( void );
  24. void AbortEditGently( void );
  25. HWND m_hwnd;
  26. POINT m_ptNTBooger;
  27. friend LRESULT CALLBACK TextWndProc(HWND, UINT, WPARAM, LPARAM);
  28. WNDPROC m_pfnEditPrev;
  29. protected:
  30. RECT m_MaxRect;
  31. WbTextEditor *m_pEditor;
  32. RECT m_rectErase;
  33. BOOL m_bInIME;
  34. BOOL m_bDontEscapeThisTime;
  35. void SetupBackgroundRepaint( POINT ptTopPaint, BOOL bNumLinesChanged=TRUE );
  36. void SelectAtLeastOne( void );
  37. void OnClearCut(void);
  38. void OnUndoPaste(void);
  39. void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  40. void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  41. void OnTimer(UINT_PTR nIDEvent);
  42. void OnLButtonUp(UINT nFlags, int x, int y);
  43. void OnMouseMove(UINT nFlags, int x, int y);
  44. void OnMove(int x, int y);
  45. void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  46. };
  47. /////////////////////////////////////////////////////////////////////////////
  48. //
  49. //
  50. // Class: WbTextEditor
  51. //
  52. // Purpose: Allow editing of the text in a DCWbGraphicText object
  53. //
  54. //
  55. class WbTextEditor : public DCWbGraphicText
  56. {
  57. friend class WbTextBox;
  58. friend class WbDrawingArea;
  59. public:
  60. //
  61. // Constructor
  62. //
  63. WbTextEditor(void);
  64. ~WbTextEditor(void);
  65. // writes text to underlying text object before relaying to text object
  66. DWORD CalculateExternalLength(void);
  67. // calcs bounds rect and sets editbox to new size
  68. void CalculateBoundsRect(void);
  69. void WriteExtra( PWB_GRAPHIC pHeader );
  70. void SetTimer( UINT nElapse );
  71. void KillTimer( void );
  72. // set editbox visibility
  73. void ShowBox( int nShow );
  74. BOOL Create( void );
  75. // Moves underlying text object and then moves editbox rect
  76. void MoveBy(int cx, int cy);
  77. void RedrawEditbox(void);
  78. // resets editbox for parent resizing
  79. void ParentResize( void );
  80. // clipboard
  81. void Copy( void )
  82. { ::SendMessage(m_pEditBox->m_hwnd, WM_COPY, 0, 0); }
  83. void Cut( void )
  84. { ::SendMessage(m_pEditBox->m_hwnd, WM_CUT, 0, 0); }
  85. void Paste( void )
  86. { ::SendMessage(m_pEditBox->m_hwnd, WM_PASTE, 0, 0); }
  87. virtual void SetFont( LOGFONT *pLogFont, BOOL bDummy=TRUE );
  88. virtual void SetFont(HFONT hFont) { DCWbGraphicText::SetFont(hFont); }
  89. //
  90. // Attach a text object to the editor. This function copies the
  91. // contents of the specified text object into the text editor. The
  92. // editor will not alter the contents of the object passed and does not
  93. // keep a copy of the pointer parameter.
  94. //
  95. BOOL SetTextObject(DCWbGraphicText * ptext);
  96. //
  97. // Return the width and height for the cursor in pixels as a size
  98. //
  99. void GetCursorSize(LPSIZE lpsize);
  100. //
  101. // Set the current edit cursor position from a point specified in
  102. // logical co-ordinates. This function does nothing if the point
  103. // specified is outside the bounding rectangle of the object being
  104. // edited. If the point specified is within the bounding rectangle the
  105. // current edit cursor position is updated to a point as close as
  106. // possible to that passed as parameter.
  107. //
  108. void SetCursorPosFromPoint(POINT pointXY);
  109. void Clear(void); // Delete all text
  110. BOOL New(void); // Delete text and reset handles
  111. //
  112. // Return TRUE if there is not text in the object
  113. //
  114. BOOL IsEmpty(void);
  115. void AbortEditGently( void )
  116. {m_pEditBox->AbortEditGently();}
  117. protected:
  118. //
  119. // Pixel position from a character position
  120. //
  121. void GetXYPosition(POINT pointChar, LPPOINT lpptGet);
  122. //
  123. // Current cursor position. Note that cursorCharPos.x gives the BYTE
  124. // position of the cursor rather than the character position. On SBCS
  125. // systems the character and byte positions will always be the same,
  126. // but on DBCS systems the number of bytes in a string can be greater
  127. // than the number of characters.
  128. //
  129. // cursorCharPos.x should NEVER be set to a byte count which is in the
  130. // middle of a double byte character.
  131. //
  132. POINT m_cursorCharPos;
  133. POINT m_cursorXYPos;
  134. WbTextBox *m_pEditBox;
  135. int m_nLastShow;
  136. void PutText(void);
  137. void GetText(void);
  138. };
  139. #endif // __TXTED_HPP_
  140.