// Name: gridg.cpp
// Purpose: wxGenericGrid
// Author: Julian Smart
-// Modified by:
+// 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
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
-#pragma implementation "gridg.h"
-#pragma interface
+ #pragma implementation "gridg.h"
+ #pragma interface
#endif
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
+#if wxUSE_GRID && !(wxUSE_NEW_GRID)
+
#ifndef WX_PRECOMP
-#include "wx/wx.h"
+ #include "wx/utils.h"
+ #include "wx/dcclient.h"
+ #include "wx/dcmemory.h"
+ #include "wx/textctrl.h"
+ #include "wx/settings.h"
#endif
#include <string.h>
#include "wx/string.h"
+
#include "wx/generic/gridg.h"
-#include "wx/settings.h"
-// Set to zero to use no double-buffering
+
+// Values used to adjust the size of the in-place-edit control, and other
+// goodies. Per-platform tweaks should be done here.
#ifdef __WXMSW__
-#define wxUSE_DOUBLE_BUFFERING 1
-#else
-#define wxUSE_DOUBLE_BUFFERING 0
+#define wxIPE_ADJUST -2
+#define wxIPE_STYLE wxNO_BORDER
+#define wxIPE_HIGHLIGHT 1
+#define wxUSE_DOUBLE_BUFFERING 1
+#endif
+
+#ifdef __WXPM__
+#define wxIPE_ADJUST -1
+#define wxIPE_STYLE wxNO_BORDER
+#define wxIPE_HIGHLIGHT 1
+#define wxUSE_DOUBLE_BUFFERING 1
+#endif
+
+#ifdef __WXGTK__
+#define wxIPE_ADJUST -1
+#define wxIPE_STYLE wxNO_BORDER
+#define wxIPE_HIGHLIGHT 0
+#define wxUSE_DOUBLE_BUFFERING 1
#endif
+#ifdef __WXMOTIF__
+#define wxIPE_ADJUST 2
+#define wxIPE_STYLE wxNO_BORDER
+#define wxIPE_HIGHLIGHT 0
+#define wxUSE_DOUBLE_BUFFERING 0
+#endif
+
+#ifndef wxIPE_ADJUST
+#define wxIPE_ADJUST 2
+#define wxIPE_STYLE wxNO_BORDER
+#define wxIPE_HIGHLIGHT 0
+#define wxUSE_DOUBLE_BUFFERING 0
+#endif
+
+
+
#define wxGRID_DRAG_NONE 0
#define wxGRID_DRAG_LEFT_RIGHT 1
#define wxGRID_DRAG_UP_DOWN 2
EVT_ERASE_BACKGROUND(wxGenericGrid::OnEraseBackground)
EVT_MOUSE_EVENTS(wxGenericGrid::OnMouseEvent)
EVT_TEXT(wxGRID_TEXT_CTRL, wxGenericGrid::OnText)
+ EVT_TEXT(wxGRID_EDIT_IN_PLACE_TEXT_CTRL, wxGenericGrid::OnTextInPlace)
+ EVT_TEXT_ENTER(wxGRID_TEXT_CTRL, wxGenericGrid::OnTextEnter)
+ EVT_TEXT_ENTER(wxGRID_EDIT_IN_PLACE_TEXT_CTRL, wxGenericGrid::OnTextInPlaceEnter)
EVT_COMMAND_SCROLL(wxGRID_HSCROLL, wxGenericGrid::OnGridScroll)
EVT_COMMAND_SCROLL(wxGRID_VSCROLL, wxGenericGrid::OnGridScroll)
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_cellBackgroundColour = *wxWHITE;
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_labelBackgroundColour = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
+ m_labelBackgroundBrush = wxNullBrush;
+ m_labelTextFont = wxNullFont;
+ m_cellTextFont = wxNullFont;
m_textItem = (wxTextCtrl *) NULL;
m_currentRectVisible = FALSE;
m_editable = TRUE;
+
+ m_editInPlace = FALSE;
+ m_inOnTextInPlace = FALSE;
+ m_inScroll = FALSE;
+
#if defined(__WIN95__)
- m_scrollWidth = wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X);
+ m_scrollWidth = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
+#elif defined(__WXGTK__)
+ m_scrollWidth = wxSystemSettings::GetMetric(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_highlightPen = 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,
- 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;
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_labelBackgroundColour = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
+ 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;
+ m_editInPlace = FALSE;
+ m_inOnTextInPlace = FALSE;
+ m_inScroll = FALSE;
#if defined(__WIN95__)
- m_scrollWidth = wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X);
+ m_scrollWidth = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
+#elif defined(__WXGTK__)
+ m_scrollWidth = wxSystemSettings::GetMetric(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(wxT("LIGHT GREY"), 1, wxSOLID);
+ m_highlightPen = * wxBLACK_PEN;
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_editingPanel = new wxPanel(this);
- m_textItem = new wxTextCtrl(m_editingPanel, wxGRID_TEXT_CTRL, "",
- wxPoint(m_editControlPosition.x, m_editControlPosition.y), wxSize(m_editControlPosition.width, -1),
- 0);
+ m_textItem = new wxTextCtrl(m_editingPanel, wxGRID_TEXT_CTRL, wxT(""),
+ wxPoint(m_editControlPosition.x, m_editControlPosition.y),
+ wxSize(m_editControlPosition.width, -1),
+ wxTE_PROCESS_ENTER);
m_textItem->Show(TRUE);
m_textItem->SetFocus();
int controlW, controlH;
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(pos.x, pos.y, size.x, size.y);
+
+ m_inPlaceTextItem = new wxTextCtrl( (wxPanel*)this, wxGRID_EDIT_IN_PLACE_TEXT_CTRL, wxT(""),
+ wxPoint( m_currentRect.x-wxIPE_ADJUST, m_currentRect.y-wxIPE_ADJUST ),
+ wxSize( m_currentRect.width+wxIPE_ADJUST*2, m_currentRect.height+wxIPE_ADJUST*2 ),
+ wxNO_BORDER | wxTE_PROCESS_ENTER );
+ m_inPlaceTextItem->Show(m_editInPlace);
+ if ( m_editInPlace )
+ m_inPlaceTextItem->SetFocus();
+
return TRUE;
}
-wxGenericGrid::~wxGenericGrid(void)
+wxGenericGrid::~wxGenericGrid()
{
ClearGrid();
}
-void wxGenericGrid::ClearGrid(void)
+void wxGenericGrid::ClearGrid()
{
int i,j;
if (m_gridCells)
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();
}
// Need to determine various dimensions
-void wxGenericGrid::UpdateDimensions(void)
+void wxGenericGrid::UpdateDimensions()
{
int canvasWidth, canvasHeight;
GetSize(&canvasWidth, &canvasHeight);
}
}
-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];
/* Hilight present cell */
SetCurrentRect(m_wCursorRow, m_wCursorColumn);
- if (m_currentRectVisible)
- HighlightCell(& dc);
+ if (m_currentRectVisible && (wxIPE_HIGHLIGHT || !(m_editable && m_editInPlace)))
+ HighlightCell(& dc, TRUE);
dc.DestroyClippingRegion();
dc.SetOptimization(TRUE);
// 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());
- if ( !cell->GetTextValue().IsNull() )
- DrawTextRect(dc, cell->GetTextValue(), &rect2, GetLabelAlignment(wxHORIZONTAL));
+ 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());
- if ( !cell->GetTextValue().IsNull() )
- DrawTextRect(dc, cell->GetTextValue(), &rect2, GetLabelAlignment(wxVERTICAL));
+ 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 ( !cell->GetTextValue().IsNull() )
+ DrawTextRect(dc, cell->GetTextValue(), &rect2, cell->GetAlignment());
}
}
}
-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_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);
}
void wxGenericGrid::OnSize(wxSizeEvent& WXUNUSED(event) )
{
if (!m_vScrollBar || !m_hScrollBar)
- return;
+ return;
AdjustScrollbars();
{
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);
SetCursor(*wxSTANDARD_CURSOR);
int cw, ch;
GetClientSize(&cw, &ch);
- wxSizeEvent evt;
+ wxSizeEvent evt;
OnSize(evt);
break;
}
SetGridClippingRegion(dc);
// Remove the highlight from the old cell
- if (m_currentRectVisible)
- HighlightCell(dc);
+ if ( m_currentRectVisible && (wxIPE_HIGHLIGHT || !(m_editable && m_editInPlace)))
+ {
+ HighlightCell(dc, FALSE);
+ }
+
// Highlight the new cell and copy its content to the edit control
SetCurrentRect(m_wCursorRow, m_wCursorColumn);
wxGridCell *cell = GetCell(m_wCursorRow, m_wCursorColumn);
if (cell)
{
- if ( cell->GetTextValue().IsNull() )
- m_textItem->SetValue("");
- else
- m_textItem->SetValue(cell->GetTextValue());
+ if ( cell->GetTextValue().IsNull() )
+ m_textItem->SetValue(wxT(""));
+ else
+ m_textItem->SetValue(cell->GetTextValue());
}
SetGridClippingRegion(dc);
- // 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);
+
+ if ( m_editable && m_editInPlace )
+ {
+ int x, y, width, height;
+ if ( m_currentRect.x <= 0 )
+ {
+ x = 0;
+ width = m_currentRect.width + wxIPE_ADJUST;
+ }
+ else
+ {
+ x = m_currentRect.x - wxIPE_ADJUST;
+ width = m_currentRect.width + wxIPE_ADJUST*2;
+ }
+
+ if ( m_currentRect.y <= 0 )
+ {
+ y = 0;
+ height = m_currentRect.height + wxIPE_ADJUST;
+ }
+ else
+ {
+ y = m_currentRect.y - wxIPE_ADJUST;
+ height = m_currentRect.height + wxIPE_ADJUST*2;
+ }
+
+ m_inPlaceTextItem->SetSize( x, y, width, height );
+
+ if ( cell ) {
+ m_inPlaceTextItem->SetFont( cell->GetFont() );
+ m_inPlaceTextItem->SetBackgroundColour(cell->GetBackgroundColour());
+ m_inPlaceTextItem->SetForegroundColour(cell->GetTextColour());
+
+ if ( cell->GetTextValue().IsNull() ) {
+ m_inPlaceTextItem->SetValue( wxT("") );
+ }
+ else {
+ m_inPlaceTextItem->SetValue( cell->GetTextValue() );
+ }
+ }
+
+ m_inPlaceTextItem->Show(TRUE);
+ m_inPlaceTextItem->SetFocus();
+#if defined(__VISAGECPP__)
+ {
+ int highlight = wxIPE_HIGHLIGHT;
+ if (highlight != 0)
+ HighlightCell(dc, TRUE);
+ }
+#else
+ if (wxIPE_HIGHLIGHT != 0)
+ HighlightCell(dc, TRUE);
#endif
+ }
+ else if (!wxIPE_HIGHLIGHT)
+ {
+ // 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.
+ //
+ // 3) It *is* needed for Motif - michael
+ //
+ // 4) It *seems* to be needed whenever
+ // wxIPE_HIGHLIGHT is not set (i.e.
+ // for both wxGTK and wxMOTIF)... SN.
+ if (!(m_editable && m_editInPlace)))
+ HighlightCell(dc, TRUE);
+ }
+
dc->DestroyClippingRegion();
- //OnSelectCell(row, col);
+ OnSelectCell(row, col);
wxGridEvent g_evt2(GetId(), wxEVT_GRID_SELECT_CELL, this, row, col);
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;
for (i = 0; i < m_totalRows; i++)
{
- sprintf(buf, "%d", i+1);
+ sprintf(buf, wxT("%d"), i+1);
SetLabelValue(wxVERTICAL, buf, i);
}
// A...Z,AA...ZZ,AAA...ZZZ, etc.
for (j = 0; j < noTimes; j++)
{
char buf2[20];
- sprintf(buf2, "%c", (char)ch);
+ sprintf(buf2, wxT("%c"), (char)ch);
strcat(buf, buf2);
}
SetLabelValue(wxHORIZONTAL, buf, i);
}
}
-void wxGenericGrid::OnChangeSelectionLabel(void)
+void wxGenericGrid::OnChangeSelectionLabel()
{
if (!GetEditable())
return;
}
}
-void wxGenericGrid::HighlightCell(wxDC *dc)
+void wxGenericGrid::HighlightCell(wxDC *dc, bool doHighlight)
{
- dc->SetLogicalFunction(wxINVERT);
+ wxPen savePen = dc->GetPen();
+ if (doHighlight)
+ dc->SetPen(m_highlightPen);
+ else
+ dc->SetPen(*wxThePenList->FindOrCreatePen(m_cellBackgroundColour, 1, wxSOLID));
// Top
dc->DrawLine( m_currentRect.x + 1,
m_currentRect.y + 1,
m_currentRect.x + m_currentRect.width - 1,
- m_currentRect.y + 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 );
+ 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);
+ 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);
+ m_currentRect.x + 1,
+ m_currentRect.y + 1);
- dc->SetLogicalFunction(wxCOPY);
+ dc->SetPen(savePen);
}
-void wxGenericGrid::DrawCellText(void)
+void wxGenericGrid::DrawCellText()
{
if (!m_currentRectVisible)
return;
if (!cell)
return;
- static char szEdit[300];
-
wxClientDC dc(this);
dc.BeginDrawing();
SetGridClippingRegion(& dc);
dc.SetBackgroundMode(wxTRANSPARENT);
- dc.SetBrush(*cell->GetBackgroundBrush());
+ dc.SetBrush(cell->GetBackgroundBrush());
- strcpy(szEdit, m_textItem->GetValue());
+ wxString editValue = m_textItem->GetValue();
- wxRectangle rect;
+ wxRect rect;
rect = m_currentRect;
rect.x += 3;
rect.y += 2;
rect.width -= 5;
rect.height -= 4;
- DrawTextRect(& dc, " ", &rect, wxLEFT);
- DrawTextRect(& dc, szEdit, &rect, cell->GetAlignment());
+ // FIXME: what's this string of spaces supposed to represent?
+ DrawTextRect(& dc, wxT(" "), &rect, wxLEFT);
+ DrawTextRect(& dc, editValue, &rect, cell->GetAlignment());
dc.DestroyClippingRegion();
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;
{
case wxRIGHT:
{
- x = (rect->x + rect->width - textWidth - 1.0);
- y = (rect->y + (rect->height - textHeight)/2.0);
+ x = (rect->x + rect->width - textWidth - (float)1.0);
+ y = (rect->y + (rect->height - textHeight)/(float)2.0);
break;
}
case wxCENTRE:
{
- x = (rect->x + (rect->width - textWidth)/2.0);
- y = (rect->y + (rect->height - textHeight)/2.0);
+ x = (rect->x + (rect->width - textWidth)/(float)2.0);
+ y = (rect->y + (rect->height - textHeight)/(float)2.0);
break;
}
case wxLEFT:
default:
{
- x = (rect->x + 1.0);
- y = (rect->y + (rect->height - textHeight)/2.0);
+ x = (rect->x + (float)1.0);
+ y = (rect->y + (rect->height - textHeight)/(float)2.0);
break;
}
}
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("");
+ static wxString emptyString(wxT(""));
wxGridCell *cell = GetCell(row, col);
if (cell)
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 = "";
+ static wxString emptyString = wxT("");
wxGridCell *cell = GetLabelCell(orientation, pos);
if (cell)
return cell->GetTextValue();
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)
m_textItem->Show(TRUE);
m_textItem->SetFocus();
}
+
+ if (m_inPlaceTextItem)
+ {
+ m_inPlaceTextItem->Show(TRUE);
+ m_inPlaceTextItem->SetFocus();
+ }
}
else
{
m_textItem->Show(FALSE);
m_editingPanel->Show(FALSE);
}
+
+ if ( m_inPlaceTextItem )
+ {
+ m_inPlaceTextItem->Show(FALSE);
+ }
}
UpdateDimensions();
SetCurrentRect(GetCursorRow(), GetCursorColumn());
*/
}
+
+void wxGenericGrid::SetEditInPlace(bool edit)
+{
+ if ( m_editInPlace != edit )
+ {
+ m_editInPlace = edit;
+
+ if ( m_editInPlace ) // switched on
+ {
+ if ( m_currentRectVisible && m_editable )
+ {
+ m_inPlaceTextItem->SetSize( m_currentRect.x-wxIPE_ADJUST,
+ m_currentRect.y-wxIPE_ADJUST,
+ m_currentRect.width+wxIPE_ADJUST*2,
+ m_currentRect.height+wxIPE_ADJUST*2 );
+
+ wxGridCell *cell = GetCell(m_wCursorRow, m_wCursorColumn);
+
+ if ( cell ) {
+ m_inPlaceTextItem->SetFont( cell->GetFont() );
+ m_inPlaceTextItem->SetBackgroundColour(cell->GetBackgroundColour());
+ m_inPlaceTextItem->SetForegroundColour(cell->GetTextColour());
+
+ if ( cell->GetTextValue().IsNull() ) {
+ m_inPlaceTextItem->SetValue( wxT("") );
+ }
+ else {
+ m_inPlaceTextItem->SetValue( cell->GetTextValue() );
+ }
+ }
+
+ m_inPlaceTextItem->Show( TRUE );
+ m_inPlaceTextItem->SetFocus();
+ }
+ }
+ else // switched off
+ {
+ m_inPlaceTextItem->Show( FALSE );
+ }
+ }
+}
+
+
void wxGenericGrid::SetCellAlignment(int flag, int row, int col)
{
wxGridCell *cell = GetCell(row, col);
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)
SetGridClippingRegion(& dc);
- if (m_currentRectVisible)
- HighlightCell(& dc);
+ if (m_currentRectVisible && (wxIPE_HIGHLIGHT || !(m_editable && m_editInPlace)))
+ HighlightCell(& dc, FALSE);
m_wCursorRow = row;
m_wCursorColumn = col;
SetCurrentRect(row, col, cw, ch);
- if (m_currentRectVisible)
- HighlightCell(& dc);
+ if (m_currentRectVisible && (wxIPE_HIGHLIGHT || !(m_editable && m_editInPlace)))
+ HighlightCell(& dc, TRUE);
dc.DestroyClippingRegion();
dc.EndDrawing();
}
-/*
- * Grid cell
- */
+// ----------------------------------------------------------------------------
+// Grid 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);
alignment = window->GetCellAlignment();
else
alignment = wxLEFT;
+
+ cellData = (void *)NULL;
}
-wxGridCell::~wxGridCell(void)
+wxGridCell::~wxGridCell()
{
}
void wxGridCell::SetBackgroundColour(const wxColour& colour)
{
backgroundColour = colour;
- backgroundBrush = wxTheBrushList->FindOrCreateBrush(backgroundColour, wxSOLID);
+ backgroundBrush = * wxTheBrushList->FindOrCreateBrush(backgroundColour, wxSOLID);
}
void wxGenericGrid::OnText(wxCommandEvent& WXUNUSED(ev) )
{
- wxGenericGrid *grid = this;
- wxGridCell *cell = grid->GetCell(grid->GetCursorRow(), grid->GetCursorColumn());
- if (cell && grid->CurrentCellVisible())
- {
- cell->SetTextValue(grid->GetTextItem()->GetValue());
- wxClientDC dc(grid);
+ // michael - added this conditional to prevent change to
+ // grid cell text when edit control is hidden but still has
+ // focus
+ //
+ if ( m_editable )
+ {
+ wxGenericGrid *grid = this;
+ wxGridCell *cell = grid->GetCell(grid->GetCursorRow(), grid->GetCursorColumn());
+ if (cell && grid->CurrentCellVisible())
+ {
+ cell->SetTextValue(grid->GetTextItem()->GetValue());
+ if ( m_editInPlace && !m_inOnTextInPlace )
+ {
+ m_inPlaceTextItem->SetValue( grid->GetTextItem()->GetValue() );
+ }
- dc.BeginDrawing();
- grid->SetGridClippingRegion(& dc);
- grid->DrawCellBackground(& dc, &grid->GetCurrentRect(), grid->GetCursorRow(), grid->GetCursorColumn());
- grid->DrawCellValue(& dc, &grid->GetCurrentRect(), grid->GetCursorRow(), grid->GetCursorColumn());
- grid->HighlightCell(& dc);
- dc.DestroyClippingRegion();
- dc.EndDrawing();
+ if (!m_editInPlace) {
+ wxClientDC dc(grid);
- //grid->OnCellChange(grid->GetCursorRow(), grid->GetCursorColumn());
- wxGridEvent g_evt(GetId(), wxEVT_GRID_CELL_CHANGE, grid,
- grid->GetCursorRow(), grid->GetCursorColumn());
- GetEventHandler()->ProcessEvent(g_evt);
+ dc.BeginDrawing();
+ grid->SetGridClippingRegion(& dc);
+ grid->DrawCellBackground(& dc, &grid->GetCurrentRect(), grid->GetCursorRow(), grid->GetCursorColumn());
+ grid->DrawCellValue(& dc, &grid->GetCurrentRect(), grid->GetCursorRow(), grid->GetCursorColumn());
+ grid->HighlightCell(& dc, TRUE);
+ dc.DestroyClippingRegion();
+ dc.EndDrawing();
+ }
-// grid->DrawCellText();
- }
+ //grid->OnCellChange(grid->GetCursorRow(), grid->GetCursorColumn());
+ wxGridEvent g_evt(GetId(), wxEVT_GRID_CELL_CHANGE, grid,
+ grid->GetCursorRow(), grid->GetCursorColumn());
+ GetEventHandler()->ProcessEvent(g_evt);
+
+ // grid->DrawCellText();
+ }
+ }
+}
+
+void wxGenericGrid::OnTextEnter(wxCommandEvent& WXUNUSED(ev) )
+{
+ // move the cursor down the current row (if possible)
+ // when the enter key has been pressed
+ //
+ if ( m_editable )
+ {
+ if ( GetCursorRow() < GetRows()-1 )
+ {
+ wxClientDC dc( this );
+ dc.BeginDrawing();
+ OnSelectCellImplementation(& dc,
+ GetCursorRow()+1,
+ GetCursorColumn() );
+ dc.EndDrawing();
+ }
+ }
+}
+
+void wxGenericGrid::OnTextInPlace(wxCommandEvent& ev )
+{
+ if ( m_editable )
+ {
+ wxGenericGrid *grid = this;
+ wxGridCell *cell = grid->GetCell(grid->GetCursorRow(), grid->GetCursorColumn());
+ if (cell && grid->CurrentCellVisible())
+ {
+ m_inOnTextInPlace = TRUE;
+ grid->GetTextItem()->SetValue( m_inPlaceTextItem->GetValue() );
+ OnText( ev );
+ m_inOnTextInPlace = FALSE;
+ }
+ }
+}
+
+void wxGenericGrid::OnTextInPlaceEnter(wxCommandEvent& WXUNUSED(ev) )
+{
+ // move the cursor down the current row (if possible)
+ // when the enter key has been pressed
+ //
+ if ( m_editable )
+ {
+ if ( GetCursorRow() < GetRows()-1 )
+ {
+ wxClientDC dc( this );
+ dc.BeginDrawing();
+ OnSelectCellImplementation(& dc,
+ GetCursorRow()+1,
+ GetCursorColumn() );
+ dc.EndDrawing();
+ }
+ }
}
void wxGenericGrid::OnGridScroll(wxScrollEvent& ev)
{
- static bool inScroll = FALSE;
+ if ( m_inScroll )
+ return;
- if ( inScroll )
- return;
+ if ( m_editInPlace ) m_inPlaceTextItem->Show(FALSE);
- inScroll = TRUE;
+ m_inScroll = TRUE;
wxGenericGrid *win = this;
bool change = FALSE;
AdjustScrollbars();
if (change) win->Refresh(FALSE);
- inScroll = FALSE;
+
+ if ( m_editInPlace && m_currentRectVisible )
+ {
+ m_inPlaceTextItem->SetSize( m_currentRect.x-wxIPE_ADJUST,
+ m_currentRect.y-wxIPE_ADJUST,
+ m_currentRect.width+wxIPE_ADJUST*2,
+ m_currentRect.height+wxIPE_ADJUST*2 );
+ m_inPlaceTextItem->Show( TRUE );
+ m_inPlaceTextItem->SetFocus();
+ }
+
+ m_inScroll = FALSE;
}
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();
}
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;
+}
+#endif // wxUSE_GRID && !(wxUSE_NEW_GRID)