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_ISDEFINE_COLOR |
24 | #endif |
25 | |
26 | /* |
27 | XW_STATUS Xw_isdefine_color(acolormap,index): |
28 | XW_EXT_COLORMAP *acolormap Colormap extension structure |
29 | int index ; Color index 0 >= x < MAXCOLOR |
30 | |
31 | Returns XW_ERROR if BadColor index or Color is not define |
32 | Returns XW_SUCCESS if Color is defined |
33 | |
34 | */ |
35 | #ifdef XW_PROTOTYPE |
36 | XW_STATUS Xw_isdefine_color (void* acolormap, int index) |
37 | #else |
38 | XW_STATUS Xw_isdefine_color (acolormap,index) |
39 | void *acolormap; |
40 | int index ; |
41 | #endif /*XW_PROTOTYPE*/ |
42 | { |
43 | XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap ; |
44 | XW_STATUS status = XW_ERROR ; |
45 | //int i ; |
46 | |
47 | if( pcolormap && ((index < 0) || |
48 | ((index >= 0) && (index < pcolormap->maxcolor) && |
49 | (pcolormap->define[index]))) ) { |
50 | status = XW_SUCCESS ; |
51 | } |
52 | |
53 | #ifdef TRACE_ISDEFINE_COLOR |
54 | if( Xw_get_trace() > 2 ) { |
55 | printf(" %d = Xw_isdefine_color(%lx,%d)\n",status,(long ) pcolormap,index) ; |
56 | } |
57 | #endif |
58 | |
59 | return (status); |
60 | } |
61 | |
62 | #ifdef XW_PROTOTYPE |
63 | XW_STATUS Xw_isdefine_colorindex (XW_EXT_COLORMAP* acolormap, int index) |
64 | #else |
65 | XW_STATUS Xw_isdefine_colorindex (acolormap,index) |
66 | XW_EXT_COLORMAP *acolormap; |
67 | int index ; |
68 | #endif /*XW_PROTOTYPE*/ |
69 | /* |
70 | Verify Index range Only |
71 | */ |
72 | { |
73 | XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap ; |
74 | XW_STATUS status = XW_ERROR ; |
75 | |
76 | if( pcolormap && (index >= 0) && (index < pcolormap->maxcolor) ) { |
77 | status = XW_SUCCESS ; |
78 | } |
79 | |
80 | #ifdef TRACE_ISDEFINE_COLOR |
81 | if( Xw_get_trace() > 2 ) { |
82 | printf(" %d = Xw_isdefine_colorindex(%lx,%d)\n",status,(long ) pcolormap,index) ; |
83 | } |
84 | #endif |
85 | |
86 | return (status) ; |
87 | } |
88 | #ifdef XW_PROTOTYPE |
89 | XW_STATUS Xw_ifsystem_colorindex (XW_EXT_COLORMAP* acolormap, int index) |
90 | #else |
91 | XW_STATUS Xw_ifsystem_colorindex (acolormap,index) |
92 | XW_EXT_COLORMAP *acolormap; |
93 | int index ; |
94 | #endif /*XW_PROTOTYPE*/ |
95 | /* |
96 | Check if System color index |
97 | */ |
98 | { |
99 | XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap ; |
100 | XW_STATUS status = XW_ERROR ; |
101 | |
102 | if( pcolormap && (index >= 0) && (index < pcolormap->maxcolor) && |
103 | (pcolormap->define[index] == SYSTEMCOLOR) ) { |
104 | status = XW_SUCCESS ; |
105 | } |
106 | |
107 | #ifdef TRACE_ISDEFINE_COLOR |
108 | if( Xw_get_trace() > 2 ) { |
109 | printf(" %d = Xw_ifsystem_colorindex(%lx,%d)\n",status,(long ) pcolormap,index) ; |
110 | } |
111 | #endif |
112 | |
113 | return (status) ; |
114 | } |
115 | |
116 | #ifdef XW_PROTOTYPE |
117 | XW_STATUS Xw_ifimage_colorindex (XW_EXT_COLORMAP* acolormap, int index) |
118 | #else |
119 | XW_STATUS Xw_ifimage_colorindex (acolormap,index) |
120 | XW_EXT_COLORMAP *acolormap; |
121 | int index ; |
122 | #endif /*XW_PROTOTYPE*/ |
123 | /* |
124 | Check if image color index |
125 | */ |
126 | { |
127 | XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap ; |
128 | XW_STATUS status = XW_ERROR ; |
129 | |
130 | if( pcolormap && (index >= 0) && (index < pcolormap->maxcolor) && |
131 | (pcolormap->define[index] == IMAGECOLOR) ) { |
132 | status = XW_SUCCESS ; |
133 | } |
134 | |
135 | #ifdef TRACE_ISDEFINE_COLOR |
136 | if( Xw_get_trace() > 2 ) { |
137 | printf(" %d = Xw_ifimage_colorindex(%lx,%d)\n",status,(long ) pcolormap,index) ; |
138 | } |
139 | #endif |
140 | |
141 | return (status) ; |
142 | } |
143 | |
144 | #ifdef XW_PROTOTYPE |
145 | XW_STATUS Xw_ifbackground_colorindex (XW_EXT_COLORMAP* acolormap, int index) |
146 | #else |
147 | XW_STATUS Xw_ifbackground_colorindex (acolormap,index) |
148 | XW_EXT_COLORMAP *acolormap; |
149 | int index ; |
150 | #endif /*XW_PROTOTYPE*/ |
151 | /* |
152 | Check if background color index |
153 | */ |
154 | { |
155 | XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap ; |
156 | XW_STATUS status = XW_ERROR ; |
157 | |
158 | if( pcolormap && ((index < 0) || |
159 | ((index >= 0) && (index < pcolormap->maxcolor) && |
160 | (pcolormap->define[index] == BACKCOLOR))) ) { |
161 | status = XW_SUCCESS ; |
162 | } |
163 | |
164 | #ifdef TRACE_ISDEFINE_COLOR |
165 | if( Xw_get_trace() > 2 ) { |
166 | printf(" %d = Xw_ifbackground_colorindex(%lx,%d)\n",status,(long ) pcolormap,index) ; |
167 | } |
168 | #endif |
169 | |
170 | return (status) ; |
171 | } |
172 | |
173 | #ifdef XW_PROTOTYPE |
174 | XW_STATUS Xw_ifhighlight_colorindex (XW_EXT_COLORMAP* acolormap, int index) |
175 | #else |
176 | XW_STATUS Xw_ifhighlight_colorindex (acolormap,index) |
177 | XW_EXT_COLORMAP *acolormap; |
178 | int index ; |
179 | #endif /*XW_PROTOTYPE*/ |
180 | /* |
181 | Check if highlight color index |
182 | */ |
183 | { |
184 | XW_EXT_COLORMAP *pcolormap = (XW_EXT_COLORMAP*)acolormap ; |
185 | XW_STATUS status = XW_ERROR ; |
186 | |
187 | if( pcolormap && (index >= 0) && (index < pcolormap->maxcolor) && |
188 | (pcolormap->define[index] == HIGHCOLOR) ) { |
189 | status = XW_SUCCESS ; |
190 | } |
191 | |
192 | #ifdef TRACE_ISDEFINE_COLOR |
193 | if( Xw_get_trace() > 2 ) { |
194 | printf(" %d = Xw_ifhighlight_colorindex(%lx,%d)\n",status,(long ) pcolormap,index) ; |
195 | } |
196 | #endif |
197 | |
198 | return (status) ; |
199 | } |