]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/grid.cpp
wxWebKit now properly updates after a resize event.
[wxWidgets.git] / src / generic / grid.cpp
index 1ca6596040d4f483603d5e593e6d660f23d7ee98..8947c56632c19ea533d9ac212af55022c0f17ad9 100644 (file)
@@ -1068,8 +1068,13 @@ void wxGridCellFloatEditor::Reset()
 void wxGridCellFloatEditor::StartingKey(wxKeyEvent& event)
 {
     int keycode = event.GetKeyCode();
+    char tmpbuf[2];
+    tmpbuf[0] = (char) keycode;
+    tmpbuf[1] = '\0';
+    bool is_decimal_point = ( wxString(tmpbuf, *wxConvCurrent) == 
+      wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER) );
         if ( wxIsdigit(keycode) || keycode == '+' || keycode == '-'
-            || keycode == wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER)[0]
+            || is_decimal_point
             || keycode ==  WXK_NUMPAD0
             || keycode ==  WXK_NUMPAD1
             || keycode ==  WXK_NUMPAD2
@@ -1168,13 +1173,21 @@ bool wxGridCellFloatEditor::IsAcceptedKey(wxKeyEvent& event)
             case WXK_NUMPAD_DECIMAL:
                 return TRUE;
 
-            default:
-                // additionally accept 'e' as in '1e+6', also '-', '+', and '.'
+            default: 
+            {
+               // additionally accept 'e' as in '1e+6', also '-', '+', and '.'
+                char tmpbuf[2];
+                tmpbuf[0] = (char) keycode;
+                tmpbuf[1] = '\0';
+                bool is_decimal_point =
+                  ( wxString(tmpbuf, *wxConvCurrent) == 
+                    wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT,
+                                      wxLOCALE_CAT_NUMBER) );
                 if ( (keycode < 128) &&
                      (wxIsdigit(keycode) || tolower(keycode) == 'e' ||
-                      keycode == wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER)[0] || 
-                      keycode == '+' || keycode == '-') )
+                      is_decimal_point || keycode == '+' || keycode == '-') )
                     return TRUE;
+            }
         }
     }
 
@@ -3466,7 +3479,7 @@ END_EVENT_TABLE()
 wxGridRowLabelWindow::wxGridRowLabelWindow( wxGrid *parent,
                                             wxWindowID id,
                                             const wxPoint &pos, const wxSize &size )
-  : wxWindow( parent, id, pos, size, wxWANTS_CHARS|wxBORDER_NONE )
+  : wxWindow( parent, id, pos, size, wxWANTS_CHARS|wxBORDER_NONE|wxFULL_REPAINT_ON_RESIZE )
 {
     m_owner = parent;
 }
@@ -3532,7 +3545,7 @@ END_EVENT_TABLE()
 wxGridColLabelWindow::wxGridColLabelWindow( wxGrid *parent,
                                             wxWindowID id,
                                             const wxPoint &pos, const wxSize &size )
-  : wxWindow( parent, id, pos, size, wxWANTS_CHARS|wxBORDER_NONE )
+  : wxWindow( parent, id, pos, size, wxWANTS_CHARS|wxBORDER_NONE|wxFULL_REPAINT_ON_RESIZE )
 {
     m_owner = parent;
 }
@@ -3597,7 +3610,7 @@ END_EVENT_TABLE()
 wxGridCornerLabelWindow::wxGridCornerLabelWindow( wxGrid *parent,
                                                   wxWindowID id,
                                                   const wxPoint &pos, const wxSize &size )
-  : wxWindow( parent, id, pos, size, wxWANTS_CHARS|wxBORDER_NONE )
+  : wxWindow( parent, id, pos, size, wxWANTS_CHARS|wxBORDER_NONE|wxFULL_REPAINT_ON_RESIZE )
 {
     m_owner = parent;
 }
@@ -3669,14 +3682,13 @@ wxGridWindow::wxGridWindow( wxGrid *parent,
                             wxWindowID id,
                             const wxPoint &pos,
                             const wxSize &size )
-            : wxWindow( parent, id, pos, size, wxWANTS_CHARS | wxBORDER_NONE | wxCLIP_CHILDREN,
+            : wxWindow( parent, id, pos, size, wxWANTS_CHARS | wxBORDER_NONE | wxCLIP_CHILDREN|wxFULL_REPAINT_ON_RESIZE,
                         wxT("grid window") )
 
 {
     m_owner = parent;
     m_rowLabelWin = rowLblWin;
     m_colLabelWin = colLblWin;
-    SetBackgroundColour(_T("WHITE"));
 }
 
 
@@ -3799,7 +3811,7 @@ IMPLEMENT_DYNAMIC_CLASS_XTI(wxGrid, wxScrolledWindow,"wx/grid.h")
 
 wxBEGIN_PROPERTIES_TABLE(wxGrid)
     wxHIDE_PROPERTY( Children )
-    wxPROPERTY_FLAGS( WindowStyle , wxGridStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
+    wxPROPERTY_FLAGS( WindowStyle , wxGridStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
 wxEND_PROPERTIES_TABLE()
 
 wxBEGIN_HANDLERS_TABLE(wxGrid)
@@ -3890,6 +3902,14 @@ wxGrid::~wxGrid()
 // ----- internal init and update functions
 //
 
+// NOTE: If using the default visual attributes works everywhere then this can
+// be removed as well as the #else cases below.
+#define _USE_VISATTR 0
+
+#if _USE_VISATTR
+#include "wx/listbox.h"
+#endif
+
 void wxGrid::Create()
 {
     m_created = FALSE;    // set to TRUE by CreateGrid
@@ -3906,13 +3926,22 @@ void wxGrid::Create()
     m_defaultCellAttr->SetKind(wxGridCellAttr::Default);
     m_defaultCellAttr->SetFont(GetFont());
     m_defaultCellAttr->SetAlignment(wxALIGN_LEFT, wxALIGN_TOP);
+    m_defaultCellAttr->SetRenderer(new wxGridCellStringRenderer);
+    m_defaultCellAttr->SetEditor(new wxGridCellTextEditor);
+
+#if _USE_VISATTR
+    wxVisualAttributes gva = wxListBox::GetClassDefaultAttributes();
+    wxVisualAttributes lva = wxPanel::GetClassDefaultAttributes();
+
+    m_defaultCellAttr->SetTextColour(gva.colFg);
+    m_defaultCellAttr->SetBackgroundColour(gva.colBg);
+    
+#else
     m_defaultCellAttr->SetTextColour(
         wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
     m_defaultCellAttr->SetBackgroundColour(
         wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
-    m_defaultCellAttr->SetRenderer(new wxGridCellStringRenderer);
-    m_defaultCellAttr->SetEditor(new wxGridCellTextEditor);
-
+#endif
 
     m_numRows = 0;
     m_numCols = 0;
@@ -3950,6 +3979,27 @@ void wxGrid::Create()
 
     SetTargetWindow( m_gridWin );
 
+#if _USE_VISATTR
+    wxColour gfg = gva.colFg;
+    wxColour gbg = gva.colBg;
+    wxColour lfg = lva.colFg;
+    wxColour lbg = lva.colBg;
+#else
+    wxColour gfg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
+    wxColour gbg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
+    wxColour lfg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
+    wxColour lbg = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
+#endif
+    m_cornerLabelWin->SetDefaultForegroundColour(lfg);
+    m_cornerLabelWin->SetDefaultBackgroundColour(lbg);
+    m_rowLabelWin->SetDefaultForegroundColour(lfg);
+    m_rowLabelWin->SetDefaultBackgroundColour(lbg);
+    m_colLabelWin->SetDefaultForegroundColour(lfg);
+    m_colLabelWin->SetDefaultBackgroundColour(lbg);
+
+    m_gridWin->SetDefaultForegroundColour(gfg);
+    m_gridWin->SetDefaultBackgroundColour(gbg);
+    
     Init();
 }
 
@@ -6267,8 +6317,7 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
                     else
                     {
                         // at the bottom of a column
-                        HideCellEditControl();
-                        SaveEditControlValue();
+                        DisableCellEditControl();
                     }
                 }
                 break;
@@ -6287,8 +6336,7 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
                     else
                     {
                         // at left of grid
-                        HideCellEditControl();
-                        SaveEditControlValue();
+                        DisableCellEditControl();
                     }
                 }
                 else
@@ -6300,8 +6348,7 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
                     else
                     {
                         // at right of grid
-                        HideCellEditControl();
-                        SaveEditControlValue();
+                        DisableCellEditControl();
                     }
                 }
                 break;
@@ -6450,7 +6497,6 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
 
     if ( m_currentCellCoords != wxGridNoCellCoords )
     {
-        HideCellEditControl();
         DisableCellEditControl();
 
         if ( IsVisible( m_currentCellCoords, FALSE ) )
@@ -9511,6 +9557,10 @@ void wxGrid::AutoSizeColOrRow( int colOrRow, bool setAsMin, bool column )
 {
     wxClientDC dc(m_gridWin);
 
+    //Cancel editting of cell
+    HideCellEditControl();
+    SaveEditControlValue();
+
     // init both of them to avoid compiler warnings, even if weo nly need one
     int row = -1,
         col = -1;