VirtFuncs.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these librararies and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: VirtFuncs.c /main/8 1995/12/18 16:24:06 cde-hp $ */
  24. /************************************<+>*************************************
  25. ****************************************************************************
  26. **
  27. ** File: VirtFuncs.c
  28. **
  29. ** Project: Cde 1.0
  30. **
  31. ** Description:
  32. **
  33. ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
  34. **
  35. ** (c) Copyright 1993, 1994 Hewlett-Packard Company
  36. ** (c) Copyright 1993, 1994 International Business Machines Corp.
  37. ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  38. ** (c) Copyright 1993, 1994 Novell, Inc.
  39. **
  40. **
  41. **
  42. ****************************************************************************
  43. ************************************<+>*************************************/
  44. /*
  45. * system includes
  46. */
  47. #include <stdlib.h>
  48. #include <string.h>
  49. /*
  50. * Canvas Engine includes
  51. */
  52. #include "CanvasP.h"
  53. #include "CanvasSegP.h"
  54. /*
  55. * private includes
  56. */
  57. #include "CanvasI.h"
  58. #include "VirtFuncsI.h"
  59. #ifdef NLS16
  60. #endif
  61. /******** Private Function Declarations ********/
  62. /******** End Private Function Declarations ********/
  63. /*****************************************************************************
  64. * Private Defines
  65. *****************************************************************************/
  66. /*****************************************************************************
  67. * Private Variables
  68. *****************************************************************************/
  69. /*****************************************************************************
  70. * Semi-Private Variables
  71. *****************************************************************************/
  72. /*****************************************************************************
  73. * Private Functions
  74. *****************************************************************************/
  75. /*****************************************************************************
  76. * Semi-Public Functions
  77. *****************************************************************************/
  78. /******************************************************************************
  79. * Function: _DtCvUnit _DtCvGetStringWidth (_DtCanvasStruct *canvas,
  80. * _DtCvSegment *segment, char *string, int len)
  81. *
  82. * Parameters:
  83. *
  84. * Returns:
  85. *
  86. *****************************************************************************/
  87. _DtCvUnit
  88. _DtCvGetStringWidth (
  89. _DtCanvasStruct *canvas,
  90. _DtCvSegment *segment,
  91. void *string,
  92. int len)
  93. {
  94. _DtCvUnit result = -1;
  95. _DtCvStringInfo strInfo;
  96. strInfo.string = string;
  97. strInfo.byte_len = len;
  98. strInfo.wc = _DtCvIsSegWideChar(segment);
  99. strInfo.font_ptr = _DtCvFontOfStringSeg(segment);
  100. if (canvas->virt_functions.get_width != NULL)
  101. result = (*(canvas->virt_functions.get_width)) (
  102. canvas->client_data, _DtCvSTRING_TYPE,
  103. (_DtCvPointer) &strInfo);
  104. if (result < 0)
  105. result = 0;
  106. return result;
  107. } /* End _DtCvGetStringWidth */
  108. /******************************************************************************
  109. * Function: void _DtCvFontMetrics (_DtCanvasStruct canvas,
  110. *
  111. * Parameters:
  112. *
  113. * Returns:
  114. *
  115. * Purpose:
  116. *
  117. ******************************************************************************/
  118. void
  119. _DtCvFontMetrics(
  120. _DtCanvasStruct *canvas,
  121. _DtCvPointer font_handle,
  122. _DtCvUnit *ret_ascent,
  123. _DtCvUnit *ret_descent,
  124. _DtCvUnit *ret_ave,
  125. _DtCvUnit *ret_super_y,
  126. _DtCvUnit *ret_sub_y)
  127. {
  128. if (ret_ascent != NULL)
  129. *ret_ascent = 0;
  130. if (ret_descent != NULL)
  131. *ret_descent = 0;
  132. if (ret_ave != NULL)
  133. *ret_ave = 0;
  134. if (ret_super_y != NULL)
  135. *ret_super_y = 0;
  136. if (ret_sub_y != NULL)
  137. *ret_sub_y = 0;
  138. if (canvas->virt_functions.get_font_metrics != NULL)
  139. (*(canvas->virt_functions.get_font_metrics))(
  140. canvas->client_data, font_handle,
  141. ret_ascent, ret_descent, ret_ave, ret_super_y, ret_sub_y);
  142. } /* End _DtCvFontMetrics */