Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / lib / DtHelp / VirtFuncs.c
1 /* $XConsortium: VirtFuncs.c /main/8 1995/12/18 16:24:06 cde-hp $ */
2 /************************************<+>*************************************
3  ****************************************************************************
4  **
5  **   File:  VirtFuncs.c
6  **
7  **   Project: Cde 1.0
8  **
9  **   Description:
10  **
11  **  (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
12  **
13  **  (c) Copyright 1993, 1994 Hewlett-Packard Company
14  **  (c) Copyright 1993, 1994 International Business Machines Corp.
15  **  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
16  **  (c) Copyright 1993, 1994 Novell, Inc.
17  **
18  **
19  **
20  ****************************************************************************
21  ************************************<+>*************************************/
22
23 /*
24  * system includes
25  */
26 #include <stdlib.h>
27 #include <string.h>
28
29 /*
30  * Canvas Engine includes
31  */
32 #include "CanvasP.h"
33 #include "CanvasSegP.h"
34
35 /*
36  * private includes
37  */
38 #include "CanvasI.h"
39 #include "VirtFuncsI.h"
40
41 #ifdef NLS16
42 #endif
43
44 /********    Private Function Declarations    ********/
45 /********    End Private Function Declarations    ********/
46
47 /*****************************************************************************
48  *              Private Defines
49  *****************************************************************************/
50 /*****************************************************************************
51  *              Private Variables
52  *****************************************************************************/
53 /*****************************************************************************
54  *              Semi-Private Variables
55  *****************************************************************************/
56 /*****************************************************************************
57  *              Private Functions
58  *****************************************************************************/
59 /*****************************************************************************
60  *              Semi-Public Functions
61  *****************************************************************************/
62 /******************************************************************************
63  * Function:    _DtCvUnit _DtCvGetStringWidth (_DtCanvasStruct *canvas,
64  *                              _DtCvSegment *segment, char *string, int len)
65  *
66  * Parameters:
67  *
68  * Returns:
69  *
70  *****************************************************************************/
71 _DtCvUnit
72 _DtCvGetStringWidth (
73     _DtCanvasStruct      *canvas,
74     _DtCvSegment           *segment,
75     void                *string,
76     int                  len)
77 {
78     _DtCvUnit   result = -1;
79     _DtCvStringInfo strInfo;
80
81     strInfo.string   = string;
82     strInfo.byte_len = len;
83     strInfo.wc       = _DtCvIsSegWideChar(segment);
84     strInfo.font_ptr = _DtCvFontOfStringSeg(segment);
85
86     if (canvas->virt_functions.get_width != NULL)
87         result = (*(canvas->virt_functions.get_width)) (
88                         canvas->client_data, _DtCvSTRING_TYPE,
89                         (_DtCvPointer) &strInfo);
90     if (result < 0)
91         result = 0;
92
93     return result;
94
95 } /* End _DtCvGetStringWidth */
96
97 /******************************************************************************
98  * Function:    void _DtCvFontMetrics (_DtCanvasStruct canvas,
99  *
100  * Parameters:
101  *
102  * Returns:
103  *
104  * Purpose:
105  *
106  ******************************************************************************/
107 void
108 _DtCvFontMetrics(
109     _DtCanvasStruct     *canvas,
110     _DtCvPointer         font_handle,
111     _DtCvUnit           *ret_ascent,
112     _DtCvUnit           *ret_descent,
113     _DtCvUnit           *ret_ave,
114     _DtCvUnit           *ret_super_y,
115     _DtCvUnit           *ret_sub_y)
116 {
117     if (ret_ascent != NULL)
118         *ret_ascent = 0;
119     if (ret_descent != NULL)
120         *ret_descent = 0;
121     if (ret_ave != NULL)
122         *ret_ave = 0;
123     if (ret_super_y != NULL)
124         *ret_super_y = 0;
125     if (ret_sub_y != NULL)
126         *ret_sub_y = 0;
127
128     if (canvas->virt_functions.get_font_metrics != NULL)
129         (*(canvas->virt_functions.get_font_metrics))(
130                 canvas->client_data, font_handle,
131                 ret_ascent, ret_descent, ret_ave, ret_super_y, ret_sub_y);
132
133 } /* End _DtCvFontMetrics */