//---------------------------------------------------------
void CVIEW_Table_Control::On_Field_Del(wxCommandEvent &event)
{
	int				i;
	CSG_Parameters	P;

	//-----------------------------------------------------
	P.Set_Name(_TL("Delete Fields"));

	for(i=0; i<m_pTable->Get_Field_Count(); i++)
	{
		P.Add_Value(NULL, SG_Get_String(i, 0), m_pTable->Get_Field_Name(i), _TL(""), PARAMETER_TYPE_Bool, false);
	}

	//-----------------------------------------------------
	if( DLG_Parameters(&P) )
	{
		for(i=m_pTable->Get_Field_Count()-1; i>=0; i--)
		{
			if( P(SG_Get_String(i, 0))->asBool() )
			{
				m_pTable->Del_Field(i);

				DeleteCols(i);
			}
		}

		g_pData->Update(m_pTable, NULL);
	}
}
//---------------------------------------------------------
void CActive_Attributes_Control::On_Field_Del(wxCommandEvent &event)
{
	if( !g_pActive->Get_Active_Data_Item() || g_pActive->Get_Active_Data_Item()->Get_Type() != WKSP_ITEM_Grids )	{	return;	}

	CSG_Grids	*pGrids	= ((CWKSP_Grids *)g_pActive->Get_Active_Data_Item())->Get_Grids();

	//-----------------------------------------------------
	int				i;
	CSG_Parameters	P;

	//-----------------------------------------------------
	P.Set_Name(_TL("Delete Fields"));

	for(i=0; i<m_pTable->Get_Field_Count(); i++)
	{
		P.Add_Value(NULL, SG_Get_String(i), m_pTable->Get_Field_Name(i), _TL(""), PARAMETER_TYPE_Bool, false);
	}

	//-----------------------------------------------------
	if( DLG_Parameters(&P) )
	{
		for(i=m_pTable->Get_Field_Count()-1; i>=0; i--)
		{
			if( P(SG_Get_String(i))->asBool() )
			{
				pGrids->Get_Attributes_Ptr()->Del_Field(i);

				DeleteCols(i);
			}
		}

		g_pData->Update(pGrids, NULL);
	}
}
//---------------------------------------------------------
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 ctlResultGrid::fillGrid( PGresult * result )
{
    int    rowCount = PQntuples( result );
    int    colCount = PQnfields( result );

    // If this PGresult represents a non-query command 
    // (like an INSERT), there won't be any columns in 
    // the result set - just return

    if( colCount == 0 )
        return;

    // Disable repaints to we don't flicker too much

    BeginBatch();

    // Clear out the old results (if any) and resize 
    // grid to match the result set

    if( GetNumberRows())
        DeleteRows( 0, GetNumberRows());
    if( GetNumberCols())
        DeleteCols( 0, GetNumberCols());

    AppendRows( rowCount );
    AppendCols( colCount );

    EnableEditing( false );

    // Copy the column names from the result set into the column headers

    for( int col = 0; col < colCount; ++col )
        SetColLabelValue( col, wxString( PQfname( result, col ), wxConvUTF8 ));

    // Now copy each value from the result set into the grid

    for( int row = 0; row < rowCount; ++row )
    {
        for( int col = 0; col < colCount; ++col )
        {
            if( PQgetisnull( result, row, col ))
                SetCellValue( row, col, wxT( "" ));
            else
                SetCellValue( row, col, wxString( PQgetvalue( result, row, col ), wxConvUTF8 ));
        }
    }

    // Resize each column to fit its content

    AutoSizeColumns( false );

    // Enable repaints

    EndBatch();
}
Exemplo n.º 5
0
void CGridLocus::_SetNumberCols(int n)
{
    int nCol = GetNumberCols();
    if(nCol == n) {
        ;   // do nothing
    }
    else if(nCol < n)
    {
        _ImplementColumn(n - 1);
    }
    else
    {
        DeleteCols(n,nCol - n);
    }
}
bool CGridAnalysis::_SetGridSize(int nRowCount, int nColCount)
{
  // return true if OK, false if error
  int nRowCurrent = GetNumberRows();
  int nColCurrent = GetNumberCols();
  bool bError = false;

  ClearSelection();
  ClearGrid();

  if((!nRowCount) || (nColCount < 1))
  {
    bError = true;
    nRowCount = 1;
    nColCount = 1;
  }
  if(nColCurrent > nColCount)
  {
    DeleteCols(nColCount,nColCurrent - nColCount);
  }
  else if(nColCurrent < nColCount)
  {
    AppendCols(nColCount - nColCurrent);
  }
  if(nRowCurrent > nRowCount)
  {
    DeleteRows(nRowCount,nRowCurrent - nRowCount);
  }
  else if(nRowCurrent < nRowCount)
  {
    AppendRows(nRowCount - nRowCurrent);
  }
  if(bError)
  {
    SetColLabelValue(0,wxEmptyString);
    SetRowLabelValue(0,wxEmptyString);
    SetCellStyle(0,0,GRID_NORMAL);
    SetCellValue(0,0,wxEmptyString);
  }
  return !bError;
}
//---------------------------------------------------------
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 );
}
Exemplo n.º 8
0
void CGridRFULimits::_Build()
{
  wxFont fontChannel = GetDefaultCellFont();
  wxFont fontDefault = fontChannel;
  fontChannel.SetWeight(wxFONTWEIGHT_BOLD);
  const CChannelColors *pChannelColors = NULL;
  int nCurrentColCount = GetNumberCols();
  int i;
  int j;
  if(nCurrentColCount < m_nCOL_COUNT)
  {
    InsertCols(m_nCOL_CHANNEL_START, m_nCOL_COUNT - nCurrentColCount);
    _UpdateReadOnly();
  }
  else if(nCurrentColCount > m_nCOL_COUNT)
  {
    DeleteCols(m_nCOL_CHANNEL_START,nCurrentColCount - m_nCOL_COUNT);
  }
  InitValidators();
  SetDefaultCellValidator(
    new nwxGridCellUIntRangeValidator(
      mainApp::RFU_MIN_ENTER,mainApp::RFU_MAX_ENTER,true));
  nwxGridCellUIntRangeValidator *pVreqd =
    new nwxGridCellUIntRangeValidator(
      mainApp::RFU_MIN_ENTER,mainApp::RFU_MAX_ENTER,false); // does not allow empty
  SetCellValidator(pVreqd,ROW_RFU_MIN,m_nCOL_SAMPLE);
  SetCellValidator(pVreqd,ROW_RFU_MIN,m_nCOL_ILS);
  SetCellValidator(pVreqd,ROW_RFU_MIN,m_nCOL_LADDER);

  EnableDragColSize(false);
  EnableDragRowSize(false);
  SetDefaultCellAlignment(wxALIGN_RIGHT,wxALIGN_CENTRE);
  for(i = 0; i < ROW_COUNT; i++)
  {
    for(j = 0; j < m_nCOL_COUNT; j++)
    {
      SetCellValue(i,j,"00000000"); // used for size
      if(_DisabledCell(i,j))
      {
        SetCellBackgroundColour(i,j,GetGridLineColour());
      }
    }
  }
  SetDefaultEditor(new wxGridCellFloatEditor(1,0));
  SetColLabelValue(m_nCOL_SAMPLE,"Sample");
  SetColLabelValue(m_nCOL_LADDER,"Ladder");
  SetColLabelValue(m_nCOL_ILS,"   ILS   ");
  SetRowLabelValue(ROW_RFU_MIN,"Analysis Threshold (RFU)");
  SetRowLabelValue(ROW_RFU_INTERLOCUS,"Min. Interlocus RFU");
  SetRowLabelValue(ROW_RFU_MAX,"Max. RFU");
  SetRowLabelValue(ROW_DETECTION,"Detection Threshold (RFU)");
  SetRowLabelAlignment(wxALIGN_LEFT, wxALIGN_CENTRE);
  SetMargins(0,0);
  ChannelNumberIterator itrChannelCol;
  int nCol;
  const wxChar *psDye = NULL;
  wxString sLabel;
  for(itrChannelCol = m_vnChannelNumbers.begin(), 
          nCol = m_nCOL_CHANNEL_START;
    itrChannelCol != m_vnChannelNumbers.end();
    ++itrChannelCol, ++nCol)
  {
    if(m_pKitColors != NULL)
    {
      pChannelColors = m_pKitColors->GetColorChannel(*itrChannelCol);
      psDye = (pChannelColors == NULL) ? NULL : (const wxChar *) pChannelColors->GetDyeName();
    }
    CGridLocusColumns::FORMAT_CHANNEL_DYE(&sLabel,*itrChannelCol,psDye);
    SetColLabelValue(nCol,sLabel);
    if(pChannelColors != NULL)
    {
      _SetupChannelColumn(nCol,pChannelColors->GetColorAnalyzed(),fontChannel);
    }
    else
    {
      _SetupDefaultChannelColumn(nCol);
    }
  }
  nwxGrid::UpdateLabelSizes(this);
  AutoSize();
  _DisableUnused();
}