dtcalc: change from obsoleted MAXFLOAT to FLT_MAX from std C
[oweals/cde.git] / cde / lib / DtHelp / VirtFuncs.c
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 /*
46  * system includes
47  */
48 #include <stdlib.h>
49 #include <string.h>
50
51 /*
52  * Canvas Engine includes
53  */
54 #include "CanvasP.h"
55 #include "CanvasSegP.h"
56
57 /*
58  * private includes
59  */
60 #include "CanvasI.h"
61 #include "VirtFuncsI.h"
62
63 #ifdef NLS16
64 #endif
65
66 /********    Private Function Declarations    ********/
67 /********    End Private Function Declarations    ********/
68
69 /*****************************************************************************
70  *              Private Defines
71  *****************************************************************************/
72 /*****************************************************************************
73  *              Private Variables
74  *****************************************************************************/
75 /*****************************************************************************
76  *              Semi-Private Variables
77  *****************************************************************************/
78 /*****************************************************************************
79  *              Private Functions
80  *****************************************************************************/
81 /*****************************************************************************
82  *              Semi-Public Functions
83  *****************************************************************************/
84 /******************************************************************************
85  * Function:    _DtCvUnit _DtCvGetStringWidth (_DtCanvasStruct *canvas,
86  *                              _DtCvSegment *segment, char *string, int len)
87  *
88  * Parameters:
89  *
90  * Returns:
91  *
92  *****************************************************************************/
93 _DtCvUnit
94 _DtCvGetStringWidth (
95     _DtCanvasStruct      *canvas,
96     _DtCvSegment           *segment,
97     void                *string,
98     int                  len)
99 {
100     _DtCvUnit   result = -1;
101     _DtCvStringInfo strInfo;
102
103     strInfo.string   = string;
104     strInfo.byte_len = len;
105     strInfo.wc       = _DtCvIsSegWideChar(segment);
106     strInfo.font_ptr = _DtCvFontOfStringSeg(segment);
107
108     if (canvas->virt_functions.get_width != NULL)
109         result = (*(canvas->virt_functions.get_width)) (
110                         canvas->client_data, _DtCvSTRING_TYPE,
111                         (_DtCvPointer) &strInfo);
112     if (result < 0)
113         result = 0;
114
115     return result;
116
117 } /* End _DtCvGetStringWidth */
118
119 /******************************************************************************
120  * Function:    void _DtCvFontMetrics (_DtCanvasStruct canvas,
121  *
122  * Parameters:
123  *
124  * Returns:
125  *
126  * Purpose:
127  *
128  ******************************************************************************/
129 void
130 _DtCvFontMetrics(
131     _DtCanvasStruct     *canvas,
132     _DtCvPointer         font_handle,
133     _DtCvUnit           *ret_ascent,
134     _DtCvUnit           *ret_descent,
135     _DtCvUnit           *ret_ave,
136     _DtCvUnit           *ret_super_y,
137     _DtCvUnit           *ret_sub_y)
138 {
139     if (ret_ascent != NULL)
140         *ret_ascent = 0;
141     if (ret_descent != NULL)
142         *ret_descent = 0;
143     if (ret_ave != NULL)
144         *ret_ave = 0;
145     if (ret_super_y != NULL)
146         *ret_super_y = 0;
147     if (ret_sub_y != NULL)
148         *ret_sub_y = 0;
149
150     if (canvas->virt_functions.get_font_metrics != NULL)
151         (*(canvas->virt_functions.get_font_metrics))(
152                 canvas->client_data, font_handle,
153                 ret_ascent, ret_descent, ret_ave, ret_super_y, ret_sub_y);
154
155 } /* End _DtCvFontMetrics */