wxGrid::AutoSize() added
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6306 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		@@ -1080,6 +1080,12 @@ public:
 | 
			
		||||
    // auto size all columns (very ineffective for big grids!)
 | 
			
		||||
    void     AutoSizeColumns( bool setAsMin = TRUE );
 | 
			
		||||
 | 
			
		||||
    void     AutoSizeRows( bool setAsMin = TRUE );
 | 
			
		||||
 | 
			
		||||
    // auto size the grid, that is make the columns/rows of the "right" size
 | 
			
		||||
    // and also set the grid size to just fit its contents
 | 
			
		||||
    void     AutoSize();
 | 
			
		||||
 | 
			
		||||
    // column won't be resized to be lesser width - this must be called during
 | 
			
		||||
    // the grid creation because it won't resize the column if it's already
 | 
			
		||||
    // narrower than the minimal width
 | 
			
		||||
 
 | 
			
		||||
@@ -1003,12 +1003,7 @@ BugsGridFrame::BugsGridFrame()
 | 
			
		||||
    grid->SetColAttr(Col_Priority, attrRangeEditor);
 | 
			
		||||
    grid->SetColAttr(Col_Severity, attrCombo);
 | 
			
		||||
 | 
			
		||||
    grid->AutoSizeColumns();
 | 
			
		||||
    grid->AutoSize();
 | 
			
		||||
 | 
			
		||||
#if defined __WXMOTIF__
 | 
			
		||||
    // MB: the grid isn't getting a sensible default size under wxMotif
 | 
			
		||||
    int cw, ch;
 | 
			
		||||
    GetClientSize( &cw, &ch );
 | 
			
		||||
    grid->SetSize( cw, ch );
 | 
			
		||||
#endif
 | 
			
		||||
    Fit();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6851,6 +6851,10 @@ int wxGrid::GetColMinimalWidth(int col) const
 | 
			
		||||
    return obj ? (int)obj : WXGRID_MIN_COL_WIDTH;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ----------------------------------------------------------------------------
 | 
			
		||||
// auto sizing
 | 
			
		||||
// ----------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
void wxGrid::AutoSizeColumn( int col, bool setAsMin )
 | 
			
		||||
{
 | 
			
		||||
    wxClientDC dc(m_gridWin);
 | 
			
		||||
@@ -6901,15 +6905,42 @@ void wxGrid::AutoSizeColumn( int col, bool setAsMin )
 | 
			
		||||
 | 
			
		||||
void wxGrid::AutoSizeColumns( bool setAsMin )
 | 
			
		||||
{
 | 
			
		||||
    int width = m_rowLabelWidth;
 | 
			
		||||
 | 
			
		||||
    for ( int col = 0; col < m_numCols; col++ )
 | 
			
		||||
    {
 | 
			
		||||
        AutoSizeColumn(col, setAsMin);
 | 
			
		||||
 | 
			
		||||
        width += GetColWidth(col);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // also set the grid size to just fit the columns
 | 
			
		||||
    SetSize(width, -1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// ------ cell value accessor functions
 | 
			
		||||
//
 | 
			
		||||
void wxGrid::AutoSizeRows(bool WXUNUSED(setAsMin))
 | 
			
		||||
{
 | 
			
		||||
    int height = m_colLabelHeight;
 | 
			
		||||
 | 
			
		||||
    for ( int row = 0; row < m_numRows; row++ )
 | 
			
		||||
    {
 | 
			
		||||
        // AutoSizeRow(row, setAsMin) -- TODO
 | 
			
		||||
 | 
			
		||||
        height += GetRowHeight(row);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    SetSize(-1, height);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void wxGrid::AutoSize()
 | 
			
		||||
{
 | 
			
		||||
    AutoSizeColumns();
 | 
			
		||||
    AutoSizeRows();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ----------------------------------------------------------------------------
 | 
			
		||||
// cell value accessor functions
 | 
			
		||||
// ----------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
void wxGrid::SetCellValue( int row, int col, const wxString& s )
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user