X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2049ba38adafa0ec146880de29f26e32dd69a125..217e13fa85b151b701e19f0e345f977231ec0b16:/src/generic/gridg.cpp?ds=sidebyside diff --git a/src/generic/gridg.cpp b/src/generic/gridg.cpp index 9c3ff80d3a..d12a8a9e1b 100644 --- a/src/generic/gridg.cpp +++ b/src/generic/gridg.cpp @@ -33,9 +33,9 @@ // Set to zero to use no double-buffering #ifdef __WXMSW__ -#define USE_DOUBLE_BUFFERING 1 +#define wxUSE_DOUBLE_BUFFERING 1 #else -#define USE_DOUBLE_BUFFERING 0 +#define wxUSE_DOUBLE_BUFFERING 0 #endif #define wxGRID_DRAG_NONE 0 @@ -57,16 +57,17 @@ END_EVENT_TABLE() wxGenericGrid::wxGenericGrid(void) { m_batchCount = 0; - m_hScrollBar = NULL; - m_vScrollBar = NULL; + m_hScrollBar = (wxScrollBar *) NULL; + m_vScrollBar = (wxScrollBar *) NULL; m_cellTextColour = *wxBLACK; m_cellBackgroundColour = *wxWHITE; m_labelTextColour = *wxBLACK; - m_labelBackgroundColour = *wxLIGHT_GREY; - m_labelBackgroundBrush = NULL; - m_labelTextFont = NULL; - m_cellTextFont = NULL; - m_textItem = NULL; +// m_labelBackgroundColour = *wxLIGHT_GREY; + m_labelBackgroundColour = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); + m_labelBackgroundBrush = (wxBrush *) NULL; + m_labelTextFont = (wxFont *) NULL; + m_cellTextFont = (wxFont *) NULL; + m_textItem = (wxTextCtrl *) NULL; m_currentRectVisible = FALSE; m_editable = TRUE; #if defined(__WIN95__) @@ -78,14 +79,14 @@ wxGenericGrid::wxGenericGrid(void) m_dragRowOrCol = 0; m_dragStartPosition = 0; m_dragLastPosition = 0; - m_divisionPen = NULL; + m_divisionPen = (wxPen *) NULL; m_leftOfSheet = wxGRID_DEFAULT_SHEET_LEFT; m_topOfSheet = wxGRID_DEFAULT_SHEET_TOP; m_cellHeight = wxGRID_DEFAULT_CELL_HEIGHT; m_totalGridWidth = 0; m_totalGridHeight = 0; - m_colWidths = NULL; - m_rowHeights = NULL; + m_colWidths = (short *) NULL; + m_rowHeights = (short *) NULL; m_verticalLabelWidth = wxGRID_DEFAULT_VERTICAL_LABEL_WIDTH; m_horizontalLabelHeight = wxGRID_DEFAULT_HORIZONAL_LABEL_HEIGHT; m_verticalLabelAlignment = wxCENTRE; @@ -101,31 +102,32 @@ wxGenericGrid::wxGenericGrid(void) m_editCreated = FALSE; m_totalRows = 0; m_totalCols = 0; - m_gridCells = NULL; - m_rowLabelCells = NULL; - m_colLabelCells = NULL; - m_textItem = NULL; - m_horizontalSashCursor = NULL; - m_verticalSashCursor = NULL; + m_gridCells = (wxGridCell ***) NULL; + m_rowLabelCells = (wxGridCell **) NULL; + m_colLabelCells = (wxGridCell **) NULL; + m_textItem = (wxTextCtrl *) NULL; + m_horizontalSashCursor = (wxCursor *) NULL; + m_verticalSashCursor = (wxCursor *) NULL; } bool wxGenericGrid::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { m_batchCount = 0; - m_editingPanel = NULL; - m_hScrollBar = NULL; - m_vScrollBar = NULL; - m_horizontalSashCursor = NULL; - m_verticalSashCursor = NULL; + m_editingPanel = (wxPanel *) NULL; + m_hScrollBar = (wxScrollBar *) NULL; + m_vScrollBar = (wxScrollBar *) NULL; + m_horizontalSashCursor = (wxCursor *) NULL; + m_verticalSashCursor = (wxCursor *) NULL; m_cellTextColour = *wxBLACK; m_cellBackgroundColour = *wxWHITE; m_labelTextColour = *wxBLACK; - m_labelBackgroundColour = *wxLIGHT_GREY; - m_labelBackgroundBrush = NULL; +// m_labelBackgroundColour = *wxLIGHT_GREY; + m_labelBackgroundColour = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); + m_labelBackgroundBrush = (wxBrush *) NULL; m_labelTextFont = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxBOLD); m_cellTextFont = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL); - m_textItem = NULL; + m_textItem = (wxTextCtrl *) NULL; m_currentRectVisible = FALSE; m_editable = TRUE; #if defined(__WIN95__) @@ -138,7 +140,7 @@ bool wxGenericGrid::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, m_dragStartPosition = 0; m_dragLastPosition = 0; m_divisionPen = wxThePenList->FindOrCreatePen("LIGHT GREY", 1, wxSOLID); - m_doubleBufferingBitmap = NULL; + m_doubleBufferingBitmap = (wxBitmap *) NULL; if (!m_horizontalSashCursor) { @@ -153,8 +155,8 @@ bool wxGenericGrid::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, m_cellHeight = wxGRID_DEFAULT_CELL_HEIGHT; m_totalGridWidth = 0; m_totalGridHeight = 0; - m_colWidths = NULL; - m_rowHeights = NULL; + m_colWidths = (short *) NULL; + m_rowHeights = (short *) NULL; m_verticalLabelWidth = wxGRID_DEFAULT_VERTICAL_LABEL_WIDTH; m_horizontalLabelHeight = wxGRID_DEFAULT_HORIZONAL_LABEL_HEIGHT; @@ -178,10 +180,10 @@ bool wxGenericGrid::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, m_totalRows = 0; m_totalCols = 0; - m_gridCells = NULL; - m_rowLabelCells = NULL; - m_colLabelCells = NULL; - m_textItem = NULL; + m_gridCells = (wxGridCell ***) NULL; + m_rowLabelCells = (wxGridCell **) NULL; + m_colLabelCells = (wxGridCell **) NULL; + m_textItem = (wxTextCtrl *) NULL; wxPanel::Create(parent, id, pos, size, style, name); @@ -225,33 +227,33 @@ void wxGenericGrid::ClearGrid(void) delete[] m_gridCells[i]; } delete[] m_gridCells; - m_gridCells = NULL; + m_gridCells = (wxGridCell ***) NULL; } if (m_colWidths) delete[] m_colWidths; - m_colWidths = NULL; + m_colWidths = (short *) NULL; if (m_rowHeights) delete[] m_rowHeights; - m_rowHeights = NULL; + m_rowHeights = (short *) NULL; if (m_rowLabelCells) { for (i = 0; i < m_totalRows; i++) delete m_rowLabelCells[i]; delete[] m_rowLabelCells; - m_rowLabelCells = NULL; + m_rowLabelCells = (wxGridCell **) NULL; } if (m_colLabelCells) { for (i = 0; i < m_totalCols; i++) delete m_colLabelCells[i]; delete[] m_colLabelCells; - m_colLabelCells = NULL; + m_colLabelCells = (wxGridCell **) NULL; } if (m_doubleBufferingBitmap) { delete m_doubleBufferingBitmap; - m_doubleBufferingBitmap = NULL; + m_doubleBufferingBitmap = (wxBitmap *) NULL; } } @@ -285,7 +287,7 @@ bool wxGenericGrid::CreateGrid(int nRows, int nCols, wxString **cellValues, shor m_gridCells[i][j]->SetTextValue(cellValues[i][j]); } else - m_gridCells[i][j] = NULL; + m_gridCells[i][j] = (wxGridCell *) NULL; m_rowLabelCells = new wxGridCell *[nRows]; for (i = 0; i < nRows; i++) @@ -304,17 +306,25 @@ bool wxGenericGrid::CreateGrid(int nRows, int nCols, wxString **cellValues, shor int objectSizeX = m_totalCols; int pageSizeX = 1; int viewLengthX = m_totalCols; + +/* m_hScrollBar->SetViewLength(viewLengthX); m_hScrollBar->SetObjectLength(objectSizeX); m_hScrollBar->SetPageSize(pageSizeX); +*/ + m_hScrollBar->SetScrollbar(m_hScrollBar->GetPosition(), pageSizeX, objectSizeX, viewLengthX); int objectSizeY = m_totalRows; int pageSizeY = 1; int viewLengthY = m_totalRows; +/* m_vScrollBar->SetViewLength(viewLengthY); m_vScrollBar->SetObjectLength(objectSizeY); m_vScrollBar->SetPageSize(pageSizeY); +*/ + + m_vScrollBar->SetScrollbar(m_vScrollBar->GetPosition(), pageSizeY, objectSizeY, viewLengthY); AdjustScrollbars(); @@ -371,10 +381,10 @@ void wxGenericGrid::UpdateDimensions(void) wxGridCell *wxGenericGrid::GetCell(int row, int col) { if (!m_gridCells) - return NULL; + return (wxGridCell *) NULL; if ((row >= m_totalRows) || (col >= m_totalCols)) - return NULL; + return (wxGridCell *) NULL; wxGridCell *cell = m_gridCells[row][col]; if (!cell) @@ -405,11 +415,10 @@ void wxGenericGrid::SetGridClippingRegion(wxDC *dc) void wxGenericGrid::OnPaint(wxPaintEvent& WXUNUSED(event)) { - wxRectangle rect; int w, h; GetClientSize(&w, &h); - bool useDoubleBuffering = (bool) USE_DOUBLE_BUFFERING; + bool useDoubleBuffering = (bool) wxUSE_DOUBLE_BUFFERING; if (useDoubleBuffering) { // Reuse the old bitmap if possible @@ -427,7 +436,7 @@ void wxGenericGrid::OnPaint(wxPaintEvent& WXUNUSED(event)) // then don't complain, just don't double-buffer if (m_doubleBufferingBitmap) delete m_doubleBufferingBitmap; - m_doubleBufferingBitmap = NULL; + m_doubleBufferingBitmap = (wxBitmap *) NULL; useDoubleBuffering = FALSE; } } @@ -486,7 +495,7 @@ void wxGenericGrid::PaintGrid(wxDC& dc) // Erase (some of) the background. // Currently, a Windows-only optimisation. -void wxGenericGrid::OnEraseBackground(wxEraseEvent& event) +void wxGenericGrid::OnEraseBackground(wxEraseEvent& WXUNUSED(event) ) { wxClientDC dc(this); dc.BeginDrawing(); @@ -840,11 +849,17 @@ void wxGenericGrid::DrawCellBackground(wxDC *dc, wxRectangle *rect, int row, int { dc->SetBrush(*cell->GetBackgroundBrush()); dc->SetPen(*wxTRANSPARENT_PEN); + +#if 0 // In wxWin 2.0 the dc code is exact. RR. #ifdef __WXMOTIF__ dc->DrawRectangle(rect->x+1, rect->y+1, rect->width-1, rect->height-1); #else dc->DrawRectangle(rect->x+1, rect->y+1, rect->width, rect->height); #endif +#endif + + dc->DrawRectangle(rect->x+1, rect->y+1, rect->width-1, rect->height-1); + dc->SetPen(*wxBLACK_PEN); } } @@ -1009,7 +1024,7 @@ void wxGenericGrid::AdjustScrollbars(void) */ m_hScrollBar->SetScrollbar(m_hScrollBar->GetPosition(), wxMax(noHorizSteps, 1), nCols, wxMax(noHorizSteps, 1)); - m_hScrollBar->SetSize(m_leftOfSheet, ch - m_scrollWidth, + m_hScrollBar->SetSize(m_leftOfSheet, ch - m_scrollWidth -2, cw - vertScrollBarWidth - m_leftOfSheet, m_scrollWidth); } @@ -1371,8 +1386,9 @@ void wxGenericGrid::OnSelectCellImplementation(wxDC *dc, int row, int col) // Why isn't this needed for Windows?? // Probably because of the SetValue?? + // Arrrrrgh. This isn't needed anywhere, of course. RR. #ifndef __WXMSW__ - HighlightCell(dc); +// HighlightCell(dc); #endif dc->DestroyClippingRegion(); @@ -1428,16 +1444,27 @@ void wxGenericGrid::OnChangeSelectionLabel(void) void wxGenericGrid::HighlightCell(wxDC *dc) { dc->SetLogicalFunction(wxINVERT); + // Top - dc->DrawLine(m_currentRect.x + 1, m_currentRect.y + 1, m_currentRect.x + m_currentRect.width - 1, m_currentRect.y + 1); + dc->DrawLine( m_currentRect.x + 1, + m_currentRect.y + 1, + m_currentRect.x + m_currentRect.width - 1, + m_currentRect.y + 1); // Right - dc->DrawLine(m_currentRect.x + m_currentRect.width - 1, m_currentRect.y + 1, - m_currentRect.x + m_currentRect.width - 1, m_currentRect.y +m_currentRect.height - 1); + dc->DrawLine( m_currentRect.x + m_currentRect.width - 1, + m_currentRect.y + 1, + m_currentRect.x + m_currentRect.width - 1, + m_currentRect.y +m_currentRect.height - 1 ); // Bottom - dc->DrawLine(m_currentRect.x + m_currentRect.width - 1, m_currentRect.y + m_currentRect.height - 1, - m_currentRect.x + 1, m_currentRect.y + m_currentRect.height - 1); + dc->DrawLine( m_currentRect.x + m_currentRect.width - 1, + m_currentRect.y + m_currentRect.height - 1, + m_currentRect.x + 1, + m_currentRect.y + m_currentRect.height - 1); // Left - dc->DrawLine(m_currentRect.x + 1, m_currentRect.y + m_currentRect.height - 1, m_currentRect.x + 1, m_currentRect.y + 1); + dc->DrawLine( m_currentRect.x + 1, + m_currentRect.y + m_currentRect.height - 1, + m_currentRect.x + 1, + m_currentRect.y + 1); dc->SetLogicalFunction(wxCOPY); } @@ -1828,14 +1855,14 @@ wxGridCell *wxGenericGrid::GetLabelCell(int orientation, int pos) if (m_colLabelCells && pos < m_totalCols) return m_colLabelCells[pos]; else - return NULL; + return (wxGridCell *) NULL; } else { if (m_rowLabelCells && pos < m_totalRows) return m_rowLabelCells[pos]; else - return NULL; + return (wxGridCell *) NULL; } } @@ -2066,7 +2093,7 @@ wxBitmap *wxGenericGrid::GetCellBitmap(int row, int col) return cell->GetCellBitmap(); } else - return NULL; + return (wxBitmap *) NULL; } bool wxGenericGrid::InsertCols(int pos, int n, bool updateLabels) @@ -2335,9 +2362,9 @@ void wxGenericGrid::SetGridCursor(int row, int col) wxGridCell::wxGridCell(wxGenericGrid *window) { - cellBitmap = NULL; - font = NULL; - backgroundBrush = NULL; + cellBitmap = (wxBitmap *) NULL; + font = (wxFont *) NULL; + backgroundBrush = (wxBrush *) NULL; if (window) textColour = window->GetCellTextColour(); else