00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #if defined(__GNUG__) && !defined(__APPLE__)
00020 #pragma implementation "display_image_frame.h"
00021 #endif
00022
00023
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
00149 return wxNullBitmap;
00151 }
00152
00157 wxIcon DisplayImageFrame::GetIconResource( const wxString& name )
00158 {
00159
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
00174
00175
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
00193 wxWindow* window = this;
00194 window->Hide();
00195
00196 _can_display = false;
00197 }
00198
00199