Shift edit control (since we shifted cells in last version!)

Only draw valid help lines in resizing.
First try to enable EditCtrl on slow clicking: Doesn't work yet.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5998 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Neis
2000-02-13 19:43:54 +00:00
parent 5330a86957
commit 025562fee3
2 changed files with 64 additions and 20 deletions

View File

@@ -31,7 +31,7 @@
#include "wx/textctrl.h" #include "wx/textctrl.h"
#include "wx/combobox.h" #include "wx/combobox.h"
#include "wx/dynarray.h" #include "wx/dynarray.h"
#include "wx/timer.h"
// Default parameters for wxGrid // Default parameters for wxGrid
// //
@@ -571,6 +571,20 @@ private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
//-----------------------------------------------------------------------------
// wxGridEditTimer (internal)
//-----------------------------------------------------------------------------
class WXDLLEXPORT wxGridEditTimer: public wxTimer
{
private:
wxGrid *m_owner;
public:
wxGridEditTimer( wxGrid *owner );
void Notify();
};
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxGrid // wxGrid
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -1184,6 +1198,8 @@ protected:
int m_dragRowOrCol; int m_dragRowOrCol;
bool m_isDragging; bool m_isDragging;
wxTimer *m_editTimer;
wxGridCellCoords m_selectionStart; wxGridCellCoords m_selectionStart;
wxCursor m_rowResizeCursor; wxCursor m_rowResizeCursor;

View File

@@ -1320,7 +1320,6 @@ void wxGridStringTable::SetColLabelValue( int col, const wxString& value )
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNAMIC_CLASS( wxGridTextCtrl, wxTextCtrl ) IMPLEMENT_DYNAMIC_CLASS( wxGridTextCtrl, wxTextCtrl )
@@ -1349,11 +1348,15 @@ void wxGridTextCtrl::OnKeyDown( wxKeyEvent& event )
{ {
switch ( event.KeyCode() ) switch ( event.KeyCode() )
{ {
#if 0
case WXK_ESCAPE: case WXK_ESCAPE:
m_grid->SetEditControlValue( startValue ); m_grid->SetEditControlValue( startValue );
SetInsertionPointEnd(); SetInsertionPointEnd();
break; break;
#else
case WXK_ESCAPE:
m_grid->EnableCellEditControl( FALSE );
#endif
case WXK_UP: case WXK_UP:
case WXK_DOWN: case WXK_DOWN:
case WXK_LEFT: case WXK_LEFT:
@@ -1398,7 +1401,6 @@ void wxGridTextCtrl::OnKeyDown( wxKeyEvent& event )
} }
} }
break; break;
case WXK_HOME: case WXK_HOME:
case WXK_END: case WXK_END:
if ( m_isCellControl ) if ( m_isCellControl )
@@ -1656,6 +1658,20 @@ void wxGridWindow::OnEraseBackground(wxEraseEvent&)
{ } { }
//-----------------------------------------------------------------------------
// wxGridEditTimer (internal)
//-----------------------------------------------------------------------------
wxGridEditTimer::wxGridEditTimer( wxGrid *owner )
{
m_owner = owner;
}
void wxGridEditTimer::Notify()
{
m_owner->EnableCellEditControl( TRUE );
}
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@@ -1695,6 +1711,7 @@ wxGrid::~wxGrid()
if (m_ownTable) if (m_ownTable)
delete m_table; delete m_table;
delete m_editTimer;
} }
@@ -1880,6 +1897,8 @@ void wxGrid::Init()
m_dragRowOrCol = -1; m_dragRowOrCol = -1;
m_isDragging = FALSE; m_isDragging = FALSE;
m_editTimer = new wxGridEditTimer ( this );
m_rowResizeCursor = wxCursor( wxCURSOR_SIZENS ); m_rowResizeCursor = wxCursor( wxCURSOR_SIZENS );
m_colResizeCursor = wxCursor( wxCURSOR_SIZEWE ); m_colResizeCursor = wxCursor( wxCURSOR_SIZEWE );
@@ -2317,6 +2336,10 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
wxClientDC dc( m_gridWin ); wxClientDC dc( m_gridWin );
PrepareDC( dc ); PrepareDC( dc );
y = wxMax( y,
m_rowBottoms[m_dragRowOrCol] -
m_rowHeights[m_dragRowOrCol] +
WXGRID_MIN_ROW_HEIGHT );
dc.SetLogicalFunction(wxINVERT); dc.SetLogicalFunction(wxINVERT);
if ( m_dragLastPos >= 0 ) if ( m_dragLastPos >= 0 )
{ {
@@ -2479,6 +2502,10 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
wxClientDC dc( m_gridWin ); wxClientDC dc( m_gridWin );
PrepareDC( dc ); PrepareDC( dc );
x = wxMax( x,
m_colRights[m_dragRowOrCol] -
m_colWidths[m_dragRowOrCol] +
WXGRID_MIN_COL_WIDTH );
dc.SetLogicalFunction(wxINVERT); dc.SetLogicalFunction(wxINVERT);
if ( m_dragLastPos >= 0 ) if ( m_dragLastPos >= 0 )
{ {
@@ -2756,6 +2783,10 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
wxClientDC dc( m_gridWin ); wxClientDC dc( m_gridWin );
PrepareDC( dc ); PrepareDC( dc );
y = wxMax( y,
m_rowBottoms[m_dragRowOrCol] -
m_rowHeights[m_dragRowOrCol] +
WXGRID_MIN_ROW_HEIGHT );
dc.SetLogicalFunction(wxINVERT); dc.SetLogicalFunction(wxINVERT);
if ( m_dragLastPos >= 0 ) if ( m_dragLastPos >= 0 )
{ {
@@ -2772,6 +2803,9 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
wxClientDC dc( m_gridWin ); wxClientDC dc( m_gridWin );
PrepareDC( dc ); PrepareDC( dc );
x = wxMax( x,
m_colRights[m_dragRowOrCol] -
m_colWidths[m_dragRowOrCol] + WXGRID_MIN_COL_WIDTH );
dc.SetLogicalFunction(wxINVERT); dc.SetLogicalFunction(wxINVERT);
if ( m_dragLastPos >= 0 ) if ( m_dragLastPos >= 0 )
{ {
@@ -2804,16 +2838,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
// //
if ( event.LeftDown() ) if ( event.LeftDown() )
{ {
if ( event.AltDown() ) EnableCellEditControl( FALSE );
{
MakeCellVisible( coords );
SetCurrentCell( coords );
EnableCellEditControl( TRUE );
}
else
{
EnableCellEditControl( FALSE );
}
if ( event.ShiftDown() ) if ( event.ShiftDown() )
{ {
SelectBlock( m_currentCellCoords, coords ); SelectBlock( m_currentCellCoords, coords );
@@ -2838,6 +2863,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
else if ( event.LeftDClick() ) else if ( event.LeftDClick() )
{ {
EnableCellEditControl( FALSE ); EnableCellEditControl( FALSE );
m_editTimer->Stop();
if ( XToEdgeOfCol(x) < 0 && YToEdgeOfRow(y) < 0 ) if ( XToEdgeOfCol(x) < 0 && YToEdgeOfRow(y) < 0 )
{ {
SendEvent( EVT_GRID_CELL_LEFT_DCLICK, SendEvent( EVT_GRID_CELL_LEFT_DCLICK,
@@ -2863,6 +2889,8 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
// been hidden for drag-shrinking. // been hidden for drag-shrinking.
if ( IsCellEditControlEnabled() ) if ( IsCellEditControlEnabled() )
ShowCellEditControl(); ShowCellEditControl();
if( IsEditable() && coords == m_currentCellCoords )
m_editTimer->Start( 100, TRUE );
} }
else if ( m_cursorMode == WXGRID_CURSOR_RESIZE_ROW ) else if ( m_cursorMode == WXGRID_CURSOR_RESIZE_ROW )
{ {
@@ -3556,11 +3584,11 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
if ( !IsCellEditControlEnabled() ) if ( !IsCellEditControlEnabled() )
EnableCellEditControl( TRUE ); EnableCellEditControl( TRUE );
if ( IsCellEditControlEnabled() ) if ( IsCellEditControlEnabled() )
{ {
event.SetEventObject( m_cellEditCtrl ); event.SetEventObject( m_cellEditCtrl );
m_cellEditCtrl->GetEventHandler()->ProcessEvent( event ); m_cellEditCtrl->GetEventHandler()->ProcessEvent( event );
} }
break; break;
} }
} }
@@ -4061,7 +4089,7 @@ void wxGrid::ShowCellEditControl()
int left, top, right, bottom; int left, top, right, bottom;
CalcScrolledPosition( rect.GetLeft(), rect.GetTop(), &left, &top ); CalcScrolledPosition( rect.GetLeft(), rect.GetTop(), &left, &top );
CalcScrolledPosition( rect.GetRight(), rect.GetBottom(), &right, &bottom ); CalcScrolledPosition( rect.GetRight(), rect.GetBottom(), &right, &bottom );
left--; top--; right--; bottom--; // cell is shifted by one pixel
int cw, ch; int cw, ch;
m_gridWin->GetClientSize( &cw, &ch ); m_gridWin->GetClientSize( &cw, &ch );