Exemplo n.º 1
0
void ctlSQLGrid::OnMouseWheel(wxMouseEvent &event)
{
	if (event.ControlDown() || event.CmdDown())
	{
		wxFont fontlabel = GetLabelFont();
		wxFont fontcells = GetDefaultCellFont();
		if (event.GetWheelRotation() > 0)
		{
			fontlabel.SetPointSize(fontlabel.GetPointSize() - 1);
			fontcells.SetPointSize(fontcells.GetPointSize() - 1);
		}
		else
		{
			fontlabel.SetPointSize(fontlabel.GetPointSize() + 1);
			fontcells.SetPointSize(fontcells.GetPointSize() + 1);
		}
		SetLabelFont(fontlabel);
		SetDefaultCellFont(fontcells);
		SetColLabelSize(fontlabel.GetPointSize() * 4);
		SetDefaultRowSize(fontcells.GetPointSize() * 2);
		for (int index = 0; index < GetNumberCols(); index++)
			SetColSize(index, -1);
		ForceRefresh();
	}
	else
		event.Skip();
}
CGridSampleLimits::CGridSampleLimits(wxWindow *parent, wxWindowID id) :
  _CGridEdit(parent,id), 
  m_pValidatePct(NULL), 
  m_pData(NULL),
  m_pMessageBook(NULL)
  //,m_bReadOnly(false)
{
  wxString PEAKS(_T("peaks"));
  CreateGrid(ROW_MESSAGE_BOOK_OFFSET,2);
  EnableDragColSize(false);
  EnableDragRowSize(false);

  EnableScrolling(false,true);

  SetRowLabelValue(ROW_PULLUP,_T("Max. No. of pullups peaks per sample"));
  SetCellValue(ROW_PULLUP,1,PEAKS);

  SetRowLabelValue(ROW_STUTTER,_T("Max. No. of stutter peaks per sample"));
  SetCellValue(ROW_STUTTER,1,PEAKS);

  SetRowLabelValue(ROW_ADENYLATION,_T("Max. No. of adenylation peaks per sample"));
  SetCellValue(ROW_ADENYLATION,1,PEAKS);

  SetRowLabelValue(ROW_OFF_LADDER,_T("Max. off-ladder alleles per sample:"));
  SetCellValue(ROW_OFF_LADDER,1,PEAKS);
  
  SetRowLabelValue(ROW_RESIDUAL,_T("Max. residual for allele (<0.5 bp):"));
  SetCellValue(ROW_RESIDUAL,1,_T("Sample/Ladder BP alignment"));
  SetCellEditor(ROW_RESIDUAL,0,new wxGridCellFloatEditor(-1,4));
  SetDefaultCellValidator(new nwxGridCellUIntRangeValidator(0,1000000,true));
  SetCellValidator(
    new nwxGridCellDoubleRangeValidator(0.0,0.5,true),
    ROW_RESIDUAL,0);
  
  SetRowLabelValue(ROW_EXCESSIVE_RESIDUAL,_T("Max. No. of peaks with excessive residual:"));
  SetCellValue(ROW_EXCESSIVE_RESIDUAL,1,PEAKS);

  SetRowLabelValue(ROW_RFU_INCOMPLETE_SAMPLE,_T("Incomplete profile threshold for Reamp More/Reamp Less:"));
  SetCellValue(ROW_RFU_INCOMPLETE_SAMPLE,1,_T("RFU"));

  SetRowLabelValue(ROW_MIN_BPS_ARTIFACTS,_T("Ignore artifacts smaller than:"));
  SetCellValue(ROW_MIN_BPS_ARTIFACTS,1,_T("bps"));
  m_clrBackground = GetLabelBackgroundColour();
  wxFont fnLabel = GetLabelFont();
  for(int nRow = 0; nRow < ROW_MESSAGE_BOOK_OFFSET; nRow++)
  {
    SetCellBackgroundColour(nRow,1,m_clrBackground);
    SetReadOnly(nRow,1,true);
    SetCellFont(nRow,1,fnLabel);
    SetCellAlignment(nRow,0,wxALIGN_RIGHT, wxALIGN_CENTRE);
  }
  SetDefaultEditor(new wxGridCellFloatEditor(1,0));
  SetColLabelValue(0,_T("Value"));
  SetColLabelValue(1,_T("Units"));
  SetRowLabelAlignment(wxALIGN_LEFT, wxALIGN_CENTRE);
  SetColLabelAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);
}
int GLIDebugVariableGrid::AddRowType(RowType addType, uint typeIndex)
{
  //Add the row and get the index
  AppendRows(1);

  //Add to the type array
  rowTypeDataArray.push_back(RowTypeData(addType, typeIndex));

  //Check that the array sizes match
  wxASSERT(rowTypeDataArray.size() == GetNumberRows());

  //Set the default properties for the different types
  int addIndex = GetNumberRows() - 1;
  switch(addType)
  {
    case(RT_Header):
      SetCellSize(addIndex, NAME_COLUMN_INDEX, 1, 3);
      SetReadOnly(addIndex, NAME_COLUMN_INDEX);
      SetCellBackgroundColour(addIndex, NAME_COLUMN_INDEX, gridGrey);
      SetCellFont(addIndex, NAME_COLUMN_INDEX, GetLabelFont());
      break;

    case(RT_WatchValue):
      SetCellRenderer(addIndex, NAME_COLUMN_INDEX, new OffsetStringGridCellRenderer(CELL_RENDER_OFFSET));  
      SetReadOnly(addIndex, VALUE_COLUMN_INDEX);
      break;

    case(RT_Uniform):
      SetReadOnly(addIndex, NAME_COLUMN_INDEX);
      SetReadOnly(addIndex, VALUE_COLUMN_INDEX);
      SetReadOnly(addIndex, TYPE_COLUMN_INDEX);

      SetCellRenderer(addIndex, NAME_COLUMN_INDEX, new OffsetStringGridCellRenderer(CELL_RENDER_OFFSET));  
      break;

    case(RT_UniformArray):
      SetReadOnly(addIndex, NAME_COLUMN_INDEX);
      SetReadOnly(addIndex, VALUE_COLUMN_INDEX);
      SetReadOnly(addIndex, TYPE_COLUMN_INDEX);

      SetCellRenderer(addIndex, NAME_COLUMN_INDEX, new OffsetStringGridCellRenderer(CELL_RENDER_OFFSET*2));  
      break;

  };


  //Return the index
  return addIndex;
}
/* not virtual in wxGrid, so code copied and modified her for painting sorting icons */
void CBOINCGridCtrl::DrawColLabel( wxDC& dc, int col )
{
    if ( GetColWidth(col) <= 0 || m_colLabelHeight <= 0 )
        return;

    int colLeft = GetColLeft(col);

    wxRect rect;
    int colRight = GetColRight(col) - 1;

    dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW),1, wxSOLID) );
    dc.DrawLine( colRight, 0,
                 colRight, m_colLabelHeight-1 );

    dc.DrawLine( colLeft, 0, colRight, 0 );

    dc.DrawLine( colLeft, m_colLabelHeight-1,
                 colRight+1, m_colLabelHeight-1 );

    dc.SetPen( *wxWHITE_PEN );
    dc.DrawLine( colLeft, 1, colLeft, m_colLabelHeight-1 );
    dc.DrawLine( colLeft, 1, colRight, 1 );
    dc.SetBackgroundMode( wxTRANSPARENT );
    dc.SetTextForeground( GetLabelTextColour() );
    dc.SetFont( GetLabelFont() );

    int hAlign, vAlign, orient;
    GetColLabelAlignment( &hAlign, &vAlign );
    orient = GetColLabelTextOrientation();

    rect.SetX( colLeft + 2 );
    rect.SetY( 2 );
    rect.SetWidth( GetColWidth(col) - 4 );
    rect.SetHeight( m_colLabelHeight - 4 );
    DrawTextRectangle( dc, GetColLabelValue( col ), rect, hAlign, vAlign, orient );
	//paint sorting indicators, if needed
	if(col == sortColumn) {
		int x = rect.GetRight() - ascBitmap.GetWidth() - 2;
		int y = rect.GetY();
		dc.DrawBitmap(this->sortAscending ? descBitmap : ascBitmap,x,y,true);
	}
}
Exemplo n.º 5
0
//
//  -- Special version of wxGrid to allow use of fast comboboxes and grid columns auto fit
//
wxDDGrid::wxDDGrid(wxWindow *parent, wxWindowID id):
	wxGrid(parent, id, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_BESTWRAP, wxT("")),
	m_selTemp(NULL), keepFit(1)
{
	// Initially all columns have s-factor=1
	for( unsigned i = 0; i < 10; ++i ) sf[i] = 1;

	Connect( wxEVT_SIZE, wxSizeEventHandler( wxDDGrid::OnSizeEvt) );
	// Adjust the default row height to be more compact
	wxFont font = GetLabelFont();
	int nWidth = 0;
	int nHeight = 18;
	GetTextExtent(wxT("W"), &nWidth, &nHeight, NULL, NULL, &font);
	SetColLabelSize(nHeight + 6);
	SetRowLabelSize(35);
#ifdef __WXGTK__
	SetDefaultRowSize(nHeight + 8, TRUE);
#else
	SetDefaultRowSize(nHeight + 4, TRUE);
#endif
}
Exemplo n.º 6
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;
			}
		}
	}
}
void CGridSampleLimits::SetData(
  CLabThresholds *pData, const CXMLmessageBook *pMessageBook)
{
  m_pData = pData;
  m_pMessageBook = pMessageBook;
  typedef map<wxString,size_t> MSG_THRESHOLDS;
  set<wxString> setMsgThresholds; // message names for thresholds already used
  size_t nCount = 
    ((m_pMessageBook != NULL) && m_pMessageBook->IsOK())
    ? m_pMessageBook->GetMessageCount()
    : 0;
  if(nCount)
  {
    const wxString sEmpty;
    const wxString sUnitPCT(_T("%"));
    const CXMLmessageBookSM *pmsgSM;
    size_t nCountKeep = 0;
    bool bPct;

    // the following 5 will not use the message book
    setMsgThresholds.insert(CLabThresholds::g_psmNumberOfPullUpsInSample);
    setMsgThresholds.insert(CLabThresholds::g_psmNumberOfStuttersInSample);
    setMsgThresholds.insert(CLabThresholds::g_psmNumberOfAdenylationsInSample);
    setMsgThresholds.insert(CLabThresholds::g_psmNumberOfOffLadderAllelesInSample);
    setMsgThresholds.insert(CLabThresholds::g_psmNumberOfExcessiveResidualsInSample);

    m_vpMsgBookSM.clear();
    m_vpMsgBookSM.reserve(nCount);
    for(size_t i = 0; i < nCount; i++)
    {
      pmsgSM = m_pMessageBook->GetMessage(i);
      if(setMsgThresholds.find(pmsgSM->GetName()) == setMsgThresholds.end())
      {
        m_vpMsgBookSM.push_back(pmsgSM);
        setMsgThresholds.insert(pmsgSM->GetName());
        if(!pmsgSM->EmptyDescriptor())
        {
          nCountKeep++;
        }
      }
    }
    SetMessageBookRows((int)nCountKeep);
    if(nCountKeep)
    {
      wxFont fn = GetLabelFont();
      vector<const CXMLmessageBookSM *>::iterator itrSM;
      int nRow = ROW_MESSAGE_BOOK_OFFSET;
      for(itrSM = m_vpMsgBookSM.begin();
        itrSM != m_vpMsgBookSM.end();
        ++itrSM)
      {
        pmsgSM = *itrSM;
        if(!pmsgSM->EmptyDescriptor())
        {
          bPct = pmsgSM->IsPercent();
          if(bPct)
          {
            SetCellValidator(GetPctValidator(),nRow,0);
          }
          SetRowLabelValue(nRow,pmsgSM->GetDescriptor());
          SetCellBackgroundColour(nRow,1,m_clrBackground);
          SetCellFont(nRow,1,fn);
          SetCellValue(nRow,1,bPct ? sUnitPCT : sEmpty);
          SetReadOnly(nRow,1,true);
          if(pmsgSM->IsPreset())
          {
            SetCellAlignment(nRow,0,wxALIGN_RIGHT,wxALIGN_CENTRE);
          }
          nRow++;
        }
      }
    }
  }
  SetCellValue(0,0,"00000000");
  SetMargins(0,0);
  nwxGrid::UpdateLabelSizes(this);
  AutoSize();
}