m_labelTextColour = *wxBLACK;
// m_labelBackgroundColour = *wxLIGHT_GREY;
m_labelBackgroundColour = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
- m_labelBackgroundBrush = (wxBrush *) NULL;
- m_labelTextFont = (wxFont *) NULL;
- m_cellTextFont = (wxFont *) NULL;
+ m_labelBackgroundBrush = wxNullBrush;
+ m_labelTextFont = wxNullFont;
+ m_cellTextFont = wxNullFont;
m_textItem = (wxTextCtrl *) NULL;
m_currentRectVisible = FALSE;
m_editable = TRUE;
#if defined(__WIN95__)
m_scrollWidth = wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X);
+#elif defined(__WXGTK__)
+ m_scrollWidth = wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X);
#else
m_scrollWidth = 16;
#endif
m_dragRowOrCol = 0;
m_dragStartPosition = 0;
m_dragLastPosition = 0;
- m_divisionPen = (wxPen *) NULL;
+ m_divisionPen = wxNullPen;
m_leftOfSheet = wxGRID_DEFAULT_SHEET_LEFT;
m_topOfSheet = wxGRID_DEFAULT_SHEET_TOP;
m_cellHeight = wxGRID_DEFAULT_CELL_HEIGHT;
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,
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 = (wxBrush *) NULL;
- m_labelTextFont = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxBOLD);
- m_cellTextFont = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL);
+ m_labelBackgroundBrush = wxNullBrush;
+ m_labelTextFont = * wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxBOLD);
+ m_cellTextFont = * wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL);
m_textItem = (wxTextCtrl *) NULL;
m_currentRectVisible = FALSE;
m_editable = TRUE;
#if defined(__WIN95__)
m_scrollWidth = wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X);
+#elif defined(__WXGTK__)
+ m_scrollWidth = wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X);
#else
m_scrollWidth = 16;
#endif
m_dragRowOrCol = 0;
m_dragStartPosition = 0;
m_dragLastPosition = 0;
- m_divisionPen = wxThePenList->FindOrCreatePen("LIGHT GREY", 1, wxSOLID);
+ m_divisionPen = * wxThePenList->FindOrCreatePen("LIGHT GREY", 1, wxSOLID);
m_doubleBufferingBitmap = (wxBitmap *) NULL;
- if (!m_horizontalSashCursor)
+ if (!m_horizontalSashCursor.Ok())
{
- m_horizontalSashCursor = new wxCursor(wxCURSOR_SIZEWE);
- m_verticalSashCursor = new wxCursor(wxCURSOR_SIZENS);
+ m_horizontalSashCursor = wxCursor(wxCURSOR_SIZEWE);
+ m_verticalSashCursor = wxCursor(wxCURSOR_SIZENS);
}
SetLabelBackgroundColour(m_labelBackgroundColour);
m_hScrollBar->SetObjectLength(objectSizeX);
m_hScrollBar->SetPageSize(pageSizeX);
*/
- m_hScrollBar->SetScrollbar(m_hScrollBar->GetPosition(), pageSizeX, objectSizeX, viewLengthX);
+ m_hScrollBar->SetScrollbar(m_hScrollBar->GetThumbPosition(), pageSizeX, objectSizeX, viewLengthX);
int objectSizeY = m_totalRows;
int pageSizeY = 1;
m_vScrollBar->SetPageSize(pageSizeY);
*/
- m_vScrollBar->SetScrollbar(m_vScrollBar->GetPosition(), pageSizeY, objectSizeY, viewLengthY);
+ m_vScrollBar->SetScrollbar(m_vScrollBar->GetThumbPosition(), pageSizeY, objectSizeY, viewLengthY);
AdjustScrollbars();
}
}
-wxGridCell *wxGenericGrid::GetCell(int row, int col)
+wxGridCell *wxGenericGrid::GetCell(int row, int col) const
{
if (!m_gridCells)
return (wxGridCell *) NULL;
if (!cell)
{
// m_gridCells[row][col] = OnCreateCell();
- wxGridEvent g_evt(GetId(), wxEVT_GRID_CREATE_CELL, this, row, col);
+ wxGridEvent g_evt(GetId(), wxEVT_GRID_CREATE_CELL, (wxGenericGrid*) this, row, col);
GetEventHandler()->ProcessEvent(g_evt);
m_gridCells[row][col] = g_evt.m_cell;
return m_gridCells[row][col];
// dc->DrawRectangle(m_rightOfSheet, m_topOfSheet, cw - m_rightOfSheet, ch - m_topOfSheet);
// Paint the label areas
- dc->SetBrush(*m_labelBackgroundBrush);
+ dc->SetBrush(m_labelBackgroundBrush);
// dc->DrawRectangle(m_leftOfSheet, m_topOfSheet, m_rightOfSheet - m_leftOfSheet + 1, m_horizontalLabelHeight + 1);
dc->DrawRectangle(m_leftOfSheet, m_topOfSheet, cw-m_leftOfSheet, m_horizontalLabelHeight + 1);
// dc->DrawRectangle(m_leftOfSheet, m_topOfSheet, m_verticalLabelWidth + 1, m_bottomOfSheet - m_topOfSheet + 1);
int i;
- if (m_divisionPen)
+ if (m_divisionPen.Ok())
{
- dc->SetPen(*m_divisionPen);
+ dc->SetPen(m_divisionPen);
int heightCount = m_topOfSheet + m_horizontalLabelHeight;
}
- if (m_divisionPen)
+ if (m_divisionPen.Ok())
{
- dc->SetPen(*m_divisionPen);
+ dc->SetPen(m_divisionPen);
// Draw vertical grey lines for cells
int widthCount = m_leftOfSheet + m_verticalLabelWidth;
return;
int i;
- wxRectangle rect;
+ wxRect rect;
// Draw letters for columns
rect.y = m_topOfSheet + 1;
}
}
-void wxGenericGrid::DrawColumnLabel(wxDC *dc, wxRectangle *rect, int col)
+void wxGenericGrid::DrawColumnLabel(wxDC *dc, wxRect *rect, int col)
{
wxGridCell *cell = GetLabelCell(wxHORIZONTAL, col);
if (cell)
{
- wxRectangle rect2;
+ wxRect rect2;
rect2 = *rect;
rect2.x += 3;
rect2.y += 2;
rect2.width -= 5;
rect2.height -= 4;
dc->SetTextForeground(GetLabelTextColour());
- dc->SetFont(*GetLabelTextFont());
+ dc->SetFont(GetLabelTextFont());
if ( !cell->GetTextValue().IsNull() )
DrawTextRect(dc, cell->GetTextValue(), &rect2, GetLabelAlignment(wxHORIZONTAL));
}
return;
int i;
- wxRectangle rect;
+ wxRect rect;
// Draw numbers for rows
rect.x = m_leftOfSheet;
}
}
-void wxGenericGrid::DrawRowLabel(wxDC *dc, wxRectangle *rect, int row)
+void wxGenericGrid::DrawRowLabel(wxDC *dc, wxRect *rect, int row)
{
wxGridCell *cell = GetLabelCell(wxVERTICAL, row);
if (cell)
{
- wxRectangle rect2;
+ wxRect rect2;
rect2 = *rect;
rect2.x += 3;
rect2.y += 2;
rect2.width -= 5;
rect2.height -= 4;
dc->SetTextForeground(GetLabelTextColour());
- dc->SetFont(*GetLabelTextFont());
+ dc->SetFont(GetLabelTextFont());
if ( !cell->GetTextValue().IsNull() )
DrawTextRect(dc, cell->GetTextValue(), &rect2, GetLabelAlignment(wxVERTICAL));
}
dc->SetPen(*wxBLACK_PEN);
}
-void wxGenericGrid::DrawCellBackground(wxDC *dc, wxRectangle *rect, int row, int col)
+void wxGenericGrid::DrawCellBackground(wxDC *dc, wxRect *rect, int row, int col)
{
wxGridCell *cell = GetCell(row, col);
if (cell)
{
- dc->SetBrush(*cell->GetBackgroundBrush());
+ dc->SetBrush(cell->GetBackgroundBrush());
dc->SetPen(*wxTRANSPARENT_PEN);
#if 0 // In wxWin 2.0 the dc code is exact. RR.
}
}
-void wxGenericGrid::DrawCellValue(wxDC *dc, wxRectangle *rect, int row, int col)
+void wxGenericGrid::DrawCellValue(wxDC *dc, wxRect *rect, int row, int col)
{
wxGridCell *cell = GetCell(row, col);
if (cell)
{
wxBitmap *bitmap = cell->GetCellBitmap();
- wxRectangle rect2;
+ wxRect rect2;
rect2 = *rect;
rect2.x += 3;
rect2.y += 2;
{
dc->SetBackgroundMode(wxTRANSPARENT);
dc->SetTextForeground(cell->GetTextColour());
- dc->SetFont(*cell->GetFont());
+ dc->SetFont(cell->GetFont());
if ( !cell->GetTextValue().IsNull() )
DrawTextRect(dc, cell->GetTextValue(), &rect2, cell->GetAlignment());
if (m_hScrollBar && !m_hScrollBar->IsShown())
horizScrollBarHeight = 0;
- if (m_hScrollBar)
+ if (m_hScrollBar && m_hScrollBar->IsShown())
{
int nCols = GetCols();
- m_hScrollBar->SetScrollbar(m_hScrollBar->GetPosition(), wxMax(noHorizSteps, 1), (noHorizSteps == 0) ? 1 : nCols, wxMax(noHorizSteps, 1));
+ m_hScrollBar->SetScrollbar(m_hScrollBar->GetThumbPosition(), wxMax(noHorizSteps, 1), (noHorizSteps == 0) ? 1 : nCols, wxMax(noHorizSteps, 1));
- m_hScrollBar->SetSize(m_leftOfSheet, ch - m_scrollWidth -2,
+/*
+ m_hScrollBar->SetSize(m_leftOfSheet, ch - m_scrollWidth -2, // why -2 ? Robert.
cw - vertScrollBarWidth - m_leftOfSheet, m_scrollWidth);
+*/
+ m_hScrollBar->SetSize(m_leftOfSheet, ch - m_scrollWidth,
+ cw - vertScrollBarWidth - m_leftOfSheet, m_scrollWidth);
+
}
- if (m_vScrollBar)
+ if (m_vScrollBar && m_vScrollBar->IsShown())
{
int nRows = GetRows();
- m_vScrollBar->SetScrollbar(m_vScrollBar->GetPosition(), wxMax(noVertSteps, 1), (noVertSteps == 0) ? 1 : nRows, wxMax(noVertSteps, 1));
+ m_vScrollBar->SetScrollbar(m_vScrollBar->GetThumbPosition(), wxMax(noVertSteps, 1), (noVertSteps == 0) ? 1 : nRows, wxMax(noVertSteps, 1));
m_vScrollBar->SetSize(cw - m_scrollWidth, m_topOfSheet,
m_scrollWidth, ch - m_topOfSheet - horizScrollBarHeight);
}
{
m_editingPanel->SetSize(0, 0, cw, m_editControlPosition.height + m_editControlPosition.y + 2);
GetTextItem()->SetSize(m_editControlPosition.x, m_editControlPosition.y,
- cw - m_editControlPosition.x, m_editControlPosition.height);
+ cw - 2*m_editControlPosition.x, m_editControlPosition.height);
}
}
if (orientation == wxHORIZONTAL)
{
m_dragStatus = wxGRID_DRAG_LEFT_RIGHT;
- SetCursor(*m_horizontalSashCursor);
+ SetCursor(m_horizontalSashCursor);
m_dragLastPosition = (int)ev.GetX();
}
else
{
m_dragStatus = wxGRID_DRAG_UP_DOWN;
- SetCursor(*m_verticalSashCursor);
+ SetCursor(m_verticalSashCursor);
m_dragLastPosition = (int)ev.GetY();
}
wxClientDC dc(this);
dc.EndDrawing();
m_dragLastPosition = (int)ev.GetX();
- SetCursor(*m_horizontalSashCursor);
+ SetCursor(m_horizontalSashCursor);
break;
}
case wxGRID_DRAG_UP_DOWN:
dc.EndDrawing();
m_dragLastPosition = (int)ev.GetY();
- SetCursor(*m_verticalSashCursor);
+ SetCursor(m_verticalSashCursor);
break;
}
}
if (LabelSashHitTest((int)ev.GetX(), (int)ev.GetY(), &orientation, &rowOrCol, &startPos))
{
if (orientation == wxHORIZONTAL)
- SetCursor(*m_horizontalSashCursor);
+ SetCursor(m_horizontalSashCursor);
else
- SetCursor(*m_verticalSashCursor);
+ SetCursor(m_verticalSashCursor);
}
else
SetCursor(*wxSTANDARD_CURSOR);
SetGridClippingRegion(dc);
- // Why isn't this needed for Windows??
- // Probably because of the SetValue??
- // Arrrrrgh. This isn't needed anywhere, of course. RR.
+ // 1) Why isn't this needed for Windows??
+ // Probably because of the SetValue?? JS.
+ // 2) Arrrrrgh. This isn't needed anywhere,
+ // of course. One hour of debugging... RR.
#ifndef __WXMSW__
// HighlightCell(dc);
#endif
SetGridClippingRegion(& dc);
dc.SetBackgroundMode(wxTRANSPARENT);
- dc.SetBrush(*cell->GetBackgroundBrush());
+ dc.SetBrush(cell->GetBackgroundBrush());
strcpy(szEdit, m_textItem->GetValue());
- wxRectangle rect;
+ wxRect rect;
rect = m_currentRect;
rect.x += 3;
rect.y += 2;
else m_currentRectVisible = TRUE;
}
-static bool wxRectIntersection(wxRectangle *rect1, wxRectangle *rect2, wxRectangle *rect3)
+static bool wxRectIntersection(wxRect *rect1, wxRect *rect2, wxRect *rect3)
{
int x2_1 = rect1->x + rect1->width;
int y2_1 = rect1->y + rect1->height;
return TRUE;
}
-void wxGenericGrid::DrawTextRect(wxDC *dc, const wxString& text, wxRectangle *rect, int flag)
+void wxGenericGrid::DrawTextRect(wxDC *dc, const wxString& text, wxRect *rect, int flag)
{
dc->BeginDrawing();
// If we're already clipping, we need to find the intersection
// between current clipping area and text clipping area.
- wxRectangle clipRect;
- wxRectangle clipRect2;
+ wxRect clipRect;
+ wxRect clipRect2;
long clipX, clipY, clipW, clipH;
dc->GetClippingBox(&clipX, &clipY, &clipW, &clipH);
clipRect.x = (int)clipX; clipRect.y = (int)clipY;
dc->EndDrawing();
}
-void wxGenericGrid::DrawBitmapRect(wxDC *dc, wxBitmap *bitmap, wxRectangle *rect, int flag)
+void wxGenericGrid::DrawBitmapRect(wxDC *dc, wxBitmap *bitmap, wxRect *rect, int flag)
{
dc->BeginDrawing();
// If we're already clipping, we need to find the intersection
// between current clipping area and text clipping area.
- wxRectangle clipRect;
- wxRectangle clipRect2;
+ wxRect clipRect;
+ wxRect clipRect2;
long clipX, clipY, clipW, clipH;
dc->GetClippingBox(&clipX, &clipY, &clipW, &clipH);
clipRect.x = (int)clipX; clipRect.y = (int)clipY;
}
}
-wxString& wxGenericGrid::GetCellValue(int row, int col)
+wxString& wxGenericGrid::GetCellValue(int row, int col) const
{
static wxString emptyString("");
m_colWidths[col] = width;
}
-int wxGenericGrid::GetColumnWidth(int col)
+int wxGenericGrid::GetColumnWidth(int col) const
{
if (col <= m_totalCols)
return m_colWidths[col];
m_rowHeights[row] = height;
}
-int wxGenericGrid::GetRowHeight(int row)
+int wxGenericGrid::GetRowHeight(int row) const
{
if (row <= m_totalRows)
return m_rowHeights[row];
SetCurrentRect(GetCursorRow(), GetCursorColumn());
}
-int wxGenericGrid::GetLabelSize(int orientation)
+int wxGenericGrid::GetLabelSize(int orientation) const
{
if (orientation == wxHORIZONTAL)
return m_horizontalLabelHeight;
return m_verticalLabelWidth;
}
-wxGridCell *wxGenericGrid::GetLabelCell(int orientation, int pos)
+wxGridCell *wxGenericGrid::GetLabelCell(int orientation, int pos) const
{
if (orientation == wxHORIZONTAL)
{
cell->SetTextValue(val);
}
-wxString& wxGenericGrid::GetLabelValue(int orientation, int pos)
+wxString& wxGenericGrid::GetLabelValue(int orientation, int pos) const
{
static wxString emptyString = "";
wxGridCell *cell = GetLabelCell(orientation, pos);
SetCurrentRect(GetCursorRow(), GetCursorColumn());
}
-int wxGenericGrid::GetLabelAlignment(int orientation)
+int wxGenericGrid::GetLabelAlignment(int orientation) const
{
if (orientation == wxHORIZONTAL)
return m_horizontalLabelAlignment;
void wxGenericGrid::SetLabelBackgroundColour(const wxColour& colour)
{
m_labelBackgroundColour = colour;
- m_labelBackgroundBrush = wxTheBrushList->FindOrCreateBrush(m_labelBackgroundColour, wxSOLID);
+ m_labelBackgroundBrush = * wxTheBrushList->FindOrCreateBrush(m_labelBackgroundColour, wxSOLID);
}
void wxGenericGrid::SetEditable(bool edit)
cell->SetAlignment(flag);
}
-int wxGenericGrid::GetCellAlignment(int row, int col)
+int wxGenericGrid::GetCellAlignment(int row, int col) const
{
wxGridCell *cell = GetCell(row, col);
if (cell)
GetCell(i, j)->SetAlignment(flag);
}
-int wxGenericGrid::GetCellAlignment(void)
+int wxGenericGrid::GetCellAlignment(void) const
{
return m_cellAlignment;
}
}
}
-wxColour& wxGenericGrid::GetCellBackgroundColour(int row, int col)
+wxColour& wxGenericGrid::GetCellBackgroundColour(int row, int col) const
{
wxGridCell *cell = GetCell(row, col);
if (cell)
return cell->GetBackgroundColour();
else
- return m_cellBackgroundColour;
+ return (wxColour&) m_cellBackgroundColour;
}
void wxGenericGrid::SetCellTextColour(const wxColour& val, int row, int col)
}
}
-void wxGenericGrid::SetCellTextFont(wxFont *fnt, int row, int col)
+void wxGenericGrid::SetCellTextFont(const wxFont& fnt, int row, int col)
{
wxGridCell *cell = GetCell(row, col);
if (cell)
}
}
-wxFont *wxGenericGrid::GetCellTextFont(int row, int col)
+wxFont& wxGenericGrid::GetCellTextFont(int row, int col) const
{
wxGridCell *cell = GetCell(row, col);
if (cell)
- return cell->GetFont();
+ return (wxFont&) cell->GetFont();
else
- return m_cellTextFont;
+ return (wxFont&) m_cellTextFont;
}
-wxColour& wxGenericGrid::GetCellTextColour(int row, int col)
+wxColour& wxGenericGrid::GetCellTextColour(int row, int col) const
{
wxGridCell *cell = GetCell(row, col);
if (cell)
- return cell->GetTextColour();
+ return (wxColour&) cell->GetTextColour();
else
- return m_cellTextColour;
+ return (wxColour&) m_cellTextColour;
}
void wxGenericGrid::SetCellTextColour(const wxColour& val)
GetCell(i, j)->SetTextColour(val);
}
-void wxGenericGrid::SetCellTextFont(wxFont *fnt)
+void wxGenericGrid::SetCellTextFont(const wxFont& fnt)
{
m_cellTextFont = fnt;
int i,j;
}
}
-wxBitmap *wxGenericGrid::GetCellBitmap(int row, int col)
+wxBitmap *wxGenericGrid::GetCellBitmap(int row, int col) const
{
wxGridCell *cell = GetCell(row, col);
if (cell)
wxGridCell::wxGridCell(wxGenericGrid *window)
{
cellBitmap = (wxBitmap *) NULL;
- font = (wxFont *) NULL;
- backgroundBrush = (wxBrush *) NULL;
+ font = wxNullFont;
+ backgroundBrush = wxNullBrush;
if (window)
textColour = window->GetCellTextColour();
else
if (window)
font = window->GetCellTextFont();
else
- font = wxTheFontList->FindOrCreateFont(12, wxSWISS, wxNORMAL, wxNORMAL);
+ font = * wxTheFontList->FindOrCreateFont(12, wxSWISS, wxNORMAL, wxNORMAL);
SetBackgroundColour(backgroundColour);
void wxGridCell::SetBackgroundColour(const wxColour& colour)
{
backgroundColour = colour;
- backgroundBrush = wxTheBrushList->FindOrCreateBrush(backgroundColour, wxSOLID);
+ backgroundBrush = * wxTheBrushList->FindOrCreateBrush(backgroundColour, wxSOLID);
}
void wxGenericGrid::OnText(wxCommandEvent& WXUNUSED(ev) )
ev.m_cell = OnCreateCell();
}
-void wxGenericGrid::_OnChangeLabels(wxGridEvent& ev)
+void wxGenericGrid::_OnChangeLabels(wxGridEvent& WXUNUSED(ev))
{
OnChangeLabels();
}
-void wxGenericGrid::_OnChangeSelectionLabel(wxGridEvent& ev)
+void wxGenericGrid::_OnChangeSelectionLabel(wxGridEvent& WXUNUSED(ev))
{
OnChangeSelectionLabel();
}