]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/gridg.cpp
the progres dialog now looks decently under Windows
[wxWidgets.git] / src / generic / gridg.cpp
index 8fae3103b21eff8e6d584bc16ad66b0e5492404c..db89849d024315e861f69f9a7b010ca7c64ec193 100644 (file)
@@ -2,7 +2,8 @@
 // Name:        gridg.cpp
 // Purpose:     wxGenericGrid
 // Author:      Julian Smart
-// Modified by:
+// Modified by: Michael Bedward 20 Apr 1999
+//                Added edit in place facility
 // Created:     04/01/98
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart and Markus Holzem
 #endif
 
 #ifndef WX_PRECOMP
-#include "wx/wx.h"
+  #include "wx/utils.h"
+  #include "wx/dcclient.h"
+  #include "wx/dcmemory.h"
+  #include "wx/textctrl.h"
 #endif
 
 #include <string.h>
@@ -33,9 +37,9 @@
 
 // Set to zero to use no double-buffering
 #ifdef __WXMSW__
-#define wxUSE_DOUBLE_BUFFERING 1
+    #define wxUSE_DOUBLE_BUFFERING 1
 #else
-#define wxUSE_DOUBLE_BUFFERING 0
+    #define wxUSE_DOUBLE_BUFFERING 0
 #endif
 
 #define wxGRID_DRAG_NONE       0
@@ -51,6 +55,7 @@ BEGIN_EVENT_TABLE(wxGenericGrid, wxPanel)
     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_COMMAND_SCROLL(wxGRID_HSCROLL, wxGenericGrid::OnGridScroll)
     EVT_COMMAND_SCROLL(wxGRID_VSCROLL, wxGenericGrid::OnGridScroll)
 
@@ -68,8 +73,6 @@ BEGIN_EVENT_TABLE(wxGenericGrid, wxPanel)
 END_EVENT_TABLE()
 
 
-
-
 wxGenericGrid::wxGenericGrid(void)
 {
   m_batchCount = 0;
@@ -80,14 +83,20 @@ wxGenericGrid::wxGenericGrid(void)
   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_labelBackgroundBrush = wxNullBrush;
+  m_labelTextFont = wxNullFont;
+  m_cellTextFont = wxNullFont;
   m_textItem = (wxTextCtrl *) NULL;
   m_currentRectVisible = FALSE;
   m_editable = TRUE;
+
+  m_editInPlace = TRUE;
+  m_inOnTextInPlace = FALSE;
+  
 #if defined(__WIN95__)
   m_scrollWidth = wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X);
+#elif defined(__WXGTK__)
+  m_scrollWidth = wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X);
 #else
   m_scrollWidth = 16;
 #endif
@@ -95,7 +104,7 @@ wxGenericGrid::wxGenericGrid(void)
   m_dragRowOrCol = 0;
   m_dragStartPosition = 0;
   m_dragLastPosition = 0;
-  m_divisionPen = (wxPen *) NULL;
+  m_divisionPen = wxNullPen;
   m_leftOfSheet = wxGRID_DEFAULT_SHEET_LEFT;
   m_topOfSheet = wxGRID_DEFAULT_SHEET_TOP;
   m_cellHeight = wxGRID_DEFAULT_CELL_HEIGHT;
@@ -122,8 +131,6 @@ wxGenericGrid::wxGenericGrid(void)
   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,
@@ -133,21 +140,21 @@ bool wxGenericGrid::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos,
   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_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;
 #if defined(__WIN95__)
   m_scrollWidth = wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X);
+#elif defined(__WXGTK__)
+  m_scrollWidth = wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X);
 #else
   m_scrollWidth = 16;
 #endif
@@ -155,13 +162,13 @@ bool wxGenericGrid::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos,
   m_dragRowOrCol = 0;
   m_dragStartPosition = 0;
   m_dragLastPosition = 0;
-  m_divisionPen = wxThePenList->FindOrCreatePen("LIGHT GREY", 1, wxSOLID);
+  m_divisionPen = wxThePenList->FindOrCreatePen("LIGHT GREY", 1, wxSOLID);
   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);
@@ -206,8 +213,9 @@ bool wxGenericGrid::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos,
   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);
+                              wxPoint(m_editControlPosition.x, m_editControlPosition.y),
+                              wxSize(m_editControlPosition.width, -1),
+                              0);
   m_textItem->Show(TRUE);
   m_textItem->SetFocus();
   int controlW, controlH;
@@ -222,6 +230,15 @@ bool wxGenericGrid::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos,
   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, "",
+                                     wxPoint( m_currentRect.x-2, m_currentRect.y-2 ), 
+                                     wxSize( m_currentRect.width+4, m_currentRect.height+4 ), 
+                                     wxNO_BORDER );
+  m_inPlaceTextItem->Show(TRUE);
+  m_inPlaceTextItem->SetFocus();
+  
   return TRUE;
 }
 
@@ -402,7 +419,7 @@ void wxGenericGrid::UpdateDimensions(void)
   }
 }
 
-wxGridCell *wxGenericGrid::GetCell(int row, int col)
+wxGridCell *wxGenericGrid::GetCell(int row, int col) const
 {
   if (!m_gridCells)
     return (wxGridCell *) NULL;
@@ -414,7 +431,7 @@ wxGridCell *wxGenericGrid::GetCell(int row, int col)
   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];
@@ -512,7 +529,7 @@ void wxGenericGrid::PaintGrid(wxDC& dc)
 
     /* Hilight present cell */
     SetCurrentRect(m_wCursorRow, m_wCursorColumn);
-    if (m_currentRectVisible)
+    if (m_currentRectVisible && !(m_editable && m_editInPlace))
       HighlightCell(& dc);
 
     dc.DestroyClippingRegion();
@@ -556,7 +573,7 @@ void wxGenericGrid::DrawLabelAreas(wxDC *dc)
 //  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);
@@ -583,9 +600,9 @@ void wxGenericGrid::DrawGridLines(wxDC *dc)
 
   int i;
 
-  if (m_divisionPen)
+  if (m_divisionPen.Ok())
   {
-    dc->SetPen(*m_divisionPen);
+    dc->SetPen(m_divisionPen);
 
     int heightCount = m_topOfSheet + m_horizontalLabelHeight;
 
@@ -653,9 +670,9 @@ void wxGenericGrid::DrawGridLines(wxDC *dc)
 
   }
 
-  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;
@@ -782,7 +799,7 @@ void wxGenericGrid::DrawColumnLabel(wxDC *dc, wxRect *rect, int col)
     rect2.width -= 5;
     rect2.height -= 4;
     dc->SetTextForeground(GetLabelTextColour());
-    dc->SetFont(*GetLabelTextFont());
+    dc->SetFont(GetLabelTextFont());
        if ( !cell->GetTextValue().IsNull() )
        DrawTextRect(dc, cell->GetTextValue(), &rect2, GetLabelAlignment(wxHORIZONTAL));
   }
@@ -835,7 +852,7 @@ void wxGenericGrid::DrawRowLabel(wxDC *dc, wxRect *rect, int row)
     rect2.width -= 5;
     rect2.height -= 4;
     dc->SetTextForeground(GetLabelTextColour());
-    dc->SetFont(*GetLabelTextFont());
+    dc->SetFont(GetLabelTextFont());
        if ( !cell->GetTextValue().IsNull() )
        DrawTextRect(dc, cell->GetTextValue(), &rect2, GetLabelAlignment(wxVERTICAL));
   }
@@ -874,7 +891,7 @@ 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.
@@ -912,7 +929,7 @@ void wxGenericGrid::DrawCellValue(wxDC *dc, wxRect *rect, int row, int col)
     {
       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());
@@ -1024,16 +1041,21 @@ void wxGenericGrid::AdjustScrollbars(void)
   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->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();
 
@@ -1057,7 +1079,7 @@ void wxGenericGrid::OnSize(wxSizeEvent& WXUNUSED(event) )
   {
     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);
   }
 }
 
@@ -1239,13 +1261,13 @@ void wxGenericGrid::OnMouseEvent(wxMouseEvent& ev)
           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);
@@ -1272,7 +1294,7 @@ void wxGenericGrid::OnMouseEvent(wxMouseEvent& ev)
         dc.EndDrawing();
 
         m_dragLastPosition = (int)ev.GetX();
-        SetCursor(*m_horizontalSashCursor);
+        SetCursor(m_horizontalSashCursor);
         break;
       }
       case wxGRID_DRAG_UP_DOWN:
@@ -1286,7 +1308,7 @@ void wxGenericGrid::OnMouseEvent(wxMouseEvent& ev)
         dc.EndDrawing();
 
         m_dragLastPosition = (int)ev.GetY();
-        SetCursor(*m_verticalSashCursor);
+        SetCursor(m_verticalSashCursor);
         break;
       }
     }
@@ -1297,9 +1319,9 @@ void wxGenericGrid::OnMouseEvent(wxMouseEvent& ev)
     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);
@@ -1390,8 +1412,11 @@ void wxGenericGrid::OnSelectCellImplementation(wxDC *dc, int row, int col)
   SetGridClippingRegion(dc);
 
   // Remove the highlight from the old cell
-  if (m_currentRectVisible)
-     HighlightCell(dc);
+  if ( m_currentRectVisible && !(m_editable && m_editInPlace) )
+    {
+      HighlightCell(dc);
+    }
+  
 
   // Highlight the new cell and copy its content to the edit control
   SetCurrentRect(m_wCursorRow, m_wCursorColumn);
@@ -1406,18 +1431,48 @@ void wxGenericGrid::OnSelectCellImplementation(wxDC *dc, int row, int col)
 
   SetGridClippingRegion(dc);
 
-  // 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.
-#ifndef __WXMSW__
-//  HighlightCell(dc);
+
+  if ( m_editable && m_editInPlace )
+    {
+      m_inPlaceTextItem->SetSize( m_currentRect.x-2, m_currentRect.y-2, 
+                                 m_currentRect.width+4, m_currentRect.height+4 );
+
+      if ( cell )
+       {
+         if ( cell->GetTextValue().IsNull() )
+           {
+             m_inPlaceTextItem->SetValue( "" );
+           }
+         else
+           {
+             m_inPlaceTextItem->SetFont( cell->GetFont() );
+             m_inPlaceTextItem->SetValue( cell->GetTextValue() );
+           }
+       }
+      
+      m_inPlaceTextItem->Show(TRUE);
+      m_inPlaceTextItem->SetFocus();
+    }
+  else
+    {      
+      // 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
+      //
+#ifdef __WXMOTIF__
+      if ( !(m_editable && m_editInPlace) )
+          HighlightCell(dc);
 #endif
+    }
+
   dc->DestroyClippingRegion();
 
-  //OnSelectCell(row, col);
+  OnSelectCell(row, col);
   wxGridEvent g_evt2(GetId(), wxEVT_GRID_SELECT_CELL, this, row, col);
-  GetEventHandler()->ProcessEvent(g_evt2);
+  GetEventHandler()->ProcessEvent(g_evt2);  
 }
 
 wxGridCell *wxGenericGrid::OnCreateCell(void)
@@ -1503,17 +1558,15 @@ void wxGenericGrid::DrawCellText(void)
   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();
 
   wxRect rect;
   rect = m_currentRect;
@@ -1522,8 +1575,9 @@ void wxGenericGrid::DrawCellText(void)
   rect.width -= 5;
   rect.height -= 4;
 
+  // FIXME: what's this string of spaces supposed to represent?
   DrawTextRect(& dc, "                                    ", &rect, wxLEFT);
-  DrawTextRect(& dc, szEdit, &rect, cell->GetAlignment());
+  DrawTextRect(& dc, editValue, &rect, cell->GetAlignment());
 
   dc.DestroyClippingRegion();
 
@@ -1816,7 +1870,7 @@ void wxGenericGrid::RefreshCell(int row, int col, bool setText)
     }
 }
 
-wxString& wxGenericGrid::GetCellValue(int row, int col)
+wxString& wxGenericGrid::GetCellValue(int row, int col) const
 {
   static wxString emptyString("");
 
@@ -1833,7 +1887,7 @@ void wxGenericGrid::SetColumnWidth(int col, int width)
     m_colWidths[col] = width;
 }
 
-int wxGenericGrid::GetColumnWidth(int col)
+int wxGenericGrid::GetColumnWidth(int col) const
 {
   if (col <= m_totalCols)
     return m_colWidths[col];
@@ -1847,7 +1901,7 @@ void wxGenericGrid::SetRowHeight(int row, int height)
     m_rowHeights[row] = height;
 }
 
-int wxGenericGrid::GetRowHeight(int row)
+int wxGenericGrid::GetRowHeight(int row) const
 {
   if (row <= m_totalRows)
     return m_rowHeights[row];
@@ -1865,7 +1919,7 @@ void wxGenericGrid::SetLabelSize(int orientation, int sz)
   SetCurrentRect(GetCursorRow(), GetCursorColumn());
 }
 
-int wxGenericGrid::GetLabelSize(int orientation)
+int wxGenericGrid::GetLabelSize(int orientation) const
 {
   if (orientation == wxHORIZONTAL)
     return m_horizontalLabelHeight;
@@ -1873,7 +1927,7 @@ int wxGenericGrid::GetLabelSize(int orientation)
     return m_verticalLabelWidth;
 }
 
-wxGridCell *wxGenericGrid::GetLabelCell(int orientation, int pos)
+wxGridCell *wxGenericGrid::GetLabelCell(int orientation, int pos) const
 {
   if (orientation == wxHORIZONTAL)
   {
@@ -1898,7 +1952,7 @@ void wxGenericGrid::SetLabelValue(int orientation, const wxString& val, int pos)
     cell->SetTextValue(val);
 }
 
-wxString& wxGenericGrid::GetLabelValue(int orientation, int pos)
+wxString& wxGenericGrid::GetLabelValue(int orientation, int pos) const
 {
  static wxString emptyString = "";
   wxGridCell *cell = GetLabelCell(orientation, pos);
@@ -1918,7 +1972,7 @@ void wxGenericGrid::SetLabelAlignment(int orientation, int align)
   SetCurrentRect(GetCursorRow(), GetCursorColumn());
 }
 
-int wxGenericGrid::GetLabelAlignment(int orientation)
+int wxGenericGrid::GetLabelAlignment(int orientation) const
 {
   if (orientation == wxHORIZONTAL)
     return m_horizontalLabelAlignment;
@@ -1935,7 +1989,7 @@ void wxGenericGrid::SetLabelTextColour(const wxColour& colour)
 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)
@@ -1954,6 +2008,12 @@ void wxGenericGrid::SetEditable(bool edit)
       m_textItem->Show(TRUE);
       m_textItem->SetFocus();
     }
+
+    if (m_inPlaceTextItem)
+      {
+       m_inPlaceTextItem->Show(TRUE);
+       m_inPlaceTextItem->SetFocus();
+      }
   }
   else
   {
@@ -1963,6 +2023,11 @@ void wxGenericGrid::SetEditable(bool edit)
       m_textItem->Show(FALSE);
       m_editingPanel->Show(FALSE);
     }
+    
+    if ( m_inPlaceTextItem )
+      {
+       m_inPlaceTextItem->Show(FALSE);
+      }
   }
   UpdateDimensions();
   SetCurrentRect(GetCursorRow(), GetCursorColumn());
@@ -1982,6 +2047,47 @@ void wxGenericGrid::SetEditable(bool edit)
 */
 }
 
+
+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-2, m_currentRect.y-2, 
+                                         m_currentRect.width+4, m_currentRect.height+4 );
+
+             wxGridCell *cell = GetCell(m_wCursorRow, m_wCursorColumn);
+
+             if ( cell )
+               {
+                 if ( cell->GetTextValue().IsNull() )
+                   {
+                     m_inPlaceTextItem->SetValue( "" );
+                   }
+                 else
+                   {
+                     m_inPlaceTextItem->SetFont( cell->GetFont() );
+                     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);
@@ -1989,7 +2095,7 @@ void wxGenericGrid::SetCellAlignment(int flag, int row, int 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)
@@ -2008,7 +2114,7 @@ void wxGenericGrid::SetCellAlignment(int flag)
         GetCell(i, j)->SetAlignment(flag);
 }
 
-int wxGenericGrid::GetCellAlignment(void)
+int wxGenericGrid::GetCellAlignment(void) const
 {
   return m_cellAlignment;
 }
@@ -2033,13 +2139,13 @@ void wxGenericGrid::SetCellBackgroundColour(const wxColour& val, int row, int co
   }
 }
 
-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)
@@ -2052,7 +2158,7 @@ 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)
@@ -2062,22 +2168,22 @@ void wxGenericGrid::SetCellTextFont(wxFont *fnt, int row, int col)
   }
 }
 
-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)
@@ -2090,7 +2196,7 @@ 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;
@@ -2110,7 +2216,7 @@ void wxGenericGrid::SetCellBitmap(wxBitmap *bitmap, int row, int col)
   }
 }
 
-wxBitmap *wxGenericGrid::GetCellBitmap(int row, int col)
+wxBitmap *wxGenericGrid::GetCellBitmap(int row, int col) const
 {
   wxGridCell *cell = GetCell(row, col);
   if (cell)
@@ -2382,7 +2488,7 @@ void wxGenericGrid::SetGridCursor(int row, int col)
 
   SetGridClippingRegion(& dc);
 
-  if (m_currentRectVisible)
+  if (m_currentRectVisible && !(m_editable && m_editInPlace) )
     HighlightCell(& dc);
 
   m_wCursorRow = row;
@@ -2393,7 +2499,7 @@ void wxGenericGrid::SetGridCursor(int row, int col)
 
   SetCurrentRect(row, col, cw, ch);
 
-  if (m_currentRectVisible)
+  if (m_currentRectVisible && !(m_editable && m_editInPlace) )
     HighlightCell(& dc);
 
   dc.DestroyClippingRegion();
@@ -2407,8 +2513,8 @@ void wxGenericGrid::SetGridCursor(int row, int col)
 wxGridCell::wxGridCell(wxGenericGrid *window)
 {
   cellBitmap = (wxBitmap *) NULL;
-  font = (wxFont *) NULL;
-  backgroundBrush = (wxBrush *) NULL;
+  font = wxNullFont;
+  backgroundBrush = wxNullBrush;
   if (window)
     textColour = window->GetCellTextColour();
   else
@@ -2421,7 +2527,7 @@ wxGridCell::wxGridCell(wxGenericGrid *window)
   if (window)
     font = window->GetCellTextFont();
   else
-    font = wxTheFontList->FindOrCreateFont(12, wxSWISS, wxNORMAL, wxNORMAL);
+    font = wxTheFontList->FindOrCreateFont(12, wxSWISS, wxNORMAL, wxNORMAL);
 
   SetBackgroundColour(backgroundColour);
 
@@ -2438,33 +2544,61 @@ wxGridCell::~wxGridCell(void)
 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);
-
-    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();
-
-    //grid->OnCellChange(grid->GetCursorRow(), grid->GetCursorColumn());
-    wxGridEvent g_evt(GetId(), wxEVT_GRID_CELL_CHANGE, grid,
-                      grid->GetCursorRow(), grid->GetCursorColumn());
-    GetEventHandler()->ProcessEvent(g_evt);
+  // 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() );
+           }
+    
+         wxClientDC dc(grid);
+
+         dc.BeginDrawing();
+         grid->SetGridClippingRegion(& dc);
+         grid->DrawCellBackground(& dc, &grid->GetCurrentRect(), grid->GetCursorRow(), grid->GetCursorColumn());
+         grid->DrawCellValue(& dc, &grid->GetCurrentRect(), grid->GetCursorRow(), grid->GetCursorColumn());
+         if ( !(m_editable && m_editInPlace ) ) grid->HighlightCell(& dc);
+         dc.DestroyClippingRegion();
+         dc.EndDrawing();
+
+         //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();
+       }
+    }
+}
 
-//    grid->DrawCellText();
-  }
+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::OnGridScroll(wxScrollEvent& ev)
@@ -2474,6 +2608,8 @@ void wxGenericGrid::OnGridScroll(wxScrollEvent& ev)
   if ( inScroll )
        return;
 
+  if ( m_editInPlace ) m_inPlaceTextItem->Show(FALSE);
+
   inScroll = TRUE;
   wxGenericGrid *win = this;
 
@@ -2500,6 +2636,15 @@ void wxGenericGrid::OnGridScroll(wxScrollEvent& ev)
   AdjustScrollbars();
 
   if (change) win->Refresh(FALSE);
+
+  if ( m_editInPlace && m_currentRectVisible )
+    {
+      m_inPlaceTextItem->SetSize( m_currentRect.x-2, m_currentRect.y-2, 
+                                 m_currentRect.width+4, m_currentRect.height+4 );
+      m_inPlaceTextItem->Show( TRUE );
+      m_inPlaceTextItem->SetFocus();     
+    }
+
   inScroll = FALSE;
 
 }