summaryrefslogtreecommitdiff
path: root/src/Xw/Xw_def_width.cxx
blob: a443aae882e60656ca3abda6bfd5224f7f58c715 (plain)
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

#include <Xw_Extension.h>

	/* ifdef then trace on */
#ifdef TRACE
#define TRACE_DEF_WIDTH
#endif

/*
   STATUS Xw_def_width (awidthmap,index,width):
   XW_EXT_WIDTHMAP *awidthmap
   int index			Line width index
   float width			width in MM

	Update Line Width Extended widthmap index 
				with the specified WIDTH value . 
	NOTE than width index 0 is the default width (1 pixel) 
					and cann't be redefined .

	Returns ERROR if BadWidth Index
	Returns SUCCESS if Successful      

*/

#ifdef XW_PROTOTYPE
XW_STATUS Xw_def_width (void* awidthmap,int index,float width)
#else
XW_STATUS Xw_def_width (awidthmap,index,width)
void *awidthmap ;
int index ;
float width ;
#endif /*XW_PROTOTYPE*/
{
XW_EXT_WIDTHMAP *pwidthmap = (XW_EXT_WIDTHMAP*)awidthmap ;
Screen *screen ;
int pwidth ;

	if ( !Xw_isdefine_widthindex(pwidthmap,index) ) {
	    /*Bad Width Index*/
	    Xw_set_error(21,"Xw_def_width",&index) ;
	    return (XW_ERROR) ;
	}

	screen = ScreenOfDisplay(_WDISPLAY,DefaultScreen(_WDISPLAY)) ;
	width = width * (float)HeightOfScreen(screen)/
					(float)HeightMMOfScreen(screen) ; 
	pwidth = (int) (0.5 + width) ;

	pwidthmap->widths[index] = 1 ;
	if( width == 0. || pwidth < 0 || pwidth > 255 ) {
	    /*Bad Width Thickness*/
	    Xw_set_error(22,"Xw_def_width",&width) ;
	}

	pwidthmap->widths[index] = (unsigned char) (pwidth) ? pwidth : 1 ;

#ifdef  TRACE_DEF_WIDTH
if( Xw_get_trace() ) {
    printf (" Xw_def_width(%lx,%d,%f)\n",(long ) pwidthmap,index,width) ;
}
#endif

	return (XW_SUCCESS);
}