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_SET_DOUBLE_BUFFER |
24 | #endif |
25 | |
26 | /* |
27 | XW_STATUS Xw_set_double_buffer (awindow, state) |
28 | XW_EXT_WINDOW *awindow |
29 | DOUBLEBUFFERMODE state ; |
30 | |
31 | Sets the double_buffering status of the window . |
32 | |
33 | returns ERROR if Double Buffering is not XW_ENABLE on this station |
34 | returns XW_SUCCESS if successful |
35 | */ |
36 | |
37 | static char SetDoubleBuffer = '\0' ; |
38 | |
39 | #ifdef XW_PROTOTYPE |
40 | XW_STATUS Xw_set_double_buffer (void *awindow, XW_DOUBLEBUFFERMODE state) |
41 | #else |
42 | XW_STATUS Xw_set_double_buffer (awindow, state) |
43 | void *awindow; |
44 | XW_DOUBLEBUFFERMODE state ; |
45 | #endif /*XW_PROTOTYPE*/ |
46 | { |
47 | XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow; |
48 | XW_STATUS status = XW_SUCCESS; |
49 | char svalue[4] ; |
50 | |
51 | if( !Xw_isdefine_window(pwindow) ) { |
52 | /*ERROR*Bad EXT_WINDOW Address*/ |
53 | Xw_set_error(24,"Xw_set_double_buffer",pwindow) ; |
54 | return (XW_ERROR) ; |
55 | } |
56 | |
57 | if( SetDoubleBuffer == '\0' ) { |
58 | SetDoubleBuffer = 'U' ; |
59 | if( Xw_get_env("Xw_SET_DOUBLE_BUFFER",svalue,sizeof(svalue)) ) { |
60 | if( strlen(svalue) ) { |
61 | SetDoubleBuffer = svalue[0] ; |
62 | } |
63 | printf(" Xw_SET_DOUBLE_BUFFER is '%c'\n",SetDoubleBuffer) ; |
64 | } |
65 | } |
66 | |
67 | if( (SetDoubleBuffer == 'Y') ) { |
68 | state = XW_ENABLE ; |
69 | } else if( SetDoubleBuffer == 'N' ) { |
70 | state = XW_DISABLE ; |
71 | } |
72 | |
73 | if( state == XW_DISABLE ) { |
74 | if( _NWBUFFER > 0 ) { |
75 | if( _DRAWABLE == _FWBUFFER ) return (XW_SUCCESS); |
76 | _DRAWABLE = _FWBUFFER ; |
77 | } else { |
78 | if( _DRAWABLE == _WINDOW ) return (XW_SUCCESS); |
79 | _DRAWABLE = _WINDOW ; |
80 | } |
81 | } else if( state == XW_ENABLE ) { |
82 | if( !_PIXMAP && !_NWBUFFER ) { |
83 | status = Xw_open_pixmap(awindow) ; |
84 | } |
85 | if( _NWBUFFER > 0 ) { |
86 | _DRAWABLE = _BWBUFFER ; |
87 | } else if( _PIXMAP ) { |
88 | _DRAWABLE = _PIXMAP ; |
89 | } else { |
90 | _DRAWABLE = _WINDOW ; |
91 | } |
92 | } |
93 | |
94 | #ifdef TRACE_SET_DOUBLE_BUFFER |
95 | if( Xw_get_trace() ) { |
96 | printf(" Xw_set_double_buffer(%lx,%d)\n",(long ) pwindow,state) ; |
97 | } |
98 | #endif |
99 | |
100 | return (status); |
101 | } |