0023414: Remove deprecated classes Xw_PixMap and WNT_PixMap
[occt.git] / src / Xw / Xw_get_pixel_windowcoord.cxx
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
18
19 #include <Xw_Extension.h>
20
21 /* ifdef then trace on */
22 #ifdef TRACE
23 #define TRACE_GET_PIXEL_WINDOWCOORD
24 #endif
25
26 /*
27    STATUS Xw_get_pixel_windowcoord (awindow,ux,uy,px,py):
28    XW_EXT_WINDOW *awindow
29    float ux,uy          Window Coordinates defined in DWU space 
30    int *px,*py          Returns Window Coordinates defined in Pixels 
31
32         Get transformed coordinate from User Space to Pixel Space
33
34         NOTE than the current mapping defined by Xw_set_mapping is apply
35
36         returns ERROR if User Coordinate is outside the window
37         returns SUCCESS if successful
38
39 */
40
41 #ifdef XW_PROTOTYPE
42 XW_STATUS Xw_get_pixel_windowcoord(void* awindow,float ux,float uy,int* px,int* py)
43 #else
44 XW_STATUS Xw_get_pixel_windowcoord(awindow,ux,uy,px,py)
45 void *awindow;
46 float ux,uy ;
47 int *px,*py ;
48 #endif /*XW_PROTOTYPE*/
49 {
50 XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
51 XW_EXT_DISPLAY *pdisplay = pwindow->connexion ;
52
53 //OCC186
54         *px = PXPOINT(ux, pwindow->xratio) ;
55         *py = PYPOINT(uy, pwindow->attributes.height, pwindow->yratio) ;
56 //OCC186
57         
58 #ifdef  TRACE_GET_PIXEL_WINDOWCOORD
59 if( Xw_get_trace() > 1 ) {
60     printf (" Xw_get_pixel_windowcoord(%lx,%f,%f,%d,%d)\n",(long ) pwindow,ux,uy,*px,*py) ;
61 }
62 #endif
63
64         if( !_DGRAB && (*px < 0 || *px > _WIDTH || *py < 0 || *py > _HEIGHT) ) 
65                                                         return (XW_ERROR);
66         else return (XW_SUCCESS);
67 }