]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/grid.cpp
Comment out direction aware code for now.
[wxWidgets.git] / src / generic / grid.cpp
index 698a97d8c8038dff10121cb632c499386a4a53a5..6d791ab4809f9acf6a6a85d231284f33a33b90e6 100644 (file)
@@ -1192,27 +1192,30 @@ bool wxGridCellFloatEditor::IsAcceptedKey(wxKeyEvent& event)
 {
     if ( wxGridCellEditor::IsAcceptedKey(event) )
     {
-        int keycode = event.GetKeyCode();
-        printf("%d\n", keycode);
-        // accept digits, 'e' as in '1e+6', also '-', '+', and '.'
-        char tmpbuf[2];
-        tmpbuf[0] = (char) keycode;
-        tmpbuf[1] = '\0';
-        wxString strbuf(tmpbuf, *wxConvCurrent);
+        const int keycode = event.GetKeyCode();
+        if ( isascii(keycode) )
+        {
+            char tmpbuf[2];
+            tmpbuf[0] = (char) keycode;
+            tmpbuf[1] = '\0';
+            wxString strbuf(tmpbuf, *wxConvCurrent);
 
 #if wxUSE_INTL
-        bool is_decimal_point =
-            ( strbuf == wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT,
-                                          wxLOCALE_CAT_NUMBER) );
+            const wxString decimalPoint =
+                wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER);
 #else
-        bool is_decimal_point = ( strbuf == _T(".") );
+            const wxString decimalPoint(_T('.'));
 #endif
 
-        if ( (keycode < 128) &&
-             (wxIsdigit(keycode) || tolower(keycode) == 'e' ||
-              is_decimal_point || keycode == '+' || keycode == '-') )
-        {
-            return true;
+            // accept digits, 'e' as in '1e+6', also '-', '+', and '.'
+            if ( wxIsdigit(keycode) ||
+                    tolower(keycode) == 'e' ||
+                        keycode == decimalPoint ||
+                            keycode == '+' ||
+                                keycode == '-' )
+            {
+                return true;
+            }
         }
     }
 
@@ -6618,6 +6621,32 @@ int wxGrid::SendEvent( const wxEventType type,
        claimed = GetEventHandler()->ProcessEvent(gridEvt);
        vetoed = !gridEvt.IsAllowed();
    }
+   else if ( type == wxEVT_GRID_LABEL_LEFT_CLICK ||
+             type == wxEVT_GRID_LABEL_LEFT_DCLICK ||
+             type == wxEVT_GRID_LABEL_RIGHT_CLICK ||
+             type == wxEVT_GRID_LABEL_RIGHT_DCLICK )
+   {
+       wxPoint pos = mouseEv.GetPosition();
+
+       if ( mouseEv.GetEventObject() == GetGridRowLabelWindow() )
+           pos.y += GetColLabelSize();
+       if ( mouseEv.GetEventObject() == GetGridColLabelWindow() )
+           pos.x += GetRowLabelSize();
+       
+       wxGridEvent gridEvt( GetId(),
+               type,
+               this,
+               row, col,
+               pos.x,
+               pos.y,
+               false,
+               mouseEv.ControlDown(),
+               mouseEv.ShiftDown(),
+               mouseEv.AltDown(),
+               mouseEv.MetaDown() );
+       claimed = GetEventHandler()->ProcessEvent(gridEvt);
+       vetoed = !gridEvt.IsAllowed();
+   }
    else
    {
        wxGridEvent gridEvt( GetId(),
@@ -7507,6 +7536,21 @@ void wxGrid::DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr )
 #endif
 }
 
+wxPen wxGrid::GetDefaultGridLinePen()
+{
+    return wxPen(GetGridLineColour(), 1, wxSOLID);
+}
+
+wxPen wxGrid::GetRowGridLinePen(int WXUNUSED(row))
+{
+    return GetDefaultGridLinePen();
+}
+
+wxPen wxGrid::GetColGridLinePen(int WXUNUSED(col))
+{
+    return GetDefaultGridLinePen();
+}
+
 void wxGrid::DrawCellBorder( wxDC& dc, const wxGridCellCoords& coords )
 {
     int row = coords.GetRow();
@@ -7514,15 +7558,16 @@ void wxGrid::DrawCellBorder( wxDC& dc, const wxGridCellCoords& coords )
     if ( GetColWidth(col) <= 0 || GetRowHeight(row) <= 0 )
         return;
 
-    dc.SetPen( wxPen(GetGridLineColour(), 1, wxSOLID) );
 
     wxRect rect = CellToRect( row, col );
 
     // right hand border
+    dc.SetPen( GetColGridLinePen(col) );
     dc.DrawLine( rect.x + rect.width, rect.y,
                  rect.x + rect.width, rect.y + rect.height + 1 );
 
     // bottom border
+    dc.SetPen( GetRowGridLinePen(row) );
     dc.DrawLine( rect.x, rect.y + rect.height,
                  rect.x + rect.width, rect.y + rect.height);
 }
@@ -7667,7 +7712,6 @@ void wxGrid::DrawAllGridLines( wxDC& dc, const wxRegion & WXUNUSED(reg) )
 
     dc.SetClippingRegion( clippedcells );
 
-    dc.SetPen( wxPen(GetGridLineColour(), 1, wxSOLID) );
 
     // horizontal grid lines
     //
@@ -7683,6 +7727,7 @@ void wxGrid::DrawAllGridLines( wxDC& dc, const wxRegion & WXUNUSED(reg) )
 
         if ( bot >= top )
         {
+            dc.SetPen( GetRowGridLinePen(i) );
             dc.DrawLine( left, bot, right, bot );
         }
     }
@@ -7702,6 +7747,7 @@ void wxGrid::DrawAllGridLines( wxDC& dc, const wxRegion & WXUNUSED(reg) )
 
         if ( colRight >= left )
         {
+            dc.SetPen( GetColGridLinePen(i) );
             dc.DrawLine( colRight, top, colRight, bottom );
         }
     }