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 // GG IMP060200 Xw_get_background_image signatuire change
21 #include <Xw_Extension.h>
23 /* ifdef then trace on */
25 #define TRACE_GET_BACKGROUND_IMAGE
29 XW_STATUS Xw_get_background_image (awindow,xc,yc,width,height):
30 XW_EXT_WINDOW *awindow
31 int xc,yc Image center location in pixels
32 int width,height Image size in pixels
34 Get the window Background from the actual Window
35 at the required Center location
37 returns ERROR if Image is outside of the window
38 returns SUCCESS if successful
43 XW_STATUS Xw_get_background_image (void* awindow,
44 int xc,int yc,int width,int height)
46 XW_STATUS Xw_get_background_image (awindow,xc,yc,width,height)
50 #endif /*XW_PROTOTYPE*/
52 XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
53 XW_EXT_DISPLAY *pdisplay = pwindow->connexion ;
58 if( !Xw_isdefine_window(pwindow) ) {
59 /*ERROR*Bad EXT_WINDOW Address*/
60 Xw_set_error(24,"Xw_get_background_image",pwindow) ;
69 if( (wx + width) < 0 || wx > _DWIDTH ||
70 (wy + height) < 0 || wy > _DHEIGHT ) {
71 /*WARNING*Try to Get Image from outside the display*/
72 Xw_set_error(45,"Xw_get_background_image",0) ;
75 pimage = XGetImage(_DISPLAY,_DROOT,wx,wy,
76 width,height,AllPlanes,ZPixmap) ;
78 if( (wx + width) < 0 || wx > _WIDTH ||
79 (wy + height) < 0 || wy > _HEIGHT ) {
80 /*WARNING*Try to Get Image from outside the window*/
81 Xw_set_error(45,"Xw_get_background_image",0) ;
84 pimage = XGetImage(_DISPLAY,_WINDOW,wx,wy,
85 width,height,AllPlanes,ZPixmap) ;
88 if( _BPIXMAP ) Xw_close_background_pixmap(pwindow) ;
90 if( _PIXMAP || _NWBUFFER > 0 ) {
91 status = Xw_open_background_pixmap(pwindow) ;
92 if( !status ) return (XW_ERROR) ;
93 for( wx=0 ; wx<_WIDTH ; wx += width ) {
94 for( wy=0 ; wy<_HEIGHT ; wy += height ) {
95 XPutImage(_DISPLAY,_BPIXMAP,pwindow->qgwind.gccopy,
96 pimage,0,0,wx,wy,width,height) ;
100 Pixmap pixmap = XCreatePixmap(_DISPLAY,_WINDOW,
101 width,height,_DEPTH);
102 if( !pixmap ) return (XW_ERROR) ;
103 XPutImage(_DISPLAY,pixmap,pwindow->qgwind.gccopy,
104 pimage,0,0,wx,wy,width,height) ;
105 XSetWindowBackgroundPixmap(_DISPLAY,_WINDOW,pixmap) ;
107 XFreePixmap(_DISPLAY,pixmap) ;
110 Xw_erase_window(pwindow) ;
112 #ifdef TRACE_GET_BACKGROUND_IMAGE
113 if( Xw_get_trace() ) {
114 printf (" Xw_get_background_image(%lx,%d,%d,%d,%d)\n",
115 (long ) pwindow,xc,yc,width,height);