b311480e |
1 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
2 | // |
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. |
7 | // |
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. |
10 | // |
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. |
17 | |
7fd59977 |
18 | |
19 | #include <Xw_Extension.h> |
20 | |
b311480e |
21 | /* ifdef then trace on */ |
7fd59977 |
22 | #ifdef TRACE |
23 | #define TRACE_GET_COLOR_NAME |
24 | #endif |
25 | |
26 | /* |
27 | STATUS Xw_get_color_name (acolormap,colorname,r,g,b): |
28 | XW_EXT_COLORMAP *acolormap |
29 | char *colorname Name of color from file /usr/lib/X11/rgb.txt |
30 | float *r,*g,*b Returns Color values in [0,1] space |
31 | |
32 | Returns ERROR if Name is not founded in the database |
33 | Returns SUCCESS if successful |
34 | |
35 | */ |
36 | |
37 | #ifdef XW_PROTOTYPE |
38 | XW_STATUS Xw_get_color_name (void* acolormap, |
39 | const char* colorname,float* r,float* g,float* b) |
40 | #else |
41 | XW_STATUS Xw_get_color_name (acolormap,colorname,r,g,b) |
42 | void *acolormap ; |
43 | const char *colorname ; |
44 | float *r,*g,*b ; |
45 | #endif /*XW_PROTOTYPE*/ |
46 | { |
47 | XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap ; |
48 | XColor color ; |
49 | //int red,green,blue ; |
50 | |
51 | if( !Xw_isdefine_colormap(pcolormap) ) { |
52 | /*ERROR*Bad EXT_COLORMAP Address*/ |
53 | Xw_set_error(42,"Xw_get_color_name",pcolormap) ; |
54 | return (XW_ERROR) ; |
55 | } |
56 | if( XParseColor(_CDISPLAY,_CINFO.colormap,colorname,&color) ) { |
57 | *r = (float)color.red/0xFFFF ; |
58 | *g = (float)color.green/0xFFFF; |
59 | *b = (float)color.blue/0xFFFF ; |
60 | } else return (XW_ERROR) ; |
61 | |
62 | #ifdef TRACE_GET_COLOR_NAME |
63 | if( Xw_get_trace() ) { |
64 | printf (" Xw_get_color_name(%lx,%s,%f,%f,%f)\n", |
65 | (long ) pcolormap,colorname,*r,*g,*b); |
66 | } |
67 | #endif |
68 | |
69 | return (XW_SUCCESS); |
70 | } |