Integration of OCCT 6.5.0 from SVN
[occt.git] / src / OpenGl / OpenGl_textheight.cxx
CommitLineData
7fd59977 1/***********************************************************************
2
3FONCTION :
4----------
5File OpenGl_textheight :
6
7
8REMARQUES:
9----------
10
11
12HISTORIQUE DES MODIFICATIONS :
13--------------------------------
14xx-xx-xx : xxx ; Creation.
1520-02-96 : FMN ; Suppression code inutile:
1601-04-96 : CAL ; Integration MINSK portage WNT
1726-04-96 : FMN ; Correction warning de compilation.
1820-11-97 : CAL ; RererereMerge avec le source de portage.
1917-12-96 : FMN ; Warning de compilation.
20
21************************************************************************/
22
23#define BUC60821 //GG 12/02/01 allow tu use the nearest font size.
24
25/*----------------------------------------------------------------------*/
26/*
27* Includes
28*/
29
30#include <OpenGl_tgl_all.hxx>
31
32#include <stddef.h>
33#include <stdio.h>
34
35#include <OpenGl_cmn_varargs.hxx>
36#include <OpenGl_telem_attri.hxx>
37#include <OpenGl_tsm.hxx>
38#include <OpenGl_telem.hxx>
39#include <OpenGl_telem_inquire.hxx>
40#include <OpenGl_tgl_tox.hxx>
41#include <OpenGl_Memory.hxx>
42
43
44/*----------------------------------------------------------------------*/
45/*
46* Fonctions statiques
47*/
48
49static TStatus TextHeightDisplay( TSM_ELEM_DATA, Tint, cmn_key* );
50static TStatus TextHeightAdd( TSM_ELEM_DATA, Tint, cmn_key* );
51static TStatus TextHeightDelete( TSM_ELEM_DATA, Tint, cmn_key* );
52static TStatus TextHeightPrint( TSM_ELEM_DATA, Tint, cmn_key* );
53static TStatus TextHeightInquire( TSM_ELEM_DATA, Tint, cmn_key* );
54
55/*----------------------------------------------------------------------*/
56static TStatus (*MtdTbl[])( TSM_ELEM_DATA, Tint, cmn_key* ) =
57{
58 TextHeightDisplay, /* PickTraverse */
59 TextHeightDisplay,
60 TextHeightAdd,
61 TextHeightDelete,
62 TextHeightPrint,
63 TextHeightInquire
64};
65
66
67/*----------------------------------------------------------------------*/
68MtblPtr
69TelTextHeightInitClass( TelType *el )
70{
71 *el = TelTextHeight;
72 return MtdTbl;
73}
74
75/*----------------------------------------------------------------------*/
76static TStatus
77TextHeightAdd( TSM_ELEM_DATA d, Tint n, cmn_key *k )
78{
79 Tfloat *data = new Tfloat();
80 if( !data )
81 return TFailure;
82
83#ifdef BUC60821
84 *data = k[0]->data.fdata;
85#else /*BUC60821*/
86#ifndef WNT
87 {
88 Tint d_wdth, d_hght;
89 call_tox_getscreen( &d_wdth, &d_hght );
90 *data = k[0]->data.fdata * d_hght;
91 }
92#else
93 *data = k[0]->data.fdata;
94#endif /* WNT */
95#endif /* BUC60821 */
96
97 ((tsm_elem_data)(d.pdata))->pdata = data;
98
99 return TSuccess;
100}
101
102
103/*----------------------------------------------------------------------*/
104static TStatus
105TextHeightDisplay( TSM_ELEM_DATA data, Tint n, cmn_key *k )
106{
107 CMN_KEY key;
108
109 key.id = TelTextHeight;
110 key.data.fdata = *(Tfloat*)(data.pdata);
111 TsmSetAttri( 1, &key );
112
113 return TSuccess;
114}
115
116
117/*----------------------------------------------------------------------*/
118static TStatus
119TextHeightDelete( TSM_ELEM_DATA data, Tint n, cmn_key *k )
120{
121 if (data.pdata)
122 delete data.pdata;
123 return TSuccess;
124}
125
126
127/*----------------------------------------------------------------------*/
128static TStatus
129TextHeightPrint( TSM_ELEM_DATA data, Tint n, cmn_key *k )
130{
131 fprintf( stdout, "TelTextHeight. Value = %g\n", *(Tfloat *)(data.pdata));
132 fprintf( stdout, "\n" );
133
134 return TSuccess;
135}
136
137
138/*----------------------------------------------------------------------*/
139static TStatus
140TextHeightInquire( TSM_ELEM_DATA data, Tint n, cmn_key *k )
141{
142 Tint i;
143 Tfloat *f = (Tfloat*)data.pdata;
144
145 for( i = 0; i < n; i++ )
146 {
147 switch( k[i]->id )
148 {
149 case INQ_GET_SIZE_ID:
150 {
151 k[i]->data.ldata = sizeof( Tint );
152 break;
153 }
154 case INQ_GET_CONTENT_ID:
155 {
156 TEL_INQ_CONTENT *c;
157 Teldata *w;
158
159 c = (TEL_INQ_CONTENT *)k[i]->data.pdata;
160 w = c->data;
161 c->act_size = 0;
162 w->fdata = *f;
163 break;
164 }
165 }
166 }
167
168 return TSuccess;
169}
170/*----------------------------------------------------------------------*/