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 = new wxScrollBar(this, wxGRID_HSCROLL, wxPoint(0, 0), wxSize(20, 100), wxHORIZONTAL);
m_vScrollBar = new wxScrollBar(this, wxGRID_VSCROLL, wxPoint(0, 0), wxSize(100, 20), wxVERTICAL);
+ SetSize(-1, -1, size.x, size.y);
+
return TRUE;
}
}
}
-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;
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));
}
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));
}
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.
{
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->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_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);
dc.SetBackgroundMode(wxTRANSPARENT);
- dc.SetBrush(*cell->GetBackgroundBrush());
+ dc.SetBrush(cell->GetBackgroundBrush());
strcpy(szEdit, m_textItem->GetValue());
}
}
-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) )