00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
00015 #pragma implementation "drawing_left_canvas.h"
00016 #endif
00017
00018
00019 #include "wx/wxprec.h"
00020
00021 #ifdef __BORLANDC__
00022 #pragma hdrstop
00023 #endif
00024
00025 #ifndef WX_PRECOMP
00026 #include "wx/wx.h"
00027 #endif
00028 #include <wx/dcbuffer.h>
00029
00032
00033 #include "drawing_left_canvas.h"
00034 #include "drawing_panel.h"
00035
00038
00043 IMPLEMENT_DYNAMIC_CLASS( DrawingLeftCanvas, wxPanel )
00044
00045
00049 BEGIN_EVENT_TABLE( DrawingLeftCanvas, wxPanel )
00050
00052 EVT_SIZE( DrawingLeftCanvas::OnSize )
00053 EVT_PAINT( DrawingLeftCanvas::OnPaint )
00054 EVT_ERASE_BACKGROUND( DrawingLeftCanvas::OnEraseBackground )
00055
00057
00058 END_EVENT_TABLE()
00059
00064 DrawingLeftCanvas::DrawingLeftCanvas( ): m_parent( NULL), m_first_time(true), m_scope_index( 0)
00065 {
00066 this->m_p_back_bitmap= new wxBitmap( 1, 1);
00067 }
00068
00069 DrawingLeftCanvas::DrawingLeftCanvas( int scope_index, wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ): m_parent( (DrawingPanel*)parent), m_first_time(true)
00070 {
00071 this->m_scope_index= scope_index;
00072 this->m_p_back_bitmap= new wxBitmap( 1, 1);
00073 Create(parent, id, pos, size, style);
00074 }
00075 DrawingLeftCanvas::~DrawingLeftCanvas()
00076 {
00077 delete this->m_p_back_bitmap;
00078 }
00079
00084 bool DrawingLeftCanvas::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
00085 {
00088
00090 wxPanel::Create( parent, id, pos, size, style );
00091
00092 CreateControls();
00093 Centre();
00095 return true;
00096 }
00097
00102 void DrawingLeftCanvas::CreateControls()
00103 {
00105
00106
00107 DrawingLeftCanvas* itemPanel1 = this;
00108
00110 }
00111
00116 bool DrawingLeftCanvas::ShowToolTips()
00117 {
00118 return true;
00119 }
00120
00125 wxBitmap DrawingLeftCanvas::GetBitmapResource( const wxString& name )
00126 {
00127
00129 wxUnusedVar(name);
00130 return wxNullBitmap;
00132 }
00133
00138 wxIcon DrawingLeftCanvas::GetIconResource( const wxString& name )
00139 {
00140
00142 wxUnusedVar(name);
00143 return wxNullIcon;
00145 }
00150 void DrawingLeftCanvas::OnSize( wxSizeEvent& event )
00151 {
00152 this->RefreshBackBitmap();
00153 event.Skip();
00154 }
00155
00160 void DrawingLeftCanvas::OnPaint( wxPaintEvent& event )
00161 {
00162 if( this->m_parent->IsFreezed())
00163 {
00164 event.Skip();
00165 return;
00166 }
00167 if( this->m_first_time )
00168 {
00169 this->RefreshBackBitmap();
00170 this->m_first_time= false;
00171 }
00172
00173
00174 if( this->m_parent->m_app_settings== NULL)
00175 return;
00176
00177 wxBufferedPaintDC dc( this );
00178 dc.DrawBitmap( *this->m_p_back_bitmap, 0, 0, false);
00179 }
00180
00185 void DrawingLeftCanvas::OnEraseBackground( wxEraseEvent& )
00186 {
00187 }
00188
00189 void DrawingLeftCanvas::DrawPosition( wxDC &dc)
00190 {
00191
00192
00193 for( size_t i= 0; i< this->m_parent->m_app_settings->m_board_array.GetCount(); i++)
00194 {
00195 GenericBoard *board= ( GenericBoard *)this->m_parent->m_app_settings->m_board_array[ i];
00196 board->DrawPosition( this->m_scope_index, dc);
00197 }
00198 }
00199 void DrawingLeftCanvas:: RefreshBackBitmap( )
00200 {
00201 if( this->m_parent->m_app_settings== NULL)
00202 return;
00203 if( this->m_parent->IsFreezed())
00204 {
00205 return;
00206 }
00207 this->m_pix_X= this->GetRect().width;
00208 this->m_pix_Y= this->GetRect().height;
00209
00210
00211 for( size_t i= 0; i< this->m_parent->m_app_settings->m_board_array.GetCount(); i++)
00212 {
00213 GenericBoard *board= ( GenericBoard *)this->m_parent->m_app_settings->m_board_array[ i];
00214 board->SetLeftDiv2Pix( this->m_scope_index, (double)this->m_pix_Y/ DrawingCanvas::NUM_DIV_PER_SCREEN);
00215 board->SetLeftPix( this->m_scope_index, this->m_pix_X, this->m_pix_Y);
00216 }
00217
00218
00219 if(( this->m_p_back_bitmap->GetWidth()!= this->m_pix_X)||
00220 ( this->m_p_back_bitmap->GetHeight()!= this->m_pix_Y))
00221 {
00222 delete this->m_p_back_bitmap;
00223 this->m_p_back_bitmap= new wxBitmap( this->m_pix_X, this->m_pix_Y);
00224 }
00225
00226 wxMemoryDC dc;
00227 dc.SelectObject( *this->m_p_back_bitmap);
00228
00229 this->DrawBackground( dc);
00230 this->DrawPosition( dc);
00231 dc.SelectObject( wxNullBitmap);
00232
00233 }
00234 void DrawingLeftCanvas::DrawBackground( wxDC &dc)
00235 {
00236 wxMutexLocker lock( this->m_parent->m_app_settings->m_mutex);
00237
00238 if( this->m_parent->m_app_settings->m_back_brush[ this->m_scope_index]== NULL)
00239 return;
00240 dc.SetBackground( *this->m_parent->m_app_settings->m_back_brush[ this->m_scope_index]);
00241 dc.Clear();
00242
00243 dc.SetBackground( *this->m_parent->m_app_settings->m_back_brush[ this->m_scope_index]);
00244 }
00245