git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36610
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
wxGridCellAttr *attr = (wxGridCellAttr *)NULL;
if ( m_data )
{
wxGridCellAttr *attr = (wxGridCellAttr *)NULL;
if ( m_data )
{
{
case (wxGridCellAttr::Any):
{
case (wxGridCellAttr::Any):
- //Get cached merge attributes.
- // Currenlty not used as no cache implemented as not mutiable
+ // Get cached merge attributes.
+ // Currently not used as no cache implemented as not mutable
// attr = m_data->m_mergeAttr.GetAttr(row, col);
if (!attr)
{
// attr = m_data->m_mergeAttr.GetAttr(row, col);
if (!attr)
{
- //Basically implement old version.
- //Also check merge cache, so we don't have to re-merge every time..
+ // Basically implement old version.
+ // Also check merge cache, so we don't have to re-merge every time..
wxGridCellAttr *attrcell = m_data->m_cellAttrs.GetAttr(row, col);
wxGridCellAttr *attrrow = m_data->m_rowAttrs.GetAttr(row);
wxGridCellAttr *attrcol = m_data->m_colAttrs.GetAttr(col);
wxGridCellAttr *attrcell = m_data->m_cellAttrs.GetAttr(row, col);
wxGridCellAttr *attrrow = m_data->m_rowAttrs.GetAttr(row);
wxGridCellAttr *attrcol = m_data->m_colAttrs.GetAttr(col);
attr = new wxGridCellAttr;
attr->SetKind(wxGridCellAttr::Merged);
attr = new wxGridCellAttr;
attr->SetKind(wxGridCellAttr::Merged);
+ // Order is important..
if (attrcell)
{
attr->MergeWith(attrcell);
if (attrcell)
{
attr->MergeWith(attrcell);
attr->MergeWith(attrrow);
attrrow->DecRef();
}
attr->MergeWith(attrrow);
attrrow->DecRef();
}
- //store merge attr if cache implemented
+
+ // store merge attr if cache implemented
//attr->IncRef();
//m_data->m_mergeAttr.SetAttr(attr, row, col);
}
//attr->IncRef();
//m_data->m_mergeAttr.SetAttr(attr, row, col);
}
attr = attrrow;
if (attrcol)
{
attr = attrrow;
if (attrcol)
{
attr->DecRef();
attr = attrcol;
}
attr->DecRef();
attr = attrcol;
}
if ( event.LeftIsDown() )
{
if ( event.LeftIsDown() )
{
+ switch ( m_cursorMode )
{
case WXGRID_CURSOR_RESIZE_ROW:
{
{
case WXGRID_CURSOR_RESIZE_ROW:
{
if ( event.LeftIsDown() )
{
if ( event.LeftIsDown() )
{
+ switch ( m_cursorMode )
{
case WXGRID_CURSOR_RESIZE_COL:
{
{
case WXGRID_CURSOR_RESIZE_COL:
{
{
//wxLogDebug("pos(%d, %d) coords(%d, %d)", pos.x, pos.y, coords.GetRow(), coords.GetCol());
{
//wxLogDebug("pos(%d, %d) coords(%d, %d)", pos.x, pos.y, coords.GetRow(), coords.GetCol());
- // Don't start doing anything until the mouse has been drug at
+ // Don't start doing anything until the mouse has been dragged at
// least 3 pixels in any direction...
if (! m_isDragging)
{
// least 3 pixels in any direction...
if (! m_isDragging)
{
// Note: However, only if it is really _shown_, i.e. not hidden!
if ( isCurrent && IsCellEditControlShown() )
{
// Note: However, only if it is really _shown_, i.e. not hidden!
if ( isCurrent && IsCellEditControlShown() )
{
+ // OSAF NB: this "#if..." is temporary and fixes a problem where the
+ // edit control is erased by this code after being rendered.
+ // On wxMac (QD build only), the cell editor is a wxTextCntl and is rendered
+ // implicitly, causing this out-of order render.
+#if !defined(__WXMAC__) || wxMAC_USE_CORE_GRAPHICS
wxGridCellEditor *editor = attr->GetEditor(this, row, col);
editor->PaintBackground(rect, attr);
editor->DecRef();
wxGridCellEditor *editor = attr->GetEditor(this, row, col);
editor->PaintBackground(rect, attr);
editor->DecRef();
else
GetTextBoxSize( dc, lines, &textHeight, &textWidth );
else
GetTextBoxSize( dc, lines, &textHeight, &textWidth );
{
case wxALIGN_BOTTOM:
if ( textOrientation == wxHORIZONTAL )
{
case wxALIGN_BOTTOM:
if ( textOrientation == wxHORIZONTAL )
{
dc.GetTextExtent(lines[l], &lineWidth, &lineHeight);
{
dc.GetTextExtent(lines[l], &lineWidth, &lineHeight);
{
case wxALIGN_RIGHT:
if ( textOrientation == wxHORIZONTAL )
{
case wxALIGN_RIGHT:
if ( textOrientation == wxHORIZONTAL )
}
else if ( m_currentCellCoords.GetRow() > 0 )
{
}
else if ( m_currentCellCoords.GetRow() > 0 )
{
+ int row = m_currentCellCoords.GetRow() - 1;
+ int col = m_currentCellCoords.GetCol();
- MakeCellVisible( m_currentCellCoords.GetRow() - 1,
- m_currentCellCoords.GetCol() );
- SetCurrentCell( m_currentCellCoords.GetRow() - 1,
- m_currentCellCoords.GetCol() );
+ MakeCellVisible( row, col );
+ SetCurrentCell( row, col );
}
else if ( m_currentCellCoords.GetRow() < m_numRows - 1 )
{
}
else if ( m_currentCellCoords.GetRow() < m_numRows - 1 )
{
+ int row = m_currentCellCoords.GetRow() + 1;
+ int col = m_currentCellCoords.GetCol();
- MakeCellVisible( m_currentCellCoords.GetRow() + 1,
- m_currentCellCoords.GetCol() );
- SetCurrentCell( m_currentCellCoords.GetRow() + 1,
- m_currentCellCoords.GetCol() );
+ MakeCellVisible( row, col );
+ SetCurrentCell( row, col );
}
else if ( m_currentCellCoords.GetCol() > 0 )
{
}
else if ( m_currentCellCoords.GetCol() > 0 )
{
+ int row = m_currentCellCoords.GetRow();
+ int col = m_currentCellCoords.GetCol() - 1;
- MakeCellVisible( m_currentCellCoords.GetRow(),
- m_currentCellCoords.GetCol() - 1 );
- SetCurrentCell( m_currentCellCoords.GetRow(),
- m_currentCellCoords.GetCol() - 1 );
+ MakeCellVisible( row, col );
+ SetCurrentCell( row, col );
}
else if ( m_currentCellCoords.GetCol() < m_numCols - 1 )
{
}
else if ( m_currentCellCoords.GetCol() < m_numCols - 1 )
{
+ int row = m_currentCellCoords.GetRow();
+ int col = m_currentCellCoords.GetCol() + 1;
- MakeCellVisible( m_currentCellCoords.GetRow(),
- m_currentCellCoords.GetCol() + 1 );
- SetCurrentCell( m_currentCellCoords.GetRow(),
- m_currentCellCoords.GetCol() + 1 );
+ MakeCellVisible( row, col );
+ SetCurrentCell( row, col );
int index = m_typeRegistry->FindOrCloneDataType(typeName);
if ( index == wxNOT_FOUND )
{
int index = m_typeRegistry->FindOrCloneDataType(typeName);
if ( index == wxNOT_FOUND )
{
errStr.Printf(wxT("Unknown data type name [%s]"), typeName.c_str());
wxFAIL_MSG(errStr.c_str());
errStr.Printf(wxT("Unknown data type name [%s]"), typeName.c_str());
wxFAIL_MSG(errStr.c_str());
int index = m_typeRegistry->FindOrCloneDataType(typeName);
if ( index == wxNOT_FOUND )
{
int index = m_typeRegistry->FindOrCloneDataType(typeName);
if ( index == wxNOT_FOUND )
{
errStr.Printf(wxT("Unknown data type name [%s]"), typeName.c_str());
wxFAIL_MSG(errStr.c_str());
errStr.Printf(wxT("Unknown data type name [%s]"), typeName.c_str());
wxFAIL_MSG(errStr.c_str());
return m_typeRegistry->GetRenderer(index);
}
return m_typeRegistry->GetRenderer(index);
}
// ----------------------------------------------------------------------------
// row/col size
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// row/col size
// ----------------------------------------------------------------------------
//
// This test then fixes sf.net bug #645734
//
// This test then fixes sf.net bug #645734
- if ( width < GetColMinimalAcceptableWidth())
+ if ( width < GetColMinimalAcceptableWidth() )
return;
if ( m_colWidths.IsEmpty() )
return;
if ( m_colWidths.IsEmpty() )
GetTextBoxSize(dc, lines, &w, &h);
width = w + 6;
}
GetTextBoxSize(dc, lines, &w, &h);
width = w + 6;
}
int w = wxMax( 0, width );
int diff = w - m_colWidths[col];
m_colWidths[col] = w;
int w = wxMax( 0, width );
int diff = w - m_colWidths[col];
m_colWidths[col] = w;
{
m_colRights[i] += diff;
}
{
m_colRights[i] += diff;
}
if ( !GetBatchCount() )
CalcDimensions();
}
if ( !GetBatchCount() )
CalcDimensions();
}
{
wxLongToLongHashMap::key_type key = (wxLongToLongHashMap::key_type)col;
wxLongToLongHashMap::const_iterator it = m_colMinWidths.find(key);
{
wxLongToLongHashMap::key_type key = (wxLongToLongHashMap::key_type)col;
wxLongToLongHashMap::const_iterator it = m_colMinWidths.find(key);
return it != m_colMinWidths.end() ? (int)it->second : m_minAcceptableColWidth;
}
return it != m_colMinWidths.end() ? (int)it->second : m_minAcceptableColWidth;
}
{
wxLongToLongHashMap::key_type key = (wxLongToLongHashMap::key_type)row;
wxLongToLongHashMap::const_iterator it = m_rowMinHeights.find(key);
{
wxLongToLongHashMap::key_type key = (wxLongToLongHashMap::key_type)row;
wxLongToLongHashMap::const_iterator it = m_rowMinHeights.find(key);
return it != m_rowMinHeights.end() ? (int)it->second : m_minAcceptableRowHeight;
}
void wxGrid::SetColMinimalAcceptableWidth( int width )
{
// We do allow a width of 0 since this gives us
return it != m_rowMinHeights.end() ? (int)it->second : m_minAcceptableRowHeight;
}
void wxGrid::SetColMinimalAcceptableWidth( int width )
{
// We do allow a width of 0 since this gives us
- // an easy way to temporarily hidding columns.
- if ( width < 0 )
- return;
- m_minAcceptableColWidth = width;
+ // an easy way to temporarily hiding columns.
+ if ( width >= 0 )
+ m_minAcceptableColWidth = width;
}
void wxGrid::SetRowMinimalAcceptableHeight( int height )
{
// We do allow a height of 0 since this gives us
}
void wxGrid::SetRowMinimalAcceptableHeight( int height )
{
// We do allow a height of 0 since this gives us
- // an easy way to temporarily hidding rows.
- if ( height < 0 )
- return;
- m_minAcceptableRowHeight = height;
+ // an easy way to temporarily hiding rows.
+ if ( height >= 0 )
+ m_minAcceptableRowHeight = height;
}
int wxGrid::GetColMinimalAcceptableWidth() const
}
int wxGrid::GetColMinimalAcceptableWidth() const
{
wxClientDC dc(m_gridWin);
{
wxClientDC dc(m_gridWin);
- //Cancel editting of cell
+ // cancel editing of cell
HideCellEditControl();
SaveEditControlValue();
HideCellEditControl();
SaveEditControlValue();
- // init both of them to avoid compiler warnings, even if weo nly need one
+ // init both of them to avoid compiler warnings, even if we only need one
int row = -1,
col = -1;
if ( column )
int row = -1,
col = -1;
if ( column )
// leave some space around text
extentMax += 10;
// leave some space around text
extentMax += 10;
- SetColSize(col, extentMax);
+ SetColSize( col, extentMax );
if ( !GetBatchCount() )
{
int cw, ch, dummy;
if ( !GetBatchCount() )
{
int cw, ch, dummy;
for ( int row = 0; row < m_numRows; row++ )
{
if ( !calcOnly )
for ( int row = 0; row < m_numRows; row++ )
{
if ( !calcOnly )
AutoSizeRow(row, setAsMin);
AutoSizeRow(row, setAsMin);
height += GetRowHeight(row);
}
height += GetRowHeight(row);
}
height = maxheight;
wxSize best(width, height);
height = maxheight;
wxSize best(width, height);
// NOTE: This size should be cached, but first we need to add calls to
// InvalidateBestSize everywhere that could change the results of this
// calculation.
// CacheBestSize(size);
// NOTE: This size should be cached, but first we need to add calls to
// InvalidateBestSize everywhere that could change the results of this
// calculation.
// CacheBestSize(size);
-//
-// ------ Block, row and col selection
-//
+// ----------------------------------------------------------------------------
+// block, row and col selection
+// ----------------------------------------------------------------------------
void wxGrid::SelectRow( int row, bool addToSelected )
{
void wxGrid::SelectRow( int row, bool addToSelected )
{
-//
-// ------ Cell, row and col deselection
-//
+// ----------------------------------------------------------------------------
+// cell, row and col deselection
+// ----------------------------------------------------------------------------
void wxGrid::DeselectRow( int row )
{
void wxGrid::DeselectRow( int row )
{
- rect = wxRect(0,0,0,0);
+ rect = wxRect(0, 0, 0, 0);
}
cellRect = CellToRect( bottomRight );
}
cellRect = CellToRect( bottomRight );
for ( j = topRow; j <= bottomRow; j++ )
{
for ( i = leftCol; i <= rightCol; i++ )
for ( j = topRow; j <= bottomRow; j++ )
{
for ( i = leftCol; i <= rightCol; i++ )
-//
-// ------ Grid event classes
-//
+// ----------------------------------------------------------------------------
+// grid event classes
+// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS( wxGridEvent, wxNotifyEvent )
IMPLEMENT_DYNAMIC_CLASS( wxGridEvent, wxNotifyEvent )