Example #1
0
void DataGrid::scrollToDay(int day)
{
	int i;
	for (i = 0; i < GetNumberRows(); i++) {
		wxString title = GetRowLabelValue(i);
		if (title.length() == DATE_LEN) {
			struct ymd_date ymd;
			str_to_ymd_date(&ymd, title);
			if (ymd.day == day) {
				MakeCellVisible(i, 1);
				break;
			}
		}
	}
}
Example #2
0
void CustomGrid::DrawRowLabel( wxDC& dc, int row )
{
    //init dc font and colours
    dc.SetFont( m_labelFont );
    dc.SetPen(GetDefaultGridLinePen());
	dc.SetBrush( wxBrush( m_labelBackgroundColour, wxBRUSHSTYLE_SOLID ) );
    int w = dc.GetTextExtent(_T("Speed")).x;
    wxString label1,label2;
    label1 = GetRowLabelValue(row).BeforeFirst(',', &label2);
    bool pline = true;
    //row is the first of 3 for the same parameter (wind ... waves ...)
    if(GetNumberRows() > row + 2 && label1 == GetRowLabelValue(row + 2).BeforeFirst(',')){
        pline = false;
        if(IsRowVisible(row + 2))
            label1 = _T(" ");
    }
    //row is the second of 3 or the first of 2
    else if(GetNumberRows() > row + 1 && label1 == GetRowLabelValue(row + 1).BeforeFirst(',')){
        pline = false;
        if(row > 0 && label1 == GetRowLabelValue(row - 1).BeforeFirst(',')){    //second of 3
            if(!IsRowVisible(row + 1))
                label1 = _T(" ");
        }
    }
    //row is the last of 3
    else if(row > 1 && label1 == GetRowLabelValue(row - 2).BeforeFirst(',')){
        if(IsRowVisible(row - 1))
            label1 = _T(" ");
    }
    //row is the last of 2
    else if(row > 0 && label1 == GetRowLabelValue(row - 1).BeforeFirst(',')){
        if(IsRowVisible(row - 1))
            label1 = _T(" ");
    }
    //draw first part of the label
    wxRect aRect(5, GetRowTop(row), m_rowLabelWidth - w, GetRowHeight(row));
    dc.DrawLabel(label1, aRect, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL);
    //draw second part of the label
    wxRect bRect(m_rowLabelWidth - w, GetRowTop(row), w, GetRowHeight(row));
    dc.SetFont( wxFont(m_labelFont).Scale(0.85) );
    dc.DrawLabel(label2 , bRect, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL);
    //draw row lines around labels
    if(pline)
        dc.DrawLine(0, GetRowBottom(row) - 1, m_rowLabelWidth, GetRowBottom(row) - 1);
    dc.DrawLine(0, GetRowTop(row), 0, GetRowBottom(row) );
    dc.DrawLine(m_rowLabelWidth - 1, GetRowTop(row), m_rowLabelWidth - 1, GetRowBottom(row) );
}
void CGridAnalysis::UpdateGridRowLabels(
  COARsampleSort *pSort, int nLabelTypeName, wxDC *pDC)
{
  wxString s;
  COARsample *pSample;
  size_t nRowCount = pSort->GetCount();
  size_t i;
  bool bEdited;
  bool bNeedsAttention;
  wxDC *pDCuse = (pDC != NULL) ? pDC : GetDC();
  DCholder xx(this,pDCuse);

  m_nLabelType = nLabelTypeName;
  m_nLabelSize = 0;
  for(i = 0; i < nRowCount; i++)
  {
    pSample = pSort->GetSample((size_t)i);
    s = GetRowLabelValue(i).Right(2);
    bNeedsAttention = s.Contains(g_sSampleLevelNeedsAttention);
    bEdited = s.Contains(COARsample::g_sCellChannelEdited);
    SetupRowLabel(pSample,i,nLabelTypeName,bEdited,bNeedsAttention);
  }
  UpdateLabelSize();
}