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.

200 lines
4.7 KiB

  1. //
  2. // TEXTOBJ.HPP
  3. // Text object
  4. //
  5. // Copyright Microsoft 1998-
  6. //
  7. #ifndef __TEXTOBJ_HPP_
  8. #define __TEXTOBJ_HPP_
  9. #include <common.h>
  10. #define NonStandardTextID "Text2\0"
  11. void GetTextDestinationAddress(SINonStandardPDU *destinationAddress, PUINT workspaceHandle, PUINT planeID);
  12. //
  13. // Definitions for text objects
  14. //
  15. #define LAST_LINE -1
  16. #define LAST_CHAR -2
  17. #ifdef _DEBUG
  18. #define DBG_UNINIT -1
  19. #endif // _DEBUG
  20. //
  21. // Definitions for debug stuff
  22. //
  23. typedef struct tagVARIABLE_STRING_HEADER
  24. {
  25. ULONG len; // length of this structure + string length
  26. POINT start; // starting X(column) Y(line) inside the previous text
  27. }VARIABLE_STRING_HEADER;
  28. typedef struct tagVARIABLE_STRING
  29. {
  30. VARIABLE_STRING_HEADER header;
  31. CHAR string;
  32. } VARIABLE_STRING;
  33. typedef struct tagTEXTPDU_HEADER
  34. {
  35. UINT nonStandardPDU;
  36. UINT textHandle;
  37. UINT workspaceHandle;
  38. }TEXTPDU_HEADER;
  39. typedef struct tagTEXTPDU_ATTRIB {
  40. DWORD attributesFlag; // flag with the attributes that changed
  41. COLORREF textPenColor;
  42. COLORREF textFillColor;
  43. UINT textViewState;
  44. UINT textZOrder;
  45. POINT textAnchorPoint;
  46. LOGFONT textFont;
  47. UINT numberOfLines;
  48. VARIABLE_STRING textString;
  49. } TEXTPDU_ATTRIB;
  50. typedef struct tagMSTextPDU
  51. {
  52. TEXTPDU_HEADER header;
  53. TEXTPDU_ATTRIB attrib;
  54. }MSTextPDU;
  55. typedef struct tagMSTextDeletePDU
  56. {
  57. TEXTPDU_HEADER header;
  58. }MSTextDeletePDU;
  59. class TextObj : public T126Obj
  60. {
  61. // Friend declaration for text editing
  62. friend class WbTextEditor;
  63. public:
  64. TextObj (void);
  65. void TextEditObj (TEXTPDU_ATTRIB* pEditPDU );
  66. ~TextObj( void );
  67. void Draw(HDC hDC = NULL, BOOL bForcedDraw = FALSE, BOOL bPrinting = FALSE);
  68. void UnDraw(void);
  69. BOOL CheckReallyHit(LPCRECT pRectHit){return RectangleHit(FALSE, pRectHit);}
  70. void SetViewHandle(UINT viewHandle){};
  71. //
  72. // PDU stuff
  73. //
  74. void CreateTextPDU(ASN1octetstring_t*, UINT);
  75. void SetTextAttrib(TEXTPDU_ATTRIB * pattributes);
  76. void GetTextAttrib(TEXTPDU_ATTRIB * pattributes);
  77. //
  78. // Get/set pen Color
  79. //
  80. void SetPenColor(COLORREF rgb, BOOL isPresent);
  81. BOOL GetPenColor(COLORREF * pcr);
  82. BOOL GetPenColor(RGBTRIPLE* rgb);
  83. //
  84. // Get/set fill Color
  85. //
  86. BOOL HasFillColor(void){return m_bIsFillColorPresent;}
  87. void SetFillColor(COLORREF rgb, BOOL isPresent);
  88. BOOL GetFillColor(COLORREF * rgb);
  89. BOOL GetFillColor(RGBTRIPLE* rgb);
  90. //
  91. // Set the text of the object
  92. //
  93. void SetText(TCHAR * strText);
  94. void SetText(const StrArray& strTextArray);
  95. //
  96. // Get/Set the font for drawing the text
  97. //
  98. virtual void SetFont(HFONT hFont);
  99. virtual void SetFont(LOGFONT *pLogFont, BOOL bReCalc=TRUE );
  100. HFONT GetFont(void) {return m_hFont;};
  101. HFONT GetFontThumb(void){return m_hFontThumb;}
  102. //
  103. // Get the UI tool from a drawing pdu
  104. //
  105. void SetUIToolType(void);
  106. //
  107. // Mask 0x0000001F
  108. //
  109. void ChangedPenColor(void){m_dwChangedAttrib |= 0x00000001;}
  110. void ChangedFillColor(void){m_dwChangedAttrib |= 0x00000002;}
  111. void ChangedViewState(void){m_dwChangedAttrib |= 0x00000004;}
  112. void ChangedZOrder(void){m_dwChangedAttrib |= 0x00000008;}
  113. void ChangedAnchorPoint(void) { m_dwChangedAttrib |= 0x00000010;}
  114. void ChangedFont(void) { m_dwChangedAttrib |= 0x00000020;}
  115. void ChangedText(void) { m_dwChangedAttrib |= 0x00000040;}
  116. BOOL HasPenColorChanged(void){return (m_dwChangedAttrib & 0x00000001);}
  117. BOOL HasFillColorChanged(void){return (m_dwChangedAttrib & 0x00000002);}
  118. BOOL HasViewStateChanged(void){return (m_dwChangedAttrib & 0x00000004);}
  119. BOOL HasZOrderChanged(void){return (m_dwChangedAttrib & 0x00000008);}
  120. BOOL HasAnchorPointChanged(void) { return (m_dwChangedAttrib & 0x00000010);}
  121. BOOL HasFontChanged(void) { return m_dwChangedAttrib & 0x00000020;}
  122. BOOL HasTextChanged(void) { return m_dwChangedAttrib & 0x00000040;}
  123. DWORD GetPresentAttribs(void){return (m_dwChangedAttrib & 0x0000007F);}
  124. void ResetAttrib(void){m_dwChangedAttrib = 0;}
  125. void SetAllAttribs(void){m_dwChangedAttrib = 0x0000007F;}
  126. void ChangedPenThickness(void){};
  127. void CalculateBoundsRect(void);
  128. void CalculateRect(int iStartX, int iStartY, int iStopX, int iStopY, LPRECT lprcResult);
  129. ABC GetTextABC( LPCTSTR pText, int iStartX, int iStopX);
  130. void GetTextRectangle(int iStartY, int iStartX, int iStopX, LPRECT lprc);
  131. void SendTextPDU(UINT choice);
  132. void OnObjectEdit(void);
  133. void OnObjectDelete(void);
  134. void SendNewObjectToT126Apps(void);
  135. void GetEncodedCreatePDU(ASN1_BUF *pBuf);
  136. TEXTMETRIC m_textMetrics;
  137. //
  138. // Array for storing text
  139. //
  140. StrArray strTextArray;
  141. HFONT m_hFont;
  142. protected:
  143. DWORD m_dwChangedAttrib;
  144. BOOL m_bIsPenColorPresent;
  145. BOOL m_bIsFillColorPresent;
  146. RGBTRIPLE m_penColor;
  147. RGBTRIPLE m_fillColor;
  148. //
  149. // Font details
  150. //
  151. HFONT m_hFontThumb;
  152. BOOL m_bFirstSetFontCall;
  153. LONG m_nKerningOffset;
  154. };
  155. #endif // __TEXTOBJ_HPP_