cleanup - reformatting

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38862 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Surovell
2006-04-20 18:23:01 +00:00
parent 900ca9b89a
commit a9339fe22c

View File

@@ -262,7 +262,6 @@ BEGIN_EVENT_TABLE( wxGridCellEditorEvtHandler, wxEvtHandler )
END_EVENT_TABLE() END_EVENT_TABLE()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// the internal data representation used by wxGridCellAttrProvider // the internal data representation used by wxGridCellAttrProvider
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -370,6 +369,7 @@ private:
wxGridDataTypeInfoArray m_typeinfo; wxGridDataTypeInfoArray m_typeinfo;
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// conditional compilation // conditional compilation
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -507,6 +507,7 @@ void wxGridCellEditor::Show(bool show, wxGridCellAttr *attr)
m_fontOld = m_control->GetFont(); m_fontOld = m_control->GetFont();
m_control->SetFont(attr->GetFont()); m_control->SetFont(attr->GetFont());
#endif #endif
// can't do anything more in the base class version, the other // can't do anything more in the base class version, the other
// attributes may only be used by the derived classes // attributes may only be used by the derived classes
} }
@@ -631,8 +632,8 @@ void wxGridCellTextEditor::Create(wxWindow* parent,
void wxGridCellTextEditor::PaintBackground(const wxRect& WXUNUSED(rectCell), void wxGridCellTextEditor::PaintBackground(const wxRect& WXUNUSED(rectCell),
wxGridCellAttr * WXUNUSED(attr)) wxGridCellAttr * WXUNUSED(attr))
{ {
// as we fill the entire client area, don't do anything here to minimize // as we fill the entire client area,
// flicker // don't do anything here to minimize flicker
} }
void wxGridCellTextEditor::SetSize(const wxRect& rectOrig) void wxGridCellTextEditor::SetSize(const wxRect& rectOrig)
@@ -706,6 +707,7 @@ bool wxGridCellTextEditor::EndEdit(int row, int col, wxGrid* grid)
grid->GetTable()->SetValue(row, col, value); grid->GetTable()->SetValue(row, col, value);
m_startValue = wxEmptyString; m_startValue = wxEmptyString;
// No point in setting the text of the hidden control // No point in setting the text of the hidden control
//Text()->SetValue(m_startValue); //Text()->SetValue(m_startValue);
@@ -5795,7 +5797,6 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
} }
} }
// ------------ Left double click // ------------ Left double click
// //
else if ( event.LeftDClick() && coords != wxGridNoCellCoords ) else if ( event.LeftDClick() && coords != wxGridNoCellCoords )
@@ -5816,7 +5817,6 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
} }
} }
// ------------ Left button released // ------------ Left button released
// //
else if ( event.LeftUp() ) else if ( event.LeftUp() )
@@ -6077,6 +6077,7 @@ void wxGrid::DoEndDragResizeCol()
if (cell_cols < subtract_cols) if (cell_cols < subtract_cols)
subtract_cols = cell_cols; subtract_cols = cell_cols;
} }
rect.x = GetColLeft(m_dragRowOrCol + subtract_cols); rect.x = GetColLeft(m_dragRowOrCol + subtract_cols);
CalcScrolledPosition(rect.x, 0, &rect.x, &dummy); CalcScrolledPosition(rect.x, 0, &rect.x, &dummy);
rect.width = cw - rect.x; rect.width = cw - rect.x;
@@ -6129,7 +6130,8 @@ void wxGrid::ClearGrid()
DisableCellEditControl(); DisableCellEditControl();
m_table->Clear(); m_table->Clear();
if ( !GetBatchCount() ) m_gridWin->Refresh(); if ( !GetBatchCount()
m_gridWin->Refresh();
} }
} }
@@ -6154,6 +6156,7 @@ bool wxGrid::InsertRows( int pos, int numRows, bool WXUNUSED(updateLabels) )
// the table will have sent the results of the insert row // the table will have sent the results of the insert row
// operation to this view object as a grid table message // operation to this view object as a grid table message
} }
return false; return false;
} }
@@ -6171,9 +6174,11 @@ bool wxGrid::AppendRows( int numRows, bool WXUNUSED(updateLabels) )
{ {
bool done = m_table && m_table->AppendRows( numRows ); bool done = m_table && m_table->AppendRows( numRows );
return done; return done;
// the table will have sent the results of the append row // the table will have sent the results of the append row
// operation to this view object as a grid table message // operation to this view object as a grid table message
} }
return false; return false;
} }
@@ -6197,6 +6202,7 @@ bool wxGrid::DeleteRows( int pos, int numRows, bool WXUNUSED(updateLabels) )
// the table will have sent the results of the delete row // the table will have sent the results of the delete row
// operation to this view object as a grid table message // operation to this view object as a grid table message
} }
return false; return false;
} }
@@ -6347,27 +6353,20 @@ int wxGrid::SendEvent( const wxEventType type,
int wxGrid::SendEvent( const wxEventType type, int wxGrid::SendEvent( const wxEventType type,
int row, int col ) int row, int col )
{ {
bool claimed; bool claimed, vetoed;
bool vetoed;
if ( type == wxEVT_GRID_ROW_SIZE || type == wxEVT_GRID_COL_SIZE ) if ( type == wxEVT_GRID_ROW_SIZE || type == wxEVT_GRID_COL_SIZE )
{ {
int rowOrCol = (row == -1 ? col : row); int rowOrCol = (row == -1 ? col : row);
wxGridSizeEvent gridEvt( GetId(), wxGridSizeEvent gridEvt( GetId(), type, this, rowOrCol );
type,
this,
rowOrCol );
claimed = GetEventHandler()->ProcessEvent(gridEvt); claimed = GetEventHandler()->ProcessEvent(gridEvt);
vetoed = !gridEvt.IsAllowed(); vetoed = !gridEvt.IsAllowed();
} }
else else
{ {
wxGridEvent gridEvt( GetId(), wxGridEvent gridEvt( GetId(), type, this, row, col );
type,
this,
row, col );
claimed = GetEventHandler()->ProcessEvent(gridEvt); claimed = GetEventHandler()->ProcessEvent(gridEvt);
vetoed = !gridEvt.IsAllowed(); vetoed = !gridEvt.IsAllowed();
@@ -6411,7 +6410,8 @@ void wxGrid::Refresh(bool eraseb, const wxRect* rect)
width_label = rectWidth; width_label = rectWidth;
height_label = m_colLabelHeight - rect_y; height_label = m_colLabelHeight - rect_y;
if (height_label > rectHeight) height_label = rectHeight; if (height_label > rectHeight)
height_label = rectHeight;
if (rect_x > m_rowLabelWidth) if (rect_x > m_rowLabelWidth)
{ {
@@ -6495,7 +6495,6 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
m_inOnKeyDown = true; m_inOnKeyDown = true;
// propagate the event up and see if it gets processed // propagate the event up and see if it gets processed
//
wxWindow *parent = GetParent(); wxWindow *parent = GetParent();
wxKeyEvent keyEvt( event ); wxKeyEvent keyEvt( event );
keyEvt.SetEventObject( parent ); keyEvt.SetEventObject( parent );
@@ -6503,7 +6502,6 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
if ( !parent->GetEventHandler()->ProcessEvent( keyEvt ) ) if ( !parent->GetEventHandler()->ProcessEvent( keyEvt ) )
{ {
// try local handlers // try local handlers
//
switch ( event.GetKeyCode() ) switch ( event.GetKeyCode() )
{ {
case WXK_UP: case WXK_UP:
@@ -6622,7 +6620,8 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
{ {
if ( m_selection ) if ( m_selection )
{ {
m_selection->ToggleCellSelection( m_currentCellCoords.GetRow(), m_selection->ToggleCellSelection(
m_currentCellCoords.GetRow(),
m_currentCellCoords.GetCol(), m_currentCellCoords.GetCol(),
event.ControlDown(), event.ControlDown(),
event.ShiftDown(), event.ShiftDown(),
@@ -6658,7 +6657,8 @@ void wxGrid::OnKeyUp( wxKeyEvent& event )
{ {
if ( m_selection ) if ( m_selection )
{ {
m_selection->SelectBlock( m_selectingTopLeft.GetRow(), m_selection->SelectBlock(
m_selectingTopLeft.GetRow(),
m_selectingTopLeft.GetCol(), m_selectingTopLeft.GetCol(),
m_selectingBottomRight.GetRow(), m_selectingBottomRight.GetRow(),
m_selectingBottomRight.GetCol(), m_selectingBottomRight.GetCol(),
@@ -6866,10 +6866,9 @@ void wxGrid::HighlightBlock( int topRow, int leftCol, int bottomRow, int rightCo
// Refresh the newly selected or deselected // Refresh the newly selected or deselected
// area to the left of the old or new selection. // area to the left of the old or new selection.
need_refresh[0] = true; need_refresh[0] = true;
rect[0] = BlockToDeviceRect( wxGridCellCoords ( oldTop, rect[0] = BlockToDeviceRect(
oldLeft ), wxGridCellCoords( oldTop, oldLeft ),
wxGridCellCoords ( oldBottom, wxGridCellCoords( oldBottom, leftCol - 1 ) );
leftCol - 1 ) );
} }
if ( oldTop < topRow ) if ( oldTop < topRow )
@@ -7133,7 +7132,7 @@ void wxGrid::DrawCell( wxDC& dc, const wxGridCellCoords& coords )
// Note: However, only if it is really _shown_, i.e. not hidden! // Note: However, only if it is really _shown_, i.e. not hidden!
if ( isCurrent && IsCellEditControlShown() ) if ( isCurrent && IsCellEditControlShown() )
{ {
// OSAF NB: this "#if..." is temporary and fixes a problem where the // NB: this "#if..." is temporary and fixes a problem where the
// edit control is erased by this code after being rendered. // edit control is erased by this code after being rendered.
// On wxMac (QD build only), the cell editor is a wxTextCntl and is rendered // On wxMac (QD build only), the cell editor is a wxTextCntl and is rendered
// implicitly, causing this out-of order render. // implicitly, causing this out-of order render.
@@ -7145,8 +7144,7 @@ void wxGrid::DrawCell( wxDC& dc, const wxGridCellCoords& coords )
} }
else else
{ {
// but all the rest is drawn by the cell renderer and hence may be // but all the rest is drawn by the cell renderer and hence may be customized
// customized
wxGridCellRenderer *renderer = attr->GetRenderer(this, row, col); wxGridCellRenderer *renderer = attr->GetRenderer(this, row, col);
renderer->Draw(*this, *attr, dc, rect, row, col, IsInSelection(coords)); renderer->Draw(*this, *attr, dc, rect, row, col, IsInSelection(coords));
renderer->DecRef(); renderer->DecRef();
@@ -7174,7 +7172,7 @@ void wxGrid::DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr )
if (penWidth > 0) if (penWidth > 0)
{ {
// The center of th drawn line is where the position/width/height of // The center of th drawn line is where the position/width/height of
// the rectangle is actually at, (on wxMSW atr least,) so we will // the rectangle is actually at, (on wxMSW at least,) so we will
// reduce the size of the rectangle to compensate for the thickness of // reduce the size of the rectangle to compensate for the thickness of
// the line. If this is too strange on non wxMSW platforms then // the line. If this is too strange on non wxMSW platforms then
// please #ifdef this appropriately. // please #ifdef this appropriately.
@@ -7210,7 +7208,7 @@ void wxGrid::DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr )
dc.SetPen(*wxBLACK_PEN); dc.SetPen(*wxBLACK_PEN);
dc.DrawLine(x1, y2, x2, y2); dc.DrawLine(x1, y2, x2, y2);
dc.DrawLine(x2, y1, x2, y2 + 1); dc.DrawLine(x2, y1, x2, y2 + 1);
#endif // 0 #endif
} }
void wxGrid::DrawCellBorder( wxDC& dc, const wxGridCellCoords& coords ) void wxGrid::DrawCellBorder( wxDC& dc, const wxGridCellCoords& coords )
@@ -7225,12 +7223,10 @@ void wxGrid::DrawCellBorder( wxDC& dc, const wxGridCellCoords& coords )
wxRect rect = CellToRect( row, col ); wxRect rect = CellToRect( row, col );
// right hand border // right hand border
//
dc.DrawLine( rect.x + rect.width, rect.y, dc.DrawLine( rect.x + rect.width, rect.y,
rect.x + rect.width, rect.y + rect.height + 1 ); rect.x + rect.width, rect.y + rect.height + 1 );
// bottom border // bottom border
//
dc.DrawLine( rect.x, rect.y + rect.height, dc.DrawLine( rect.x, rect.y + rect.height,
rect.x + rect.width, rect.y + rect.height); rect.x + rect.width, rect.y + rect.height);
} }
@@ -7369,6 +7365,7 @@ void wxGrid::DrawAllGridLines( wxDC& dc, const wxRegion & WXUNUSED(reg) )
} }
} }
#endif #endif
dc.SetClippingRegion( clippedcells ); dc.SetClippingRegion( clippedcells );
dc.SetPen( wxPen(GetGridLineColour(), 1, wxSOLID) ); dc.SetPen( wxPen(GetGridLineColour(), 1, wxSOLID) );
@@ -7406,6 +7403,7 @@ void wxGrid::DrawAllGridLines( wxDC& dc, const wxRegion & WXUNUSED(reg) )
dc.DrawLine( colRight, top, colRight, bottom ); dc.DrawLine( colRight, top, colRight, bottom );
} }
} }
dc.DestroyClippingRegion(); dc.DestroyClippingRegion();
} }
@@ -7446,11 +7444,8 @@ void wxGrid::DrawRowLabel( wxDC& dc, int row )
rowBottom = GetRowBottom(row) - 1; rowBottom = GetRowBottom(row) - 1;
dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW), 1, wxSOLID) ); dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW), 1, wxSOLID) );
dc.DrawLine( m_rowLabelWidth-1, rowTop, dc.DrawLine( m_rowLabelWidth - 1, rowTop, m_rowLabelWidth - 1, rowBottom );
m_rowLabelWidth-1, rowBottom );
dc.DrawLine( 0, rowTop, 0, rowBottom ); dc.DrawLine( 0, rowTop, 0, rowBottom );
dc.DrawLine( 0, rowBottom, m_rowLabelWidth, rowBottom ); dc.DrawLine( 0, rowBottom, m_rowLabelWidth, rowBottom );
dc.SetPen( *wxWHITE_PEN ); dc.SetPen( *wxWHITE_PEN );
@@ -7509,9 +7504,7 @@ void wxGrid::DrawColLabel( wxDC& dc, int col )
dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW), 1, wxSOLID) ); dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW), 1, wxSOLID) );
dc.DrawLine( colRight, 0, colRight, m_colLabelHeight - 1 ); dc.DrawLine( colRight, 0, colRight, m_colLabelHeight - 1 );
dc.DrawLine( colLeft, 0, colRight, 0 ); dc.DrawLine( colLeft, 0, colRight, 0 );
dc.DrawLine( colLeft, m_colLabelHeight - 1, dc.DrawLine( colLeft, m_colLabelHeight - 1,
colRight + 1, m_colLabelHeight - 1 ); colRight + 1, m_colLabelHeight - 1 );
@@ -7675,6 +7668,7 @@ void wxGrid::StringToLines( const wxString& value, wxArrayString& lines )
{ {
lines.Add( value.Mid(startPos, pos) ); lines.Add( value.Mid(startPos, pos) );
} }
startPos += pos + 1; startPos += pos + 1;
} }
@@ -7773,8 +7767,7 @@ void wxGrid::EnableCellEditControl( bool enable )
return; return;
// this should be checked by the caller! // this should be checked by the caller!
wxASSERT_MSG( CanEnableCellControl(), wxASSERT_MSG( CanEnableCellControl(), _T("can't enable editing for this cell!") );
_T("can't enable editing for this cell!") );
// do it before ShowCellEditControl() // do it before ShowCellEditControl()
m_cellEditCtrlEnabled = enable; m_cellEditCtrlEnabled = enable;
@@ -7809,7 +7802,6 @@ bool wxGrid::CanEnableCellControl() const
{ {
return m_editable && (m_currentCellCoords != wxGridNoCellCoords) && return m_editable && (m_currentCellCoords != wxGridNoCellCoords) &&
!IsCurrentCellReadOnly(); !IsCurrentCellReadOnly();
} }
bool wxGrid::IsCellEditControlEnabled() const bool wxGrid::IsCellEditControlEnabled() const
@@ -7872,14 +7864,13 @@ void wxGrid::ShowCellEditControl()
} }
// convert to scrolled coords // convert to scrolled coords
//
CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y ); CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
int nXMove = 0; int nXMove = 0;
if (rect.x < 0) if (rect.x < 0)
nXMove = rect.x; nXMove = rect.x;
// done in PaintBackground() // performed in PaintBackground()
#if 0 #if 0
// erase the highlight and the cell contents because the editor // erase the highlight and the cell contents because the editor
// might not cover the entire cell // might not cover the entire cell
@@ -7888,7 +7879,7 @@ void wxGrid::ShowCellEditControl()
dc.SetBrush(*wxLIGHT_GREY_BRUSH); //wxBrush(attr->GetBackgroundColour(), wxSOLID)); dc.SetBrush(*wxLIGHT_GREY_BRUSH); //wxBrush(attr->GetBackgroundColour(), wxSOLID));
dc.SetPen(*wxTRANSPARENT_PEN); dc.SetPen(*wxTRANSPARENT_PEN);
dc.DrawRectangle(rect); dc.DrawRectangle(rect);
#endif // 0 #endif
// cell is shifted by one pixel // cell is shifted by one pixel
// However, don't allow x or y to become negative // However, don't allow x or y to become negative
@@ -8176,7 +8167,7 @@ int wxGrid::XToEdgeOfCol( int x )
if ( GetColWidth(i) > WXGRID_LABEL_EDGE_ZONE ) if ( GetColWidth(i) > WXGRID_LABEL_EDGE_ZONE )
{ {
// We know that we are in column i, test whether we are // We know that we are in column i; test whether we are
// close enough to right or left border, respectively. // close enough to right or left border, respectively.
if ( abs(GetColRight(i) - x) < WXGRID_LABEL_EDGE_ZONE ) if ( abs(GetColRight(i) - x) < WXGRID_LABEL_EDGE_ZONE )
return i; return i;
@@ -8241,7 +8232,6 @@ bool wxGrid::IsVisible( int row, int col, bool wholeCellVisible )
if ( wholeCellVisible ) if ( wholeCellVisible )
{ {
// is the cell wholly visible ? // is the cell wholly visible ?
//
return ( left >= 0 && right <= cw && return ( left >= 0 && right <= cw &&
top >= 0 && bottom <= ch ); top >= 0 && bottom <= ch );
} }
@@ -8884,7 +8874,8 @@ void wxGrid::SetColLabelSize( int height )
else if ( m_colLabelHeight == 0 ) else if ( m_colLabelHeight == 0 )
{ {
m_colLabelWin->Show( true ); m_colLabelWin->Show( true );
if ( m_rowLabelWidth > 0 ) m_cornerLabelWin->Show( true ); if ( m_rowLabelWidth > 0 )
m_cornerLabelWin->Show( true );
} }
m_colLabelHeight = height; m_colLabelHeight = height;
@@ -9010,15 +9001,11 @@ void wxGrid::SetColLabelAlignment( int horiz, int vert )
void wxGrid::SetColLabelTextOrientation( int textOrientation ) void wxGrid::SetColLabelTextOrientation( int textOrientation )
{ {
if ( textOrientation == wxHORIZONTAL || textOrientation == wxVERTICAL ) if ( textOrientation == wxHORIZONTAL || textOrientation == wxVERTICAL )
{
m_colLabelTextOrientation = textOrientation; m_colLabelTextOrientation = textOrientation;
}
if ( !GetBatchCount() ) if ( !GetBatchCount() )
{
m_colLabelWin->Refresh(); m_colLabelWin->Refresh();
} }
}
void wxGrid::SetRowLabelValue( int row, const wxString& s ) void wxGrid::SetRowLabelValue( int row, const wxString& s )
{ {