00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
00015 #pragma implementation "record_ch_control.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
00031
00032 #include "record_ch_control.h"
00033
00036
00041 IMPLEMENT_DYNAMIC_CLASS( RecordChControl, wxPanel )
00042
00043
00047 BEGIN_EVENT_TABLE( RecordChControl, wxPanel )
00048
00050 EVT_TOGGLEBUTTON( ID_TOGGLEBUTTON, RecordChControl::OnTogglebuttonClick )
00051
00052 EVT_SPINCTRL( ID_RATE_DIVIDER_SPINCTRL, RecordChControl::OnRateDividerSpinctrlUpdated )
00053
00054 EVT_CHOICE( ID_FORMAT_CHOICE, RecordChControl::OnFormatChoiceSelected )
00055
00057 EVT_TEXT_ENTER( ID_RATE_DIVIDER_SPINCTRL, RecordChControl::OnRateDividerSpinctrlTextUpdated )
00058
00059 END_EVENT_TABLE()
00060
00065 RecordChControl::RecordChControl( )
00066 {
00067 }
00068
00069 RecordChControl::RecordChControl( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
00070 {
00071 Create(parent, id, pos, size, style);
00072 }
00073
00078 bool RecordChControl::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
00079 {
00081 m_main_sizer_text = NULL;
00082 m_ch_enable_control = NULL;
00083 m_ch_rate_divider_control = NULL;
00084 m_format_control = NULL;
00086
00088 wxPanel::Create( parent, id, pos, size, style );
00089
00090 CreateControls();
00091 if (GetSizer())
00092 {
00093 GetSizer()->SetSizeHints(this);
00094 }
00095 Centre();
00097 return true;
00098 }
00099
00104 void RecordChControl::CreateControls()
00105 {
00107
00108
00109 RecordChControl* itemPanel1 = this;
00110
00111 this->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxNORMAL, false, _T("Verdana")));
00112 m_main_sizer_text = new wxStaticBox(itemPanel1, wxID_ANY, _("???"));
00113 wxStaticBoxSizer* itemStaticBoxSizer2 = new wxStaticBoxSizer(m_main_sizer_text, wxVERTICAL);
00114 itemPanel1->SetSizer(itemStaticBoxSizer2);
00115
00116 m_ch_enable_control = new wxToggleButton( itemPanel1, ID_TOGGLEBUTTON, _("???"), wxDefaultPosition, wxSize(75, -1), 0 );
00117 m_ch_enable_control->SetValue(true);
00118 m_ch_enable_control->SetHelpText(_("Enable/Disable channel record"));
00119 if (ShowToolTips())
00120 m_ch_enable_control->SetToolTip(_("Enable/Disable channel record"));
00121 m_ch_enable_control->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, _T("Verdana")));
00122 itemStaticBoxSizer2->Add(m_ch_enable_control, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0);
00123
00124 m_ch_rate_divider_control = new wxSpinCtrl( itemPanel1, ID_RATE_DIVIDER_SPINCTRL, _T("1"), wxDefaultPosition, wxSize(75, -1), wxSP_ARROW_KEYS, 1, 99999, 1 );
00125 m_ch_rate_divider_control->SetHelpText(_("Set sample rate divider"));
00126 if (ShowToolTips())
00127 m_ch_rate_divider_control->SetToolTip(_("Set sample rate divider"));
00128 itemStaticBoxSizer2->Add(m_ch_rate_divider_control, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP, 3);
00129
00130 wxString* m_format_controlStrings = NULL;
00131 m_format_control = new wxChoice( itemPanel1, ID_FORMAT_CHOICE, wxDefaultPosition, wxSize(80, -1), 0, m_format_controlStrings, 0 );
00132 m_format_control->SetStringSelection(_("HEX"));
00133 m_format_control->SetHelpText(_("Select output file format"));
00134 if (ShowToolTips())
00135 m_format_control->SetToolTip(_("Select output file format"));
00136 itemStaticBoxSizer2->Add(m_format_control, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
00137
00139
00140 this->m_format_control->Append( _("HEX"));
00141 this->m_format_control->Append( _("ASCII DEC"));
00142 this->m_format_control->Append( _("ASCII HEX"));
00143
00144 }
00145
00150 void RecordChControl::OnTogglebuttonClick( wxCommandEvent& )
00151 {
00152 this->m_p_board_channel->m_record_enabled= this->m_ch_enable_control->GetValue( )!= 0;
00153 this->m_ch_enable_control->SetLabel( this->m_p_board_channel->m_record_enabled? _("Disable"): _("Enable"));
00154 }
00155
00160 void RecordChControl::OnRateDividerSpinctrlUpdated( wxSpinEvent& event)
00161 {
00162 this->UpdateRateDivider( event.GetPosition());
00163 }
00164
00169 void RecordChControl::OnRateDividerSpinctrlTextUpdated( wxCommandEvent& )
00170 {
00171 int value= atoi( this->m_ch_rate_divider_control->GetLabel( ));
00172 this->UpdateRateDivider( value);
00173 }
00174
00179 bool RecordChControl::ShowToolTips()
00180 {
00181 return true;
00182 }
00183
00188 wxBitmap RecordChControl::GetBitmapResource( const wxString& name )
00189 {
00190
00192 wxUnusedVar(name);
00193 return wxNullBitmap;
00195 }
00196
00201 wxIcon RecordChControl::GetIconResource( const wxString& name )
00202 {
00203
00205 wxUnusedVar(name);
00206 return wxNullIcon;
00208 }
00209
00210 bool RecordChControl::SetupBoard( GenericBoard* p_board, int ch_index, int ch_count, bool is_virtual)
00211 {
00212 this->m_is_virtual= is_virtual;
00213 this->m_p_board= p_board;
00214 this->m_ch_index= ch_index;
00215 this->m_ch_count= ch_count;
00216 if( this->m_is_virtual)
00217 {
00218 if( ( size_t)this->m_ch_index>= this->m_p_board->m_virtual_channel_array.GetCount())
00219 return false;
00220 this->m_p_board_channel= (GenericBoardChannel*)this->m_p_board->m_virtual_channel_array[ this->m_ch_index];
00221 }
00222 else
00223 {
00224 if( ( size_t)this->m_ch_index>= this->m_p_board->m_channel_array.GetCount())
00225 return false;
00226 this->m_p_board_channel= (GenericBoardChannel*)this->m_p_board->m_channel_array[ this->m_ch_index];
00227 }
00228 this->m_p_board_channel->m_p_record_ch_control= this;
00229
00230 if( !this->UpdateControls())
00231 return false;
00232 return true;
00233 }
00234 bool RecordChControl::UpdateControls( void)
00235 {
00236 if( this->m_is_virtual)
00237 {
00238 this->m_main_sizer_text->SetLabel( wxString::Format( "VIRT %d", this->m_ch_count));
00239 }
00240 else
00241 {
00242 this->m_main_sizer_text->SetLabel( wxString::Format( "%d", this->m_ch_count));
00243 }
00244 this->m_ch_rate_divider_control->SetValue( this->m_p_board_channel->m_record_rate_divider);
00245 this->m_ch_enable_control->SetValue( this->m_p_board_channel->m_record_enabled);
00246 this->m_ch_enable_control->SetLabel( this->m_ch_enable_control->GetValue( )? _("Disable"): _("Enable"));
00247 this->m_format_control->SetSelection( this->m_p_board_channel->m_record_format_type);
00248
00249 return true;
00250 }
00251 void RecordChControl::UpdateRateDivider( int value)
00252 {
00253 this->m_p_board_channel->m_record_rate_divider= value;
00254 }
00259 void RecordChControl::OnFormatChoiceSelected( wxCommandEvent& )
00260 {
00261 this->m_p_board_channel->m_record_format_type= ( GenericBoardChannel::RECORD_FORMAT_TYPE)this->m_format_control->GetSelection();
00262 }
00263
00264