// Modified by: Michael Bedward
// Added edit in place facility, 20 Apr 1999
// Added cursor key control, 29 Jun 1999
+// Gerhard Gruber
+// Added keyboard navigation, client data, other fixes
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
END_EVENT_TABLE()
-wxGenericGrid::wxGenericGrid(void)
+wxGenericGrid::wxGenericGrid()
{
+ m_viewWidth = 0;
+ m_viewHeight = 0;
m_batchCount = 0;
m_hScrollBar = (wxScrollBar *) NULL;
m_vScrollBar = (wxScrollBar *) NULL;
m_textItem = (wxTextCtrl *) NULL;
}
-bool wxGenericGrid::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
- long style, const wxString& name)
+bool wxGenericGrid::Create(wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
{
+ m_viewWidth = 0;
+ m_viewHeight = 0;
m_batchCount = 0;
m_editingPanel = (wxPanel *) NULL;
m_hScrollBar = (wxScrollBar *) NULL;
return TRUE;
}
-wxGenericGrid::~wxGenericGrid(void)
+wxGenericGrid::~wxGenericGrid()
{
ClearGrid();
}
-void wxGenericGrid::ClearGrid(void)
+void wxGenericGrid::ClearGrid()
{
int i,j;
if (m_gridCells)
}
// Need to determine various dimensions
-void wxGenericGrid::UpdateDimensions(void)
+void wxGenericGrid::UpdateDimensions()
{
int canvasWidth, canvasHeight;
GetSize(&canvasWidth, &canvasHeight);
}
}
-void wxGenericGrid::AdjustScrollbars(void)
+void wxGenericGrid::AdjustScrollbars()
{
int cw, ch;
GetClientSize(&cw, &ch);
int noHorizSteps = 0;
int noVertSteps = 0;
- if (m_totalGridWidth + vertScrollBarWidth <= cw)
- noHorizSteps = 0;
- else
+ if (m_totalGridWidth + vertScrollBarWidth > cw)
{
- noHorizSteps = 0;
int widthCount = 0;
int i;
- int nx = 0;
+ int nx = 0;
for (i = m_scrollPosX ; i < m_totalCols; i++)
{
widthCount += m_colWidths[i];
- // A partial bit doesn't count, we still have to scroll to see the
- // rest of it
+ // A partial bit doesn't count, we still have to scroll to see the
+ // rest of it
if (widthCount + m_leftOfSheet + m_verticalLabelWidth > (cw-vertScrollBarWidth))
break;
- else
- nx ++;
-
+ else
+ nx ++;
}
noHorizSteps += nx;
}
- if (m_totalGridHeight + horizScrollBarHeight <= ch)
- noVertSteps = 0;
- else
+ m_viewWidth = noHorizSteps;
+
+ if (m_totalGridHeight + horizScrollBarHeight > ch)
{
- noVertSteps = 0;
int heightCount = 0;
int i;
- int ny = 0;
+ int ny = 0;
for (i = m_scrollPosY ; i < m_totalRows; i++)
{
heightCount += m_rowHeights[i];
- // A partial bit doesn't count, we still have to scroll to see the
- // rest of it
+ // A partial bit doesn't count, we still have to scroll to see the
+ // rest of it
if (heightCount + m_topOfSheet + m_horizontalLabelHeight > (ch-horizScrollBarHeight))
break;
- else
- ny ++;
+ else
+ ny ++;
}
noVertSteps += ny;
}
+ m_viewHeight = noVertSteps;
+
if (m_totalGridWidth + vertScrollBarWidth <= cw)
{
- if ( m_hScrollBar )
- m_hScrollBar->Show(FALSE);
+ if ( m_hScrollBar )
+ m_hScrollBar->Show(FALSE);
SetScrollPosX(0);
}
else
if ( m_editable && m_editInPlace )
{
- m_inPlaceTextItem->SetSize( m_currentRect.x-2, m_currentRect.y-2,
- m_currentRect.width+4, m_currentRect.height+4 );
+ int x, y, width, height;
+ if ( m_currentRect.x <= 0 )
+ {
+ x = 0;
+ width = m_currentRect.width + 2;
+ }
+ else
+ {
+ x = m_currentRect.x - 2;
+ width = m_currentRect.width + 4;
+ }
+
+ if ( m_currentRect.y <= 0 )
+ {
+ y = 0;
+ height = m_currentRect.height + 2;
+ }
+ else
+ {
+ y = m_currentRect.y - 2;
+ height = m_currentRect.height + 4;
+ }
+
+ m_inPlaceTextItem->SetSize( x, y, width, height );
if ( cell )
{
GetEventHandler()->ProcessEvent(g_evt2);
}
-wxGridCell *wxGenericGrid::OnCreateCell(void)
+wxGridCell *wxGenericGrid::OnCreateCell()
{
return new wxGridCell(this);
}
-void wxGenericGrid::OnChangeLabels(void)
+void wxGenericGrid::OnChangeLabels()
{
char buf[100];
int i;
}
}
-void wxGenericGrid::OnChangeSelectionLabel(void)
+void wxGenericGrid::OnChangeSelectionLabel()
{
if (!GetEditable())
return;
dc->SetLogicalFunction(wxCOPY);
}
-void wxGenericGrid::DrawCellText(void)
+void wxGenericGrid::DrawCellText()
{
if (!m_currentRectVisible)
return;
dc.EndDrawing();
}
-/*
- * Grid cell
- */
+// ----------------------------------------------------------------------------
+// Grid cell
+// ----------------------------------------------------------------------------
wxGridCell::wxGridCell(wxGenericGrid *window)
{
alignment = window->GetCellAlignment();
else
alignment = wxLEFT;
+
+ cellData = (void *)NULL;
}
-wxGridCell::~wxGridCell(void)
+wxGridCell::~wxGridCell()
{
}
OnLabelRightClick(ev.m_row, ev.m_col, ev.m_x, ev.m_y, ev.m_control, ev.m_shift);
}
+void *wxGenericGrid::SetCellData(void *data, int row, int col)
+{
+ void *rc = NULL;
+
+ wxGridCell *cell = GetCell(row, col);
+ if ( cell )
+ rc = cell->SetCellData(data);
+
+ return rc;
+}
+
+void *wxGenericGrid::GetCellData(int row, int col)
+{
+ void *rc = NULL;
+
+ wxGridCell *cell = GetCell(row, col);
+ if ( cell )
+ rc = cell->GetCellData();
+
+ return rc;
+}