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.

416 lines
13 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: textobj.hxx *
  3. * *
  4. * Supporting routines for text output, mostly computation of text *
  5. * positioning and text extent. *
  6. * *
  7. * Created: 16-Jan-1991 13:44:27 *
  8. * Author: Bodin Dresevic [BodinD] *
  9. * *
  10. * Copyright (c) 1992-1999 Microsoft Corporation *
  11. \**************************************************************************/
  12. /*********************************Class************************************\
  13. * class ESTROBJ; *
  14. * *
  15. * The global aspects of the text positioning and text size computation. *
  16. * *
  17. * Public Interface: *
  18. * *
  19. * History: *
  20. * Fri 13-Mar-1992 02:10:27 -by- Charles Whitmer [chuckwh] *
  21. * Simplified all the work and put it into the vInit call. Deleted lots of *
  22. * methods. *
  23. * *
  24. * 21-Jan-1991 -by- Bodin Dresevic [BodinD] *
  25. * Wrote it. *
  26. \**************************************************************************/
  27. // The flTO flags. Leave room for the TSIM flags.
  28. #define TO_MEM_ALLOCATED 0x0001L //Memory was allocated.
  29. #define TO_ALL_PTRS_VALID 0x0002L //All pointers to cache locked.
  30. #define TO_VALID 0x0004L //ESTROBJ constructor succeeded.
  31. #define TO_ESC_NOT_ORIENT 0x0008L //Escapement not equal to orientation.
  32. #define TO_PWSZ_ALLOCATED 0x0010L //pwszOrg needs to be released
  33. #define TO_HIGHRESTEXT 0x0100L //Printer driver wants 28.4 text coords.
  34. #define TO_BITMAPS 0x0200L //pgdf contains GLYPHBITS pointer
  35. #ifdef FE_SB
  36. #define TO_PARTITION_INIT 0x0400L //The partitioning info has been initialized.
  37. #define TO_ALLOC_FACENAME 0x0800L //FaceName glyphs array was allocated.
  38. #define TO_SYS_PARTITION 0x1000L //System glyphs partition initialized
  39. #endif
  40. #define POINTS_PER_INCH 72
  41. #define DEFAULT_SCALABLE_FONT_HEIGHT_IN_POINTS 24
  42. #ifndef GDIFLAGS_ONLY // used for gdikdx
  43. class ESTROBJ : public _STROBJ // so
  44. {
  45. public:
  46. // The following five fields are inherited from the STROBJ.
  47. // ULONG cGlyphs; // Number of glyphs.
  48. // FLONG flAccel; // Accelerator flags exposed to the driver.
  49. // ULONG ulCharInc; // Non-zero if constant character increment.
  50. // RECTL rclBkGround; // Background rect of the string.
  51. // GLYPHPOS *pgp; // Accelerator if all GLYPHPOS's are valid.
  52. // PWSTR pwszOrg; // pointer to original unicode string.
  53. ULONG cgposCopied; // For enumeration.
  54. ULONG cgposPositionsEnumerated; // only used for enumerating positions in linked strings
  55. RFONTOBJ *prfo; // Remember our RFONTOBJ.
  56. FLONG flTO; // flags
  57. EGLYPHPOS *pgpos; // Pointer to the GLYPHPOS structures.
  58. POINTFIX ptfxRef; // Reference point.
  59. POINTFIX ptfxUpdate; // CP advancement for the string.
  60. POINTFIX ptfxEscapement; // The total escapement vector.
  61. RECTFX rcfx; // The TextBox, projected onto the base and ascent.
  62. FIX fxExtent; // The Windows compatible text extent.
  63. FIX xExtra; // computed in H3, G2,3 cases
  64. FIX xBreakExtra; // computed in H3, G2,3 cases
  65. DWORD dwCodePage; // accelerator for ps driver
  66. ULONG cExtraRects; // Rectangles for underline
  67. RECTL arclExtra[3]; // and strikeout.
  68. #ifdef FE_SB
  69. RECTL rclBkGroundSave; // used to save a copy of BkGroundRect
  70. WCHAR *pwcPartition; // For partitioning
  71. LONG *plPartition; // Points to partitioning information
  72. LONG *plNext; // Next glyph in font
  73. GLYPHPOS *pgpNext; // For enumeration
  74. LONG lCurrentFont; // For enumeration
  75. POINTL ptlBaseLineAdjust; // Used to adjust SysEUDC baseline
  76. ULONG cTTSysGlyphs; // Number of TT system font glyphs in a string
  77. ULONG cSysGlyphs; // Number of system eudc glyphs in a string.
  78. ULONG cDefGlyphs; // Number of default eudc glyphs in a string.
  79. ULONG cNumFaceNameLinks; // Number of linked face name eudc in a string .
  80. ULONG *pacFaceNameGlyphs; // Pointer to array of number of face name glyphs.
  81. ULONG acFaceNameGlyphs[QUICK_FACE_NAME_LINKS]; // Number of face name glyphs
  82. // in a string.
  83. #endif
  84. public:
  85. VOID vInit // TEXTOBJ.CXX
  86. (
  87. PWSZ pwsz,
  88. LONG cwc,
  89. XDCOBJ& dco,
  90. RFONTOBJ& rfo,
  91. EXFORMOBJ& xo,
  92. LONG *pdx,
  93. BOOL bPdy,
  94. LONG lEsc,
  95. LONG lExtra,
  96. LONG lBreakExtra,
  97. LONG cBreak,
  98. FIX xRef,
  99. FIX yRef,
  100. FLONG flControl,
  101. LONG *pdxOut,
  102. PVOID pvBuffer,
  103. DWORD dwCodePage
  104. );
  105. VOID vInitSimple // TEXTOBJ.CXX
  106. (
  107. PWSZ pwsz,
  108. LONG cwc,
  109. XDCOBJ& dco,
  110. RFONTOBJ& rfo,
  111. LONG xRef,
  112. LONG yRef,
  113. PVOID pvBuffer
  114. );
  115. ESTROBJ() {flTO = 0;}
  116. // constructor -- initialize the object on the frame
  117. ESTROBJ
  118. (
  119. PWSZ pwsz,
  120. LONG cwc,
  121. XDCOBJ& dco,
  122. RFONTOBJ& rfo,
  123. EXFORMOBJ& xo,
  124. LONG *pdx,
  125. BOOL bPdy,
  126. LONG lEsc,
  127. LONG lExtra,
  128. LONG lBExtra,
  129. LONG cBreak,
  130. FIX x,
  131. FIX y,
  132. FLONG fl,
  133. LONG *pdxOut
  134. )
  135. {
  136. vInit(pwsz,
  137. cwc,
  138. dco,
  139. rfo,xo,pdx,bPdy,lEsc,lExtra,lBExtra,cBreak,x,y,fl,pdxOut,NULL,0);
  140. }
  141. // destructor -- Frees the memory pointed to by pgpos.
  142. ~ESTROBJ()
  143. {
  144. #ifdef FE_SB
  145. if (flTO & (TO_MEM_ALLOCATED|TO_ALLOC_FACENAME))
  146. {
  147. if (flTO & TO_MEM_ALLOCATED)
  148. FREEALLOCTEMPBUFFER((PVOID) pgpos);
  149. if (flTO & TO_ALLOC_FACENAME)
  150. VFREEMEM((PVOID) pacFaceNameGlyphs);
  151. }
  152. #else
  153. if (flTO & TO_MEM_ALLOCATED)
  154. {
  155. //
  156. // NOTE:
  157. // Use this macro because allocation of the ESTROBJ goes through
  158. // The fast allocator.
  159. //
  160. FREEALLOCTEMPBUFFER((PVOID) pgpos);
  161. }
  162. #endif
  163. }
  164. // bValid -- Checks if memory allocation in the constructor has failed.
  165. BOOL bValid() {return(flTO & TO_VALID);}
  166. // bOpaqueArea -- Computes the area that would need opaquing behind the text.
  167. // Returns TRUE if the result is complex.
  168. BOOL bOpaqueArea(POINTFIX *pptfx,RECTL *prcl);
  169. // prclExtraRects -- Returns the rectangles that simulate underlines.
  170. RECTL *prclExtraRects()
  171. {
  172. return((cExtraRects == 0) ? NULL : arclExtra);
  173. }
  174. // bTextExtent -- Transform the TextBox extents back to logical coordinates.
  175. #ifdef FE_SB
  176. BOOL bTextExtent(RFONTOBJ& rfo,LONG lEsc,PSIZE pSize);
  177. #else
  178. BOOL bTextExtent(PSIZE pSize);
  179. #endif
  180. // ptfxAdvance -- Returns the amount that the current position should be offset.
  181. POINTFIX& ptfxAdvance() {return(ptfxUpdate);}
  182. // bTextToPath -- Draws the string into the given path.
  183. BOOL bTextToPath( EPATHOBJ& po, XDCOBJ& dco, BOOL bNeedUnflattend = FALSE);
  184. BOOL bLinkedTextToPath( EPATHOBJ& po, XDCOBJ& dco, BOOL bNeedUnflattend = FALSE);
  185. BOOL bTextToPathWorkhorse( EPATHOBJ& po, BOOL bNeedUnflattend = FALSE);
  186. // bExtraRectsToPath -- Draws underlines and strikeouts into a path.
  187. BOOL bExtraRectsToPath(EPATHOBJ& po, BOOL bNeedUnflattend = FALSE);
  188. VOID vEnumStart()
  189. {
  190. cgposCopied = 0;
  191. cgposPositionsEnumerated = 0;
  192. }
  193. // vCharPos -- Special case character positioning routines.
  194. VOID vCharPos_H1
  195. (
  196. XDCOBJ& dco,
  197. RFONTOBJ& rfo,
  198. FIX xRef,
  199. FIX yRef,
  200. LONG *pdx,
  201. EFLOAT efScale
  202. );
  203. VOID ESTROBJ::vCharPos_H2
  204. (
  205. XDCOBJ& dco,
  206. RFONTOBJ& rfo,
  207. FIX xRef,
  208. FIX yRef
  209. #ifdef FE_SB
  210. ,EFLOAT efScale
  211. #endif
  212. );
  213. VOID vCharPos_H3
  214. (
  215. XDCOBJ& dco,
  216. RFONTOBJ& rfo,
  217. FIX xRef,
  218. FIX yRef,
  219. LONG lExtra,
  220. LONG lBreakExtra,
  221. LONG cBreak,
  222. EFLOAT efScale
  223. #ifdef FE_SB
  224. ,PBOOL pAccel = NULL
  225. #endif
  226. );
  227. VOID ESTROBJ::vCharPos_H4
  228. (
  229. XDCOBJ& dco,
  230. RFONTOBJ& rfo,
  231. FIX xRef,
  232. FIX yRef,
  233. LONG *pdxdy,
  234. EFLOAT efXScale,
  235. EFLOAT efYScale
  236. );
  237. VOID vCharPos_G1
  238. (
  239. XDCOBJ& dco,
  240. RFONTOBJ& rfo,
  241. FIX xRef,
  242. FIX yRef,
  243. LONG *pdx,
  244. LONG *pdxOut
  245. );
  246. VOID vCharPos_G2
  247. (
  248. XDCOBJ& dco,
  249. RFONTOBJ& rfo,
  250. FIX xRef,
  251. FIX yRef,
  252. LONG lExtra,
  253. LONG lBreakExtra,
  254. LONG cBreak,
  255. LONG *pdxOut
  256. );
  257. VOID vCharPos_G3
  258. (
  259. XDCOBJ& dco,
  260. RFONTOBJ& rfo,
  261. FIX xRef,
  262. FIX yRef,
  263. LONG lExtra,
  264. LONG lBreakExtra,
  265. LONG cBreak,
  266. LONG *pdx,
  267. LONG *pdxOut
  268. );
  269. VOID vCharPos_G4
  270. (
  271. XDCOBJ& dco,
  272. RFONTOBJ& rfo,
  273. FIX xRef,
  274. FIX yRef,
  275. LONG *pdxdy
  276. );
  277. VOID vEudcOpaqueArea(POINTFIX *pptfx, BOOL bComplexBackGround);
  278. PGLYPHPOS pgpGet() {return(pgpos); }
  279. ULONG cGlyphsGet() {return(cGlyphs); }
  280. PWSZ pwszGet() {return(pwszOrg); }
  281. #ifdef FE_SB
  282. // methods for EUDC functionality
  283. VOID vFontSet( LONG _lCurrentFont )
  284. { lCurrentFont = _lCurrentFont; cgposCopied = 0;}
  285. FLONG flAccelGet() { return( flAccel ); }
  286. VOID flAccelSet( FLONG _flAccel ) { flAccel = _flAccel ;}
  287. VOID vClearCharInc() { ulCharInc = 0; }
  288. VOID pgpSet( GLYPHPOS *_pgp ) { pgp = _pgp; }
  289. VOID prfntSet( PRFONTOBJ _prfnt ) { prfo = _prfnt; }
  290. VOID pwszSet( PWSZ _pwszOrg ) { pwszOrg = _pwszOrg; }
  291. BOOL bLinkedGlyphs()
  292. {
  293. return((flTO & (TO_SYS_PARTITION|TO_PARTITION_INIT )) ? TRUE : FALSE);
  294. }
  295. VOID cGlyphsSet( LONG _cGlyphs ) { cGlyphs = _cGlyphs; }
  296. ULONG cFaceNameGlyphsGet( ULONG ul )
  297. {
  298. return( pacFaceNameGlyphs ? pacFaceNameGlyphs[ul] : 0);
  299. }
  300. VOID vFaceNameInc( ULONG ul ) { (pacFaceNameGlyphs[ul]) += 1; }
  301. ULONG cTTSysGlyphsGet() { return( cTTSysGlyphs ); }
  302. ULONG cSysGlyphsGet() { return( cSysGlyphs ); }
  303. VOID vSysGlyphsInc() { cSysGlyphs += 1; }
  304. VOID vTTSysGlyphsInc() { cTTSysGlyphs += 1; }
  305. ULONG cDefGlyphsGet() { return( cDefGlyphs ); }
  306. VOID vDefGlyphsInc() { cDefGlyphs += 1; }
  307. VOID vInflateTextRect(ERECTL _rclInflate) { (ERECTL)rclBkGround += _rclInflate; }
  308. VOID ptlBaseLineAdjustSet( POINTL& _ptlBaseLineAdjust );
  309. BOOL bPartitionInit() { return(flTO & TO_PARTITION_INIT ); }
  310. BOOL bSystemPartitionInit(){ return(flTO & TO_SYS_PARTITION);}
  311. BOOL bPartitionInit(COUNT c, UINT uiNumLinks, BOOL bEUDCInit);
  312. LONG *plPartitionGet() { return( plPartition ); }
  313. WCHAR *pwcPartitionGet() { return( pwcPartition ); }
  314. VOID vSaveBkGroundRect() {rclBkGroundSave = rclBkGround;}
  315. VOID vRestoreBkGroundRect() {rclBkGround = rclBkGroundSave;}
  316. #endif
  317. #if DBG
  318. void vCorrectBackGround();
  319. void vCorrectBackGroundError( GLYPHPOS *pgp );
  320. #endif
  321. };
  322. BOOL
  323. GreExtTextOutWLocked(
  324. XDCOBJ &dco,
  325. int x,
  326. int y,
  327. UINT flOpts,
  328. LPRECT prcl,
  329. LPWSTR pwsz,
  330. int cwc,
  331. LPINT pdx,
  332. ULONG ulBkMode,
  333. PVOID pvBuffer,
  334. DWORD dwCodePage
  335. );
  336. BOOL
  337. ExtTextOutRect(
  338. XDCOBJ &dcoDst,
  339. LPRECT prcl
  340. );
  341. BOOL
  342. GreBatchTextOut(
  343. XDCOBJ &dcoDst,
  344. PBATCHTEXTOUT pbText,
  345. ULONG cjBatchLength
  346. );
  347. #endif // GDIFLAGS_ONLY used for gdikdx