display_image_frame.cpp

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) Massimo Cora' 2006 <maxcvs@gmail.com>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #if defined(__GNUG__) && !defined(__APPLE__)
00020 #pragma implementation "display_image_frame.h"
00021 #endif
00022 
00023 // For compilers that support precompilation, includes "wx/wx.h".
00024 #include "wx/wxprec.h"
00025 
00026 #ifdef __BORLANDC__
00027 #pragma hdrstop
00028 #endif
00029 
00030 #ifndef WX_PRECOMP
00031 #include "wx/wx.h"
00032 #endif
00033 
00036 
00037 #include "display_image_frame.h"
00038 
00041 
00046 IMPLEMENT_CLASS( DisplayImageFrame, wxFrame )
00047 
00048 
00052 BEGIN_EVENT_TABLE( DisplayImageFrame, wxFrame )
00053 
00055     EVT_CLOSE( DisplayImageFrame::OnCloseWindow )
00056 
00058 
00059 END_EVENT_TABLE()
00060 
00065 DisplayImageFrame::DisplayImageFrame( )
00066 {
00067 }
00068 
00069 DisplayImageFrame::~DisplayImageFrame( )
00070 {
00071 }
00072 
00073 DisplayImageFrame::DisplayImageFrame( wxWindow* parent, 
00074                                                                          int stream_id,
00075                                                                          const wxSize& size, 
00076                                                                          wxWindowID id, 
00077                                                                          const wxString& caption,
00078                                                                          const wxPoint& pos, 
00079                                                                          long style ) : _stream_id ( stream_id )
00080 {
00081         char tmp_str[0xff];
00082 
00083         sprintf(tmp_str, "Stream detected %d", stream_id);
00084 #ifdef __LINUX__        
00085         wxChar buf[50];
00086 
00087         ::wxSnprintf(buf, 50, wxT("Stream detected %d"), stream_id);
00088         wxString caption_tmp(buf);
00089 #else   // WIN32
00090         wxString caption_tmp(wxT(tmp_str));
00091 #endif
00092     Create( parent, id, caption_tmp, pos, size, style );
00093 }
00094 
00099 bool DisplayImageFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
00100 {
00103 
00104     wxFrame::Create( parent, id, caption, pos, size, style );
00105 
00106         _window_width = size.GetWidth();
00107         _window_height = size.GetHeight();
00108 
00109     CreateControls();
00110     Centre();
00111 
00112 
00113         _can_display = false;
00114     return TRUE;
00115 }
00116 
00121 void DisplayImageFrame::CreateControls()
00122 {    
00124     DisplayImageFrame* itemFrame1 = this;
00125 
00126     itemPanel2 = new wxPanel( itemFrame1, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
00127 
00129         _display_canvas = NULL;
00130 }
00131 
00136 bool DisplayImageFrame::ShowToolTips()
00137 {
00138     return TRUE;
00139 }
00140 
00145 wxBitmap DisplayImageFrame::GetBitmapResource( const wxString& name )
00146 {
00147     // Bitmap retrieval
00149     return wxNullBitmap;
00151 }
00152 
00157 wxIcon DisplayImageFrame::GetIconResource( const wxString& name )
00158 {
00159     // Icon retrieval
00161     return wxNullIcon;
00163 }
00164 
00165 
00166 
00167 void DisplayImageFrame::DisplayIplImage( IplImage *image )
00168 {
00169         if ( _display_canvas == NULL ) {
00170                 _display_canvas = new DisplayCanvas( itemPanel2, wxSize(image->width, image->height) );
00171         }
00172 
00173         // we adopt the rule that if the stream go on we will go on
00174         // displaying it's contents. The window can just be minimized, but not
00175         // destroyed.
00176         if ( _can_display == false ) {
00177             wxWindow* window = this;
00178                 window->Show();         
00179                 _can_display = true;
00180         }
00181 
00182         _display_canvas->DrawIplImage( image );
00183 }
00184 
00185 
00190 void DisplayImageFrame::OnCloseWindow( wxCloseEvent& event )
00191 {
00192     // Before editing this code, remove the block markers.
00193     wxWindow* window = this;
00194     window->Hide();
00195 
00196         _can_display = false;
00197 }
00198 
00199 

Generated on Tue Dec 26 10:32:38 2006 for Omnimeeting by  doxygen 1.4.7