//--------------------------------------------------------- bool CVIEW_Table_Control::Update_Table(void) { if( GetBatchCount() > 0 ) { return( false ); } BeginBatch(); //----------------------------------------------------- int Difference = (m_pTable->Get_Field_Count() - m_Field_Offset) - GetNumberCols(); if( Difference > 0 ) { AppendCols(Difference); } else if( (Difference = -Difference < GetNumberCols() ? -Difference : GetNumberCols()) > 0 ) { // here is (or was!?) a memory leak - solution: use own wxGridTableBase derived grid table class DeleteCols(0, Difference); } //----------------------------------------------------- for(int iCol=0, iField=m_Field_Offset; iField<m_pTable->Get_Field_Count(); iCol++, iField++) { SetColLabelValue(iCol, m_pTable->Get_Field_Name(iField)); switch( m_pTable->Get_Field_Type(iField) ) { default: case SG_DATATYPE_Byte: case SG_DATATYPE_Char: case SG_DATATYPE_String: case SG_DATATYPE_Date: case SG_DATATYPE_Binary: SetColFormatCustom(iCol, wxGRID_VALUE_STRING); break; case SG_DATATYPE_Bit: case SG_DATATYPE_Word: case SG_DATATYPE_Short: case SG_DATATYPE_DWord: case SG_DATATYPE_Int: case SG_DATATYPE_ULong: case SG_DATATYPE_Long: case SG_DATATYPE_Color: SetColFormatNumber(iCol); break; case SG_DATATYPE_Float: case SG_DATATYPE_Double: SetColFormatFloat(iCol); break; } } //----------------------------------------------------- EndBatch(); return( _Set_Records() ); }
void CatheterGrid::formatDefaultGrid(int nrows) { SetColLabelValue(CHANNEL_COL, wxT("Channel")); SetColLabelValue(CURRENT_COL, wxT("Current (mA)")); SetColLabelValue(DIRECTION_COL, wxT("Direction")); SetColLabelValue(DELAY_COL, wxT("Delay (ms)")); //HideRowLabels(); SetColFormatNumber(CHANNEL_COL); //channel address SetColFormatFloat(CURRENT_COL); // MA current //default is String for Direction SetColFormatNumber(DELAY_COL); //delay for (int i = 0; i < nrows; i++) formatDefaultRow(i); setRowReadOnly(0, false); }
CatheterCmdGrid::CatheterCmdGrid(const CatheterCmdGrid& C) : wxGrid(C.GetParent(), wxID_ANY), cmd_count(C.cmd_count), dir_choices{ wxT("neg"), wxT("pos") } { dir_choices[DIR_POS] = wxT("pos"); dir_choices[DIR_NEG] = wxT("neg"); CreateGrid(NCHANNELS, NFIELDS); SetColLabelValue(CHANNEL_COL, wxT("Channel")); SetColLabelValue(CURRENT_COL, wxT("Current (MA)")); SetColLabelValue(DIR_COL, wxT("Direction")); SetColLabelValue(DELAY_COL, wxT("Delay (ms)")); //HideRowLabels(); // set column attributes GetTable()->SetAttrProvider(new wxGridCellAttrProvider()); for (int i = 0; i < NFIELDS; i++) GetTable()->GetAttrProvider()->SetColAttr(new wxGridCellAttr(), i); SetColFormatNumber(CHANNEL_COL); //channel address SetColFormatFloat(CURRENT_COL); // MA current SetColFormatNumber(DELAY_COL); //delay wxGridCellAttr* dirAttr = GetTable()->GetAttrProvider()->GetAttr(0, DIR_COL, wxGridCellAttr::Col); wxGridCellAttr* channelAttr = GetTable()->GetAttrProvider()->GetAttr(0, CHANNEL_COL, wxGridCellAttr::Col); if (channelAttr == NULL || dirAttr == NULL) { printf("attribute is NULL\n"); exit(EXIT_FAILURE); } dirAttr->SetEditor(new wxGridCellChoiceEditor(2, dir_choices)); channelAttr->SetEditor(new wxGridCellNumberEditor(1, NCHANNELS)); SetColAttr(DIR_COL, dirAttr); SetColAttr(CHANNEL_COL, channelAttr); for (int i = 1; i < GetNumberRows(); i++) { setRowReadOnly(i, true); } appendCommandRow(); }
//--------------------------------------------------------- bool CActive_Attributes_Control::Update_Table(void) { if( GetBatchCount() > 0 ) { return( false ); } BeginBatch(); //----------------------------------------------------- int Difference = (m_pTable->Get_Field_Count() - m_Field_Offset) - GetNumberCols(); if( Difference > 0 ) { AppendCols(Difference); } else if( (Difference = -Difference < GetNumberCols() ? -Difference : GetNumberCols()) > 0 ) { // here is (or was!?) a memory leak - solution: use own wxGridTableBase derived grid table class DeleteCols(0, Difference); } //----------------------------------------------------- for(int iCol=0, iField=m_Field_Offset; iField<m_pTable->Get_Field_Count(); iCol++, iField++) { SetColLabelValue(iCol, m_pTable->Get_Field_Name(iField)); switch( m_pTable->Get_Field_Type(iField) ) { default: case SG_DATATYPE_Byte: case SG_DATATYPE_Char: case SG_DATATYPE_String: case SG_DATATYPE_Date: case SG_DATATYPE_Binary: SetColFormatCustom(iCol, wxGRID_VALUE_STRING); break; case SG_DATATYPE_Bit: case SG_DATATYPE_Word: case SG_DATATYPE_Short: case SG_DATATYPE_DWord: case SG_DATATYPE_Int: case SG_DATATYPE_ULong: case SG_DATATYPE_Long: case SG_DATATYPE_Color: SetColFormatNumber(iCol); break; case SG_DATATYPE_Float: case SG_DATATYPE_Double: SetColFormatFloat(iCol); break; } } //----------------------------------------------------- if( (Difference = m_pTable->Get_Count() - GetNumberRows()) > 0 ) { AppendRows(Difference); } else if( Difference < 0 && (Difference = -Difference < GetNumberRows() ? -Difference : GetNumberRows()) > 0 ) { DeleteRows(0, Difference); } //------------------------------------------------- for(int iRecord=0; iRecord<m_pTable->Get_Count(); iRecord++) { _Set_Record(iRecord); } //----------------------------------------------------- if( GetNumberCols() > 0 && GetNumberRows() > 0 ) { SetRowLabelSize(wxGRID_AUTOSIZE); if( m_Field_Offset ) // feature attributes { if( GetClientSize().x > GetRowLabelSize() ) { SetColSize(0, GetClientSize().x - GetRowLabelSize()); } } else // grid cell values { AutoSizeColumns(); } } Enable(GetNumberRows() > 0); m_pTable->Set_Modified(false); //----------------------------------------------------- EndBatch(); return( true ); }