Пример #1
0
void wxPropertyList::OnCellChange( wxGridEvent& event )
{
    int row = event.GetRow();

    wxPropertyItem *pItem = GetPropertyItemFromRow(row);
    if(pItem && row != wxNOT_FOUND)
    {
        // write propery back, and set as new
        pItem->SetNewValue(true);
        
        // write back bool
        if(pItem->GetItemType() == CHECKBOX)
        {
            if(GetCellValue(row, 1).IsSameAs("1"))
                pItem->SetCurValue("ON");
            else
                pItem->SetCurValue("OFF");
        }
        else
            pItem->SetCurValue(GetCellValue(row, 1));
    
        UpdatePropertyItem(pItem, row);
        event.Skip();
    }
}
void CBOINCGridCtrl::SaveGridCursorPosition() {
	m_cursorcol = GetGridCursorCol();
	m_cursorrow = GetGridCursorRow();	
	if(m_cursorrow>=0 && m_cursorcol >=0) {
		m_szCursorKey1 = GetCellValue(m_cursorrow,m_pkColumnIndex1);
                if (m_pkColumnIndex2 >= 0) {
                    m_szCursorKey2 = GetCellValue(m_cursorrow,m_pkColumnIndex2);
                }
	}
}
/* save the key values of the currently selected rows for later restore */
void CBOINCGridCtrl::SaveSelection() {
	if(m_pkColumnIndex1>=0) {
		wxArrayInt arrSelRows = GetSelectedRows2();	
		m_arrSelectedKeys1.Empty();
		m_arrSelectedKeys2.Empty();
		for(unsigned int i=0; i< arrSelRows.GetCount();i++) {
			m_arrSelectedKeys1.Add(GetCellValue(arrSelRows[i],m_pkColumnIndex1));
			if (m_pkColumnIndex2 >= 0) {
                            m_arrSelectedKeys2.Add(GetCellValue(arrSelRows[i],m_pkColumnIndex2));
                        } else {
                           m_arrSelectedKeys2.Add(wxEmptyString);
                        }
		}
	}
}
Пример #4
0
void DataGrid::onCellChange(wxGridEvent &event)
{
	long money = 0, moneyI = 0, moneyO = 0;
	int row = event.GetRow();
	int col = event.GetCol();
	struct item *it = dataPosFromRow(row);
	wxString text;
	if (m_data == NULL || row == 0) return;
	if (!(text = GetCellValue(row, IncomeIndex)).IsEmpty()) {
		moneyI = -str_to_money(text);
	}
	if (!(text = GetCellValue(row, OutlayIndex)).IsEmpty()) {
		moneyO = str_to_money(text);
	}
	if (moneyI != 0 && moneyO != 0) {
		wxMessageBox(HaStrings::errDupMoney, HaStrings::appName, wxOK | wxICON_ERROR);
		if (col == IncomeIndex) {
			money = moneyI;
			SetCellValue(row, OutlayIndex, wxT(""));
		} else if (col == OutlayIndex) {
			money = moneyO;
			SetCellValue(row, IncomeIndex, wxT(""));
		}
	} else if (moneyI != 0) {
		money = moneyI;
		SetCellValue(row, OutlayIndex, wxT(""));
	} else {
		money = moneyO;
		SetCellValue(row, IncomeIndex, wxT(""));
	}
	wxString desc = GetCellValue(row, DescIndex);
	desc.Trim(true).Trim(false);
	wxString comment = GetCellValue(row, CommentIndex);
	comment.Trim(true).Trim(false);
	struct string s_desc, s_comment;
	string_fill_slice(&s_desc, desc, '\0');
	string_fill_slice(&s_comment, comment, '\0');
	if (item_set(it, money, &s_desc, &s_comment) == NULL) throw std::bad_alloc();
	m_data->setModified();
	if (col == IncomeIndex || col == OutlayIndex) {
		updateBalanceAndTotal();
	}
	if (is_dummy_item(it)) clearRow(row);
	wxCommandEvent ev(wxEVT_RESIZE_COL, GetId());
	ev.SetEventObject(this);
	ev.SetInt(col);
	wxPostEvent(this, ev);
}
Пример #5
0
bool CGridLocus::XferName(int nCol, COARallele *pAllele)
{
    bool bRtn = true;
    if(!GetBoolValue(ROW_DISABLE,nCol))
    {
        bool bAmel = m_pLocusEdited->IsAmel();
        s = GetCellValue(ROW_ALLELE,nCol);
        nwxString::Trim(&s);
        if(bAmel)
        {
            s.MakeUpper();
            const char *ps = s.c_str();
            if( (!*ps) || (strchr("XY12",*ps) == NULL) )
            {
                // not x/y
                bRtn = false;
                mainApp::ShowError(_T("Invalid allele name"),this);
                SetCellValue(ROW_ALLELE,nCol,pAllele->FormatName(true,false));
                SetGridCursor(ROW_ALLELE,nCol);
                SelectBlock(ROW_ALLELE,nCol,ROW_ALLELE,nCol);
            }
        }
        if(bRtn)
        {
            pAllele->SetName(s,bAmel);
        }
    }
    return bRtn;
}
Пример #6
0
const std::string wex::grid::get_find_string() const
{
  if (IsSelection())
  {
    // This does not work (if single cell selected, array count is 0!
    // const wxGridCellCoordsArray cells(GetSelectedCells());
    tokenizer tkz(get_selected_cells_value(), "\n");

    // Only if we have one cell, so one EOL.
    if (tkz.count_tokens() == 1)
    {
      find_replace_data::get()->set_find_string(tkz.get_next_token());
    }
  }
  else
  {
    // Just take current cell value, if not empty.
    const auto row = GetGridCursorRow();
    const auto col = GetGridCursorCol();
    const std::string val = GetCellValue(row, col);

    if (!val.empty())
    {
      find_replace_data::get()->set_find_string(val);
    }
  }
    
  return find_replace_data::get()->get_find_string();
}
Пример #7
0
const std::string wex::grid::get_selected_cells_value() const
{
  // This does not work, only filled in for singly selected cells.
  // wxGridCellCoordsArray cells = GetSelectedCells();
  wxString text;

  for (int i = 0; i < GetNumberRows(); i++)
  {
    bool value_added = false;

    for (int j = 0; j < GetNumberCols(); j++)
    {
      if (IsInSelection(i, j))
      {
        if (value_added)
        {
          text << "\t";
        }

        text << GetCellValue(i, j);

        value_added = true;
      }
    }

    if (value_added)
    {
      text << "\n";
    }
  }

  return text;
}
Пример #8
0
bool CLogSpreadSheet::IsRecordNotExist(int nRow)
{
	if(GetCellValue(1,nRow).IsEmpty())
		return true;
	else
		return false;
}
Пример #9
0
wxString ctlSQLGrid::GetExportLine(int row, wxArrayInt cols)
{
	wxString str;
	unsigned int col;

	if (GetNumberCols() == 0)
		return str;

	for (col = 0 ; col < cols.Count() ; col++)
	{
		if (col > 0)
			str.Append(settings->GetCopyColSeparator());

		wxString text = GetCellValue(row, cols[col]);

		bool needQuote  = false;
		if (settings->GetCopyQuoting() == 1)
		{
			needQuote = IsColText(cols[col]);
		}
		else if (settings->GetCopyQuoting() == 2)
			/* Quote everything */
			needQuote = true;

		if (needQuote)
			str.Append(settings->GetCopyQuoteChar());
		str.Append(text);
		if (needQuote)
			str.Append(settings->GetCopyQuoteChar());
	}
	return str;
}
Пример #10
0
void CGridAlleleBase::CheckRowCount()
{
  wxString s;
  int nRows = GetNumberRows();
  int nCols = GetNumberCols();
  int nStart = nRows - 2;
  int nCol;
  int nRow;

  if(nStart < 0)
  {
    nStart = 0;
  }
  for(nRow = nStart; nRow < nRows; nRow++)
  {
    for(nCol = 0; nCol < nCols; nCol++)
    {
      s = GetCellValue(nRow,nCol);
      nwxString::Trim(&s);
      if(s.Len())
      {
        nwxGrid::SetRowCount(nRows + 4);
        nCol = nCols;  // loop exit
        nRow = nRows;
      }
    }
  }
}
int CatheterGrid::getGridRowChannel(int row) {
    const wxString& channel = GetCellValue(wxGridCellCoords(row, CHANNEL_COL));
    if (!wxStrcmp(channel, "global"))
        return GLOBAL_ADDR;
    else
        return wxAtoi(channel);
}
dir_t CatheterGrid::getGridRowDirection(int row) {
    const wxString& dirStr = GetCellValue(wxGridCellCoords(row, DIRECTION_COL));
    if (!wxStrcmp(dirStr, DIRPOSSTR)) {
        return DIR_POS;
    } else {
        return DIR_NEG;
    }
}
Пример #13
0
void CGridLocus::XferHomozygous(int nCol, COARallele *pAllele)
{
    if(!GetBoolValue(ROW_DISABLE,nCol))
    {
        s = GetCellValue(ROW_HOMOZYGOUS,nCol);
        bool b = IsTrue(s.c_str());
        pAllele->SetCountBool(b);
    }
}
Пример #14
0
void CGridLocus::XferBPS(int nCol, COARallele *pAllele)
{
    if(!GetBoolValue(ROW_DISABLE,nCol))
    {
        s = GetCellValue(ROW_BPS,nCol);
        nwxString::Trim(&s);
        pAllele->SetBPS(atof(s.c_str()));
    }
}
Пример #15
0
void nwxGrid::OnEditorStart(wxGridEvent &e)
{
  m_nEditorOn++;
  m_nEditorRow = e.GetRow();
  m_nEditorCol = e.GetCol();
  m_sEditorStartValue = GetCellValue(m_nEditorRow, m_nEditorCol);
  SaveCellValue();
  e.Skip();
}
Пример #16
0
void CGridLocus::XferOL(int nCol, COARallele *pAllele)
{
    if(!GetBoolValue(ROW_DISABLE,nCol))
    {
        s = GetCellValue(ROW_OFF_LADDER,nCol);
        bool b = IsTrue(s.c_str());
        pAllele->SetOffLadderString(b ? IOARpeak::OL_TRUE : IOARpeak::OL_FALSE);
    }
}
Пример #17
0
bool DataGrid::clearCellData(int row, int col)
{
	if (!IsReadOnly(row, col) && !GetCellValue(row, col).IsEmpty()) {
		clearCell(row, col);
		wxGridEvent ev(GetId(), wxEVT_GRID_CELL_CHANGED, this, row, col);
		wxPostEvent(this, ev);
	}
	return false;
}
int CGridRFULimits::_GetCellIntValue(int nRow, int nCol)
{
  wxString s = GetCellValue(nRow,nCol);
  int nRtn = 
    s.IsEmpty()
    ? -1
    : atoi(s.c_str());
  return nRtn;
}
Пример #19
0
int CheckInstanceBinaryMapCollision(float PosX, float PosY, float scaleX, float scaleY)
{
	int Flag = 0;
	float x1, x2, y1, y2;

	// check top
		// HS 1
		y1 = PosY + scaleY/2;
		x1 = PosX + scaleX/4;
		// HS 2
		y2 = PosY + scaleY/2;
		x2 = PosX - scaleX/4;

	if(GetCellValue(x1,y1) == 1) Flag |= COLLISION_TOP;
	if(GetCellValue(x2,y2) == 1) Flag |= COLLISION_TOP;

	// check bottom
		// HS 1
		y1 = PosY - scaleY/2;
		x1 = PosX + scaleX/4;
		// HS 2
		y2 = PosY - scaleY/2;
		x2 = PosX - scaleX/4;		

	if(GetCellValue(x1,y1) == 1) Flag |= COLLISION_BOTTOM;
	if(GetCellValue(x2,y2) == 1) Flag |= COLLISION_BOTTOM;


	// check left
		// HS 1
		y1 = PosY + scaleY/4;
		x1 = PosX - scaleX/2;
		// HS 2
		y2 = PosY - scaleY/4;
		x2 = PosX - scaleX/2;		

	if(GetCellValue(x1,y1) == 1) Flag |= COLLISION_LEFT;
	if(GetCellValue(x2,y2) == 1) Flag |= COLLISION_LEFT;


	// check right
		// HS 1
		y1 = PosY + scaleY/4;
		x1 = PosX + scaleX/2;
		// HS 2
		y2 = PosY - scaleY/4;
		x2 = PosX + scaleX/2;		

	if(GetCellValue(x1,y1) == 1) Flag |= COLLISION_RIGHT;
	if(GetCellValue(x2,y2) == 1) Flag |= COLLISION_RIGHT;

	return Flag;
}
Пример #20
0
const std::string wex::grid::build_page()
{
  wxString text;

  text << "<TABLE ";

  if (GridLinesEnabled())
    text << "border=1";
  else
    text << "border=0";

  text << " cellpadding=4 cellspacing=0 >\n";
  text << "<tr>\n";

  // Add the col labels only if they are shown.
  if (GetColLabelSize() > 0)
  {
    for (int c = 0 ; c < GetNumberCols(); c++)
    {
      text << "<td><i>" << GetColLabelValue(c) << "</i>\n";
    }
  }

  for (int i = 0 ; i < GetNumberRows(); i++)
  {
    text << "<tr>\n";

    for (int j = 0 ; j < GetNumberCols(); j++)
    {
      text << "<td>" <<
        (GetCellValue(i, j).empty() ? "&nbsp": GetCellValue(i, j)) << "\n";
    }
  }

  text << "</TABLE>\n";

  // This can be useful for testing, paste in a file and
  // check in your browser (there indeed rules are okay).
  // clipboard_add(text);

  return text;
}
Пример #21
0
int wxPropertyList::FindProperty(wxPropertyItem *pItem)
{
    if(GetNumberRows() > 0 && pItem != 0) 
    {
        // find the property the traditional way
        for(size_t j = 0; j < (size_t)GetNumberRows(); j++)
        {
            if(pItem->GetPropName().IsSameAs(GetCellValue(j, 0)))
                return j;
        }
    }

    return -1;
}
Пример #22
0
wxPropertyItem *wxPropertyList::GetPropertyItemFromRow(int row)
{
    if(row < GetNumberRows() && row >= 0) 
    {
        wxString str = GetCellValue(row, 0);
        // find the property the traditional way
        for(size_t i = 0; i < (size_t)m_PropertyItems.Count(); i++)
        {
            if(m_PropertyItems[i]->GetPropName().IsSameAs(str))
                return m_PropertyItems[i];
        }
    }

    return 0;   
}
Пример #23
0
double CGridLabThresholds::GetCellValueDouble(int nRow, int nCol)
{
  wxString s = GetCellValue(nRow,nCol);
  double d;
  if(s.IsEmpty())
  {
    d = -1.0;
  }
  else
  {
    d = nwxRound::Round(atof(s.utf8_str()) * 10000.0);
    d *= 0.0001;
  }
  return d;
}
//---------------------------------------------------------
void CVIEW_Table_Control::On_Changed(wxGridEvent &event)
{
	CSG_Table_Record	*pRecord	= m_pRecords[event.GetRow()];

	if( pRecord )
	{
		int	iField	= m_Field_Offset + event.GetCol();

		if( iField >= m_Field_Offset && iField < m_pTable->Get_Field_Count() )
		{
			pRecord->Set_Value(iField, GetCellValue(event.GetRow(), event.GetCol()).wx_str());

			SetCellValue(event.GetRow(), event.GetCol(), pRecord->asString(iField));
		}
	}
}
Пример #25
0
void Level1_Update(void) {
    fprintf(output, "\n\n\nLevel1:Update\n");

    if (!(--current_health))
        GSM_NEXT = LEVEL_2;

    fprintf(output, "Cell value (%i, 1) = %i\n", ++i, GetCellValue(i, 1));

    Flag = 0;

    if(i == 1)
        Flag = CheckInstanceBinaryMapCollision(3.4f, 1.7f, 1.0f, 1.0f);
    else if(i == 2)
        Flag = CheckInstanceBinaryMapCollision(1.7f, 2.2f, 1.0f, 1.0f);
    else if(i == 3)
        Flag = CheckInstanceBinaryMapCollision(1.2f, 3.8f, 1.0f, 1.0f);

}
Пример #26
0
int CheckInstanceBinaryMapCollision(float PosX, float PosY, float scaleX, float scaleY) {
	int FLAG = 0;
	float x1, x2, y1, y2;

	x1 = PosX - scaleX/2;
	y1 = PosY + scaleY/4;

	x2 = PosX - scaleX/2;
	y2 = PosX - scaleY/4;

	if(GetCellValue(x1, y1) || GetCellValue(x2, y2))
		FLAG |= COLLISION_LEFT;

	x1 = PosX + scaleX/2;
	y1 = PosY + scaleY/4;

	x2 = PosX + scaleX/2;
	y2 = PosX - scaleY/4;

	if(GetCellValue(x1, y1) || GetCellValue(x2, y2))
		FLAG |= COLLISION_RIGHT;

	x1 = PosX + scaleX/4;
	y1 = PosY + scaleY/2;

	x2 = PosX - scaleX/4;
	y2 = PosX + scaleY/2;

	if(GetCellValue(x1, y1) || GetCellValue(x2, y2))
		FLAG |= COLLISION_TOP;

	x1 = PosX + scaleX/4;
	y1 = PosY - scaleY/2;

	x2 = PosX - scaleX/4;
	y2 = PosX - scaleY/2;

	if(GetCellValue(x1, y1) || GetCellValue(x2, y2))
		FLAG |= COLLISION_BOTTOM;

	return FLAG;
}
Пример #27
0
void CGridAlleleBase::OnCellChange(wxGridEvent &e)
{
  if(AutoExpand())
  {
    int nRows = GetNumberRows();
    int nThisRow = e.GetRow();
    int nThisCol = e.GetCol();
    if(nThisRow >= (nRows - 2))
    {
      // last or second to last row, add some rows
      wxString sValue = GetCellValue(nThisRow,nThisCol);
      nwxString::Trim(&sValue);
      if(sValue.Len())
      {
        nwxGrid::SetRowCount(nRows + 4);
      }
    }
  }
  e.Skip();
}
Пример #28
0
void wxStfGrid::Copy(wxCommandEvent& WXUNUSED(event)) {
    if (!IsSelection()) {
        wxGetApp().ErrorMsg( wxT("Select cells first") );
        return;
    }
    // Write some text to the clipboard
    // These data objects are held by the clipboard, 
    // so do not delete them in the app.
    selection.Clear();
    bool newline=true;
    for (int nRow=0;nRow<GetNumberRows();++nRow) {
        /* bool selected=false;*/
        newline=true;
        for (int nCol=0;nCol<GetNumberCols();++nCol) {
            if (IsInSelection(nRow,nCol)) {
                // Add a line break if this is not the first line:
                if (newline && selection != wxT("") ) {
                    selection << wxT("\n");
                }
                if (!newline) {
                    selection << wxT("\t");
                }
                newline=false;
                try {
                    selection << GetCellValue(nRow,nCol);
                    /* selected=true;*/
                }
                catch (const std::out_of_range& e) {
                    throw e;
                }
            }
        }
    }
    if (wxTheClipboard->Open()) {
        wxTheClipboard->SetData(
                                new wxTextDataObject(selection)
                                );
        wxTheClipboard->Close();
    }
}
Пример #29
0
void wxPropertyList::UpdateGridView()
{
    // make sure all items are shown, remove items that should not be shown
    bool keepItem;
    int row;
    for(size_t i = 0; i < m_PropertyItems.Count(); i++)
    {
        // to begin with, does this item fit the query?
        keepItem = m_strQuery.IsEmpty() || (m_PropertyItems[i]->GetPropName().Find(m_strQuery) != -1);
        if(keepItem)
        {
            // when advanced items are allowed to be shown, keep when ok
            if(!m_ShowAdvanced)
                keepItem = !m_PropertyItems[i]->GetAdvanced();
        }

        // find the item, if not present but keep is true, add, if 
        // present but keep is false, remove
        row = -1;
        for(size_t j = 0; j < (size_t)GetNumberRows(); j++)
        {
            if(m_PropertyItems[i]->GetPropName().IsSameAs(GetCellValue(j, 0)))
            {
                row = j;
                break;
            }
        }

        if(row == -1 && keepItem)
            AddPropertyToGrid(m_PropertyItems[i], (m_ShowAdvanced ? 2 : 0));                
        else if(row != -1 && !keepItem)
            DeleteRows(row, 1);
    }

#ifdef __LINUX__
    // fix to make sure scrollbars are drawn properly
    wxGrid::AdjustScrollbars();
#endif
}
Пример #30
0
void wxPropertyList::RemoveProperty(wxPropertyItem *pItem)
{
    HideControls();
  
    // look for property in grid, delete it when present        
    for(size_t j = 0; j < (size_t)GetNumberRows(); j++)
    {
        if(pItem->GetPropName().IsSameAs(GetCellValue(j, 0), false))
        {
            DeleteRows(j, 1);                   
            
#ifdef __LINUX__
            // fix to make sure scrollbars are drawn properly
            wxGrid::AdjustScrollbars();
#endif
             break;
        }
    }

    // delete the item from the list
    m_PropertyItems.Remove(pItem);
    delete pItem;
}