gridWindow->GetOwner()->PrepareDC(dc);
dc.SetPen(*wxTRANSPARENT_PEN);
- dc.SetBrush(wxBrush(attr->GetBackgroundColour(), wxSOLID));
+ dc.SetBrush(wxBrush(attr->GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
dc.DrawRectangle(rectCell);
// redraw the control we just painted over
wxWindowID id,
wxEvtHandler* evtHandler)
{
- int style = wxBORDER_NONE;
- if (!m_allowOthers)
+ int style = wxTE_PROCESS_ENTER |
+ wxTE_PROCESS_TAB |
+ wxBORDER_NONE;
+
+ if ( !m_allowOthers )
style |= wxCB_READONLY;
m_control = new wxComboBox(parent, id, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
- m_choices, style );
+ m_choices,
+ style);
wxGridCellEditor::Create(parent, id, evtHandler);
}
int WXUNUSED(row), int WXUNUSED(col),
bool isSelected)
{
- dc.SetBackgroundMode( wxSOLID );
+ dc.SetBackgroundMode( wxBRUSHSTYLE_SOLID );
// grey out fields if the grid is disabled
if ( grid.IsEnabled() )
clr = grid.GetSelectionBackground();
else
clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW);
- dc.SetBrush( wxBrush(clr, wxSOLID) );
+ dc.SetBrush( wxBrush(clr, wxBRUSHSTYLE_SOLID) );
}
else
{
- dc.SetBrush( wxBrush(attr.GetBackgroundColour(), wxSOLID) );
+ dc.SetBrush( wxBrush(attr.GetBackgroundColour(), wxBRUSHSTYLE_SOLID) );
}
}
else
{
- dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE), wxSOLID));
+ dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE), wxBRUSHSTYLE_SOLID));
}
dc.SetPen( *wxTRANSPARENT_PEN );
wxDC& dc,
bool isSelected)
{
- dc.SetBackgroundMode( wxTRANSPARENT );
+ dc.SetBackgroundMode( wxBRUSHSTYLE_TRANSPARENT );
// TODO some special colours for attr.IsReadOnly() case?
int flags = 0;
if (value)
- flags |= wxCONTROL_CHECKED;
-
+ flags |= wxCONTROL_CHECKED;
+
wxRendererNative::Get().DrawCheckBox( &grid, dc, rectBorder, flags );
}
int n = FindIndex(row, col);
if ( n == wxNOT_FOUND )
{
- // add the attribute
- m_attrs.Add(new wxGridCellWithAttr(row, col, attr));
+ if ( attr )
+ {
+ // add the attribute
+ m_attrs.Add(new wxGridCellWithAttr(row, col, attr));
+ }
+ //else: nothing to do
}
else
{
wxRendererNative::Get().DrawHeaderButton( this, dc, rect, 0 );
#else // !__WXGTK__
- dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW), 1, wxSOLID) );
+ dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW), 1, wxPENSTYLE_SOLID) );
dc.DrawLine( client_width - 1, client_height - 1, client_width - 1, 0 );
dc.DrawLine( client_width - 1, client_height - 1, 0, client_height - 1 );
dc.DrawLine( 0, 0, client_width, 0 );
m_currentCellCoords = coords;
wxGridCellAttr *attr = GetCellAttr( coords );
-#if !defined(__WXMAC__)
+#if !defined(__WXMAC__)
DrawCellHighlight( dc, attr );
#endif
attr->DecRef();
int left, top;
CalcUnscrolledPosition( 0, 0, &left, &top );
- dc.SetBrush( wxBrush(GetDefaultCellBackgroundColour(), wxSOLID) );
+ dc.SetBrush( wxBrush(GetDefaultCellBackgroundColour(), wxBRUSHSTYLE_SOLID) );
dc.SetPen( *wxTRANSPARENT_PEN );
if ( right > rightCol )
// Now draw the rectangle
// use the cellHighlightColour if the cell is inside a selection, this
// will ensure the cell is always visible.
- dc.SetPen(wxPen(IsInSelection(row,col) ? m_selectionForeground : m_cellHighlightColour, penWidth, wxSOLID));
+ dc.SetPen(wxPen(IsInSelection(row,col) ? m_selectionForeground : m_cellHighlightColour, penWidth, wxPENSTYLE_SOLID));
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawRectangle(rect);
}
wxPen wxGrid::GetDefaultGridLinePen()
{
- return wxPen(GetGridLineColour(), 1, wxSOLID);
+ return wxPen(GetGridLineColour(), 1, wxPENSTYLE_SOLID);
}
wxPen wxGrid::GetRowGridLinePen(int WXUNUSED(row))
}
}
- dc.SetClippingRegion( clippedcells );
+ dc.SetDeviceClippingRegion( clippedcells );
// horizontal grid lines
int rowTop = GetRowTop(row),
rowBottom = GetRowBottom(row) - 1;
- dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW), 1, wxSOLID) );
+ dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW), 1, wxPENSTYLE_SOLID) );
dc.DrawLine( m_rowLabelWidth - 1, rowTop, m_rowLabelWidth - 1, rowBottom );
dc.DrawLine( 0, rowTop, 0, rowBottom );
dc.DrawLine( 0, rowBottom, m_rowLabelWidth, rowBottom );
dc.DrawLine( 1, rowTop, 1, rowBottom );
dc.DrawLine( 1, rowTop, m_rowLabelWidth - 1, rowTop );
- dc.SetBackgroundMode( wxTRANSPARENT );
+ dc.SetBackgroundMode( wxBRUSHSTYLE_TRANSPARENT );
dc.SetTextForeground( GetLabelTextColour() );
dc.SetFont( GetLabelFont() );
int height = wxRendererNative::Get().GetHeaderButtonHeight( this );
SetColLabelSize( height );
}
-
+
m_colLabelWin->Refresh();
}
{
int colRight = GetColRight(col) - 1;
- dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW), 1, wxSOLID) );
+ dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW), 1, wxPENSTYLE_SOLID) );
dc.DrawLine( colRight, 0, colRight, m_colLabelHeight - 1 );
dc.DrawLine( colLeft, 0, colRight, 0 );
dc.DrawLine( colLeft, m_colLabelHeight - 1,
dc.DrawLine( colLeft, 1, colRight, 1 );
}
- dc.SetBackgroundMode( wxTRANSPARENT );
+ dc.SetBackgroundMode( wxBRUSHSTYLE_TRANSPARENT );
dc.SetTextForeground( GetLabelTextColour() );
dc.SetFont( GetLabelFont() );
wxClientDC dc( m_gridWin );
PrepareDC( dc );
wxGridCellAttr* attr = GetCellAttr(row, col);
- dc.SetBrush(wxBrush(attr->GetBackgroundColour(), wxSOLID));
+ dc.SetBrush(wxBrush(attr->GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
dc.SetPen(*wxTRANSPARENT_PEN);
dc.DrawRectangle(rect);
if (rect.GetRight() > client_right)
rect.SetRight( client_right - 1 );
}
-
+
editor->SetCellAttr( attr );
editor->SetSize( rect );
if (nXMove != 0)
// make any visible change if the the thickness is getting smaller.
int row = m_currentCellCoords.GetRow();
int col = m_currentCellCoords.GetCol();
- if ( GetColWidth(col) <= 0 || GetRowHeight(row) <= 0 )
+ if ( row == -1 || col == -1 ||
+ GetColWidth(col) <= 0 || GetRowHeight(row) <= 0 )
return;
wxRect rect = CellToRect(row, col);
// This function returns the rectangle that encloses the given block
// in device coords clipped to the client size of the grid window.
//
-wxRect wxGrid::BlockToDeviceRect( const wxGridCellCoords &topLeft,
- const wxGridCellCoords &bottomRight ) const
+wxRect wxGrid::BlockToDeviceRect( const wxGridCellCoords& topLeft,
+ const wxGridCellCoords& bottomRight ) const
{
- wxRect rect( wxGridNoCellRect );
- wxRect cellRect;
-
- cellRect = CellToRect( topLeft );
- if ( cellRect != wxGridNoCellRect )
+ wxRect resultRect;
+ wxRect tempCellRect = CellToRect(topLeft);
+ if ( tempCellRect != wxGridNoCellRect )
{
- rect = cellRect;
+ resultRect = tempCellRect;
}
else
{
- rect = wxRect(0, 0, 0, 0);
+ resultRect = wxRect(0, 0, 0, 0);
}
- cellRect = CellToRect( bottomRight );
- if ( cellRect != wxGridNoCellRect )
+ tempCellRect = CellToRect(bottomRight);
+ if ( tempCellRect != wxGridNoCellRect )
{
- rect += cellRect;
+ resultRect += tempCellRect;
}
else
{
+ // If both inputs were "wxGridNoCellRect," then there's nothing to do.
return wxGridNoCellRect;
}
- int i, j;
- int left = rect.GetLeft();
- int top = rect.GetTop();
- int right = rect.GetRight();
- int bottom = rect.GetBottom();
+ // Ensure that left/right and top/bottom pairs are in order.
+ int left = resultRect.GetLeft();
+ int top = resultRect.GetTop();
+ int right = resultRect.GetRight();
+ int bottom = resultRect.GetBottom();
int leftCol = topLeft.GetCol();
int topRow = topLeft.GetRow();
if (left > right)
{
- i = left;
+ int tmp = left;
left = right;
- right = i;
- i = leftCol;
+ right = tmp;
+
+ tmp = leftCol;
leftCol = rightCol;
- rightCol = i;
+ rightCol = tmp;
}
if (top > bottom)
{
- i = top;
+ int tmp = top;
top = bottom;
- bottom = i;
- i = topRow;
+ bottom = tmp;
+
+ tmp = topRow;
topRow = bottomRow;
- bottomRow = i;
+ bottomRow = tmp;
}
- for ( j = topRow; j <= bottomRow; j++ )
+ // The following loop is ONLY necessary to detect and handle merged cells.
+ int cw, ch;
+ m_gridWin->GetClientSize( &cw, &ch );
+
+ // Get the origin coordinates: notice that they will be negative if the
+ // grid is scrolled downwards/to the right.
+ int gridOriginX = 0;
+ int gridOriginY = 0;
+ CalcScrolledPosition(gridOriginX, gridOriginY, &gridOriginX, &gridOriginY);
+
+ int onScreenLeftmostCol = internalXToCol(-gridOriginX);
+ int onScreenUppermostRow = internalYToRow(-gridOriginY);
+
+ int onScreenRightmostCol = internalXToCol(-gridOriginX + cw);
+ int onScreenBottommostRow = internalYToRow(-gridOriginY + ch);
+
+ // Bound our loop so that we only examine the portion of the selected block
+ // that is shown on screen. Therefore, we compare the Top-Left block values
+ // to the Top-Left screen values, and the Bottom-Right block values to the
+ // Bottom-Right screen values, choosing appropriately.
+ const int visibleTopRow = wxMax(topRow, onScreenUppermostRow);
+ const int visibleBottomRow = wxMin(bottomRow, onScreenBottommostRow);
+ const int visibleLeftCol = wxMax(leftCol, onScreenLeftmostCol);
+ const int visibleRightCol = wxMin(rightCol, onScreenRightmostCol);
+
+ for ( int j = visibleTopRow; j <= visibleBottomRow; j++ )
{
- for ( i = leftCol; i <= rightCol; i++ )
+ for ( int i = visibleLeftCol; i <= visibleRightCol; i++ )
{
- if ((j == topRow) || (j == bottomRow) || (i == leftCol) || (i == rightCol))
+ if ( (j == visibleTopRow) || (j == visibleBottomRow) ||
+ (i == visibleLeftCol) || (i == visibleRightCol) )
{
- cellRect = CellToRect( j, i );
+ tempCellRect = CellToRect( j, i );
- if (cellRect.x < left)
- left = cellRect.x;
- if (cellRect.y < top)
- top = cellRect.y;
- if (cellRect.x + cellRect.width > right)
- right = cellRect.x + cellRect.width;
- if (cellRect.y + cellRect.height > bottom)
- bottom = cellRect.y + cellRect.height;
+ if (tempCellRect.x < left)
+ left = tempCellRect.x;
+ if (tempCellRect.y < top)
+ top = tempCellRect.y;
+ if (tempCellRect.x + tempCellRect.width > right)
+ right = tempCellRect.x + tempCellRect.width;
+ if (tempCellRect.y + tempCellRect.height > bottom)
+ bottom = tempCellRect.y + tempCellRect.height;
}
else
{
- i = rightCol; // jump over inner cells.
+ i = visibleRightCol; // jump over inner cells.
}
}
}
- // convert to scrolled coords
- //
+ // Convert to scrolled coords
CalcScrolledPosition( left, top, &left, &top );
CalcScrolledPosition( right, bottom, &right, &bottom );
- int cw, ch;
- m_gridWin->GetClientSize( &cw, &ch );
-
if (right < 0 || bottom < 0 || left > cw || top > ch)
return wxRect(0,0,0,0);
- rect.SetLeft( wxMax(0, left) );
- rect.SetTop( wxMax(0, top) );
- rect.SetRight( wxMin(cw, right) );
- rect.SetBottom( wxMin(ch, bottom) );
+ resultRect.SetLeft( wxMax(0, left) );
+ resultRect.SetTop( wxMax(0, top) );
+ resultRect.SetRight( wxMin(cw, right) );
+ resultRect.SetBottom( wxMin(ch, bottom) );
- return rect;
+ return resultRect;
}
// ----------------------------------------------------------------------------