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_PIXEL_WINDOWCOORD
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
32 Get transformed coordinate from User Space to Pixel Space
34 NOTE than the current mapping defined by Xw_set_mapping is apply
36 returns ERROR if User Coordinate is outside the window
37 returns SUCCESS if successful
42 XW_STATUS Xw_get_pixel_windowcoord(void* awindow,float ux,float uy,int* px,int* py)
44 XW_STATUS Xw_get_pixel_windowcoord(awindow,ux,uy,px,py)
48 #endif /*XW_PROTOTYPE*/
50 XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
51 XW_EXT_DISPLAY *pdisplay = pwindow->connexion ;
54 *px = PXPOINT(ux, pwindow->xratio) ;
55 *py = PYPOINT(uy, pwindow->attributes.height, pwindow->yratio) ;
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) ;
64 if( !_DGRAB && (*px < 0 || *px > _WIDTH || *py < 0 || *py > _HEIGHT) )
66 else return (XW_SUCCESS);