// unix
//
#if defined(__WXGTK__)
- rect.Inflate(rect.x ? 1 : 0, rect.y ? 1 : 0);
+ if (rect.x != 0)
+ {
+ rect.x += 1;
+ rect.y += 1;
+ rect.width -= 1;
+ rect.height -= 1;
+ }
#else // !GTK
int extra_x = ( rect.x > 2 )? 2 : 1;
int extra_y = ( rect.y > 2 )? 2 : 1;
m_inOnKeyDown = FALSE;
m_batchCount = 0;
+
+ m_extraWidth =
+ m_extraHeight = 50;
+
+ CalcDimensions();
}
// ----------------------------------------------------------------------------
if ( m_numRows > 0 && m_numCols > 0 )
{
- int right = GetColRight( m_numCols-1 ) + 50;
- int bottom = GetRowBottom( m_numRows-1 ) + 50;
+ int right = GetColRight( m_numCols-1 ) + m_extraWidth;
+ int bottom = GetRowBottom( m_numRows-1 ) + m_extraHeight;
// TODO: restore the scroll position that we had before sizing
//
// Otherwise fall through to default
default:
- // alphanumeric keys enable the cell edit control
+ // alphanumeric keys or F2 (special key just for this) enable
+ // the cell edit control
if ( !(event.AltDown() ||
event.MetaDown() ||
event.ControlDown()) &&
- isalnum(event.KeyCode()) &&
+ (isalnum(event.KeyCode()) || event.KeyCode() == WXK_F2) &&
!IsCellEditControlEnabled() &&
CanEnableCellControl() )
{
new wxGridCellEditorEvtHandler(this, editor));
}
+ editor->Show( TRUE, attr );
+
editor->SetSize( rect );
- editor->Show( TRUE, attr );
editor->BeginEdit(row, col, this);
attr->DecRef();
}
return obj ? (int)obj : WXGRID_MIN_COL_WIDTH;
}
+// ----------------------------------------------------------------------------
+// auto sizing
+// ----------------------------------------------------------------------------
+
void wxGrid::AutoSizeColumn( int col, bool setAsMin )
{
wxClientDC dc(m_gridWin);
}
}
-void wxGrid::AutoSizeColumns( bool setAsMin )
+int wxGrid::SetOrCalcColumnSizes(bool calcOnly, bool setAsMin)
{
+ int width = m_rowLabelWidth;
+
for ( int col = 0; col < m_numCols; col++ )
{
- AutoSizeColumn(col, setAsMin);
+ if ( !calcOnly )
+ {
+ AutoSizeColumn(col, setAsMin);
+ }
+
+ width += GetColWidth(col);
}
+
+ return width;
}
-//
-// ------ cell value accessor functions
-//
+int wxGrid::SetOrCalcRowSizes(bool calcOnly, bool setAsMin)
+{
+ int height = m_colLabelHeight;
+
+ for ( int row = 0; row < m_numRows; row++ )
+ {
+ // if ( !calcOnly ) AutoSizeRow(row, setAsMin) -- TODO
+
+ height += GetRowHeight(row);
+ }
+
+ return height;
+}
+
+void wxGrid::AutoSize()
+{
+ // set the size too
+ SetSize(SetOrCalcColumnSizes(FALSE), SetOrCalcRowSizes(FALSE));
+}
+
+wxSize wxGrid::DoGetBestSize() const
+{
+ // don't set sizes, only calculate them
+ wxGrid *self = (wxGrid *)this; // const_cast
+
+ return wxSize(self->SetOrCalcColumnSizes(TRUE),
+ self->SetOrCalcRowSizes(TRUE));
+}
+
+void wxGrid::Fit()
+{
+ AutoSize();
+}
+
+// ----------------------------------------------------------------------------
+// cell value accessor functions
+// ----------------------------------------------------------------------------
void wxGrid::SetCellValue( int row, int col, const wxString& s )
{