]> rtime.felk.cvut.cz Git - opencv.git/blob - opencv/src/highgui/window.cpp
removed duplicate cvGet/SetWindowProperty() (thanks to Stefano Fabri)
[opencv.git] / opencv / src / highgui / window.cpp
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 //  By downloading, copying, installing or using the software you agree to this license.
6 //  If you do not agree to this license, do not download, install,
7 //  copy or use the software.
8 //
9 //
10 //                        Intel License Agreement
11 //                For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
15 //
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
18 //
19 //   * Redistribution's of source code must retain the above copyright notice,
20 //     this list of conditions and the following disclaimer.
21 //
22 //   * Redistribution's in binary form must reproduce the above copyright notice,
23 //     this list of conditions and the following disclaimer in the documentation
24 //     and/or other materials provided with the distribution.
25 //
26 //   * The name of Intel Corporation may not be used to endorse or promote products
27 //     derived from this software without specific prior written permission.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 //M*/
41
42 #include "_highgui.h"
43
44 // in later times, use this file as a dispatcher to implementations like cvcap.cpp
45
46 CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_value)
47 {
48         switch(prop_id)
49         {
50                 case CV_WND_PROP_FULLSCREEN://accept CV_WINDOW_NORMAL or CV_WINDOW_FULLSCREEN 
51                 
52                         if (!name || (prop_value!=CV_WINDOW_NORMAL && prop_value!=CV_WINDOW_FULLSCREEN))//bag argument
53                                 break;
54                 
55                         #if   defined WIN32 || defined _WIN32 
56                         cvChangeMode_W32(name,prop_value);
57                         #elif defined (HAVE_GTK)
58                         cvChangeMode_GTK(name,prop_value);
59                         #elif defined (HAVE_CARBON)
60                         cvChangeMode_QT(name,prop_value);
61                         #endif
62                 break;
63                 
64                 case CV_WND_PROP_AUTOSIZE:
65                 
66                 break;
67                 
68         default:;
69         }
70 }
71
72 /* return -1 if error */
73 CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
74 {
75         switch(prop_id)
76         {
77                 case CV_WND_PROP_FULLSCREEN:
78                 
79                         if (!name)//bad argument
80                                 return -1;
81                                 
82                         #if   defined WIN32 || defined _WIN32 
83                                 return cvGetMode_W32(name);
84                         #elif defined (HAVE_GTK)
85                                 return cvGetMode_GTK(name);
86                         #elif defined (HAVE_CARBON)
87                                 return cvGetMode_QT(name);
88                         #endif
89                 return -1;
90                 
91                 case CV_WND_PROP_AUTOSIZE:
92                 
93                         if (!name)//bad argument
94                                 return -1;
95                                 
96                 return -1;
97                 
98         default:
99                 return -1;
100         }
101 }
102
103 namespace cv
104 {
105
106 void namedWindow( const string& winname, int flags )
107 {
108     cvNamedWindow( winname.c_str(), flags );
109 }
110
111 //YV
112 void setWindowProperty(const string& winname, int prop_id, double prop_value)
113 {
114         cvSetWindowProperty( winname.c_str(),prop_id,prop_value);
115 }
116
117 //YV
118 double getWindowProperty(const string& winname, int prop_id)
119 {
120         return  cvGetWindowProperty(winname.c_str(),prop_id);
121 }
122
123 void imshow( const string& winname, const Mat& img )
124 {
125     CvMat _img = img;
126     cvShowImage( winname.c_str(), &_img );
127 }
128
129 int waitKey(int delay)
130 {
131     return cvWaitKey(delay);
132 }
133
134 int createTrackbar(const string& trackbarName, const string& winName,
135                    int* value, int count, TrackbarCallback callback,
136                    void* userdata)
137 {
138     return cvCreateTrackbar2(trackbarName.c_str(), winName.c_str(),
139                              value, count, callback, userdata);
140 }
141
142 void setTrackbarPos( const string& trackbarName, const string& winName, int value )
143 {
144     cvSetTrackbarPos(trackbarName.c_str(), winName.c_str(), value );
145 }
146
147 int getTrackbarPos( const string& trackbarName, const string& winName )
148 {
149         return cvGetTrackbarPos(trackbarName.c_str(), winName.c_str());
150 }
151
152 }
153
154 #if   defined WIN32 || defined _WIN32         // see window_w32.cpp
155 #elif defined (HAVE_GTK)      // see window_gtk.cpp
156 #elif defined (HAVE_COCOA)   // see window_carbon.cpp
157 #elif defined (HAVE_CARBON)
158
159
160 #else
161
162 // No windowing system present at compile time ;-(
163 // 
164 // We will build place holders that don't break the API but give an error
165 // at runtime. This way people can choose to replace an installed HighGUI
166 // version with a more capable one without a need to recompile dependent
167 // applications or libraries.
168
169
170 #define CV_NO_GUI_ERROR(funcname) \
171     cvError( CV_StsError, funcname, \
172     "The function is not implemented. " \
173     "Rebuild the library with Windows, GTK+ 2.x or Carbon support. "\
174     "If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script", \
175     __FILE__, __LINE__ )
176
177
178 CV_IMPL int cvNamedWindow( const char*, int )
179 {
180     CV_NO_GUI_ERROR("cvNamedWindow");
181     return -1;
182 }    
183
184 CV_IMPL void cvDestroyWindow( const char* )
185 {
186     CV_NO_GUI_ERROR( "cvDestroyWindow" );
187 }
188
189 CV_IMPL void
190 cvDestroyAllWindows( void )
191 {
192     CV_NO_GUI_ERROR( "cvDestroyAllWindows" );
193 }
194
195 CV_IMPL void
196 cvShowImage( const char*, const CvArr* )
197 {
198     CV_NO_GUI_ERROR( "cvShowImage" );
199 }
200
201 CV_IMPL void cvResizeWindow( const char*, int, int )
202 {
203     CV_NO_GUI_ERROR( "cvResizeWindow" );
204 }
205
206 CV_IMPL void cvMoveWindow( const char*, int, int )
207 {
208     CV_NO_GUI_ERROR( "cvMoveWindow" );
209 }
210
211 CV_IMPL int
212 cvCreateTrackbar( const char*, const char*,
213                   int*, int, CvTrackbarCallback )
214 {
215     CV_NO_GUI_ERROR( "cvCreateTrackbar" );
216     return -1;
217 }
218
219 CV_IMPL int
220 cvCreateTrackbar2( const char* trackbar_name, const char* window_name,
221                    int* val, int count, CvTrackbarCallback2 on_notify2,
222                    void* userdata )
223 {
224     CV_NO_GUI_ERROR( "cvCreateTrackbar2" );
225     return -1;
226 }
227
228 CV_IMPL void
229 cvSetMouseCallback( const char*, CvMouseCallback, void* )
230 {
231     CV_NO_GUI_ERROR( "cvSetMouseCallback" );
232 }
233
234 CV_IMPL int cvGetTrackbarPos( const char*, const char* )
235 {
236     CV_NO_GUI_ERROR( "cvGetTrackbarPos" );
237     return -1;
238 }
239
240 CV_IMPL void cvSetTrackbarPos( const char*, const char*, int )
241 {
242     CV_NO_GUI_ERROR( "cvSetTrackbarPos" );
243 }
244
245 CV_IMPL void* cvGetWindowHandle( const char* )
246 {
247     CV_NO_GUI_ERROR( "cvGetWindowHandle" );
248     return 0;
249 }
250     
251 CV_IMPL const char* cvGetWindowName( void* )
252 {
253     CV_NO_GUI_ERROR( "cvGetWindowName" );
254     return 0;
255 }
256
257 CV_IMPL int cvWaitKey( int )
258 {
259     CV_NO_GUI_ERROR( "cvWaitKey" );
260     return -1;
261 }
262
263 CV_IMPL int cvInitSystem( int argc, char** argv )
264 {
265
266     CV_NO_GUI_ERROR( "cvInitSystem" );
267     return -1;
268 }
269
270 CV_IMPL int cvStartWindowThread()
271 {
272
273     CV_NO_GUI_ERROR( "cvStartWindowThread" );
274     return -1;
275 }
276
277 #endif
278
279 /* End of file. */