1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#include <Xw_FontMap.ixx>
#include <Aspect_TypeOfFont.hxx>
#include <Aspect_FontStyle.hxx>
#include <Standard_ShortReal.hxx>
// Routines C a declarer en extern
//extern "C" {
#include <Xw_Cextern.hxx>
//}
//-Static data definitions
static char *ErrorMessag ;
static int ErrorNumber ;
static int ErrorGravity ;
static XW_STATUS status ;
Xw_FontMap::Xw_FontMap () {
}
Xw_FontMap::Xw_FontMap (const Standard_CString Connexion) {
MyExtendedDisplay = Xw_open_display((Standard_PCharacter)Connexion) ;
if( !MyExtendedDisplay ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity )
Aspect_FontMapDefinitionError::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
MyExtendedFontMap = Xw_def_fontmap(MyExtendedDisplay,(int)0) ;
if( !Xw_isdefine_fontmap(MyExtendedFontMap) ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity )
Aspect_FontMapDefinitionError::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
}
void Xw_FontMap::SetEntry (const Aspect_FontMapEntry& Entry) {
Aspect_FontStyle style = Entry.Type() ;
int ffont = (int) Entry.Index() ;
Standard_CString value = style.FullName() ;
float csize = TOMILLIMETER(style.Size()) ;
if( ffont ) { /* Don't modify Index 0,Default font */
status = Xw_def_font(MyExtendedFontMap,ffont,csize,(char*)value);
if( !status ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity > 2 )
Aspect_BadAccess::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
}
}
void Xw_FontMap::SetEntries (const Handle(Aspect_FontMap)& Fontmap) {
Standard_Integer size = Fontmap->Size() ;
Standard_Integer i ;
if( !Xw_isdefine_fontmap(MyExtendedFontMap) ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity > 2 )
Aspect_FontMapDefinitionError::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
for( i=1 ; i<=size ; i++ ) {
SetEntry(Fontmap->Entry(i)) ;
}
}
void Xw_FontMap::Destroy() {
if( MyExtendedFontMap ) {
Xw_close_fontmap(MyExtendedFontMap) ;
MyExtendedFontMap = NULL ;
}
}
Standard_Integer Xw_FontMap::FreeFonts( ) const {
Standard_Integer nfont ;
int mfont,ufont,dfont,ffont ;
status = Xw_get_fontmap_info(MyExtendedFontMap,
&mfont,&ufont,&dfont,&ffont) ;
if( !status ) {
ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
if( ErrorGravity > 2 )
Aspect_BadAccess::Raise (ErrorMessag) ;
else Xw_print_error() ;
}
nfont = ufont - dfont ;
return (nfont) ;
}
Standard_Address Xw_FontMap::ExtendedFontMap () const {
return (MyExtendedFontMap);
}
|