//////////////////////////////////////////////////////////////////////
-
-IMPLEMENT_DYNAMIC_CLASS( wxGridTextCtrl, wxTextCtrl )
-
-BEGIN_EVENT_TABLE( wxGridTextCtrl, wxTextCtrl )
- EVT_KEY_DOWN( wxGridTextCtrl::OnKeyDown )
-END_EVENT_TABLE()
-
-
-wxGridTextCtrl::wxGridTextCtrl( wxWindow *par,
- wxGrid *grid,
- bool isCellControl,
- wxWindowID id,
- const wxString& value,
- const wxPoint& pos,
- const wxSize& size,
- long style )
- : wxTextCtrl( par, id, value, pos, size, style )
-{
- m_grid = grid;
- m_isCellControl = isCellControl;
-}
-
-
-void wxGridTextCtrl::OnKeyDown( wxKeyEvent& event )
-{
- switch ( event.KeyCode() )
- {
-#if 0
- case WXK_ESCAPE:
- m_grid->SetEditControlValue( startValue );
- SetInsertionPointEnd();
- break;
-#else
- case WXK_ESCAPE:
- m_grid->EnableCellEditControl( FALSE );
-#endif
- case WXK_UP:
- case WXK_DOWN:
- case WXK_LEFT:
- case WXK_RIGHT:
- case WXK_PRIOR:
- case WXK_NEXT:
- case WXK_SPACE:
- if ( m_isCellControl )
- {
- // send the event to the parent grid, skipping the
- // event if nothing happens
- //
- event.Skip( m_grid->ProcessEvent( event ) );
- }
- else
- {
- // default text control response within the top edit
- // control
- //
- event.Skip();
- }
- break;
-
- case WXK_RETURN:
- if ( m_isCellControl )
- {
- if ( !m_grid->ProcessEvent( event ) )
- {
-#if defined(__WXMOTIF__) || defined(__WXGTK__)
- // wxMotif needs a little extra help...
- //
- int pos = GetInsertionPoint();
- wxString s( GetValue() );
- s = s.Left(pos) + "\n" + s.Mid(pos);
- SetValue(s);
- SetInsertionPoint( pos );
-#else
- // the other ports can handle a Return key press
- //
- event.Skip();
-#endif
- }
- }
- break;
- case WXK_HOME:
- case WXK_END:
- if ( m_isCellControl )
- {
- // send the event to the parent grid, skipping the
- // event if nothing happens
- //
- event.Skip( m_grid->ProcessEvent( event ) );
- }
- else
- {
- // default text control response within the top edit
- // control
- //
- event.Skip();
- }
- break;
-
- default:
- event.Skip();
- }
-}
-
-void wxGridTextCtrl::SetStartValue( const wxString& s )
-{
- startValue = s;
- wxTextCtrl::SetValue(s);
-}
-
-
-
//////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNAMIC_CLASS( wxGridRowLabelWindow, wxWindow )
//////////////////////////////////////////////////////////////////////
-#define ID_EDIT_TIMER 1001
IMPLEMENT_DYNAMIC_CLASS( wxGrid, wxScrolledWindow )
EVT_SIZE( wxGrid::OnSize )
EVT_KEY_DOWN( wxGrid::OnKeyDown )
EVT_ERASE_BACKGROUND( wxGrid::OnEraseBackground )
- EVT_TIMER( ID_EDIT_TIMER, wxGrid::OnEditTimer )
END_EVENT_TABLE()
wxGrid::wxGrid( wxWindow *parent,
if (m_ownTable)
delete m_table;
- delete m_editTimer;
}
void wxGrid::Create()
{
m_created = FALSE; // set to TRUE by CreateGrid
- m_displayed = FALSE; // set to TRUE by OnPaint
+ m_displayed = TRUE; // FALSE; // set to TRUE by OnPaint
m_table = (wxGridTableBase *) NULL;
m_ownTable = FALSE;
{
if ( m_created )
{
+ // RD: Actually, this should probably be allowed. I think it would be
+ // nice to be able to switch multiple Tables in and out of a single
+ // View at runtime. Is there anything in the implmentation that would
+ // prevent this?
+
wxFAIL_MSG( wxT("wxGrid::CreateGrid or wxGrid::SetTable called more than once") );
return FALSE;
}
m_isDragging = FALSE;
m_startDragPos = wxDefaultPosition;
- m_editTimer = new wxTimer( this, ID_EDIT_TIMER );
m_waitForSlowClick = FALSE;
m_rowResizeCursor = wxCursor( wxCURSOR_SIZENS );
if (m_waitForSlowClick && coords == m_currentCellCoords) {
EnableCellEditControl(TRUE);
ShowCellEditControl();
+ m_waitForSlowClick = FALSE;
}
else {
SetCurrentCell( coords );
- m_editTimer->Start( 1500, TRUE );
m_waitForSlowClick = TRUE;
}
}
{ }
-void wxGrid::OnEditTimer(wxTimerEvent&)
-{
- m_waitForSlowClick = FALSE;
-}
-
void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
// Clear the old current cell highlight
wxRect r = BlockToDeviceRect(m_currentCellCoords, m_currentCellCoords);
- m_currentCellCoords = coords; // Otherwise refresh redraws the hilit!
+ m_currentCellCoords = coords; // Otherwise refresh redraws the highlight!
m_gridWin->Refresh( FALSE, &r );
}
if ( m_displayed )
{
-#if 0
- ShowCellEditControl();
-#else
wxClientDC dc(m_gridWin);
PrepareDC(dc);
DrawCellHighlight(dc);
-#endif
if ( IsSelection() )
{
dc.SetPen(wxPen(m_gridLineColour, 3, wxSOLID));
dc.SetBrush(*wxTRANSPARENT_BRUSH);
- //dc.SetLogicalFunction(wxINVERT);
dc.DrawRectangle(rect);
}
void wxGrid::SetEditControlValue( const wxString& value )
{
+ // RD: The new Editors get the value from the table themselves now. This
+ // method can probably be removed...
}