当前位置: 首页>>代码示例>>C++>>正文


C++ wxGrid类代码示例

本文整理汇总了C++中wxGrid的典型用法代码示例。如果您正苦于以下问题:C++ wxGrid类的具体用法?C++ wxGrid怎么用?C++ wxGrid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了wxGrid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WXUNUSED

wxSize TimeRenderer::GetBestSize(wxGrid &grid,
                                 wxGridCellAttr & WXUNUSED(attr),
                                 wxDC & WXUNUSED(dc),
                                 int row,
                                 int col)
{
    wxGridTableBase *table = grid.GetTable();
    TimeEditor *te = (TimeEditor *) grid.GetCellEditor(row, col);
    wxSize sz;

    if (te) {
        double value;
        table->GetValue(row, col).ToDouble(&value);
        NumericTextCtrl tt(NumericConverter::TIME, &grid,
                           wxID_ANY,
                           te->GetFormat(),
                           value,
                           te->GetRate(),
                           wxPoint(10000, 10000),  // create offscreen
                           wxDefaultSize,
                           true);
        sz = tt.GetSize();

        te->DecRef();
    }

    return sz;
}
开发者ID:ducknoir,项目名称:audacity,代码行数:28,代码来源:Grid.cpp

示例2: WXUNUSED

wxSize NumericRenderer::GetBestSize(wxGrid &grid,
                                 wxGridCellAttr & WXUNUSED(attr),
                                 wxDC & WXUNUSED(dc),
                                 int row,
                                 int col)
{
   wxGridTableBase *table = grid.GetTable();
   NumericEditor *ne =
      static_cast<NumericEditor *>(grid.GetCellEditor(row, col));
   wxSize sz;

   if (ne) {
      double value;
      table->GetValue(row, col).ToDouble(&value);
      NumericTextCtrl tt(mType, &grid,
                      wxID_ANY,
                      ne->GetFormat(),
                      value,
                      ne->GetRate(),
                      wxPoint(10000, 10000),  // create offscreen
                      wxDefaultSize,
                      true);
      sz = tt.GetSize();

      ne->DecRef();
   }

   return sz;
}
开发者ID:RaphaelMarinier,项目名称:audacity,代码行数:29,代码来源:Grid.cpp

示例3: Draw

void wxGridCellRenderer::Draw(wxGrid& grid,
                              wxGridCellAttr& attr,
                              wxDC& dc,
                              const wxRect& rect,
                              int WXUNUSED(row), int WXUNUSED(col),
                              bool isSelected)
{
    dc.SetBackgroundMode( wxBRUSHSTYLE_SOLID );

    wxColour clr;
    if ( grid.IsThisEnabled() )
    {
        if ( isSelected )
        {
            if ( grid.HasFocus() )
                clr = grid.GetSelectionBackground();
            else
                clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW);
        }
        else
        {
            clr = attr.GetBackgroundColour();
        }
    }
    else // grey out fields if the grid is disabled
    {
        clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
    }

    dc.SetBrush(clr);
    dc.SetPen( *wxTRANSPARENT_PEN );
    dc.DrawRectangle(rect);
}
开发者ID:3v1n0,项目名称:wxWidgets,代码行数:33,代码来源:gridctrl.cpp

示例4: GetBestSize

wxSize TimeRenderer::GetBestSize(wxGrid &grid,
                                 wxGridCellAttr &attr,
                                 wxDC &dc,
                                 int row,
                                 int col)
{
   wxGridTableBase *table = grid.GetTable();
   TimeEditor *te = (TimeEditor *) grid.GetCellEditor(row, col);
   wxSize sz;

   if (te) {
      double value;
      table->GetValue(row, col).ToDouble(&value);
      TimeTextCtrl tt(&grid,
                      wxID_ANY,
                      wxT(""),
                      value,
                      te->GetRate(),
                      wxPoint(10000, 10000),  // create offscreen
                      wxDefaultSize,
                      true);
      tt.SetFormatString(tt.GetBuiltinFormat(te->GetFormat()));
      sz = tt.GetSize();

      te->DecRef();
   }

   return sz;
}
开发者ID:tuanmasterit,项目名称:audacity,代码行数:29,代码来源:Grid.cpp

示例5: DrawBackground

/* draws alternating background colours */
void CBOINCGridCellRenderer::DrawBackground(wxGrid& grid,
                              wxDC& dc,
                              const wxRect& rect,
                              int row,
                              bool isSelected)
{
    dc.SetBackgroundMode( wxSOLID );

    // grey out fields if the grid is disabled
    if( grid.IsEnabled() )
    {
        if ( isSelected )
        {
            dc.SetBrush( wxBrush(grid.GetSelectionBackground(), wxSOLID) );
        }
        else
        {
			//alternate background colours
			if(row % 2 == 0) {
				dc.SetBrush(wxBrush(wxColour(240,240,240)));
			}
			else {
				dc.SetBrush(*wxWHITE_BRUSH);
			}
        }
    }
    else
    {
        dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE), wxSOLID));
    }

    dc.SetPen( *wxTRANSPARENT_PEN );
    dc.DrawRectangle(rect);
}
开发者ID:Rytiss,项目名称:native-boinc-for-android,代码行数:35,代码来源:BOINCGridCtrl.cpp

示例6: firstFreeRow

/**
 * @brief Returns 0-based index of the first free row in the grid
 */
int firstFreeRow(const wxGrid &grid) {
  using cit = boost::counting_iterator<int>;
  const auto size = grid.GetNumberRows();
  const auto row = find_if(cit(0), cit(size), [&grid](int x) {
    return "" == grid.GetCellValue(x, 0) && "" == grid.GetCellValue(x, 1);
  });
  return *row;
}
开发者ID:tpasternak,项目名称:CDP,代码行数:11,代码来源:MainFrame.cpp

示例7: DoProgressDrawing

/* paints the progress bar */
void CBOINCGridCellProgressRenderer::DoProgressDrawing(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rectCell, int row, int col, bool isSelected) {
    wxRect rect = rectCell;
    rect.Inflate(-1);

    // erase only this cells background, overflow cells should have been erased
	this->DrawBackground(grid, dc, rectCell, row, isSelected);
	// set text attributes
    int hAlign, vAlign;
	attr.GetAlignment(&hAlign, &vAlign);
    SetTextColoursAndFont(grid, attr, dc, isSelected);

	//calculate the two parts of the progress rect
    //
	double dv = 0.0;
	wxString strValue = grid.GetCellValue(row,col);
	if(m_bDoPercentAppending) {
		strValue = strValue + wxT(" %");
	}

    // Project view uses the format:  %0.0f (%0.2f%%)
    // Everyone else uses: %.3f%%
    if (strValue.Find(wxT("(")) != wxNOT_FOUND) {
        strValue.SubString(strValue.Find(wxT("(")) + 1, strValue.Find(wxT(")")) - 1).ToDouble( &dv );
    } else {
    	strValue.ToDouble ( &dv );	 // NOTE: we should do error-checking/reporting here!!
    }


	wxRect p1(rect);
	wxRect p2(rect);
	int r = (int)((rect.GetRight()-rect.GetLeft())*dv / 100.0);
	p1.SetRight(rect.GetLeft()+r);
	p2.SetLeft(rect.GetLeft()+r+1);
	p2.SetRight(rect.GetRight()-1);
	//start drawing
	dc.SetClippingRegion(rect);
	wxBrush old = dc.GetBrush();
	wxColour progressColour = wxTheColourDatabase->Find(wxT("LIGHT BLUE"));
	wxBrush* progressBrush = wxTheBrushList->FindOrCreateBrush(progressColour);
	wxPen* progressPen = wxThePenList->FindOrCreatePen(progressColour,1,wxSOLID);
	//draw the outline rectangle
	dc.SetBrush(*wxTRANSPARENT_BRUSH);
	dc.SetPen(*progressPen);
	dc.DrawRectangle(rect);
	// Draw the left part
	dc.SetBrush(*progressBrush);
	dc.DrawRectangle(p1);
	//draw the right part
	dc.SetBrush(old);
	dc.DrawRectangle(p2);
	//
	dc.DestroyClippingRegion();
	// draw the text
	grid.DrawTextRectangle(dc, strValue, rect, hAlign, vAlign);
}
开发者ID:Rytiss,项目名称:native-boinc-for-android,代码行数:56,代码来源:BOINCGridCtrl.cpp

示例8: Draw

void CellRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected)
{
  dc.SetClippingRegion(rect);
  wxGridCellStringRenderer::Draw(grid, attr, dc, rect, row, col, false);

  if( m_Renderer != NULL && imageName != NULL && StrOp.len(imageName) > 0 ) {
    int cx = 0;
    int cy = 0;

    if( imageBitmap == NULL ) {
      wxMemoryDC tmpDC;
      m_Renderer->sizeSvgSym( imageName, wItem.west, &cx, &cy );
      if( imageBitmap != NULL )
        delete imageBitmap;
      imageBitmap = new wxBitmap();
      imageBitmap->Create(cx * 32 * m_Scale, cy * 32 * m_Scale , -1);
      tmpDC.SelectObject(*imageBitmap);
      tmpDC.SetBackground(*wxWHITE_BRUSH);
      tmpDC.Clear();
      tmpDC.SetUserScale( m_Scale, m_Scale );
      m_Renderer->drawSvgSym( (wxPaintDC&)tmpDC, 0, 0, imageName, wItem.west, &cx, &cy );
      tmpDC.SelectObject(wxNullBitmap);

      m_RowSize = cy * 32 * m_Scale + 4;

      if( grid.GetColSize(col) <  cx * 32 * m_Scale )
        grid.SetColSize(col, cx * 32 * m_Scale );
      if( grid.GetRowSize(row) <  m_RowSize )
        grid.SetRowSize(row, m_RowSize );
      TraceOp.trc( "cellrenderer", TRCLEVEL_DEBUG, __LINE__, 9999, "image: %s dc=%X row=%d col=%d cx=%d cy=%d rowsize=%d", imageName,
          &dc, row, col, cx, cy, m_RowSize );
    }

    dc.DrawBitmap(*imageBitmap, rect.x, rect.y + 2);

  }
  else if( imageName != NULL && StrOp.len(imageName) > 0 ) {
    if( imageBitmap == NULL )
      updateImage(rect);
    if( imageBitmap != NULL ) {
      dc.DrawBitmap(*imageBitmap, rect.x, rect.y);
      if( !m_bDidResize ) {
        grid.AutoSizeColumn(col);
        m_bDidResize = true;
      }
    }
  }

  dc.DestroyClippingRegion();
}
开发者ID:KlausMerkert,项目名称:FreeRail,代码行数:50,代码来源:cellrenderer.cpp

示例9: rect

wxSize
wxGridCellAutoWrapStringRenderer::GetBestSize(wxGrid& grid,
                                              wxGridCellAttr& attr,
                                              wxDC& dc,
                                              int row, int col)
{
    wxCoord x,y, height , width = grid.GetColSize(col) -20;
    // for width, subtract 20 because ColSize includes a magin of 10 pixels
    // that we do not want here and because we always start with an increment
    // by 10 in the loop below.
    int count = 250; //Limit iterations..

    wxRect rect(0,0,width,10);

    // M is a nice large character 'y' gives descender!.
    dc.GetTextExtent(wxT("My"), &x, &y);

    do
    {
        width+=10;
        rect.SetWidth(width);
        height = y * (wx_truncate_cast(wxCoord, GetTextLines(grid,dc,attr,rect,row,col).GetCount()));
        count--;
    // Search for a shape no taller than the golden ratio.
    } while (count && (width  < (height*1.68)) );


    return wxSize(width,height);
}
开发者ID:BloodRedd,项目名称:gamekit,代码行数:29,代码来源:gridctrl.cpp

示例10: rect

wxSize
wxGridCellAutoWrapStringRenderer::GetBestSize(wxGrid& grid,
                                              wxGridCellAttr& attr,
                                              wxDC& dc,
                                              int row, int col)
{
    wxCoord x,y, height , width = grid.GetColSize(col) -10;
    int count = 250; //Limit iterations..

    wxRect rect(0,0,width,10);

    // M is a nice large character 'y' gives descender!.
    dc.GetTextExtent(wxT("My"), &x, &y);

    do
    {
        width+=10;
        rect.SetWidth(width);
        height = y * (wx_truncate_cast(wxCoord, GetTextLines(grid,dc,attr,rect,row,col).GetCount()));
        count--;
    // Search for a shape no taller than the golden ratio.
    } while (count && (width  < (height*1.68)) );


    return wxSize(width,height);
}
开发者ID:georgemoralis,项目名称:jpcsp2c,代码行数:26,代码来源:gridctrl.cpp

示例11: GetBestSize

wxSize wxGridCellStringRenderer::GetBestSize(wxGrid& grid,
                                             wxGridCellAttr& attr,
                                             wxDC& dc,
                                             int row, int col)
{
    return DoGetBestSize(attr, dc, grid.GetCellValue(row, col));
}
开发者ID:3v1n0,项目名称:wxWidgets,代码行数:7,代码来源:gridctrl.cpp

示例12: GetString

wxString wxGridCellDateTimeRenderer::GetString(const wxGrid& grid, int row, int col)
{
    wxGridTableBase *table = grid.GetTable();

    bool hasDatetime = false;
    wxDateTime val;
    wxString text;
    if ( table->CanGetValueAs(row, col, wxGRID_VALUE_DATETIME) )
    {
        void * tempval = table->GetValueAsCustom(row, col,wxGRID_VALUE_DATETIME);

        if (tempval)
        {
            val = *((wxDateTime *)tempval);
            hasDatetime = true;
            delete (wxDateTime *)tempval;
        }

    }

    if (!hasDatetime )
    {
        text = table->GetValue(row, col);
        const char * const end = val.ParseFormat(text, m_iformat, m_dateDef);
        hasDatetime = end && !*end;
    }

    if ( hasDatetime )
        text = val.Format(m_oformat, m_tz );

    // If we failed to parse string just show what we where given?
    return text;
}
开发者ID:3v1n0,项目名称:wxWidgets,代码行数:33,代码来源:gridctrl.cpp

示例13: tk

wxArrayString
wxGridCellAutoWrapStringRenderer::GetTextLines(wxGrid& grid,
                                               wxDC& dc,
                                               const wxGridCellAttr& attr,
                                               const wxRect& rect,
                                               int row, int col)
{
    wxString  data = grid.GetCellValue(row, col);

    wxArrayString lines;
    dc.SetFont(attr.GetFont());

    //Taken from wxGrid again!
    wxCoord x = 0, y = 0, curr_x = 0;
    wxCoord max_x = rect.GetWidth();

    dc.SetFont(attr.GetFont());
    wxStringTokenizer tk(data , wxT(" \n\t\r"));
    wxString thisline = wxEmptyString;

    while ( tk.HasMoreTokens() )
    {
        wxString tok = tk.GetNextToken();
        //FIXME: this causes us to print an extra unnecesary
        //       space at the end of the line. But it
        //       is invisible , simplifies the size calculation
        //       and ensures tokens are separated in the display
        tok += wxT(" ");

        dc.GetTextExtent(tok, &x, &y);
        if ( curr_x + x > max_x)
        {
            if ( curr_x == 0 )
            {
                // this means that a single token is wider than the maximal
                // width -- still use it as is as we need to show at least the
                // part of it which fits
                lines.Add(tok);
            }
            else
            {
                lines.Add(thisline);
                thisline = tok;
                curr_x = x;
            }
        }
        else
        {
            thisline+= tok;
            curr_x += x;
        }
    }
    //Add last line
    lines.Add( wxString(thisline) );

    return lines;
}
开发者ID:BloodRedd,项目名称:gamekit,代码行数:57,代码来源:gridctrl.cpp

示例14: Draw

void CBOINCGridCellMessageRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected) {
	wxString szError(wxT("Error"));
	if(grid.GetCellValue(row,column).Trim(false).IsSameAs(szError)) {
		attr.SetTextColour(*wxRED);
	}
	else {
		attr.SetTextColour(*wxBLACK);
	}
	CBOINCGridCellRenderer::Draw(grid,attr,dc,rect,row,col,isSelected);
}
开发者ID:Rytiss,项目名称:native-boinc-for-android,代码行数:10,代码来源:BOINCGridCtrl.cpp

示例15: GetString

wxString wxGridCellFloatRenderer::GetString(const wxGrid& grid, int row, int col)
{
    wxGridTableBase *table = grid.GetTable();

    bool hasDouble;
    double val;
    wxString text;
    if ( table->CanGetValueAs(row, col, wxGRID_VALUE_FLOAT) )
    {
        val = table->GetValueAsDouble(row, col);
        hasDouble = true;
    }
    else
    {
        text = table->GetValue(row, col);
        hasDouble = text.ToDouble(&val);
    }

    if ( hasDouble )
    {
        if ( !m_format )
        {
            if ( m_width == -1 )
            {
                if ( m_precision == -1 )
                {
                    // default width/precision
                    m_format = wxT("%f");
                }
                else
                {
                    m_format.Printf(wxT("%%.%df"), m_precision);
                }
            }
            else if ( m_precision == -1 )
            {
                // default precision
                m_format.Printf(wxT("%%%d.f"), m_width);
            }
            else
            {
                m_format.Printf(wxT("%%%d.%df"), m_width, m_precision);
            }
        }

        text.Printf(m_format, val);

    }
    //else: text already contains the string

    return text;
}
开发者ID:BloodRedd,项目名称:gamekit,代码行数:52,代码来源:gridctrl.cpp


注:本文中的wxGrid类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。