]> git.saurik.com Git - wxWidgets.git/commitdiff
Added enabling/disabling of cell edit control.
authorStefan Neis <Stefan.Neis@t-online.de>
Sun, 13 Feb 2000 16:58:43 +0000 (16:58 +0000)
committerStefan Neis <Stefan.Neis@t-online.de>
Sun, 13 Feb 2000 16:58:43 +0000 (16:58 +0000)
Moved grid lines and cells by one pixel.
Call SelectBlock in SetCurrentCell (possibly not, what we want?)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5994 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/generic/grid.h
src/generic/grid.cpp

index c82e4bc6b04c23cf9c6302a907bfd1d85de3892c..1828a1ddf308025705683bbbe968b3fad4af04fb 100644 (file)
@@ -679,9 +679,7 @@ public:
     bool IsEditable() { return m_editable; }
     void EnableEditing( bool edit );
 
     bool IsEditable() { return m_editable; }
     void EnableEditing( bool edit );
 
-#if 0  // at the moment the cell edit control is always active
     void     EnableCellEditControl( bool enable );
     void     EnableCellEditControl( bool enable );
-#endif
 
     bool     IsCellEditControlEnabled()
              { return (m_cellEditCtrl && m_cellEditCtrlEnabled); }
 
     bool     IsCellEditControlEnabled()
              { return (m_cellEditCtrl && m_cellEditCtrlEnabled); }
index cbdb0110ac6db378959c237c65d0dc8868225a20..0355d2f816e5ef79f371c9222f17b7f2573bbd36 100644 (file)
@@ -457,7 +457,6 @@ void wxGridCellRenderer::Draw(wxGrid& grid,
     }
 
     dc.SetPen( *wxTRANSPARENT_PEN );
     }
 
     dc.SetPen( *wxTRANSPARENT_PEN );
-
     dc.DrawRectangle(rect);
 }
 
     dc.DrawRectangle(rect);
 }
 
@@ -1609,7 +1608,6 @@ wxGridWindow::wxGridWindow( wxGrid *parent,
     m_owner = parent;
     m_rowLabelWin = rowLblWin;
     m_colLabelWin = colLblWin;
     m_owner = parent;
     m_rowLabelWin = rowLblWin;
     m_colLabelWin = colLblWin;
-
     SetBackgroundColour( "WHITE" );
 }
 
     SetBackgroundColour( "WHITE" );
 }
 
@@ -1901,7 +1899,7 @@ void wxGrid::Init()
     //
     m_cellEditCtrl = new wxGridTextCtrl( m_gridWin,
                                          this,
     //
     m_cellEditCtrl = new wxGridTextCtrl( m_gridWin,
                                          this,
-                                         TRUE,
+                                         FALSE,
                                          wxGRID_CELLCTRL,
                                          "",
                                          wxPoint(1,1),
                                          wxGRID_CELLCTRL,
                                          "",
                                          wxPoint(1,1),
@@ -1912,7 +1910,7 @@ void wxGrid::Init()
                                          );
 
     m_cellEditCtrl->Show( FALSE );
                                          );
 
     m_cellEditCtrl->Show( FALSE );
-    m_cellEditCtrlEnabled = TRUE;
+    m_cellEditCtrlEnabled = FALSE;
     m_editCtrlType = wxGRID_TEXTCTRL;
 }
 
     m_editCtrlType = wxGRID_TEXTCTRL;
 }
 
@@ -2806,6 +2804,16 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
         //
         if ( event.LeftDown() )
         {
         //
         if ( event.LeftDown() )
         {
+            if ( event.AltDown() )
+            {
+                MakeCellVisible( coords );
+                SetCurrentCell( coords );
+                EnableCellEditControl( TRUE );
+            }
+            else
+            {
+                EnableCellEditControl( FALSE );
+            }
             if ( event.ShiftDown() )
             {
                 SelectBlock( m_currentCellCoords, coords );
             if ( event.ShiftDown() )
             {
                 SelectBlock( m_currentCellCoords, coords );
@@ -2829,6 +2837,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
         //
         else if ( event.LeftDClick() )
         {
         //
         else if ( event.LeftDClick() )
         {
+            EnableCellEditControl( FALSE );
             if ( XToEdgeOfCol(x) < 0  &&  YToEdgeOfRow(y) < 0 )
             {
                 SendEvent( EVT_GRID_CELL_LEFT_DCLICK,
             if ( XToEdgeOfCol(x) < 0  &&  YToEdgeOfRow(y) < 0 )
             {
                 SendEvent( EVT_GRID_CELL_LEFT_DCLICK,
@@ -2884,6 +2893,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
         //
         else if ( event.RightDown() )
         {
         //
         else if ( event.RightDown() )
         {
+            EnableCellEditControl( FALSE );
             if ( !SendEvent( EVT_GRID_CELL_RIGHT_CLICK,
                              coords.GetRow(),
                              coords.GetCol(),
             if ( !SendEvent( EVT_GRID_CELL_RIGHT_CLICK,
                              coords.GetRow(),
                              coords.GetCol(),
@@ -2898,6 +2908,7 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
         //
         else if ( event.RightDClick() )
         {
         //
         else if ( event.RightDClick() )
         {
+            EnableCellEditControl( FALSE );
             if ( !SendEvent( EVT_GRID_CELL_RIGHT_DCLICK,
                              coords.GetRow(),
                              coords.GetCol(),
             if ( !SendEvent( EVT_GRID_CELL_RIGHT_DCLICK,
                              coords.GetRow(),
                              coords.GetCol(),
@@ -3542,12 +3553,14 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
             default:
                 // now try the cell edit control
                 //
             default:
                 // now try the cell edit control
                 //
+                if ( !IsCellEditControlEnabled() )
+                    EnableCellEditControl( TRUE );
                 if ( IsCellEditControlEnabled() )
                 if ( IsCellEditControlEnabled() )
-                {
-                    event.SetEventObject( m_cellEditCtrl );
-                    m_cellEditCtrl->GetEventHandler()->ProcessEvent( event );
-                }
-                break;
+               {
+                   event.SetEventObject( m_cellEditCtrl );
+                   m_cellEditCtrl->GetEventHandler()->ProcessEvent( event );
+               }
+               break;
         }
     }
 
         }
     }
 
@@ -3575,7 +3588,7 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
     m_currentCellCoords = coords;
 
     SetEditControlValue();
     m_currentCellCoords = coords;
 
     SetEditControlValue();
-
+#if 0
     if ( m_displayed )
     {
         ShowCellEditControl();
     if ( m_displayed )
     {
         ShowCellEditControl();
@@ -3587,6 +3600,9 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
             if ( !GetBatchCount() ) m_gridWin->Refresh( FALSE, &r );
         }
     }
             if ( !GetBatchCount() ) m_gridWin->Refresh( FALSE, &r );
         }
     }
+#else
+    SelectBlock ( coords, coords );
+#endif
 }
 
 
 }
 
 
@@ -3665,8 +3681,8 @@ void wxGrid::DrawCell( wxDC& dc, const wxGridCellCoords& coords )
     // but all the rest is drawn by the cell renderer and hence may be
     // customized
     wxRect rect;
     // but all the rest is drawn by the cell renderer and hence may be
     // customized
     wxRect rect;
-    rect.x = m_colRights[col] - m_colWidths[col] + 1;
-    rect.y = m_rowBottoms[row] - m_rowHeights[row] + 1;
+    rect.x = m_colRights[col] - m_colWidths[col];
+    rect.y = m_rowBottoms[row] - m_rowHeights[row];
     rect.width = m_colWidths[col] - 1;
     rect.height = m_rowHeights[row] - 1;
 
     rect.width = m_colWidths[col] - 1;
     rect.height = m_rowHeights[row] - 1;
 
@@ -3736,13 +3752,13 @@ void wxGrid::DrawAllGridLines( wxDC& dc, const wxRegion & reg )
     int i;
     for ( i = 0; i < m_numRows; i++ )
     {
     int i;
     for ( i = 0; i < m_numRows; i++ )
     {
-        if ( m_rowBottoms[i] > bottom )
+        if ( m_rowBottoms[i]-1 > bottom )
         {
             break;
         }
         {
             break;
         }
-        else if ( m_rowBottoms[i] >= top )
+        else if ( m_rowBottoms[i]-1 >= top )
         {
         {
-            dc.DrawLine( left, m_rowBottoms[i], right, m_rowBottoms[i] );
+            dc.DrawLine( left, m_rowBottoms[i]-1, right, m_rowBottoms[i]-1 );
         }
     }
 
         }
     }
 
@@ -3751,13 +3767,13 @@ void wxGrid::DrawAllGridLines( wxDC& dc, const wxRegion & reg )
     //
     for ( i = 0; i < m_numCols; i++ )
     {
     //
     for ( i = 0; i < m_numCols; i++ )
     {
-        if ( m_colRights[i] > right )
+        if ( m_colRights[i]-1 > right )
         {
             break;
         }
         {
             break;
         }
-        else if ( m_colRights[i] >= left )
+        else if ( m_colRights[i]-1 >= left )
         {
         {
-            dc.DrawLine( m_colRights[i], top, m_colRights[i], bottom );
+            dc.DrawLine( m_colRights[i]-1, top, m_colRights[i]-1, bottom );
         }
     }
 }
         }
     }
 }
@@ -4000,27 +4016,30 @@ void wxGrid::EnableEditing( bool edit )
 }
 
 
 }
 
 
-#if 0  // disabled for the moment - the cell control is always active
 void wxGrid::EnableCellEditControl( bool enable )
 {
 void wxGrid::EnableCellEditControl( bool enable )
 {
+    if ( m_currentCellCoords == wxGridNoCellCoords )
+        SetCurrentCell( 0, 0 );
     if ( m_cellEditCtrl &&
          enable != m_cellEditCtrlEnabled )
     {
     if ( m_cellEditCtrl &&
          enable != m_cellEditCtrlEnabled )
     {
-        m_cellEditCtrlEnabled = enable;
 
 
-        if ( m_cellEditCtrlEnabled )
+        if ( enable )
         {
         {
+            m_cellEditCtrlEnabled = enable;
             SetEditControlValue();
             SetEditControlValue();
+                 // requires m_cellEditCtrlEnabled to be already true
             ShowCellEditControl();
         }
         else
         {
             HideCellEditControl();
             ShowCellEditControl();
         }
         else
         {
             HideCellEditControl();
+                 // requires m_cellEditCtrlEnabled to be still true
             SaveEditControlValue();
             SaveEditControlValue();
+            m_cellEditCtrlEnabled = enable;
         }
     }
 }
         }
     }
 }
-#endif
 
 
 void wxGrid::ShowCellEditControl()
 
 
 void wxGrid::ShowCellEditControl()
@@ -4124,6 +4143,7 @@ void wxGrid::HideCellEditControl()
     if ( IsCellEditControlEnabled() )
     {
         m_cellEditCtrl->Show( FALSE );
     if ( IsCellEditControlEnabled() )
     {
         m_cellEditCtrl->Show( FALSE );
+        SetFocus();
     }
 }
 
     }
 }