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_ERASE_AREA |
24 | #endif |
25 | |
26 | /* |
27 | STATUS Xw_erase_area (awindow,px,py,pwidth,pheight) |
28 | XW_EXT_WINDOW *awindow |
29 | int px,py area center given in PIXELS |
30 | int pwidth,pheight area size given in PIXELS |
31 | |
32 | Erase the attached Drawable area . |
33 | |
34 | returns ERROR if NO attached pixmap exist or |
35 | area is out of window |
36 | returns SUCCESS if successful |
37 | |
38 | */ |
39 | |
40 | #ifdef XW_PROTOTYPE |
41 | XW_STATUS Xw_erase_area (void* awindow, |
42 | int px,int py,int pwidth,int pheight) |
43 | #else |
44 | XW_STATUS Xw_erase_area (awindow,px,py,pwidth,pheight) |
45 | void *awindow; |
46 | int px,py,pwidth,pheight ; |
47 | #endif /*XW_PROTOTYPE*/ |
48 | { |
49 | XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow; |
50 | int i ; |
51 | |
52 | if( !Xw_isdefine_window(pwindow) ) { |
53 | /*ERROR*Bad EXT_WINDOW Address*/ |
54 | Xw_set_error(24,"Xw_erase_area",pwindow) ; |
55 | return (XW_ERROR) ; |
56 | } |
57 | |
58 | if( (px + pwidth/2) < 0 || (px - pwidth/2) > _WIDTH || |
59 | (py + pheight/2) < 0 || (py - pheight/2) > _HEIGHT ) { |
60 | /*WARNING*Try to Erase outside the window*/ |
61 | Xw_set_error(40,"Xw_erase_area",pwindow) ; |
62 | return (XW_ERROR) ; |
63 | } |
64 | |
65 | px -= pwidth/2 ; py -= pheight/2 ; |
66 | |
67 | if( _BPIXMAP ) { |
68 | XCopyArea(_DISPLAY,_BPIXMAP,_DRAWABLE,pwindow->qgwind.gccopy, |
69 | px,py,pwidth,pheight,px,py) ; |
70 | } else { |
71 | if( _DRAWABLE == _WINDOW ) { |
72 | XClearArea(_DISPLAY,_WINDOW,px,py,pwidth,pheight,False) ; |
73 | } else { |
74 | XFillRectangle(_DISPLAY,_DRAWABLE,pwindow->qgwind.gcclear, |
75 | px,py,pwidth,pheight) ; |
76 | } |
77 | } |
78 | |
79 | for( i=1 ; i<MAXBUFFERS ; i++ ) { |
80 | if( _BUFFER(i).isdrawn ) { |
81 | int xmin,ymin,xmax,ymax ; |
82 | if( _BUFFER(i).isupdated ) { |
83 | xmin = _BUFFER(i).uxmin ; |
84 | ymin = _BUFFER(i).uymin ; |
85 | xmax = _BUFFER(i).uxmax ; |
86 | ymax = _BUFFER(i).uymax ; |
87 | } else { |
88 | xmin = _BUFFER(i).rxmin ; |
89 | ymin = _BUFFER(i).rymin ; |
90 | xmax = _BUFFER(i).rxmax ; |
91 | ymax = _BUFFER(i).rymax ; |
92 | } |
93 | if( xmax < px || xmin > px+pwidth ) continue ; |
94 | if( ymax < py || ymin > py+pheight ) continue ; |
95 | Xw_erase_buffer(pwindow,-i) ; |
96 | } |
97 | } |
98 | |
99 | XFlush(_DISPLAY) ; |
100 | |
101 | #ifdef TRACE_ERASE_AREA |
102 | if( Xw_get_trace() > 1 ) { |
103 | printf(" Xw_erase_area(%lx,%d,%d,%d,%d)\n",(long ) pwindow,px,py,pwidth,pheight); |
104 | } |
105 | #endif |
106 | |
107 | return (XW_SUCCESS); |
108 | } |