7fd59977 |
1 | // File Xw_Window.cxx |
2 | // Created Fevrier 1993 |
3 | // Author NW,JPB,CAL,GG |
4 | // Modified : |
5 | // GG PRO5426 21/11/96 |
6 | // Proteger le viewer 2D contre des tentatives d'affichage |
7 | // dans une fentre detruite ou iconifiee. |
8 | // GG PRO6633 21/08/97 |
9 | // Protection contre capture d'image de taille NULLE. |
10 | // GG OPTIMISATION 18/09/97 |
11 | // remplacer les appels myWindow->Position() par |
12 | // myWindow->Size() qui est plus optimum. |
13 | // GG OPTIMISATION 20/10/97 |
14 | // Implementation de DoMapping() |
15 | // qui met a jour le MAPPING de la fenetre lorsque |
16 | // un evenemment de type GUI_IconifyEvent arrive dans |
17 | // l'application. |
18 | // GG PRO10676 15/12/97 |
19 | // Permettre de definir une couleur directement par ses |
20 | // composantes. |
21 | // GG PRO14093 03/07/98 |
22 | // Eviter de "raiser" lorsqu'une erreur est detectee. |
23 | // GG PRO14951 20/07/98 |
24 | // Ne pas modifier la couleur du background de la fenetre |
25 | // lorsque aucune fille n'est cree. |
26 | // (voir GUI_WidgetTools::DumpWidget()) |
27 | // GG CSR404 11/05/99 |
28 | // Avoid a crash in Dialog engine with a great number |
29 | // of views. |
30 | // GG G004 28/01/00 Add gama correction computation before dumping |
31 | // an image. |
32 | // GG IMP060200 |
33 | // Xw_get_image() signature change. |
34 | // GG IMP070200 |
35 | // Add MMSize() method |
36 | // TCL at October 2000 (G002); new method SetBackground( CString aName ) |
37 | // SAV 24/11/01 SetBackground( Quantity_Color ) |
38 | |
39 | #define BUC60701 //GG 23/06/00 Enable to dump an exact image size |
40 | // according to the window size |
41 | #define RIC120302 //GG Add a NEW XParentWindow methods which enable |
42 | // to retrieve the parent of the actual Xwindow ID. |
43 | |
44 | //-Copyright MatraDatavision 1991,1992,1993 |
45 | |
46 | //-Version |
47 | |
48 | //-Design Creation d'une fenetre X |
49 | |
50 | //-Warning |
51 | |
52 | //-References |
53 | |
54 | //-Language C++ 2.0 |
55 | |
56 | //-Declarations |
57 | |
58 | // for the class |
59 | #include <Xw_Window.ixx> |
60 | // Routines C a declarer en extern |
61 | //extern "C" { |
62 | #include <Xw_Cextern.hxx> |
63 | //} |
64 | #include <Aspect_Convert.hxx> |
65 | #include <Image_PixMap.hxx> |
66 | |
67 | #include <Xw_Extension.h> |
68 | |
69 | //-Static data definitions |
70 | |
71 | static XW_STATUS status ; |
72 | |
73 | //============================================================================ |
74 | //==== HashCode : Returns a HashCode CString |
75 | //============================================================================ |
76 | inline Standard_Integer HashCode (const Standard_CString Value) |
77 | { |
78 | Standard_Integer i,n,aHashCode = 0; |
79 | union { |
80 | char charPtr[80]; |
81 | int intPtr[20]; |
82 | } u; |
83 | |
84 | n = strlen(Value); |
85 | |
86 | if( n > 0 ) { |
87 | if( n < 80 ) { |
88 | n = (n+3)/4; |
89 | u.intPtr[n-1] = 0; |
90 | strcpy(u.charPtr,Value); |
91 | } else { |
92 | n = 20; |
93 | strncpy(u.charPtr,Value,80); |
94 | } |
95 | |
96 | for( i=0 ; i<n ; i++ ) { |
97 | aHashCode = aHashCode ^ u.intPtr[i]; |
98 | } |
99 | } |
100 | |
101 | //printf(" HashCode of '%s' is %d\n",Value,aHashCode); |
102 | |
103 | return Abs(aHashCode) + 1; |
104 | } |
105 | |
106 | void Xw_Window::PrintError() { |
107 | Standard_CString ErrorMessag ; |
108 | Standard_Integer ErrorNumber ; |
109 | Standard_Integer ErrorGravity ; |
110 | |
111 | status = XW_SUCCESS ; |
112 | ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ; |
113 | Xw_print_error() ; |
114 | } |
115 | |
116 | //-Aliases |
117 | |
118 | //-Global data definitions |
119 | |
120 | //-Constructors |
121 | |
122 | Xw_Window::Xw_Window (const Handle(Xw_GraphicDevice)& Device) |
123 | : Aspect_Window(Device) |
124 | { |
125 | Init(); |
126 | } |
127 | |
128 | |
129 | //======================================================================= |
130 | //function : Xw_Window |
131 | //purpose : |
132 | //======================================================================= |
133 | Xw_Window::Xw_Window (const Handle(Xw_GraphicDevice)& Device, |
134 | const Standard_Integer aPart1, |
135 | const Standard_Integer aPart2, |
136 | const Xw_WindowQuality Quality, |
137 | const Quantity_NameOfColor BackColor) |
138 | : Aspect_Window(Device) |
139 | { |
140 | Init(); |
141 | Aspect_Handle aWindow = (aPart1 << 16) | (aPart2 & 0xFFFF); |
142 | SetWindow (aWindow, Quality, BackColor); |
143 | } |
144 | |
145 | //======================================================================= |
146 | //function : Xw_Window |
147 | //purpose : |
148 | //======================================================================= |
149 | Xw_Window::Xw_Window (const Handle(Xw_GraphicDevice)& Device, |
150 | const Aspect_Handle aWindow, |
151 | const Xw_WindowQuality Quality, |
152 | const Quantity_NameOfColor BackColor) |
153 | : Aspect_Window(Device) |
154 | { |
155 | Init(); |
156 | SetWindow (aWindow, Quality, BackColor); |
157 | } |
158 | |
159 | //======================================================================= |
160 | //function : Xw_Window |
161 | //purpose : |
162 | //======================================================================= |
163 | Xw_Window::Xw_Window (const Handle(Xw_GraphicDevice)& Device, |
164 | const Standard_CString Title, |
165 | const Quantity_Parameter Xc, |
166 | const Quantity_Parameter Yc, |
167 | const Quantity_Parameter Width, |
168 | const Quantity_Parameter Height, |
169 | const Xw_WindowQuality Quality, |
170 | const Quantity_NameOfColor BackColor, |
171 | const Aspect_Handle Parent) |
172 | : Aspect_Window(Device) |
173 | { |
174 | Init(); |
175 | SetWindow (Title,Xc,Yc,Width,Height,Quality,BackColor,Parent); |
176 | } |
177 | |
178 | //======================================================================= |
179 | //function : Xw_Window |
180 | //purpose : |
181 | //======================================================================= |
182 | Xw_Window::Xw_Window (const Handle(Xw_GraphicDevice)& theDevice, |
183 | const Standard_CString theTitle, |
184 | const Standard_Integer thePxLeft, |
185 | const Standard_Integer thePxTop, |
186 | const Standard_Integer theWidth, |
187 | const Standard_Integer theHeight, |
188 | const Xw_WindowQuality theQuality, |
189 | const Quantity_NameOfColor theBackColor, |
190 | const Aspect_Handle theParent) |
191 | : Aspect_Window (theDevice) |
192 | { |
193 | Init(); |
194 | |
195 | MyExtendedDisplay = theDevice->ExtendedDisplay(); |
196 | Standard_Integer aParentSizeX = 1; |
197 | Standard_Integer aParentSizeY = 1; |
198 | |
199 | Aspect_Handle aRoot, aColormap, *aDisplay; |
200 | Xw_TypeOfVisual aVisualClass; |
201 | Standard_Integer aVisualDepth; |
202 | Xw_get_display_info (MyExtendedDisplay, |
203 | &aDisplay, &aRoot, &aColormap, &aVisualClass, &aVisualDepth); |
204 | Xw_get_screen_size (MyExtendedDisplay, &aParentSizeX, &aParentSizeY); |
205 | if (theParent) |
206 | { |
207 | XWindowAttributes anAttributes; |
208 | if(XGetWindowAttributes ((Display* )aDisplay, theParent, &anAttributes)) |
209 | { |
210 | aParentSizeX = anAttributes.width; |
211 | aParentSizeY = anAttributes.height; |
212 | } |
213 | } |
214 | Quantity_Parameter aQCenterX, aQCenterY, aQSizeX, aQSizeY; |
215 | Aspect_Convert::ConvertCoordinates (aParentSizeX, aParentSizeY, |
216 | thePxLeft, thePxTop, theWidth, theHeight, |
217 | aQCenterX, aQCenterY, aQSizeX, aQSizeY); |
218 | SetWindow (theTitle, aQCenterX, aQCenterY, aQSizeX, aQSizeY, |
219 | theQuality, theBackColor, theParent); |
220 | } |
221 | |
222 | void Xw_Window::Init() |
223 | { |
224 | MyBackgroundIndex = 0 ; |
225 | |
226 | MyXWindow = 0 ; |
227 | MyXParentWindow = 0 ; |
228 | MyXPixmap = 0 ; |
229 | MyDepth = 0 ; |
230 | MyExtendedDisplay = NULL ; |
231 | MyExtendedWindow = NULL ; |
232 | MyExtendedColorMap = NULL ; |
233 | MyExtendedTypeMap = NULL ; |
234 | MyExtendedWidthMap = NULL ; |
235 | MyExtendedFontMap = NULL ; |
236 | MyExtendedMarkMap = NULL ; |
237 | |
238 | MyQuality = Xw_WQ_3DQUALITY; |
239 | MyVisualClass = Xw_TOV_STATICGRAY; |
240 | } |
241 | |
242 | //======================================================================= |
243 | //function : SetWindow |
244 | //purpose : |
245 | //======================================================================= |
246 | |
247 | void Xw_Window::SetWindow (const Aspect_Handle aWindow, |
248 | const Xw_WindowQuality Quality, |
249 | const Quantity_NameOfColor BackColor) |
250 | { |
251 | if( (Quality == Xw_WQ_TRANSPARENT) || (Quality == Xw_WQ_OVERLAY) ) { |
252 | SetWindow ("",0.5,0.5,1.0,1.0,Quality,BackColor,aWindow); |
253 | } else { |
254 | Aspect_Handle window,root,colormap,pixmap ; |
255 | Xw_TypeOfVisual visualclass ; |
256 | int visualdepth,visualid ; |
257 | const Handle(Xw_GraphicDevice)& Device = |
258 | Handle(Xw_GraphicDevice)::DownCast(MyGraphicDevice); |
259 | |
260 | MyExtendedDisplay = Device->ExtendedDisplay() ; |
261 | |
262 | MyBackgroundIndex = 0 ; |
263 | MyXWindow = aWindow ; |
264 | MyXParentWindow = aWindow ; |
265 | MyQuality = Quality ; |
266 | |
267 | if( !MyXWindow ) { |
268 | PrintError() ; |
269 | } |
270 | |
271 | MyExtendedWindow = |
272 | Xw_def_window (MyExtendedDisplay,MyXWindow,Standard_False); |
273 | |
274 | status = Xw_get_window_info(MyExtendedWindow,&window,&pixmap, |
275 | &root,&colormap,&visualclass, |
276 | &visualdepth,&visualid); |
277 | if( !status ) { |
278 | PrintError() ; |
279 | } |
280 | |
281 | Standard_Boolean Res1 = |
282 | (Device->ExtendedColorMap3D() == Device->ExtendedColorMap2D()); |
283 | Standard_Boolean Res2 = |
284 | (Quality == Xw_WQ_SAMEQUALITY); |
285 | Standard_Boolean Res3 = |
286 | (Quality == Xw_WQ_DRAWINGQUALITY && visualclass == Xw_TOV_PSEUDOCOLOR); |
287 | Standard_Boolean Res4 = |
288 | (Quality == Xw_WQ_3DQUALITY && visualclass == Xw_TOV_TRUECOLOR); |
289 | |
290 | //if (Quality == Xw_WQ_3DQUALITY && visualclass == Xw_TOV_PSEUDOCOLOR) { |
291 | //Res4 = Standard_True; |
292 | //visualclass = Xw_TOV_TRUECOLOR; |
293 | //} |
294 | |
295 | if (Res1 || Res2 || Res3 || Res4) { |
296 | |
297 | MyVisualClass = visualclass ; |
298 | MyXPixmap = pixmap ; |
299 | MyDepth = visualdepth ; |
300 | |
301 | if( MyVisualClass == Xw_TOV_TRUECOLOR ) { |
302 | MyColorMap = Device->ColorMap3D() ; |
303 | } else { |
304 | MyColorMap = Device->ColorMap2D() ; |
305 | } |
306 | |
307 | if( visualid == MyColorMap->OverlayVisualID() ) { |
308 | MyExtendedColorMap = MyColorMap->ExtendedOverlayColorMap(); |
309 | } else { |
310 | MyExtendedColorMap = MyColorMap->ExtendedColorMap(); |
311 | } |
312 | |
313 | MyTypeMap = Device->TypeMap() ; |
314 | MyExtendedTypeMap = Device->ExtendedTypeMap(); |
315 | MyWidthMap = Device->WidthMap() ; |
316 | MyExtendedWidthMap = Device->ExtendedWidthMap(); |
317 | MyFontMap = Device->FontMap() ; |
318 | MyExtendedFontMap = Device->ExtendedFontMap(); |
319 | MyMarkMap = Device->MarkMap() ; |
320 | MyExtendedMarkMap = Device->ExtendedMarkMap(); |
321 | |
322 | status = Xw_set_colormap(MyExtendedWindow,MyExtendedColorMap) ; |
323 | |
324 | if( !status ) { |
325 | PrintError() ; |
326 | } |
327 | |
328 | status = Xw_set_typemap(MyExtendedWindow,MyExtendedTypeMap) ; |
329 | |
330 | if( !status ) { |
331 | PrintError() ; |
332 | } |
333 | |
334 | status = Xw_set_widthmap(MyExtendedWindow,MyExtendedWidthMap) ; |
335 | |
336 | if( !status ) { |
337 | PrintError() ; |
338 | } |
339 | |
340 | status = Xw_set_fontmap(MyExtendedWindow,MyExtendedFontMap) ; |
341 | |
342 | if( !status ) { |
343 | PrintError() ; |
344 | } |
345 | |
346 | status = Xw_set_markmap(MyExtendedWindow,MyExtendedMarkMap) ; |
347 | |
348 | if( !status ) { |
349 | PrintError() ; |
350 | } |
351 | SetBackground(BackColor) ; |
352 | |
353 | } else { // Create a child of this Window in the right Visual |
354 | XW_WINDOWSTATE state = XW_WS_UNKNOWN ; |
355 | int pxc, pyc; |
356 | int width, height; |
357 | float ratio; |
358 | Quantity_Parameter Width = 1.0; |
359 | Quantity_Parameter Height= 1.0; |
360 | |
361 | state = Xw_get_window_position (MyExtendedWindow, |
362 | &pxc,&pyc,&width,&height); |
363 | if( state == XW_WS_UNKNOWN ) { |
364 | Xw_print_error() ; |
365 | } |
366 | ratio = float (width)/ float (height); |
367 | if (ratio > 1.) |
368 | Width = Width*ratio; |
369 | else |
370 | Height = Height/ratio; |
371 | SetWindow ("",0.5,0.5,Width,Height,Quality,BackColor,MyXWindow); |
372 | } |
373 | } |
374 | } |
375 | |
376 | //======================================================================= |
377 | //function : SetWindow |
378 | //purpose : |
379 | //======================================================================= |
380 | |
381 | void Xw_Window::SetWindow (const Standard_CString Title, |
382 | const Quantity_Parameter Xc, |
383 | const Quantity_Parameter Yc, |
384 | const Quantity_Parameter Width, |
385 | const Quantity_Parameter Height, |
386 | const Xw_WindowQuality Quality, |
387 | const Quantity_NameOfColor BackColor, |
388 | const Aspect_Handle Parent) |
389 | { |
390 | Aspect_Handle window,root,colormap,pixmap,*display ; |
391 | Xw_TypeOfVisual visualclass ; |
392 | Standard_Integer visualdepth,visualid,istransparent = Standard_False ; |
393 | |
394 | const Handle(Xw_GraphicDevice)& Device = |
395 | Handle(Xw_GraphicDevice)::DownCast(MyGraphicDevice); |
396 | |
397 | MyBackgroundIndex = 0 ; |
398 | MyExtendedDisplay = Device->ExtendedDisplay() ; |
399 | MyXParentWindow = Parent ; |
400 | MyXWindow = 0 ; |
401 | MyQuality = Quality ; |
402 | |
403 | switch (Quality) { |
404 | case Xw_WQ_3DQUALITY : |
405 | case Xw_WQ_PICTUREQUALITY : |
406 | MyColorMap = Device->ColorMap3D() ; |
407 | MyVisualClass = Device->VisualClass3D() ; |
408 | MyExtendedColorMap = Device->ExtendedColorMap3D(); |
409 | break ; |
410 | case Xw_WQ_DRAWINGQUALITY : |
411 | MyColorMap = Device->ColorMap2D() ; |
412 | MyVisualClass = Device->VisualClass2D() ; |
413 | MyExtendedColorMap = Device->ExtendedColorMap2D(); |
414 | break ; |
415 | case Xw_WQ_SAMEQUALITY : |
416 | if( !MyXParentWindow ) { |
417 | status = Xw_get_display_info (MyExtendedDisplay, |
418 | &display,&root,&colormap,&visualclass, |
419 | &visualdepth) ; |
420 | } else { |
421 | MyExtendedWindow = Xw_def_window(MyExtendedDisplay, |
422 | MyXParentWindow,Standard_False); |
423 | |
424 | status = Xw_get_window_info(MyExtendedWindow,&window, |
425 | &pixmap,&root,&colormap,&visualclass,&visualdepth, |
426 | &visualid) ; |
427 | Xw_close_window(MyExtendedWindow,Standard_False) ; |
428 | MyExtendedWindow = NULL; |
429 | } |
430 | |
431 | if( !status ) { |
432 | PrintError() ; |
433 | } |
434 | if( visualclass == Xw_TOV_TRUECOLOR ) { |
435 | MyColorMap = Device->ColorMap3D() ; |
436 | MyVisualClass = Device->VisualClass3D() ; |
437 | MyExtendedColorMap = Device->ExtendedColorMap3D(); |
438 | } else if( visualclass == Xw_TOV_PSEUDOCOLOR ) { |
439 | MyColorMap = Device->ColorMap2D() ; |
440 | MyVisualClass = Device->VisualClass2D() ; |
441 | MyExtendedColorMap = Device->ExtendedColorMap2D(); |
442 | } |
443 | break ; |
444 | case Xw_WQ_TRANSPARENT : |
445 | istransparent = Standard_True ; |
446 | case Xw_WQ_OVERLAY : |
447 | if( !MyXParentWindow ) { |
448 | status = Xw_get_display_info (MyExtendedDisplay, |
449 | &display,&root,&colormap,&visualclass, |
450 | &visualdepth) ; |
451 | } else { |
452 | MyExtendedWindow = Xw_def_window(MyExtendedDisplay, |
453 | MyXParentWindow,istransparent); |
454 | |
455 | status = Xw_get_window_info(MyExtendedWindow,&window, |
456 | &pixmap,&root,&colormap,&visualclass,&visualdepth, |
457 | &visualid) ; |
458 | Xw_close_window(MyExtendedWindow,Standard_False) ; |
459 | MyExtendedWindow = NULL; |
460 | } |
461 | |
462 | if( !status ) { |
463 | PrintError() ; |
464 | } |
465 | if( visualclass == Xw_TOV_TRUECOLOR ) { |
466 | MyColorMap = Device->ColorMap3D() ; |
467 | MyExtendedColorMap = Device->ExtendedOverlayColorMap3D(); |
468 | MyVisualClass = Xw_TOV_OVERLAY; |
469 | if( !MyExtendedColorMap ) { |
470 | MyVisualClass = Device->VisualClass3D() ; |
471 | MyExtendedColorMap = Device->ExtendedColorMap3D(); |
472 | } |
473 | } else if( visualclass == Xw_TOV_PSEUDOCOLOR ) { |
474 | MyColorMap = Device->ColorMap2D() ; |
475 | MyExtendedColorMap = Device->ExtendedOverlayColorMap2D(); |
476 | MyVisualClass = Xw_TOV_OVERLAY; |
477 | if( !MyExtendedColorMap ) { |
478 | MyVisualClass = Device->VisualClass2D() ; |
479 | MyExtendedColorMap = Device->ExtendedColorMap2D(); |
480 | } |
481 | } |
482 | break ; |
483 | } |
484 | |
485 | if( MyVisualClass != Xw_TOV_DEFAULT ) { |
486 | MyTypeMap = Device->TypeMap() ; |
487 | MyExtendedTypeMap = Device->ExtendedTypeMap(); |
488 | MyWidthMap = Device->WidthMap() ; |
489 | MyExtendedWidthMap = Device->ExtendedWidthMap(); |
490 | MyFontMap = Device->FontMap() ; |
491 | MyExtendedFontMap = Device->ExtendedFontMap(); |
492 | MyMarkMap = Device->MarkMap() ; |
493 | MyExtendedMarkMap = Device->ExtendedMarkMap(); |
494 | |
495 | MyXWindow = Xw_open_window(MyExtendedDisplay,MyVisualClass,MyXParentWindow, |
496 | (float)Xc,(float)Yc,(float)Width,(float)Height, |
497 | (Standard_PCharacter)Title,istransparent) ; |
498 | if( !MyXWindow ) { |
499 | PrintError() ; |
500 | } |
501 | |
502 | MyExtendedWindow = |
503 | Xw_def_window (MyExtendedDisplay,MyXWindow,istransparent); |
504 | |
505 | status = Xw_get_window_info(MyExtendedWindow,&window,&pixmap, |
506 | &root,&colormap,&visualclass,&visualdepth, |
507 | &visualid) ; |
508 | if( !status ) { |
509 | PrintError() ; |
510 | } |
511 | |
512 | MyXPixmap = pixmap ; |
513 | MyDepth = visualdepth ; |
514 | |
515 | status = Xw_set_colormap(MyExtendedWindow,MyExtendedColorMap) ; |
516 | |
517 | if( !status ) { |
518 | PrintError() ; |
519 | } |
520 | |
521 | status = Xw_set_typemap(MyExtendedWindow,MyExtendedTypeMap) ; |
522 | |
523 | if( !status ) { |
524 | PrintError() ; |
525 | } |
526 | |
527 | status = Xw_set_widthmap(MyExtendedWindow,MyExtendedWidthMap) ; |
528 | |
529 | if( !status ) { |
530 | PrintError() ; |
531 | } |
532 | |
533 | status = Xw_set_fontmap(MyExtendedWindow,MyExtendedFontMap) ; |
534 | |
535 | if( !status ) { |
536 | PrintError() ; |
537 | } |
538 | |
539 | status = Xw_set_markmap(MyExtendedWindow,MyExtendedMarkMap) ; |
540 | |
541 | if( !status ) { |
542 | PrintError() ; |
543 | } |
544 | |
545 | SetBackground(BackColor) ; |
546 | |
547 | if( MyXParentWindow && (MyXWindow != MyXParentWindow) ) Map() ; |
548 | } |
549 | } |
550 | |
551 | void Xw_Window::SetBackground (const Aspect_Background& Background) { |
552 | Quantity_Color Color = Background.Color() ; |
553 | |
554 | SetBackground(Color.Name()); |
555 | |
556 | } |
557 | |
558 | void Xw_Window::SetBackground (const Quantity_NameOfColor BackColor) { |
559 | Quantity_Color Color ; |
560 | Standard_Real r,g,b ; |
561 | Standard_Integer index; |
562 | |
563 | Standard_Integer bcolor = Standard_Integer(BackColor); |
564 | if( (MyQuality != Xw_WQ_TRANSPARENT) && (bcolor >= 0) ) { |
565 | MyBackground.SetColor(BackColor) ; |
566 | |
567 | Color = MyBackground.Color() ; |
568 | Color.Values(r,g,b,Quantity_TOC_RGB) ; |
569 | |
570 | status = Xw_get_color_index(MyExtendedColorMap, |
571 | (float)r,(float)g,(float)b,&index); |
572 | |
573 | if( status ) { |
574 | MyBackgroundIndex = index; |
575 | status = Xw_close_background_pixmap(MyExtendedWindow); |
576 | status = Xw_set_background_index (MyExtendedWindow,index) ; |
577 | } |
578 | |
579 | if( !status ) { |
580 | PrintError() ; |
581 | } |
582 | } |
583 | } |
584 | |
585 | void Xw_Window::SetBackground(const Quantity_Color& color ) |
586 | { |
587 | Standard_Real r,g,b; |
588 | Standard_Integer index; |
589 | |
590 | Standard_Integer bcolor = Standard_Integer( color.Name() ); |
591 | |
592 | if( ( MyQuality != Xw_WQ_TRANSPARENT ) && ( bcolor >= 0 ) ) { |
593 | |
594 | MyBackground.SetColor( color ) ; |
595 | color.Values( r, g, b, Quantity_TOC_RGB ); |
596 | |
597 | status = Xw_get_color_index( MyExtendedColorMap, |
598 | (float)r, (float)g, (float)b, &index); |
599 | |
600 | if( status ) { |
601 | MyBackgroundIndex = index; |
602 | status = Xw_close_background_pixmap( MyExtendedWindow ); |
603 | status = Xw_set_background_index( MyExtendedWindow, index ); |
604 | } |
605 | |
606 | if( !status ) { |
607 | PrintError() ; |
608 | } |
609 | } |
610 | } |
611 | |
612 | //======================================================================= |
613 | //function : SetBackground |
614 | //purpose : |
615 | //======================================================================= |
616 | |
617 | void Xw_Window::SetBackground (const Aspect_Handle aPixmap) |
618 | { |
619 | status = Xw_set_background_pixmap( MyExtendedWindow, aPixmap); |
620 | if ( status ) { |
621 | MyHBackground = aPixmap; |
622 | MyBackgroundImage.Clear(); |
623 | MyBackgroundFillMethod = Aspect_FM_NONE; |
624 | } else { |
625 | PrintError(); |
626 | } |
627 | } |
628 | |
629 | Standard_Boolean Xw_Window::SetBackground( const Standard_CString aName, |
630 | const Aspect_FillMethod aMethod ) { |
631 | |
632 | if( !aName ) return Standard_False; |
633 | |
634 | status = XW_ERROR; |
635 | Standard_Integer hash_code = ::HashCode( aName ); |
636 | XW_EXT_IMAGEDATA* pimage = (XW_EXT_IMAGEDATA* )Xw_get_image_handle (MyExtendedWindow, (void* )hash_code); |
637 | |
638 | if ( !pimage ) |
639 | pimage = (XW_EXT_IMAGEDATA* )Xw_load_image(MyExtendedWindow,(void*)hash_code,(Standard_PCharacter)aName ); |
640 | |
641 | if ( pimage ) |
642 | status = Xw_put_background_image( MyExtendedWindow, pimage, aMethod ); |
643 | |
644 | if ( status ) { |
645 | MyBackgroundImage = aName; |
646 | MyBackgroundFillMethod = aMethod; |
647 | Xw_get_background_pixmap( MyExtendedWindow, MyHBackground); |
648 | } else { |
649 | PrintError(); |
650 | } |
651 | |
652 | return status; |
653 | |
654 | } // end Xw_Window::SetBackground |
655 | |
656 | void Xw_Window::SetBackground (const Aspect_GradientBackground& GrBackground) { |
657 | |
658 | Quantity_Color Color1, Color2; |
659 | GrBackground.Colors(Color1,Color2); |
660 | SetBackground(Color1,Color2, GrBackground.BgGradientFillMethod()); |
661 | |
662 | } |
663 | |
664 | void Xw_Window::SetBackground( const Quantity_Color& color1, |
665 | const Quantity_Color& color2, |
666 | const Aspect_GradientFillMethod aMethod) { |
667 | |
668 | Standard_Integer bcolor = Standard_Integer( color1.Name() ) + Standard_Integer( color2.Name() ); |
669 | if( ( MyQuality != Xw_WQ_TRANSPARENT ) && ( bcolor >= 0 ) ) |
670 | MyGradientBackground.SetColors( color1, color2, aMethod ) ; |
671 | |
672 | } |
673 | |
674 | void Xw_Window::SetDoubleBuffer (const Standard_Boolean DBmode) { |
675 | |
676 | status = Xw_set_double_buffer(MyExtendedWindow, |
677 | (XW_DOUBLEBUFFERMODE)DBmode) ; |
678 | |
679 | if( !status ) { |
680 | PrintError() ; |
681 | } |
682 | } |
683 | |
684 | void Xw_Window::Flush() const { |
685 | |
686 | status = Xw_flush (MyExtendedWindow,Standard_False); |
687 | |
688 | if( !status ) { |
689 | PrintError() ; |
690 | } |
691 | } |
692 | |
693 | void Xw_Window::Map () const { |
694 | #ifdef RIC120302 |
695 | if( MyXWindow == MyXParentWindow ) return; |
696 | #endif |
697 | if (IsVirtual()) return; |
698 | status = Xw_set_window_state (MyExtendedWindow, XW_MAP); |
699 | if( !status ) { |
700 | PrintError() ; |
701 | } |
702 | } |
703 | |
704 | void Xw_Window::Unmap () const { |
705 | #ifdef RIC120302 |
706 | if( MyXWindow == MyXParentWindow ) return; |
707 | #endif |
708 | status = Xw_set_window_state (MyExtendedWindow, XW_ICONIFY); |
709 | if( !status ) { |
710 | PrintError() ; |
711 | } |
712 | } |
713 | |
714 | Aspect_TypeOfResize Xw_Window::DoResize () const { |
715 | XW_RESIZETYPE state ; |
716 | |
717 | state = Xw_resize_window (MyExtendedWindow); |
718 | // if( state == Aspect_TOR_UNKNOWN ) { |
719 | if( state == XW_TOR_UNKNOWN ) { |
720 | PrintError() ; |
721 | } |
722 | |
723 | return (Aspect_TypeOfResize(state)) ; |
724 | } |
725 | |
726 | Standard_Boolean Xw_Window::DoMapping () const { |
727 | int pxc,pyc,width,height; |
728 | XW_WINDOWSTATE state; |
729 | |
730 | state = Xw_get_window_position (MyExtendedWindow,&pxc,&pyc,&width,&height); |
731 | |
732 | return IsMapped(); |
733 | } |
734 | |
735 | void Xw_Window::Destroy () { |
736 | Standard_Boolean destroy = |
737 | ( MyXWindow == MyXParentWindow ) ? Standard_False : Standard_True; |
738 | |
739 | status = Xw_close_window (MyExtendedWindow,destroy); |
740 | if( !status ) { |
741 | PrintError() ; |
742 | } |
743 | |
744 | MyXWindow = 0 ; |
745 | MyExtendedWindow = NULL ; |
746 | MyExtendedColorMap = NULL ; |
747 | MyExtendedTypeMap = NULL ; |
748 | MyExtendedWidthMap = NULL ; |
749 | MyExtendedFontMap = NULL ; |
750 | MyExtendedMarkMap = NULL ; |
751 | } |
752 | |
753 | void Xw_Window::Clear () const { |
754 | |
755 | status = Xw_erase_window (MyExtendedWindow); |
756 | |
757 | if( !status ) { |
758 | PrintError() ; |
759 | } |
760 | } |
761 | |
762 | void Xw_Window::ClearArea (const Standard_Integer Xc, const Standard_Integer Yc, const Standard_Integer Width, const Standard_Integer Height) const { |
763 | |
764 | status = Xw_erase_area (MyExtendedWindow,int(Xc),int(Yc), |
765 | int(Width),int(Height)); |
766 | |
767 | if( !status ) { |
768 | PrintError() ; |
769 | } |
770 | } |
771 | |
772 | void Xw_Window::Restore () const { |
773 | |
774 | if( !IsMapped() ) return; |
775 | status = Xw_restore_window (MyExtendedWindow); |
776 | |
777 | if( !status ) { |
778 | PrintError() ; |
779 | } |
780 | } |
781 | |
782 | void Xw_Window::RestoreArea (const Standard_Integer Xc, const Standard_Integer Yc, const Standard_Integer Width, const Standard_Integer Height) const { |
783 | |
784 | if( !IsMapped() ) return; |
785 | status = Xw_restore_area (MyExtendedWindow,int(Xc),int(Yc), |
786 | int(Width),int(Height)); |
787 | |
788 | if( !status ) { |
789 | PrintError() ; |
790 | } |
791 | } |
792 | |
793 | Standard_Boolean Xw_Window::Dump (const Standard_CString theFilename, |
794 | const Standard_Real theGammaValue) const |
795 | { |
796 | int aDummy, aWidth, aHeight; |
797 | XW_WINDOWSTATE state = Xw_get_window_position (MyExtendedWindow, |
798 | &aDummy, &aDummy, &aWidth, &aHeight); |
799 | if (state == XW_WS_UNKNOWN) |
800 | { |
801 | return Standard_False; |
802 | } |
803 | |
804 | return DumpArea (theFilename, aWidth / 2, aHeight / 2, |
805 | aWidth, aHeight, theGammaValue); |
806 | } |
807 | |
808 | Standard_Boolean Xw_Window::DumpArea (const Standard_CString theFilename, |
809 | const Standard_Integer theXc, const Standard_Integer theYc, |
810 | const Standard_Integer theWidth, const Standard_Integer theHeight, |
811 | const Standard_Real theGammaValue) const |
812 | { |
813 | int aWidth = Abs(theWidth); |
814 | int aHeight = Abs(theHeight); |
815 | XW_EXT_IMAGEDATA* pimage = NULL; |
816 | if (DoubleBuffer()) |
817 | { |
818 | Aspect_Handle window, root, colormap, pixmap; |
819 | Xw_TypeOfVisual visualclass; |
820 | int visualdepth, visualid; |
821 | Xw_get_window_info (MyExtendedWindow, &window, &pixmap, |
822 | &root, &colormap, &visualclass, |
823 | &visualdepth, &visualid); |
824 | |
825 | pimage = (XW_EXT_IMAGEDATA* )Xw_get_image_from_pixmap (MyExtendedWindow, (Standard_PCharacter )theFilename, |
826 | pixmap, |
827 | theXc, theYc, aWidth, aHeight); |
828 | } |
829 | else |
830 | { |
831 | pimage = (XW_EXT_IMAGEDATA* )Xw_get_image (MyExtendedWindow, (Standard_PCharacter )theFilename, |
832 | theXc, theYc, aWidth, aHeight); |
833 | } |
834 | |
835 | if (pimage == NULL) |
836 | { |
837 | return Standard_False; |
838 | } |
839 | |
840 | if (theGammaValue != 1.0) |
841 | { |
842 | Xw_gamma_image (pimage, Standard_ShortReal (theGammaValue)); |
843 | } |
844 | XW_STATUS aStatus = Xw_save_image (MyExtendedWindow, pimage, (Standard_PCharacter )theFilename); |
845 | Xw_close_image (pimage); |
846 | |
847 | return Standard_Boolean(aStatus); |
848 | } |
849 | |
850 | Handle(Aspect_PixMap) Xw_Window::ToPixMap() const |
851 | { |
852 | Handle(Image_PixMap) anImagePixMap; |
853 | int aDummy, aWidth, aHeight; |
854 | XW_WINDOWSTATE state = Xw_get_window_position (MyExtendedWindow, |
855 | &aDummy, &aDummy, &aWidth, &aHeight); |
856 | if (state == XW_WS_UNKNOWN) |
857 | { |
858 | return anImagePixMap; |
859 | } |
860 | |
861 | XW_EXT_IMAGEDATA* pimage = NULL; |
862 | if (DoubleBuffer()) |
863 | { |
864 | Aspect_Handle window, root, colormap, pixmap; |
865 | Xw_TypeOfVisual visualclass; |
866 | int visualdepth, visualid; |
867 | Xw_get_window_info (MyExtendedWindow, &window, &pixmap, |
868 | &root, &colormap, &visualclass, |
869 | &visualdepth, &visualid); |
870 | |
871 | pimage = (XW_EXT_IMAGEDATA* )Xw_get_image_from_pixmap (MyExtendedWindow, NULL, |
872 | pixmap, |
873 | aWidth / 2, aHeight / 2, aWidth, aHeight); |
874 | } |
875 | else |
876 | { |
877 | pimage = (XW_EXT_IMAGEDATA* )Xw_get_image (MyExtendedWindow, NULL, |
878 | aWidth / 2, aHeight / 2, aWidth, aHeight); |
879 | } |
880 | |
881 | if (pimage == NULL) |
882 | { |
883 | return anImagePixMap; |
884 | } |
885 | |
886 | XImage* pximage = (pimage->zximage) ? pimage->zximage : pimage->pximage; |
887 | XW_EXT_WINDOW* pwindow = (XW_EXT_WINDOW* )MyExtendedWindow; |
888 | if (pwindow->pcolormap->visual->c_class == TrueColor) |
889 | { |
890 | Standard_Byte* aDataPtr = (Standard_Byte* )pximage->data; |
891 | anImagePixMap = new Image_PixMap (aDataPtr, |
892 | pximage->width, pximage->height, |
893 | pximage->bytes_per_line, |
894 | pximage->bits_per_pixel, |
895 | Standard_True); |
896 | } |
897 | Xw_close_image (pimage); |
898 | return anImagePixMap; |
899 | } |
900 | |
901 | Standard_Boolean Xw_Window::Load (const Standard_CString aFilename) const { |
902 | Standard_Integer hashcode = ::HashCode(aFilename) ; |
903 | XW_WINDOWSTATE state; |
904 | int pxc,pyc,wwidth,wheight,iwidth,iheight,idepth,resize = Standard_False; |
905 | float izoom; |
906 | |
907 | state = Xw_get_window_position (MyExtendedWindow,&pxc,&pyc,&wwidth,&wheight); |
908 | |
909 | status = XW_ERROR; |
910 | XW_EXT_IMAGEDATA* pimage = (XW_EXT_IMAGEDATA* )Xw_get_image_handle( MyExtendedWindow,(void*)hashcode ) ; |
911 | if( !pimage ) { |
912 | pimage = (XW_EXT_IMAGEDATA* )Xw_load_image(MyExtendedWindow,(void*)hashcode,(Standard_PCharacter)aFilename ); |
913 | } |
914 | |
915 | if( pimage ) { |
916 | status = Xw_get_image_info(pimage,&izoom,&iwidth,&iheight,&idepth); |
917 | iwidth = (int)(iwidth/izoom); |
918 | iheight = (int)(iheight/izoom); |
919 | } |
920 | |
921 | if( status && state != XW_WS_UNKNOWN ) { |
922 | float uxc,uyc ; |
923 | if( iwidth > wwidth ) { |
924 | resize = Standard_True; |
925 | wwidth = iwidth; |
926 | } |
927 | if( iheight > wheight ) { |
928 | resize = Standard_True; |
929 | wheight = iheight; |
930 | } |
931 | if( resize ) { |
932 | status = Xw_set_window_position (MyExtendedWindow, |
933 | pxc,pyc,wwidth,wheight); |
934 | } |
935 | status = Xw_get_window_pixelcoord(MyExtendedWindow, |
936 | wwidth/2,wheight/2,&uxc,&uyc); |
937 | status = Xw_draw_image(MyExtendedWindow, pimage, uxc, uyc); |
938 | Xw_flush(MyExtendedWindow, Standard_True); |
939 | } else status = XW_ERROR ; |
940 | |
941 | if( !status ) { |
942 | PrintError() ; |
943 | } |
944 | |
945 | return Standard_Boolean(status); |
946 | } |
947 | |
948 | Standard_Boolean Xw_Window::LoadArea (const Standard_CString aFilename, const Standard_Integer Xc, const Standard_Integer Yc, const Standard_Integer Width, const Standard_Integer Height) const { |
949 | Standard_Integer hashcode = ::HashCode(aFilename) ; |
950 | int pxc,pyc,wwidth,wheight,iwidth,iheight,idepth; |
951 | float izoom,uxc,uyc; |
952 | |
953 | XW_WINDOWSTATE state = Xw_get_window_position (MyExtendedWindow,&pxc,&pyc,&wwidth,&wheight); |
954 | status = XW_ERROR; |
955 | XW_EXT_IMAGEDATA* pimage = (XW_EXT_IMAGEDATA* )Xw_get_image_handle( MyExtendedWindow,(void*)hashcode ) ; |
956 | if( !pimage ) { |
957 | pimage = (XW_EXT_IMAGEDATA* )Xw_load_image(MyExtendedWindow,(void*)hashcode,(Standard_PCharacter)aFilename ); |
958 | } |
959 | |
960 | if( pimage ) { |
961 | status = Xw_get_image_info(pimage,&izoom,&iwidth,&iheight,&idepth); |
962 | iwidth = (int)(iwidth/izoom); |
963 | iheight = (int)(iheight/izoom); |
964 | } |
965 | |
966 | if( status && state != XW_WS_UNKNOWN ) { |
967 | if( iwidth > Width || iheight > Height ) { |
968 | izoom = (float)Min(Width,Height)/(float)Max(iwidth,iheight) ; |
969 | status = Xw_zoom_image(pimage,izoom) ; |
970 | } |
971 | status = Xw_get_window_pixelcoord(MyExtendedWindow,Xc,Yc,&uxc,&uyc); |
972 | status = Xw_draw_image(MyExtendedWindow, pimage, uxc, uyc); |
973 | Xw_flush(MyExtendedWindow, Standard_True); |
974 | } else status = XW_ERROR ; |
975 | |
976 | if( !status ) { |
977 | PrintError() ; |
978 | } |
979 | |
980 | return Standard_Boolean(status); |
981 | } |
982 | |
983 | void Xw_Window::SetCursor (const Standard_Integer anId, const Quantity_NameOfColor aColor) const { |
984 | Quantity_Color Color(aColor) ; |
985 | Standard_Real r,g,b ; |
986 | |
987 | Color.Values(r,g,b,Quantity_TOC_RGB) ; |
988 | |
989 | status = Xw_set_hard_cursor (MyExtendedWindow,(int)anId,0, |
990 | (float)r, |
991 | (float)g, |
992 | (float)b) ; |
993 | |
994 | if( !status ) { |
995 | PrintError() ; |
996 | } |
997 | } |
998 | |
999 | Standard_Boolean Xw_Window::BackingStore () const { |
1000 | |
1001 | if( MyXPixmap ) status = XW_SUCCESS ; |
1002 | else { |
1003 | status = Xw_open_pixmap(MyExtendedWindow) ; |
1004 | } |
1005 | |
1006 | return (Standard_Boolean(status)) ; |
1007 | } |
1008 | |
1009 | Standard_Boolean Xw_Window::DoubleBuffer () const { |
1010 | XW_DOUBLEBUFFERMODE state = Xw_get_double_buffer(MyExtendedWindow) ; |
1011 | |
1012 | return (state == XW_ENABLE ? Standard_True : Standard_False) ; |
1013 | } |
1014 | |
1015 | Standard_Boolean Xw_Window::IsMapped () const { |
1016 | if (IsVirtual()) { |
1017 | return Standard_True; |
1018 | } |
1019 | XW_WINDOWSTATE state; |
1020 | state = Xw_get_window_state (MyExtendedWindow); |
1021 | switch (state) { |
1022 | case XW_WS_UNKNOWN: |
1023 | return Standard_False; |
1024 | case XW_ICONIFY: |
1025 | return Standard_False; |
1026 | case XW_PUSH: |
1027 | return Standard_True; |
1028 | case XW_MAP: |
1029 | return Standard_True; |
1030 | #ifndef DEB |
1031 | default: |
1032 | return Standard_False; |
1033 | #endif |
1034 | } |
1035 | return Standard_False; |
1036 | } |
1037 | |
1038 | Standard_Real Xw_Window::Ratio () const { |
1039 | int width, height; |
1040 | |
1041 | status = Xw_get_window_size (MyExtendedWindow,&width,&height); |
1042 | if( !status ) { |
1043 | Xw_print_error() ; |
1044 | } |
1045 | |
1046 | return ((Standard_Real)width/height) ; |
1047 | } |
1048 | |
1049 | void Xw_Window::Size (Standard_Real &Width, Standard_Real &Height) const { |
1050 | int width, height; |
1051 | |
1052 | status = Xw_get_window_size (MyExtendedWindow,&width,&height); |
1053 | if( !status ) { |
1054 | Xw_print_error() ; |
1055 | } |
1056 | |
1057 | Width = Xw_get_screen_pixelvalue (MyExtendedDisplay,width) ; |
1058 | Height = Xw_get_screen_pixelvalue (MyExtendedDisplay,height) ; |
1059 | } |
1060 | |
1061 | void Xw_Window::Size (Standard_Integer &Width, Standard_Integer &Height) const { |
1062 | int width, height; |
1063 | status = Xw_get_window_size (MyExtendedWindow,&width,&height); |
1064 | if( !status ) { |
1065 | Xw_print_error() ; |
1066 | } |
1067 | |
1068 | Width = width ; |
1069 | Height = height ; |
1070 | } |
1071 | |
1072 | void Xw_Window::MMSize (Standard_Real &Width, Standard_Real &Height) const { |
1073 | int width, height; |
1074 | |
1075 | status = Xw_get_window_size (MyExtendedWindow,&width,&height); |
1076 | if( !status ) { |
1077 | Xw_print_error() ; |
1078 | } |
1079 | |
1080 | float x,y ; |
1081 | status = Xw_get_window_pixelcoord(MyExtendedWindow, |
1082 | width,0,&x,&y) ; |
1083 | if( !status ) { |
1084 | PrintError() ; |
1085 | } |
1086 | |
1087 | Width = Standard_Real(x); Height = Standard_Real(y); |
1088 | } |
1089 | |
1090 | void Xw_Window::Position (Standard_Real &X1, Standard_Real &Y1, Standard_Real &X2, Standard_Real &Y2) const { |
1091 | XW_WINDOWSTATE state = XW_WS_UNKNOWN ; |
1092 | int pxc, pyc; |
1093 | int width, height; |
1094 | float x1,y1,x2,y2 ; |
1095 | |
1096 | state = Xw_get_window_position (MyExtendedWindow, |
1097 | &pxc,&pyc,&width,&height); |
1098 | if( state == XW_WS_UNKNOWN ) { |
1099 | Xw_print_error() ; |
1100 | } |
1101 | Xw_get_screen_pixelcoord (MyExtendedDisplay,pxc-width/2, |
1102 | pyc-height/2, |
1103 | &x1,&y1) ; |
1104 | Xw_get_screen_pixelcoord (MyExtendedDisplay,pxc+width/2, |
1105 | pyc+height/2, |
1106 | &x2,&y2) ; |
1107 | X1 = x1 ; Y1 = y2 ; X2 = x2 ; Y2 = y1 ; |
1108 | } |
1109 | |
1110 | void Xw_Window::Position (Standard_Integer &X1, Standard_Integer &Y1, Standard_Integer &X2, Standard_Integer &Y2) const { |
1111 | XW_WINDOWSTATE state = XW_WS_UNKNOWN ; |
1112 | int pxc, pyc; |
1113 | int width, height; |
1114 | |
1115 | state = Xw_get_window_position (MyExtendedWindow, |
1116 | &pxc,&pyc,&width,&height); |
1117 | if( state == XW_WS_UNKNOWN ) { |
1118 | Xw_print_error() ; |
1119 | } |
1120 | |
1121 | X1 = pxc - width/2 ; Y1 = pyc - height/2 ; |
1122 | X2 = X1 + width - 1 ; Y2 = Y1 + height - 1 ; |
1123 | } |
1124 | |
1125 | Standard_Real Xw_Window::Convert (const Standard_Integer Pv) const { |
1126 | Standard_Real Dv ; |
1127 | |
1128 | Dv = Xw_get_screen_pixelvalue(MyExtendedDisplay,(int)Pv) ; |
1129 | |
1130 | return (Dv) ; |
1131 | } |
1132 | |
1133 | void Xw_Window::Convert (const Standard_Integer Px, const Standard_Integer Py, Standard_Real &Dx, Standard_Real &Dy ) const { |
1134 | float x,y ; |
1135 | |
1136 | status = Xw_get_screen_pixelcoord(MyExtendedDisplay, |
1137 | (int)Px,(int)Py,&x,&y) ; |
1138 | |
1139 | if( !status ) { |
1140 | Xw_print_error() ; |
1141 | } |
1142 | |
1143 | Dx = x ; Dy = y ; |
1144 | } |
1145 | |
1146 | Standard_Integer Xw_Window::Convert (const Standard_Real Dv) const { |
1147 | Standard_Integer Pv ; |
1148 | |
1149 | Pv = Xw_get_pixel_screenvalue(MyExtendedDisplay,(float)Dv) ; |
1150 | |
1151 | return (Pv) ; |
1152 | } |
1153 | |
1154 | void Xw_Window::Convert (const Standard_Real Dx, const Standard_Real Dy, Standard_Integer &Px, Standard_Integer &Py ) const { |
1155 | int x,y ; |
1156 | |
1157 | status = Xw_get_pixel_screencoord(MyExtendedDisplay, |
1158 | (float)Dx,(float)Dy,&x,&y) ; |
1159 | |
1160 | if( !status ) { |
1161 | Xw_print_error() ; |
1162 | } |
1163 | |
1164 | Px = x ; Py = y ; |
1165 | } |
1166 | |
1167 | Handle(Xw_ColorMap) Xw_Window::ColorMap() const { |
1168 | |
1169 | return (MyColorMap) ; |
1170 | } |
1171 | |
1172 | Handle(Xw_TypeMap) Xw_Window::TypeMap() const { |
1173 | |
1174 | return (MyTypeMap) ; |
1175 | } |
1176 | |
1177 | Handle(Xw_WidthMap) Xw_Window::WidthMap() const { |
1178 | |
1179 | return (MyWidthMap) ; |
1180 | } |
1181 | |
1182 | Handle(Xw_FontMap) Xw_Window::FontMap() const { |
1183 | |
1184 | return (MyFontMap) ; |
1185 | } |
1186 | |
1187 | Handle(Xw_MarkMap) Xw_Window::MarkMap() const { |
1188 | |
1189 | return (MyMarkMap) ; |
1190 | } |
1191 | |
1192 | Aspect_Handle Xw_Window::XWindow () const { |
1193 | |
1194 | return (MyXWindow); |
1195 | |
1196 | } |
1197 | |
1198 | void Xw_Window::XWindow (Standard_Integer& aPart1, Standard_Integer& aPart2) const { |
1199 | |
1200 | aPart1 = (Standard_Integer)((MyXWindow >> 16 ) & 0xffff); |
1201 | aPart2 = (Standard_Integer)(MyXWindow & 0xffff); |
1202 | } |
1203 | |
1204 | // RIC120302 |
1205 | Aspect_Handle Xw_Window::XParentWindow () const { |
1206 | |
1207 | return (MyXParentWindow); |
1208 | |
1209 | } |
1210 | |
1211 | void Xw_Window::XParentWindow (Standard_Integer& aPart1, Standard_Integer& aPart2) const { |
1212 | |
1213 | aPart1 = (Standard_Integer)((MyXParentWindow >> 16 ) & 0xffff); |
1214 | aPart2 = (Standard_Integer)(MyXParentWindow & 0xffff); |
1215 | } |
1216 | // RIC120302 |
1217 | |
1218 | Aspect_Handle Xw_Window::XPixmap () const { |
1219 | Aspect_Handle window,pixmap,root,colormap ; |
1220 | Xw_TypeOfVisual visualclass ; |
1221 | int visualdepth,visualid ; |
1222 | |
1223 | status = Xw_get_window_info(MyExtendedWindow,&window,&pixmap, |
1224 | &root,&colormap,&visualclass,&visualdepth,&visualid) ; |
1225 | |
1226 | return (pixmap); |
1227 | } |
1228 | |
1229 | Standard_Address Xw_Window::XVisual( ) const |
1230 | { |
1231 | Aspect_Handle *VisualInfo ; |
1232 | Xw_TypeOfVisual VisualClass ; |
1233 | int MaxColor,BaseColor,MaxUserColor,MaxDefineColor,FirstFreeColorIndex,visualid ; |
1234 | |
1235 | status = Xw_get_colormap_info(MyExtendedColorMap,&VisualInfo, |
1236 | &VisualClass,&visualid,&MaxColor,&BaseColor, |
1237 | &MaxUserColor,&MaxDefineColor,&FirstFreeColorIndex); |
1238 | |
1239 | if( !status ) { |
1240 | PrintError() ; |
1241 | } |
1242 | |
1243 | return (VisualInfo) ; |
1244 | } |
1245 | |
1246 | Aspect_Handle Xw_Window::XColorMap( ) const |
1247 | { |
1248 | Aspect_Handle colormap ; |
1249 | |
1250 | colormap = Xw_get_colormap_xid(MyExtendedColorMap) ; |
1251 | |
1252 | if( !colormap ) { |
1253 | PrintError() ; |
1254 | } |
1255 | |
1256 | return (colormap) ; |
1257 | } |
1258 | |
1259 | Standard_Boolean Xw_Window::PointerPosition (Standard_Integer& X, Standard_Integer& Y) const { |
1260 | Standard_Boolean cstatus ; |
1261 | int x,y ; |
1262 | |
1263 | cstatus = Xw_get_cursor_position(MyExtendedWindow,&x,&y) ; |
1264 | X = x ; |
1265 | Y = y ; |
1266 | |
1267 | return (cstatus); |
1268 | } |
1269 | |
1270 | Xw_TypeOfVisual Xw_Window::VisualClass () const { |
1271 | |
1272 | return (MyVisualClass); |
1273 | |
1274 | } |
1275 | |
1276 | Standard_Integer Xw_Window::VisualDepth () const { |
1277 | |
1278 | return (MyDepth); |
1279 | |
1280 | } |
1281 | |
1282 | Standard_Integer Xw_Window::VisualID( ) const { |
1283 | Aspect_Handle *VisualInfo ; |
1284 | Xw_TypeOfVisual VisualClass ; |
1285 | int MaxColor,BasePixel,MaxUserColor,MaxDefineColor,FirstFreeColorIndex,visualid |
1286 | ; |
1287 | |
1288 | status = Xw_get_colormap_info(MyExtendedColorMap,&VisualInfo, |
1289 | &VisualClass,&visualid,&MaxColor,&BasePixel, |
1290 | &MaxUserColor,&MaxDefineColor,&FirstFreeColorIndex) ; |
1291 | |
1292 | return (visualid) ; |
1293 | } |
1294 | |
1295 | Xw_WindowQuality Xw_Window::Quality () const { |
1296 | |
1297 | return (MyQuality); |
1298 | |
1299 | } |
1300 | |
1301 | Standard_Boolean Xw_Window::PixelOfColor ( const Quantity_NameOfColor aColor, Standard_Integer &aPixel ) const { |
1302 | Standard_Real Red,Green,Blue ; |
1303 | unsigned long pixel ; |
1304 | Standard_Integer isapproximate; |
1305 | Quantity_Color color(aColor); |
1306 | |
1307 | color.Values(Red,Green,Blue,Quantity_TOC_RGB) ; |
1308 | |
1309 | status = Xw_get_color_pixel(MyExtendedColorMap, |
1310 | (float)Red,(float)Green,(float)Blue,&pixel,&isapproximate) ; |
1311 | if( !status ) PrintError() ; |
1312 | |
1313 | aPixel = Standard_Integer(pixel); |
1314 | |
1315 | return (isapproximate) ? Standard_True : Standard_False; |
1316 | } |
1317 | |
1318 | Standard_Boolean Xw_Window::PixelOfColor ( const Quantity_Color &aColor, Standard_Integer &aPixel ) const { |
1319 | Standard_Real Red,Green,Blue ; |
1320 | unsigned long pixel ; |
1321 | Standard_Integer isapproximate; |
1322 | |
1323 | aColor.Values(Red,Green,Blue,Quantity_TOC_RGB) ; |
1324 | |
1325 | status = Xw_get_color_pixel(MyExtendedColorMap, |
1326 | (float)Red,(float)Green,(float)Blue,&pixel,&isapproximate) ; |
1327 | if( !status ) PrintError() ; |
1328 | |
1329 | aPixel = Standard_Integer(pixel); |
1330 | |
1331 | return (isapproximate) ? Standard_True : Standard_False; |
1332 | } |
1333 | |
1334 | Standard_Boolean Xw_Window::BackgroundPixel ( Standard_Integer &aPixel ) const { |
1335 | unsigned long pixel ; |
1336 | |
1337 | status = Xw_get_background_pixel(MyExtendedWindow,&pixel) ; |
1338 | if( !status ) PrintError() ; |
1339 | |
1340 | aPixel = Standard_Integer(pixel); |
1341 | |
1342 | return status; |
1343 | } |
1344 | |
1345 | |
1346 | Standard_Address Xw_Window::ExtendedWindow () const { |
1347 | |
1348 | return (MyExtendedWindow); |
1349 | |
1350 | } |
1351 | |
1352 | Standard_Address Xw_Window::ExtendedColorMap () const { |
1353 | |
1354 | return (MyExtendedColorMap); |
1355 | |
1356 | } |
1357 | |
1358 | Standard_Address Xw_Window::ExtendedTypeMap () const { |
1359 | |
1360 | return (MyExtendedTypeMap); |
1361 | |
1362 | } |
1363 | |
1364 | Standard_Address Xw_Window::ExtendedWidthMap () const { |
1365 | |
1366 | return (MyExtendedWidthMap); |
1367 | |
1368 | } |
1369 | |
1370 | Standard_Address Xw_Window::ExtendedFontMap () const { |
1371 | |
1372 | return (MyExtendedFontMap); |
1373 | |
1374 | } |
1375 | |
1376 | Standard_Address Xw_Window::ExtendedMarkMap () const { |
1377 | |
1378 | return (MyExtendedMarkMap); |
1379 | |
1380 | } |