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.

111 lines
2.7 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: text.c
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * This module contains the MessageBox API and related functions.
  7. *
  8. * History:
  9. * 10-01-90 EricK Created.
  10. * 11-20-90 DarrinM Merged in User text APIs.
  11. * 02-07-91 DarrinM Removed TextOut, ExtTextOut, and GetTextExtentPoint stubs.
  12. \***************************************************************************/
  13. /***************************************************************************\
  14. * PSMGetTextExtent
  15. *
  16. * NOTE: This routine should only be called with the system font since having
  17. * to realize a new font would cause memory to move...
  18. *
  19. * LATER: Can't this be eliminated altogether? Nothing should be moving
  20. * anymore.
  21. *
  22. * History:
  23. * 11-13-90 JimA Ported.
  24. \***************************************************************************/
  25. #ifdef _USERK_
  26. BOOL xxxPSMGetTextExtent(
  27. HDC hdc,
  28. LPWSTR lpstr,
  29. int cch,
  30. PSIZE psize)
  31. {
  32. int result;
  33. WCHAR szTemp[255], *pchOut;
  34. PTHREADINFO ptiCurrent = PtiCurrentShared();
  35. TL tl;
  36. if (cch > sizeof(szTemp)/sizeof(WCHAR)) {
  37. pchOut = (WCHAR*)UserAllocPool((cch+1) * sizeof(WCHAR), TAG_RTL);
  38. if (pchOut == NULL) {
  39. psize->cx = psize->cy = 0;
  40. return FALSE;
  41. }
  42. ThreadLockPool(ptiCurrent, pchOut, &tl);
  43. } else {
  44. pchOut = szTemp;
  45. }
  46. result = HIWORD(GetPrefixCount(lpstr, cch, pchOut, cch));
  47. if (result) {
  48. lpstr = pchOut;
  49. cch -= result;
  50. }
  51. if (CALL_LPK(ptiCurrent)) {
  52. xxxClientGetTextExtentPointW(hdc, lpstr, cch, psize);
  53. } else {
  54. UserGetTextExtentPointW(hdc, lpstr, cch, psize);
  55. }
  56. if (pchOut != szTemp)
  57. ThreadUnlockAndFreePool(ptiCurrent, &tl);
  58. /*
  59. * IanJa everyone seems to ignore the ret val
  60. */
  61. return TRUE;
  62. }
  63. #else
  64. BOOL PSMGetTextExtent(
  65. HDC hdc,
  66. LPCWSTR lpstr,
  67. int cch,
  68. PSIZE psize)
  69. {
  70. int result;
  71. WCHAR szTemp[255], *pchOut;
  72. if (cch > sizeof(szTemp)/sizeof(WCHAR)) {
  73. pchOut = (WCHAR*)UserLocalAlloc(0, (cch+1) * sizeof(WCHAR));
  74. if (pchOut == NULL) {
  75. psize->cx = psize->cy = 0;
  76. return FALSE;
  77. }
  78. } else {
  79. pchOut = szTemp;
  80. }
  81. result = HIWORD(GetPrefixCount(lpstr, cch, pchOut, cch));
  82. if (result) {
  83. lpstr = pchOut;
  84. cch -= result;
  85. }
  86. UserGetTextExtentPointW(hdc, lpstr, cch, psize);
  87. if (pchOut != szTemp)
  88. UserLocalFree(pchOut);
  89. /*
  90. * IanJa everyone seems to ignore the ret val
  91. */
  92. return TRUE;
  93. }
  94. #endif // _USERK_