1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
19 #include <Xw_Extension.h>
21 /* ifdef then trace on */
23 #define TRACE_GET_HIGHLIGHT_COLOR
24 #define TRACE_GET_HIGHLIGHT_PIXEL
28 XW_STATUS Xw_get_highlight_color(acolormap,r,g,b):
29 XW_EXT_COLORMAP *acolormap Colormap extension structure
30 float *r,*g,*b ; Returns Red,Green,Blue color value 0. >= x <= 1.
32 Get R,G,B Highlight Color values from Default index .
34 Returns ERROR if Extended Colormap Address is badly defined
35 Returns SUCCESS if Successful
37 XW_STATUS Xw_get_highlight_pixel(acolormap,pixel):
38 XW_EXT_COLORMAP *acolormap Colormap extension structure
39 unsigned long *pixel; Returns HighLight pixel
44 XW_STATUS Xw_get_highlight_color (void* acolormap,
45 float* r,float* g,float* b)
47 XW_STATUS Xw_get_highlight_color (acolormap,r,g,b)
50 #endif /*XW_PROTOTYPE*/
52 XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap;
55 if ( !Xw_isdefine_colormap(pcolormap) ) {
56 /*ERROR*Bad EXTENDED Colormap ADDRESS*/
57 Xw_set_error(42,"Xw_get_highlight_color",pcolormap) ;
65 color.pixel = pcolormap->highpixel ;
66 XQueryColor(_CDISPLAY,_CINFO.colormap,&color) ;
67 *r = (float)color.red/0xFFFF ;
68 *g = (float)color.green/0xFFFF ;
69 *b = (float)color.blue/0xFFFF ;
73 { unsigned long mask = _CVISUAL->map_entries-1 ;
74 unsigned long red,green,blue ;
75 unsigned long rmask = _CVISUAL->red_mask ;
76 unsigned long gmask = _CVISUAL->green_mask ;
77 unsigned long bmask = _CVISUAL->blue_mask ;
79 color.pixel = pcolormap->highpixel ;
80 red = color.pixel & rmask ;
81 while ( !(rmask & 0x01) ) { rmask >>= 1; red >>= 1; }
83 green = color.pixel & gmask ;
84 while ( !(gmask & 0x01) ) { gmask >>= 1; green >>= 1; }
86 blue = color.pixel & bmask ;
87 while ( !(bmask & 0x01) ) { bmask >>= 1; blue >>= 1; }
89 *r = (float)red/mask ;
90 *g = (float)green/mask ;
91 *b = (float)blue/mask ;
96 /*Unmatchable Visual class*/
97 Xw_set_error(67,"Xw_get_highlight_color",&_CCLASS) ;
103 #ifdef TRACE_GET_HIGHLIGHT_COLOR
104 if( Xw_get_trace() > 1 ) {
105 printf(" Xw_get_highlight_color(%lx,%f,%f,%f)\n",(long ) pcolormap,*r,*g,*b) ;
113 XW_STATUS Xw_get_highlight_pixel (void* acolormap,unsigned long *pixel)
115 XW_STATUS Xw_get_highlight_pixel (acolormap,pixel)
117 unsigned long *pixel;
118 #endif /*XW_PROTOTYPE*/
120 XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap;
123 if ( !Xw_isdefine_colormap(pcolormap) ) {
124 /*ERROR*Bad EXTENDED Colormap ADDRESS*/
125 Xw_set_error(42,"Xw_get_highlight_pixel",pcolormap) ;
129 *pixel = pcolormap->highpixel ;
131 #ifdef TRACE_GET_HIGHLIGHT_PIXEL
132 if( Xw_get_trace() > 1 ) {
133 printf(" Xw_get_highlight_pixel(%lx,%lx)\n",(long ) pcolormap,*pixel) ;