Integration of OCCT 6.5.0 from SVN
[occt.git] / src / Xw / Xw_get_highlight_color.cxx
CommitLineData
7fd59977 1
2#include <Xw_Extension.h>
3
4 /* ifdef then trace on */
5#ifdef TRACE
6#define TRACE_GET_HIGHLIGHT_COLOR
7#define TRACE_GET_HIGHLIGHT_PIXEL
8#endif
9
10/*
11 XW_STATUS Xw_get_highlight_color(acolormap,r,g,b):
12 XW_EXT_COLORMAP *acolormap Colormap extension structure
13 float *r,*g,*b ; Returns Red,Green,Blue color value 0. >= x <= 1.
14
15 Get R,G,B Highlight Color values from Default index .
16
17 Returns ERROR if Extended Colormap Address is badly defined
18 Returns SUCCESS if Successful
19
20 XW_STATUS Xw_get_highlight_pixel(acolormap,pixel):
21 XW_EXT_COLORMAP *acolormap Colormap extension structure
22 unsigned long *pixel; Returns HighLight pixel
23
24*/
25
26#ifdef XW_PROTOTYPE
27XW_STATUS Xw_get_highlight_color (void* acolormap,
28 float* r,float* g,float* b)
29#else
30XW_STATUS Xw_get_highlight_color (acolormap,r,g,b)
31void *acolormap;
32float *r,*g,*b ;
33#endif /*XW_PROTOTYPE*/
34{
35XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap;
36XColor color ;
37
38 if ( !Xw_isdefine_colormap(pcolormap) ) {
39 /*ERROR*Bad EXTENDED Colormap ADDRESS*/
40 Xw_set_error(42,"Xw_get_highlight_color",pcolormap) ;
41 return (XW_ERROR) ;
42 }
43
44 switch ( _CCLASS ) {
45
46 case PseudoColor :
47 case StaticColor :
48 color.pixel = pcolormap->highpixel ;
49 XQueryColor(_CDISPLAY,_CINFO.colormap,&color) ;
50 *r = (float)color.red/0xFFFF ;
51 *g = (float)color.green/0xFFFF ;
52 *b = (float)color.blue/0xFFFF ;
53 break ;
54
55 case TrueColor :
56 { unsigned long mask = _CVISUAL->map_entries-1 ;
57 unsigned long red,green,blue ;
58 unsigned long rmask = _CVISUAL->red_mask ;
59 unsigned long gmask = _CVISUAL->green_mask ;
60 unsigned long bmask = _CVISUAL->blue_mask ;
61
62 color.pixel = pcolormap->highpixel ;
63 red = color.pixel & rmask ;
64 while ( !(rmask & 0x01) ) { rmask >>= 1; red >>= 1; }
65
66 green = color.pixel & gmask ;
67 while ( !(gmask & 0x01) ) { gmask >>= 1; green >>= 1; }
68
69 blue = color.pixel & bmask ;
70 while ( !(bmask & 0x01) ) { bmask >>= 1; blue >>= 1; }
71
72 *r = (float)red/mask ;
73 *g = (float)green/mask ;
74 *b = (float)blue/mask ;
75 }
76 break ;
77
78 default :
79 /*Unmatchable Visual class*/
80 Xw_set_error(67,"Xw_get_highlight_color",&_CCLASS) ;
81 return (XW_ERROR) ;
82 }
83
84
85
86#ifdef TRACE_GET_HIGHLIGHT_COLOR
87if( Xw_get_trace() > 1 ) {
88 printf(" Xw_get_highlight_color(%lx,%f,%f,%f)\n",(long ) pcolormap,*r,*g,*b) ;
89}
90#endif
91
92 return (XW_SUCCESS);
93}
94
95#ifdef XW_PROTOTYPE
96XW_STATUS Xw_get_highlight_pixel (void* acolormap,unsigned long *pixel)
97#else
98XW_STATUS Xw_get_highlight_pixel (acolormap,pixel)
99void *acolormap;
100unsigned long *pixel;
101#endif /*XW_PROTOTYPE*/
102{
103XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap;
104//XColor color ;
105
106 if ( !Xw_isdefine_colormap(pcolormap) ) {
107 /*ERROR*Bad EXTENDED Colormap ADDRESS*/
108 Xw_set_error(42,"Xw_get_highlight_pixel",pcolormap) ;
109 return (XW_ERROR) ;
110 }
111
112 *pixel = pcolormap->highpixel ;
113
114#ifdef TRACE_GET_HIGHLIGHT_PIXEL
115if( Xw_get_trace() > 1 ) {
116 printf(" Xw_get_highlight_pixel(%lx,%lx)\n",(long ) pcolormap,*pixel) ;
117}
118#endif
119
120 return (XW_SUCCESS);
121}