// 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
IMPLEMENT_DYNAMIC_CLASS(wxGenericGrid, wxPanel)
BEGIN_EVENT_TABLE(wxGenericGrid, wxPanel)
- EVT_SIZE(wxGenericGrid::OnSize)
- EVT_PAINT(wxGenericGrid::OnPaint)
- EVT_ERASE_BACKGROUND(wxGenericGrid::OnEraseBackground)
- EVT_MOUSE_EVENTS(wxGenericGrid::OnMouseEvent)
+ EVT_SIZE(wxGenericGrid::OnSize)
+ EVT_PAINT(wxGenericGrid::OnPaint)
+ EVT_ERASE_BACKGROUND(wxGenericGrid::OnEraseBackground)
+ EVT_MOUSE_EVENTS(wxGenericGrid::OnMouseEvent)
EVT_TEXT(wxGRID_TEXT_CTRL, wxGenericGrid::OnText)
EVT_COMMAND_SCROLL(wxGRID_HSCROLL, wxGenericGrid::OnGridScroll)
EVT_COMMAND_SCROLL(wxGRID_VSCROLL, wxGenericGrid::OnGridScroll)
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_labelBackgroundColour = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
- m_labelBackgroundBrush = NULL;
- m_labelTextFont = NULL;
- m_cellTextFont = NULL;
- m_textItem = NULL;
+ 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__)
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;
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_labelBackgroundColour = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
- m_labelBackgroundBrush = NULL;
+ 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__)
m_dragStartPosition = 0;
m_dragLastPosition = 0;
m_divisionPen = wxThePenList->FindOrCreatePen("LIGHT GREY", 1, wxSOLID);
- m_doubleBufferingBitmap = NULL;
+ m_doubleBufferingBitmap = (wxBitmap *) NULL;
if (!m_horizontalSashCursor)
{
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_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);
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;
}
}
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++)
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)
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
// then don't complain, just don't double-buffer
if (m_doubleBufferingBitmap)
delete m_doubleBufferingBitmap;
- m_doubleBufferingBitmap = NULL;
+ m_doubleBufferingBitmap = (wxBitmap *) NULL;
useDoubleBuffering = FALSE;
}
}
int cw, ch;
GetClientSize(&cw, &ch);
- // To calculate the number of steps for each scrollbar,
- // we need to see how much will fit onto the canvas
- // at the present size. So:
- // 1) Find the *last* row r1 such that when it's at the top of the
- // window, all the remaining rows are visible.
- // 2) There should therefore be r1 - 1 steps in the scrollbar.
- // Similarly with columns.
-
- // IGNORE THE ABOVE, it's crap.
// We find the view size by seeing how many rows/cols fit on
// the current view.
// BUT... this means that the scrollbar should be adjusted every time
int noHorizSteps = 0;
int noVertSteps = 0;
- if (m_totalGridWidth <= cw)
+ if (m_totalGridWidth + vertScrollBarWidth <= cw)
noHorizSteps = 0;
else
{
noHorizSteps = 0;
int widthCount = 0;
-/*
- if (GetLabelSize(wxVERTICAL) > 0)
- noHorizSteps ++;
-*/
int i;
int nx = 0;
noHorizSteps += nx;
}
- if (m_totalGridHeight <= ch)
+ if (m_totalGridHeight + horizScrollBarHeight <= ch)
noVertSteps = 0;
else
{
noVertSteps = 0;
int heightCount = 0;
-/*
- if (GetLabelSize(wxHORIZONTAL) > 0)
- noVertSteps ++;
-*/
int i;
int ny = 0;
noVertSteps += ny;
}
- if (m_totalGridWidth <= cw)
+ if (m_totalGridWidth + vertScrollBarWidth <= cw)
{
if ( m_hScrollBar )
m_hScrollBar->Show(FALSE);
}
else
{
- if ( m_hScrollBar )
- m_hScrollBar->Show(TRUE);
+ if ( m_hScrollBar )
+ m_hScrollBar->Show(TRUE);
}
- if (m_totalGridHeight <= ch)
+ if (m_totalGridHeight + horizScrollBarHeight <= ch)
{
- if ( m_vScrollBar )
- m_vScrollBar->Show(FALSE);
- SetScrollPosY(0);
+ if ( m_vScrollBar )
+ m_vScrollBar->Show(FALSE);
+ SetScrollPosY(0);
}
else
{
- if ( m_vScrollBar )
- m_vScrollBar->Show(TRUE);
+ if ( m_vScrollBar )
+ m_vScrollBar->Show(TRUE);
}
UpdateDimensions(); // Necessary in case m_scrollPosX/Y changed
if (m_hScrollBar)
{
int nCols = GetCols();
-/*
- m_hScrollBar->SetPageSize(wxMax(noHorizSteps, 1));
- m_hScrollBar->SetViewLength(wxMax(noHorizSteps, 1));
- m_hScrollBar->SetObjectLength(nCols);
-*/
- m_hScrollBar->SetScrollbar(m_hScrollBar->GetPosition(), wxMax(noHorizSteps, 1), nCols, wxMax(noHorizSteps, 1));
+ m_hScrollBar->SetScrollbar(m_hScrollBar->GetPosition(), wxMax(noHorizSteps, 1), (noHorizSteps == 0) ? 1 : nCols, wxMax(noHorizSteps, 1));
m_hScrollBar->SetSize(m_leftOfSheet, ch - m_scrollWidth -2,
cw - vertScrollBarWidth - m_leftOfSheet, m_scrollWidth);
if (m_vScrollBar)
{
int nRows = GetRows();
-/*
- m_vScrollBar->SetPageSize(wxMax(noVertSteps, 1));
- m_vScrollBar->SetViewLength(wxMax(noVertSteps, 1));
- m_vScrollBar->SetObjectLength(nRows);
-*/
- m_vScrollBar->SetScrollbar(m_vScrollBar->GetPosition(), wxMax(noVertSteps, 1), nRows, wxMax(noVertSteps, 1));
+ m_vScrollBar->SetScrollbar(m_vScrollBar->GetPosition(), wxMax(noVertSteps, 1), (noVertSteps == 0) ? 1 : nRows, wxMax(noVertSteps, 1));
m_vScrollBar->SetSize(cw - m_scrollWidth, m_topOfSheet,
m_scrollWidth, ch - m_topOfSheet - horizScrollBarHeight);
}
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;
}
}
return cell->GetCellBitmap();
}
else
- return NULL;
+ return (wxBitmap *) NULL;
}
bool wxGenericGrid::InsertCols(int pos, int n, bool updateLabels)
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
}
win->UpdateDimensions();
+
win->SetCurrentRect(win->GetCursorRow(), win->GetCursorColumn());
// Because rows and columns can be arbitrary sizes,