Integration of OCCT 6.5.0 from SVN
[occt.git] / src / Xw / Xw_get_widthmap_info.cxx
1
2 #include <Xw_Extension.h>
3
4         /* ifdef then trace on */
5 #ifdef TRACE
6 #define TRACE_GET_WIDTHMAP_INFO
7 #endif
8
9 /*
10    XW_STATUS Xw_get_widthmap_info (awidthmap,mwidth,uwidth,dwidth,fwidth):
11    XW_EXT_WIDTHMAP *awidthmap
12    int *mwidth          Return the maximum width number of the widthmap
13    int *uwidth          Return the User width number used in the widthmap
14    int *dwidth          Return the User width number defined in the widthmap
15    int *fwidth          Return the First Free width index in the widthmap
16    NOTE than if fwidth < 0 , No more Free width exist in the widthmap 
17
18         Returns XW_ERROR if the Extended Widthmap is not defined
19         Returns XW_SUCCESS if successful
20
21 */
22
23 #ifdef XW_PROTOTYPE
24 XW_STATUS Xw_get_widthmap_info (void *awidthmap,int *mwidth,int *uwidth,int *dwidth,int *fwidth)
25 #else
26 XW_STATUS Xw_get_widthmap_info (awidthmap,mwidth,uwidth,dwidth,fwidth)
27 void *awidthmap;
28 int *mwidth,*uwidth,*dwidth,*fwidth ;
29 #endif /*XW_PROTOTYPE*/
30 {
31   XW_EXT_WIDTHMAP *pwidthmap = (XW_EXT_WIDTHMAP*)awidthmap;
32   int i ;
33
34         if( !Xw_isdefine_widthmap(pwidthmap) ) {
35             /*ERROR*Bad EXT_WIDTHMAP Address*/
36             Xw_set_error(53,"Xw_get_widthmap_info",pwidthmap) ;
37             return (XW_ERROR) ;
38         }
39
40         *mwidth = MAXWIDTH ;
41         *uwidth = pwidthmap->maxwidth ;
42         *dwidth = 1 ;
43         *fwidth = -1 ;
44         for( i=0 ; i< *uwidth ; i++ ) {
45             if( pwidthmap->widths[i] ) (*dwidth)++ ;
46             else if( i && *fwidth < 0 ) *fwidth = i ;
47         }
48         
49 #ifdef  TRACE_GET_WIDTHMAP_INFO
50 if( Xw_get_trace() ) {
51     printf (" Xw_get_widthmap_info(%lx,%d,%d,%d,%d)\n",
52                         (long ) pwidthmap,*mwidth,*uwidth,*dwidth,*fwidth) ;
53 }
54 #endif
55
56         return (XW_SUCCESS);
57 }