void CatheterCmdGrid::createCatheterCmdGrid() {
    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 CVIEW_Table_Control::Update_Selection(void)
{
	if( GetBatchCount() == 0 )
	{
		BeginBatch();

		if( m_pTable->Get_Selection_Count() >= m_pTable->Get_Count() )
		{
			SelectAll();
		}
		else
		{
			ClearSelection();

			if( m_pTable->Get_Selection_Count() > 0 )
			{
				#pragma omp parallel for
				for(int iRecord=0; iRecord<GetNumberRows(); iRecord++)
				{
					if( m_pRecords[iRecord]->is_Selected() )
					{
						SelectRow(iRecord, true);
					}
				}
			}
		}

		EndBatch();

		_Update_Views();

		return( true );
	}

	return( false );
}
void CatheterGrid::SetCommands(const std::vector<CatheterChannelCmdSet>& cmds)
{
    resetDefaultGrid(NROWS_DEFAULT);
	int rowIndex(0);
    for (int i = 0; i < cmds.size(); i++) {
        
		for( int j(0); j < cmds[i].commandList.size(); j++)
		{
			cmdCount++;
			if (rowIndex >= GetNumberRows()) addGridRow(false);
			setGridRowChannel(rowIndex, cmds[i].commandList[j].channel);
			setGridRowcurrentMilliAmp(rowIndex, cmds[i].commandList[j].currentMilliAmp);
			
			if ( j + 1 <  cmds[i].commandList.size())
			{
				rowIndex++;
			}
		}
		setGridRowDelayMS(rowIndex,cmds[i].delayTime);
		rowIndex++;
    }
	// add the blank row
    addGridRow(false);
}
Esempio n. 4
0
void CLayerTypeGrid::ExpandLayerGroup(int groupNameRowIndx)
{
   int rowCnt = GetNumberRows();
   int lastColIndx = GetNumberCols() - 1;

   bool keepGoing = true;
   for (int rowIndx = groupNameRowIndx+1; rowIndx < rowCnt && keepGoing; rowIndx++)
   {
      CString cellText( QuickGetText(lastColIndx, rowIndx) );
      int layerType = atoi(cellText);
      if (layerType < 0)
      {
         keepGoing = false;
      }
      else
      {
         SetRowHeight(rowIndx, m_expandedRowHeight);
      }
   }

   CString groupNameText( QuickGetText(0, groupNameRowIndx) );
   groupNameText.SetAt(0, '-');  // Is now expanded, show operator to collapse.
   QuickSetText(0, groupNameRowIndx, groupNameText);
}
Esempio n. 5
0
void ctlSQLGrid::AutoSizeColumns(bool setAsMin)
{
	wxCoord newSize, oldSize;
	wxCoord maxSize, totalSize = 0, availSize;
	int col, nCols = GetNumberCols();
	int row, nRows = GetNumberRows();
	colMaxSizes.Empty();

	/* We need to check each cell's width to choose best. wxGrid::AutoSizeColumns()
	 * is good, but looping through long result sets gives a noticeable slowdown.
	 * Thus we'll check every first 500 cells for each column.
	 */

	// First pass: auto-size columns
	for (col = 0 ; col < nCols; col++)
	{
		ColKeySizeHashMap::iterator it = colSizes.find(GetColKeyValue(col));
		if (it != colSizes.end()) // Restore user-specified size
		{
			newSize = it->second;
			colMaxSizes.Add(-1);
		}
		else
		{
			wxClientDC dc(GetGridWindow());
			newSize = 0;
			// get cells's width
			for (row = 0 ; row < wxMin(nRows, 500) ; row++)
			{
				wxSize size = GetBestSize(row, col);
				if ( size.x > newSize )
					newSize = size.x;
			}
			// get column's label width
			wxCoord w, h;
			dc.SetFont( GetLabelFont() );
			dc.GetMultiLineTextExtent( GetColLabelValue(col), &w, &h );
			if ( GetColLabelTextOrientation() == wxVERTICAL )
				w = h;

			if ( w > newSize )
				newSize = w;

			if (!newSize)
				newSize = GetRowLabelSize();
			else
				// leave some space around text
				newSize += 6;

			colMaxSizes.Add(newSize);
		}
		SetColSize(col, newSize);
		totalSize += newSize;
	}

	availSize = GetClientSize().GetWidth() - GetRowLabelSize();

	// Second pass: shrink wide columns if exceeded available width
	if (totalSize > availSize)
	{
		// A wide column shouldn't take up more than 50% of the visible space
		maxSize = availSize / 2;
		for (col = 0 ; col < nCols ; col++)
		{
			oldSize = GetColSize(col);
			// Is too wide and no user-specified size
			if (oldSize > maxSize && !(col < (int)colMaxSizes.GetCount() && colMaxSizes[col] == -1))
			{
				totalSize -= oldSize;
				/* Shrink wide column to maxSize.
				 * If the rest of the columns are short, make sure to use all the remaining space,
				 *   but no more than oldSize (which is enough according to first pass)
				 */
				newSize = wxMin(oldSize, wxMax(maxSize, availSize - totalSize));
				SetColSize(col, newSize);
				totalSize += newSize;
			}
		}
	}
}
Esempio n. 6
0
void ctlSQLGrid::OnLabelDoubleClick(wxGridEvent &event)
{
	int maxHeight, maxWidth;
	GetClientSize(&maxWidth, &maxHeight);
	int row = event.GetRow();
	int col = event.GetCol();

	int extent, extentWant = 0;

	if (row >= 0)
	{
		for (col = 0 ; col < GetNumberCols() ; col++)
		{
			extent = GetBestSize(row, col).GetHeight();
			if (extent > extentWant)
				extentWant = extent;
		}

		extentWant += EXTRAEXTENT_HEIGHT;
		extentWant = wxMax(extentWant, GetRowMinimalAcceptableHeight());
		extentWant = wxMin(extentWant, maxHeight * 3 / 4);
		int currentHeight = GetRowHeight(row);

		if (currentHeight >= maxHeight * 3 / 4 || currentHeight == extentWant)
			extentWant = GetRowMinimalAcceptableHeight();
		else if (currentHeight < maxHeight / 4)
			extentWant = wxMin(maxHeight / 4, extentWant);
		else if (currentHeight < maxHeight / 2)
			extentWant = wxMin(maxHeight / 2, extentWant);
		else if (currentHeight < maxHeight * 3 / 4)
			extentWant = wxMin(maxHeight * 3 / 4, extentWant);

		if (extentWant != currentHeight)
		{
			BeginBatch();
			if(IsCellEditControlShown())
			{
				HideCellEditControl();
				SaveEditControlValue();
			}

			SetRowHeight(row, extentWant);
			EndBatch();
		}
	}
	else if (col >= 0)
	{
		// Holding Ctrl or Meta switches back to automatic column's sizing
		if (event.ControlDown() || event.CmdDown())
		{
			colSizes.erase(GetColKeyValue(col));
			BeginBatch();
			if(IsCellEditControlShown())
			{
				HideCellEditControl();
				SaveEditControlValue();
			}
			AutoSizeColumn(col, false);
			EndBatch();
		}
		else // toggle between some predefined sizes
		{

			if (col < (int)colMaxSizes.GetCount() && colMaxSizes[col] >= 0)
				extentWant = colMaxSizes[col];
			else
			{
				for (row = 0 ; row < GetNumberRows() ; row++)
				{
					if (CheckRowPresent(row))
					{
						extent = GetBestSize(row, col).GetWidth();
						if (extent > extentWant)
							extentWant = extent;
					}
				}
			}

			extentWant += EXTRAEXTENT_WIDTH;
			extentWant = wxMax(extentWant, GetColMinimalAcceptableWidth());
			extentWant = wxMin(extentWant, maxWidth * 3 / 4);
			int currentWidth = GetColumnWidth(col);

			if (currentWidth >= maxWidth * 3 / 4 || currentWidth == extentWant)
				extentWant = GetColMinimalAcceptableWidth();
			else if (currentWidth < maxWidth / 4)
				extentWant = wxMin(maxWidth / 4, extentWant);
			else if (currentWidth < maxWidth / 2)
				extentWant = wxMin(maxWidth / 2, extentWant);
			else if (currentWidth < maxWidth * 3 / 4)
				extentWant = wxMin(maxWidth * 3 / 4, extentWant);

			if (extentWant != currentWidth)
			{
				BeginBatch();
				if(IsCellEditControlShown())
				{
					HideCellEditControl();
					SaveEditControlValue();
				}
				SetColumnWidth(col, extentWant);
				EndBatch();
				colSizes[GetColKeyValue(col)] = extentWant;
			}
		}
	}
}
Esempio n. 7
0
int ctlSQLGrid::Copy()
{
	wxString str;
	int copied = 0;
	size_t i;



	if (GetSelectedRows().GetCount())
	{
		AppendColumnHeader(str, 0, (GetNumberCols() - 1));

		wxArrayInt rows = GetSelectedRows();

		for (i = 0 ; i < rows.GetCount() ; i++)
		{
			str.Append(GetExportLine(rows.Item(i)));

			if (rows.GetCount() > 1)
				str.Append(END_OF_LINE);
		}

		copied = rows.GetCount();
	}
	else if (GetSelectedCols().GetCount())
	{
		wxArrayInt cols = GetSelectedCols();
		size_t numRows = GetNumberRows();

		AppendColumnHeader(str, cols);

		for (i = 0 ; i < numRows ; i++)
		{
			str.Append(GetExportLine(i, cols));

			if (numRows > 1)
				str.Append(END_OF_LINE);
		}

		copied = numRows;
	}
	else if (GetSelectionBlockTopLeft().GetCount() > 0 &&
	         GetSelectionBlockBottomRight().GetCount() > 0)
	{
		unsigned int x1, x2, y1, y2;

		x1 = GetSelectionBlockTopLeft()[0].GetCol();
		x2 = GetSelectionBlockBottomRight()[0].GetCol();
		y1 = GetSelectionBlockTopLeft()[0].GetRow();
		y2 = GetSelectionBlockBottomRight()[0].GetRow();

		AppendColumnHeader(str, x1, x2);

		for (i = y1; i <= y2; i++)
		{
			str.Append(GetExportLine(i, x1, x2));

			if (y2 > y1)
				str.Append(END_OF_LINE);
		}

		copied = y2 - y1 + 1;
	}
	else
	{
		int row, col;

		row = GetGridCursorRow();
		col = GetGridCursorCol();

		AppendColumnHeader(str, col, col);

		str.Append(GetExportLine(row, col, col));
		copied = 1;
	}

	if (copied && wxTheClipboard->Open())
	{
		wxTheClipboard->SetData(new wxTextDataObject(str));
		wxTheClipboard->Close();
	}
	else
	{
		copied = 0;
	}

	return copied;
}
Esempio n. 8
0
bool CGridAllelePosCtrl::TransferDataFromWindow()
{
  bool bRtn = (m_pData != NULL);
  if(bRtn)
  {
    wxString sName;
    wxString sFileString;
    wxString sAlleles;
    vector<wxString> vsAlleles;
    vector<CLabLocus *> vpNewLoci;
    vector<CLabPositiveControl *> vpNewPosCtrl;

    vector<CLabLocus *> *pvpLoci(NULL);
    CLabPositiveControl *pCtrl;
    CLabLocus *pLocus;

    int nRows = GetNumberRows();
    int nRow;
    int nCols = GetNumberCols();
    int nCol;

    for(nRow = 1; nRow < nRows; nRow++)
    {
      sName = GetCellValueTrimmed(nRow,0);
      if(!sName.IsEmpty())
      {
        sFileString = GetCellValueTrimmed(nRow,1);
        pCtrl = NULL;
        for(nCol = 2; nCol < nCols; nCol++)
        {
          sAlleles = GetCellValueTrimmed(nRow,nCol);
          if(!sAlleles.IsEmpty())
          {
            if(CLabLocus::BuildList(
              sAlleles,&vsAlleles,nCol == m_nAmelColumn))
            {
              if(pCtrl == NULL)
              {
                pCtrl = _GetPosCtrl();
                pCtrl->SetName(sName);
                pCtrl->SetFileNameString(sFileString);
                vpNewPosCtrl.push_back(pCtrl);
                pvpLoci = pCtrl->Get();
                vpNewLoci.clear();
              }
              pLocus = _NewLabLocus(pvpLoci,GetColLabelValue(nCol)); // recycle loci or create new
              pLocus->SetAlleles(vsAlleles);
              vpNewLoci.push_back(pLocus);
            }
          }
        } //end nCol loop
        if(pCtrl != NULL)
        {
          // clean up remaining old loci in this positive control
          // if any
          vectorptr<CLabLocus>::cleanup(pvpLoci);
          // copy the new loci to the new positive control
          (*pvpLoci) = vpNewLoci; // copy pointers
          vpNewLoci.clear();
        }
      }
    } // end nRow loop
    m_pData->SetPositiveControls(&vpNewPosCtrl);
  }
  return bRtn;
}
void CatheterCmdGrid::appendCommandRow() {
    cmd_count++;
    if (cmd_count >= GetNumberRows())
        AppendRows(1);
    setRowReadOnly(cmd_count - 1, false);
}
//---------------------------------------------------------
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 );
}
Esempio n. 11
0
bool DefaultDetail::IsValid()
{
#if 1
    wxColour REQUIRED_COL = wxColour(230, 250, 255);
    wxColour VALID_COL = wxColour(255, 255, 255);
    wxColour NOT_VALID_COL = wxColour(255, 255, 135);

    wxGrid* grid = GetView();

    int maxrows = GetNumberRows();
    int maxcols = GetNumberCols();
    bool m_valid = true;
    int error_count = 0;

    int first_error_row = -1;
    int first_error_col = -1;

    wxProgressDialog dialog(VALIDATING_DETAIL_PROCESS_TITLE,
                            VALIDATING_DETAIL_PROCESS_MESSAGES,
                            maxrows, 
                            GetView(),
                            wxPD_AUTO_HIDE |
                            wxPD_APP_MODAL );
    for (int i=0; i<maxrows; i++) {

//------ dialog update
        if ( i % (maxrows/20 + 1) == 0 ) {
            dialog.Update(i);
        }

        for (int j=0; j<maxcols; j++) {
            ElementDescriptor* ed = GetColumnDescriptor(j);
            wxString value = GetValue(i, j);                

// ----- convert to Upper Case
            if ( ed->GetType().Cmp("text") == 0 ) {
                SetValue(i, j, value.Upper());
            }

//------ remove last <CR> or <LF>
            if ( (GetValue(i, j).Last() == '\r') || (GetValue(i, j).Last() == '\n')) {
                SetValue(i, j, GetValue(i, j).RemoveLast());
            }

//------ parsing dates
            if ( (ed->GetType().Cmp("date")==0)||(ed->GetType().Cmp("longdate")==0) ) {
                wxDateTime date;
                if ( value.Cmp("  /  /    ")==0 ) {
                    grid->SetCellValue(i, j, "");
                } else if ( date.ParseFormat(value, "%m/%d/%Y") ) {
                    grid->SetCellValue(i, j, date.Format("%m/%d/%Y"));
                };
            }

//------ Verification
            if ( !ed->IsValid( GetValue(i, j) ) ) {
                grid->SetCellBackgroundColour(i, j, NOT_VALID_COL);
                m_valid = false;
                error_count++;
                if ( error_count > MAX_ERRORS ) {
                    break;
                }
            } else {
                if ( grid->GetCellBackgroundColour(i, j) == NOT_VALID_COL ) {
                    if ( ed->IsRequired() ) {
                        grid->SetCellBackgroundColour(i, j, REQUIRED_COL);
                    } else {
                        grid->SetCellBackgroundColour(i, j, VALID_COL);
                    }
                }
            }

//------ goto first error
            if ( (error_count == 1) && (first_error_row == -1) && (first_error_col == -1)) {
                first_error_row = i;
                first_error_row = j;
                grid->SetGridCursor(i, j);
                grid->MakeCellVisible(i, j);
            }
        }
        if ( error_count > MAX_ERRORS ) {
            break;
        }
    }
    dialog.Update(maxrows);
    grid->ForceRefresh();
    if ( error_count > MAX_ERRORS ) {
        wxMessageBox(VALIDATING_DETAIL_TOO_MUCH_ERRORS, 
                        VALIDATING_DETAIL_TOO_MUCH_ERRORS_TITLE, 
                        wxOK | wxCENTRE | wxICON_EXCLAMATION );
    }
    return m_valid;
#else
    return true;
#endif
};
Esempio n. 12
0
bool wxPropertyList::UpdatePropertyItem(wxPropertyItem *pItem, int row)
{
    wxCHECK(row < GetNumberRows(), false);

    // reflect the property's state to match the grid row

    SetReadOnly(row, 0);
    // TODO: Make this a UpdatePropItem where ADVANCED, and new edit values are reflected
    SetCellValue(row,0, pItem->GetPropName());
    
    // boolean renderer
    if(pItem->GetItemType() == wxPropertyList::CHECKBOX)
    {
        // translate ON or TRUE (case insensitive to a checkbox)
        if(pItem->GetCurValue().IsSameAs(wxT("ON"), false) ||
           pItem->GetCurValue().IsSameAs(wxT("TRUE"), false))
            SetCellValue(row, 1, wxT("1"));
        else
            SetCellValue(row, 1, wxT("0"));
    }
    else
    {
        // for normal path values, give bold in cell when
        // the NOTFOUND is present, for emphasis
        wxString str = pItem->GetPropName() + wxT("-NOTFOUND");     
        if(pItem->GetCurValue().IsSameAs(str))
        {
            wxFont fnt = GetCellFont(row, 0);       
            fnt.SetWeight(wxFONTWEIGHT_BOLD);
            SetCellFont(row, 1, fnt);
        }
        else
            SetCellFont(row, 1, GetCellFont(row, 0));

        SetCellValue(row,1, pItem->GetCurValue());
    }

    if(pItem->GetCurValue().IsSameAs("IGNORE"))
    {
        // ignored cell is completely dimmed
        wxColour col(192,192,192);
        SetCellTextColour(row, 1, col);
    }
    else
    {
        // we colour paths blue, filenames green, all else black
        wxColour col;
        if(pItem->IsDirPath())
            col.Set(0,0,255);
        else if(pItem->IsFilePath())
            col.Set(0,128,0);
        else
            col = GetCellTextColour(row, 0);

        SetCellTextColour(row, 1, col);
    }

    if(pItem->GetNewValue())
    {
        // new cell is red
        wxColour col(255,100,100);
        SetCellBackgroundColour(row, 0, col);
    }
    else
    {
        // old cell is grey
        wxColour col(192, 192, 192);
        SetCellBackgroundColour(row, 0, col);
    }

    return true;
}
Esempio n. 13
0
bool CGridAllele::_TransferDataToWindow1()
{
#ifdef __WXDEBUG__
  set<wxString,nwxStringLessNoCase> ssInvalid;
  set<wxString,nwxStringLessNoCase>::iterator itrInvalid;
#endif
  CLabLocusCollection::iterator itr;
  CLabLocus *pLocus;
  bool bRtn = true;
  int nRowCount = GetNumberRows();
  int nCol;
  int nAlleles;
  int i;
  int nNeeded;
  for(itr = m_pData->begin();
    itr != m_pData->end();
    ++itr)
  {
    pLocus = *itr;
    const wxString &sName(pLocus->GetName());
    nCol = _GetLocusColumn(sName);
    if(nCol < 0)
    {
#ifdef __WXDEBUG__
      ssInvalid.insert(sName);
#endif
      mainApp::LogMessageV(
        wxS("CGridAllele::TransferDataToWindow1() invalid locus %ls"),
        sName.wc_str());
    }
    else
    {
      int &nRow = m_vnLastRowUsed[nCol];
      nAlleles = (int) pLocus->GetAlleleCount();
      nNeeded = nRow + nAlleles;
      if(nNeeded >= nRowCount)
      {
        nRowCount = nNeeded + 3;
        nwxGrid::SetRowCount(this,nRowCount);
      }
      for(i = 0; i < nAlleles; i++)
      {
        nRow++;
        SetCellValue(nRow,nCol,pLocus->GetAllele(i));
      }
    }
  }
#ifdef __WXDEBUG__
  if(ssInvalid.size())
  {
    wxString sError;
    sError.reserve(ssInvalid.size() << 4);
    sError = "Invalid locus:\n";
    for(itrInvalid = ssInvalid.begin();
      itrInvalid != ssInvalid.end();
      ++itrInvalid)
    {
      sError.Append("\n");
      sError.Append(*itrInvalid);
    }
    wxASSERT_MSG(0,sError);
  }
#endif
  return bRtn;
}
Esempio n. 14
0
bool CGridAllelePosCtrl::TransferDataToWindow()
{
  bool bRtn = (m_pData != NULL);
  if(bRtn)
  {
    wxString sAlleles;
#ifdef __WXDEBUG__
    wxString sErrors;
#endif
    vector<CLabPositiveControl *>::iterator itrCtrl;
    vector<CLabLocus *>::iterator itrLocus;
    vector<CLabPositiveControl *> *vpCtrl = m_pData->Get();
    vector<CLabLocus *> *vpLoci;

    CLabPositiveControl *pCtrl;
    int nMinSize = (int)vpCtrl->size() + 2;
    int nRowCount = GetNumberRows();
    int nRow = 1;
    int nCol;

    if(nMinSize > nRowCount)
    {
      SetRowCount(nMinSize);
      nRowCount = nMinSize;
    }
    Clear();
    nRow = 1;
    for(itrCtrl = vpCtrl->begin(); itrCtrl != vpCtrl->end(); ++itrCtrl)
    {
      pCtrl = *itrCtrl;
      vpLoci = (*itrCtrl)->Get();
      if((vpLoci != NULL) && !vpLoci->empty())
      {
        _SetRowEnabled(nRow,true);
        SetCellValue(nRow,0,pCtrl->GetName());
        SetCellValue(nRow,1,pCtrl->GetFileNameString());
        for(itrLocus = vpLoci->begin();
          itrLocus != vpLoci->end();
          ++itrLocus)
        {
          const wxString &sName((*itrLocus)->GetName());
          nCol = _GetLocusColumn(sName);
          if(nCol > 0)
          {
            sAlleles = (*itrLocus)->FormatAlleleList();
            SetCellValue(nRow,nCol,sAlleles);
          }
#ifdef __WXDEBUG__
          else
          {
            sErrors.Append("\nCannot find locus column: ");
            sErrors.Append(sName);
          }
#endif
        }
        nRow++;
      }
    }
#ifdef __WXDEBUG__
    wxASSERT_MSG(sErrors.IsEmpty(),sErrors);
#endif
    
    _SetRowNextControl(nRow);
    for(++nRow; nRow < nRowCount; ++nRow)
    {
      _SetRowEnabled(nRow,false);
    }
  }
  return bRtn;
}
Esempio n. 15
0
/// Clear attributes
bool ctPropertyEditorGrid::ClearAttributes()
{
    if (GetNumberRows() > 0)
        DeleteRows(0, GetNumberRows());
    return true;
}
bool CatheterGrid::isGridRowNumValid(int row) {
    return (row < GetNumberRows() && !IsReadOnly(row, 0));
}
Esempio n. 17
0
void CRealTimeGrid::OnTimer(UINT nIDEvent) 
{
	CUGCell cell, enableCell;
	CString string;
	int		row,random;
	double	oldValue;
	double	newValue;
	long	direction;
	
	int numRows = (int)GetNumberRows();

	//update the progress bars
	for ( row=0; row < numRows; row++)
	{
		GetCellIndirect( 5, row, &enableCell );
		if( enableCell.GetBool() == FALSE )
			continue;
		
		//get the old info
		GetCell(0,row,&cell);
				
		oldValue = cell.GetNumber();
		direction = cell.GetCellTypeEx();

		//get the random number
		random = rand() % 7;

		//move the current position in the same direction
		if (random < 6){
			if (direction == CT_NEGATIVE){
				newValue = oldValue  - random;
				if(newValue < 0){
					newValue = 0;
					cell.SetCellTypeEx(CT_POSITIVE);		
				}
			}
			else{
				newValue = oldValue  + random;
				if(newValue >100){
					newValue = 100;
					cell.SetCellTypeEx(CT_NEGATIVE);
				}
			}

			//update the cell	
			cell.SetNumber(newValue);
			SetCell(0,row,&cell);
			QuickRedrawCell(0,row);

			//set the alert status
			GetCell(3,row,&cell);

			// turn off themes for these cells, to show the coloured backgrounds.
			cell.UseThemes(false);
			cell.GetText(&string);
			if( newValue > 90 )// && string != _T( "Alert" ) )
			{
				cell.SetBackColor(RGB(255,0,0));
				cell.SetTextColor(RGB(255,255,255));
				cell.SetText( _T( "Ahhhhhhh!" ) );
				SetCell( 3, row, &cell );
				QuickRedrawCell( 3, row );
			} 
			else if( newValue <= 90 && newValue >= 50 ) //string == "Alert"){
			{
				cell.SetBackColor( RGB( 200, 200, 0 ) );
				cell.SetTextColor( RGB( 0, 0, 0 ) );
				cell.SetText( _T( "Uh-oh!" ) );
				SetCell( 3, row, &cell );
				QuickRedrawCell( 3, row );
			}	
			else
			{
				cell.SetBackColor(RGB(255,255,255));
				cell.SetTextColor(RGB(0,0,0));
				cell.SetText( _T( "Okay" ) );
				SetCell( 3, row, &cell );
				QuickRedrawCell( 3, row );
			}
		}
		//reverse directions
		else{
			if (direction == CT_NEGATIVE)
				direction = CT_POSITIVE;
			else
				direction = CT_NEGATIVE;
			cell.SetCellTypeEx(direction);
			SetCell(0,row,&cell);
		}
	}
	
	CUGCtrl::OnTimer(nIDEvent);
}
void CatheterGrid::addGridRow(bool readOnly) {
    AppendRows(1);
    formatDefaultRow(GetNumberRows() - 1);
    setRowReadOnly(GetNumberRows() - 1, readOnly);
}
Esempio n. 19
0
void Grid::OnKeyDown(wxKeyEvent &event)
{
    switch (event.GetKeyCode())
    {
    case WXK_LEFT:
    case WXK_RIGHT:
    {
        int rows = GetNumberRows();
        int cols = GetNumberCols();
        int crow = GetGridCursorRow();
        int ccol = GetGridCursorCol();

        if (event.GetKeyCode() == WXK_LEFT) {
            if (crow == 0 && ccol == 0) {
                // do nothing
            }
            else if (ccol == 0) {
                SetGridCursor(crow - 1, cols - 1);
            }
            else {
                SetGridCursor(crow, ccol - 1);
            }
        }
        else {
            if (crow == rows - 1 && ccol == cols - 1) {
                // do nothing
            }
            else if (ccol == cols - 1) {
                SetGridCursor(crow + 1, 0);
            }
            else {
                SetGridCursor(crow, ccol + 1);
            }
        }

#if wxUSE_ACCESSIBILITY
        // Make sure the NEW cell is made available to the screen reader
        mAx->SetCurrentCell(GetGridCursorRow(), GetGridCursorCol());
#endif
    }
    break;

    case WXK_TAB:
    {
        int rows = GetNumberRows();
        int cols = GetNumberCols();
        int crow = GetGridCursorRow();
        int ccol = GetGridCursorCol();

        if (event.ControlDown()) {
            int flags = wxNavigationKeyEvent::FromTab |
                        ( event.ShiftDown() ?
                          wxNavigationKeyEvent::IsBackward :
                          wxNavigationKeyEvent::IsForward );
            Navigate(flags);
            return;
        }
        else if (event.ShiftDown()) {
            if (crow == 0 && ccol == 0) {
                Navigate(wxNavigationKeyEvent::FromTab | wxNavigationKeyEvent::IsBackward);
                return;
            }
            else if (ccol == 0) {
                SetGridCursor(crow - 1, cols - 1);
            }
            else {
                SetGridCursor(crow, ccol - 1);
            }
        }
        else {
            if (crow == rows - 1 && ccol == cols - 1) {
                Navigate(wxNavigationKeyEvent::FromTab | wxNavigationKeyEvent::IsForward);
                return;
            }
            else if (ccol == cols - 1) {
                SetGridCursor(crow + 1, 0);
            }
            else {
                SetGridCursor(crow, ccol + 1);
            }
        }
        MakeCellVisible(GetGridCursorRow(), GetGridCursorCol());

#if wxUSE_ACCESSIBILITY
        // Make sure the NEW cell is made available to the screen reader
        mAx->SetCurrentCell(GetGridCursorRow(), GetGridCursorCol());
#endif
    }
    break;

    case WXK_RETURN:
    case WXK_NUMPAD_ENTER:
    {
        if (!IsCellEditControlShown()) {
            wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
            wxWindow *def = tlw->GetDefaultItem();
            if (def && def->IsEnabled()) {
                wxCommandEvent cevent(wxEVT_COMMAND_BUTTON_CLICKED,
                                      def->GetId());
                GetParent()->GetEventHandler()->ProcessEvent(cevent);
            }
        }
        else {
            wxGrid::OnKeyDown(event);

            // This looks strange, but what it does is selects the cell when
            // enter is pressed after editing.  Without it, Jaws and Window-Eyes
            // do not speak the NEW cell contents (the one below the edited one).
            SetGridCursor(GetGridCursorRow(), GetGridCursorCol());
        }
        break;
    }

    default:
        wxGrid::OnKeyDown(event);
        break;
    }
}
Esempio n. 20
0
void ctlSQLGrid::OnLabelDoubleClick(wxGridEvent &event)
{
	int maxHeight, maxWidth;
	GetClientSize(&maxWidth, &maxHeight);
	int row = event.GetRow();
	int col = event.GetCol();

	int extent, extentWant = 0;

	if (row >= 0)
	{
		for (col = 0 ; col < GetNumberCols() ; col++)
		{
			extent = GetBestSize(row, col).GetHeight();
			if (extent > extentWant)
				extentWant = extent;
		}

		extentWant += EXTRAEXTENT_HEIGHT;
		extentWant = wxMax(extentWant, GetRowMinimalAcceptableHeight());
		extentWant = wxMin(extentWant, maxHeight * 3 / 4);
		int currentHeight = GetRowHeight(row);

		if (currentHeight >= maxHeight * 3 / 4 || currentHeight == extentWant)
			extentWant = GetRowMinimalAcceptableHeight();
		else if (currentHeight < maxHeight / 4)
			extentWant = wxMin(maxHeight / 4, extentWant);
		else if (currentHeight < maxHeight / 2)
			extentWant = wxMin(maxHeight / 2, extentWant);
		else if (currentHeight < maxHeight * 3 / 4)
			extentWant = wxMin(maxHeight * 3 / 4, extentWant);

		if (extentWant != currentHeight)
		{
			BeginBatch();
			if(IsCellEditControlShown())
			{
				HideCellEditControl();
				SaveEditControlValue();
			}

			SetRowHeight(row, extentWant);
			EndBatch();
		}
	}
	else if (col >= 0)
	{
		for (row = 0 ; row < GetNumberRows() ; row++)
		{
			if (CheckRowPresent(row))
			{
				extent = GetBestSize(row, col).GetWidth();
				if (extent > extentWant)
					extentWant = extent;
			}
		}

		extentWant += EXTRAEXTENT_WIDTH;
		extentWant = wxMax(extentWant, GetColMinimalAcceptableWidth());
		extentWant = wxMin(extentWant, maxWidth * 3 / 4);
		int currentWidth = GetColumnWidth(col);

		if (currentWidth >= maxWidth * 3 / 4 || currentWidth == extentWant)
			extentWant = GetColMinimalAcceptableWidth();
		else if (currentWidth < maxWidth / 4)
			extentWant = wxMin(maxWidth / 4, extentWant);
		else if (currentWidth < maxWidth / 2)
			extentWant = wxMin(maxWidth / 2, extentWant);
		else if (currentWidth < maxWidth * 3 / 4)
			extentWant = wxMin(maxWidth * 3 / 4, extentWant);

		if (extentWant != currentWidth)
		{
			BeginBatch();
			if(IsCellEditControlShown())
			{
				HideCellEditControl();
				SaveEditControlValue();
			}
			SetColumnWidth(col, extentWant);
			EndBatch();
		}
	}
}
Esempio n. 21
0
void ctlSQLResult::DisplayData(bool single)
{
	if (!thread || !thread->DataValid())
		return;

	if (thread->ReturnCode() != PGRES_TUPLES_OK)
		return;

	rowcountSuppressed = single;
	Freeze();

	/*
	 * Resize and repopulate by informing it to delete all the rows and
	 * columns, then append the correct number of them. Probably is a
	 * better way to do this.
	 */
	wxGridTableMessage *msg;
	sqlResultTable *table = (sqlResultTable *)GetTable();
	msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, GetNumberRows());
	ProcessTableMessage(*msg);
	delete msg;
	msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_COLS_DELETED, 0, GetNumberCols());
	ProcessTableMessage(*msg);
	delete msg;
	msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, NumRows());
	ProcessTableMessage(*msg);
	delete msg;
	msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_COLS_APPENDED, thread->DataSet()->NumCols());
	ProcessTableMessage(*msg);
	delete msg;

	if (single)
	{
		int w, h;
		if (colSizes.GetCount() == 1)
			w = colSizes.Item(0);
		else
			GetSize(&w, &h);

		colNames.Add(thread->DataSet()->ColName(0));
		colTypes.Add(wxT(""));
		colTypClasses.Add(0L);

		SetColSize(0, w);
	}
	else
	{
		wxString colName, colType;
		int w;

		size_t hdrIndex = 0;
		long col, nCols = thread->DataSet()->NumCols();

		for (col = 0 ; col < nCols ; col++)
		{
			colName = thread->DataSet()->ColName(col);
			colType = thread->DataSet()->ColFullType(col);
			colNames.Add(colName);
			colTypes.Add(colType);
			colTypClasses.Add(thread->DataSet()->ColTypClass(col));

			wxString colHeader = colName + wxT("\n") + colType;

			if (hdrIndex < colHeaders.GetCount() && colHeaders.Item(hdrIndex) == colHeader)
				w = colSizes.Item(hdrIndex++);
			else
				w = -1;

			SetColSize(col, w);
			if (thread->DataSet()->ColTypClass(col) == PGTYPCLASS_NUMERIC)
			{
				/*
				 * For numeric columns, set alignment to right.
				 */
				wxGridCellAttr *attr = new wxGridCellAttr();
				attr->SetAlignment(wxALIGN_RIGHT, wxALIGN_TOP);
				SetColAttr(col, attr);
			}
		}
	}
	Thaw();
}
Esempio n. 22
0
bool wex::grid::find_next(const std::string& text, bool forward)
{
  if (text.empty())
  {
    return false;
  }

  static bool recursive = false;
  static int start_row;
  static int end_row;
  static int init_row;
  static int start_col;
  static int end_col;

  wxString text_use = text;

  if (!find_replace_data::get()->match_case())
  {
    text_use.MakeUpper();
  }

  wxGridCellCoords grid_cursor(GetGridCursorRow(), GetGridCursorCol());

  if (forward)
  {
    init_row = 0;

    if (recursive)
    {
      start_row = init_row;
      start_col = 0;
    }
    else
    {
      start_row = grid_cursor.GetRow() + 1;
      start_col = grid_cursor.GetCol();
    }

    end_row = GetNumberRows();
    end_col = GetNumberCols();
  }
  else
  {
    init_row = GetNumberRows() - 1;

    if (recursive)
    {
      start_row = init_row;
      start_col = GetNumberCols() - 1;
    }
    else
    {
      start_row = grid_cursor.GetRow() - 1;
      start_col = grid_cursor.GetCol();
    }

    end_row = -1;
    end_col = -1;
  }
  
  if (start_col == -1)
  {
    start_col = 0;
  }

  if (start_row == -1)
  {
    start_row = 0;
  }
  
  wxGridCellCoords match;

  for (int j = start_col; j != end_col && !match; (forward ? j++: j--))
  {
    for (int i = (j == start_col ? start_row: init_row);
         i != end_row && !match;
         (forward ? i++: i--))
    {
      wxString text = GetCellValue(i, j);

      if (!find_replace_data::get()->match_case())
      {
        text.MakeUpper();
      }

      if (find_replace_data::get()->match_word())
      {
        if (text == text_use)
        {
          match = wxGridCellCoords(i, j);
        }
      }
      else
      {
        if (text.Contains(text_use))
        {
          match = wxGridCellCoords(i, j);
        }
      }
    }
  }

  if (!match)
  {
    bool result = false;
    
    frame::statustext(
      get_find_result(text, forward, recursive), std::string());
    
    if (!recursive)
    {
      recursive = true;
      result = find_next(text, forward);
      recursive = false;
    }
    
    return result;
  }
  else
  {
    recursive = false;
    SetGridCursor(match.GetRow(), match.GetCol());
    MakeCellVisible(match); // though docs say this isn't necessary, it is
    return true;
  }
}
//---------------------------------------------------------
bool CVIEW_Table_Control::_Set_Records(bool bSelection_To_Top)
{
	BeginBatch();

	//-----------------------------------------------------
	if( m_bSelOnly && m_pTable->Get_Selection_Count() <= 0 )
	{
		m_bSelOnly	= false;
	}

	int	Difference, nRecords	= m_bSelOnly ? m_pTable->Get_Selection_Count() : m_pTable->Get_Count();

	if( (Difference = nRecords - GetNumberRows()) > 0 )
	{
		AppendRows(Difference);
	}
	else if( Difference < 0 && (Difference = -Difference < GetNumberRows() ? -Difference : GetNumberRows()) > 0 )
	{
		DeleteRows(0, Difference);
	}

	m_pRecords	= (CSG_Table_Record **)SG_Realloc(m_pRecords, nRecords * sizeof(CSG_Table_Record *));

	ClearSelection();

	//-----------------------------------------------------
	if( m_bSelOnly )
	{
	//	#pragma omp parallel for
		for(int iRecord=0; iRecord<nRecords; iRecord++)
		{
			_Set_Record(iRecord, m_pTable->Get_Selection(iRecord));
		}
	}
	else if( !bSelection_To_Top )
	{
	//	#pragma omp parallel for
		for(int iRecord=0; iRecord<nRecords; iRecord++)
		{
			_Set_Record(iRecord, m_pTable->Get_Record_byIndex(iRecord));
		}
	}
	else // if( bSelection_To_Top && m_pTable->Get_Selection_Count() > 0 )
	{
		for(int iRecord=0, iSel=0, iNoSel=m_pTable->Get_Selection_Count(); iRecord<nRecords && PROGRESSBAR_Set_Position(iRecord, nRecords); iRecord++)
		{
			CSG_Table_Record	*pRecord	= m_pTable->Get_Record_byIndex(iRecord);

			if( pRecord->is_Selected() )
			{
				_Set_Record(iSel  ++, pRecord);
			}
			else
			{
				_Set_Record(iNoSel++, pRecord);
			}
		}

		PROCESS_Set_Okay();
	}

	//-----------------------------------------------------
	EndBatch();

	_Update_Views();

	return( true );
}
Esempio n. 24
0
void CGridRFURunBase::_Build()  // called from _SetupKit();
{
  nwxLabelGridBatch x(this);
  ClearAll();  // nwxGrid.h nwxLabelGrid::ClearAll();
  wxFont fontChannel = GetDefaultCellFont();
  wxFont fontLabel = fontChannel;
  fontChannel.SetWeight(wxFONTWEIGHT_BOLD);
  fontLabel.SetStyle(wxFONTSTYLE_ITALIC);
  SetDefaultLabelFont(fontLabel);
  SetDefaultLabelTextColour(wxColour(192, 192, 192));
  const CChannelColors *pChannelColors = NULL;
  int nCurrentRowCount = GetNumberRows();
  int i;
  int j;
  if(nCurrentRowCount < m_nROW_COUNT)
  {
    InsertRows(m_nROW_CHANNEL_START, m_nROW_COUNT - nCurrentRowCount);
    _UpdateReadOnly();
  }
  else if(nCurrentRowCount > m_nROW_COUNT)
  {
    DeleteRows(m_nROW_CHANNEL_START,nCurrentRowCount - m_nROW_COUNT);
  }
  SetDefaultCellValidator(
    new nwxGridCellUIntRangeValidator(
      mainApp::RFU_MIN_ENTER,mainApp::RFU_MAX_ENTER,true));
  EnableDragColSize(false);
  EnableDragRowSize(false);
  SetDefaultCellAlignment(wxALIGN_RIGHT,wxALIGN_CENTRE);
  for(i = 0; i < m_nROW_COUNT; i++)
  {
    for(j = 0; j < COL_COUNT; j++)
    {
      SetCellValue(i,j,"00000000"); // used for size
      if(_DisabledCell(i,j))
      {
        SetCellBackgroundColour(i,j,GetGridLineColour());
      }
    }
  }
  SetDefaultEditor(new wxGridCellFloatEditor(1,0));
  SetRowLabelValue(m_nROW_SAMPLE,"Sample");
  SetRowLabelValue(m_nROW_LADDER,"Ladder");
  SetRowLabelValue(m_nROW_ILS,"   ILS   ");

  SetColLabelValue(COL_ANALYSIS,"Analysis");
  SetColLabelValue(COL_DETECTION,"Detection");
  SetColLabelValue(COL_INTERLOCUS,"Interlocus");
  SetRowLabelAlignment(wxALIGN_LEFT, wxALIGN_CENTRE);
  SetMargins(0,0);
  ChannelNumberIterator itrChannelCol;
  int nRow;
  const wxChar *psDye = NULL;
  wxString sLabel;
  for(itrChannelCol = m_vnChannelNumbers.begin(), 
          nRow = m_nROW_CHANNEL_START;
    itrChannelCol != m_vnChannelNumbers.end();
    ++itrChannelCol, ++nRow)
  {
    if(m_pKitColors != NULL)
    {
      pChannelColors = m_pKitColors->GetColorChannel(*itrChannelCol);
      psDye = (pChannelColors == NULL) ? NULL : (const wxChar *) pChannelColors->GetDyeName();
    }
    CGridLocusColumns::FORMAT_CHANNEL_DYE(&sLabel,*itrChannelCol,psDye);
    SetRowLabelValue(nRow,sLabel);
    if(pChannelColors != NULL)
    {
      _SetupChannelRow(nRow,pChannelColors->GetColorAnalyzed(),fontChannel);
    }
    else
    {
      _SetupDefaultChannelRow(nRow);
    }
  }
  nwxGrid::UpdateLabelSizes(this);
  AutoSize();
  _DisableUnused();
}