]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/grid.cpp
cursor event support for mac activated
[wxWidgets.git] / src / generic / grid.cpp
index af23eb352bd6d3099da8f1a262e4a244d2180db6..f60e2bced655fa141799fc2421fa8d87f5b66099 100644 (file)
 
 #if wxUSE_GRID
 
-#if !defined(wxUSE_NEW_GRID) || !(wxUSE_NEW_GRID)
-    #include "gridg.cpp"
-#else // wxUSE_NEW_GRID
-
 #ifndef WX_PRECOMP
     #include "wx/utils.h"
     #include "wx/dcclient.h"
@@ -5410,15 +5406,15 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
     {
         if ( m_cursorMode == WXGRID_CURSOR_SELECT_CELL )
         {
+            if (m_winCapture)
+            {
+                if (m_winCapture->HasCapture()) m_winCapture->ReleaseMouse();
+                m_winCapture = NULL;
+            }
+
             if ( m_selectingTopLeft != wxGridNoCellCoords &&
                  m_selectingBottomRight != wxGridNoCellCoords )
             {
-                if (m_winCapture)
-                {
-                    if (m_winCapture->HasCapture()) m_winCapture->ReleaseMouse();
-                    m_winCapture = NULL;
-                }
-
                 if ( m_selection )
                 {
                     m_selection->SelectBlock( m_selectingTopLeft.GetRow(),
@@ -7102,110 +7098,110 @@ void wxGrid::DrawTextRectangle( wxDC& dc,
                                 int textOrientation )
 {
     wxArrayString lines;
-
+    
     StringToLines( value, lines );
-
-
+    
+    
     //Forward to new API.
     DrawTextRectangle(  dc,
-                        lines,
-                        rect,
-                        horizAlign,
-                        vertAlign,
-                        textOrientation );
-
+        lines,
+        rect,
+        horizAlign,
+        vertAlign,
+        textOrientation );
+    
 }
 
 void wxGrid::DrawTextRectangle( wxDC& dc,
-                                const wxArrayString& lines,
-                                const wxRect& rect,
-                                int horizAlign,
-                                int vertAlign,
-                                int textOrientation )
+                               const wxArrayString& lines,
+                               const wxRect& rect,
+                               int horizAlign,
+                               int vertAlign,
+                               int textOrientation )
 {
     long textWidth, textHeight;
     long lineWidth, lineHeight;
     int nLines;
-
+    
     dc.SetClippingRegion( rect );
-
+    
     nLines = lines.GetCount();
     if( nLines > 0 )
     {
-      int l;
-      float x, y;
-
-      if( textOrientation == wxHORIZONTAL )
-      GetTextBoxSize(dc, lines, &textWidth, &textHeight);
-      else
-         GetTextBoxSize( dc, lines, &textHeight, &textWidth );
-
-      switch( vertAlign )
-      {
+        int l;
+        float x = 0.0, y = 0.0;
+        
+        if( textOrientation == wxHORIZONTAL )
+            GetTextBoxSize(dc, lines, &textWidth, &textHeight);
+        else
+            GetTextBoxSize( dc, lines, &textHeight, &textWidth );
+        
+        switch( vertAlign )
+        {
         case wxALIGN_BOTTOM:
             if( textOrientation == wxHORIZONTAL )
-          y = rect.y + (rect.height - textHeight - 1);
+                y = rect.y + (rect.height - textHeight - 1);
             else
-               x = rect.x + rect.width - textWidth;
-          break;
-
+                x = rect.x + rect.width - textWidth;
+            break;
+            
         case wxALIGN_CENTRE:
             if( textOrientation == wxHORIZONTAL )
-          y = rect.y + ((rect.height - textHeight)/2);
+                y = rect.y + ((rect.height - textHeight)/2);
             else
-               x = rect.x + ((rect.width - textWidth)/2);
-          break;
-
+                x = rect.x + ((rect.width - textWidth)/2);
+            break;
+            
         case wxALIGN_TOP:
         default:
             if( textOrientation == wxHORIZONTAL )
-          y = rect.y + 1;
+                y = rect.y + 1;
             else
-               x = rect.x + 1;
-          break;
-      }
-
-      // Align each line of a multi-line label
-      for( l = 0; l < nLines; l++ )
-      {
-        dc.GetTextExtent(lines[l], &lineWidth, &lineHeight);
-
-        switch( horizAlign )
-        {
-          case wxALIGN_RIGHT:
-               if( textOrientation == wxHORIZONTAL )
-            x = rect.x + (rect.width - lineWidth - 1);
-               else
-                  y = rect.y + lineWidth + 1;
-            break;
-
-          case wxALIGN_CENTRE:
-               if( textOrientation == wxHORIZONTAL )
-            x = rect.x + ((rect.width - lineWidth)/2);
-               else
-                  y = rect.y + rect.height - ((rect.height - lineWidth)/2);
-            break;
-
-          case wxALIGN_LEFT:
-          default:
-               if( textOrientation == wxHORIZONTAL )
-            x = rect.x + 1;
-               else
-                  y = rect.y + rect.height - 1;
+                x = rect.x + 1;
             break;
         }
-
-         if( textOrientation == wxHORIZONTAL )
-         {
-        dc.DrawText( lines[l], (int)x, (int)y );
-        y += lineHeight;
-      }
-         else
-         {
-            dc.DrawRotatedText( lines[l], (int)x, (int)y, 90.0 );
-            x += lineHeight;
-         }
-      }
+        
+        // Align each line of a multi-line label
+        for( l = 0; l < nLines; l++ )
+        {
+            dc.GetTextExtent(lines[l], &lineWidth, &lineHeight);
+            
+            switch( horizAlign )
+            {
+            case wxALIGN_RIGHT:
+                if( textOrientation == wxHORIZONTAL )
+                    x = rect.x + (rect.width - lineWidth - 1);
+                else
+                    y = rect.y + lineWidth + 1;
+                break;
+                
+            case wxALIGN_CENTRE:
+                if( textOrientation == wxHORIZONTAL )
+                    x = rect.x + ((rect.width - lineWidth)/2);
+                else
+                    y = rect.y + rect.height - ((rect.height - lineWidth)/2);
+                break;
+                
+            case wxALIGN_LEFT:
+            default:
+                if( textOrientation == wxHORIZONTAL )
+                    x = rect.x + 1;
+                else
+                    y = rect.y + rect.height - 1;
+                break;
+            }
+            
+            if( textOrientation == wxHORIZONTAL )
+            {
+                dc.DrawText( lines[l], (int)x, (int)y );
+                y += lineHeight;
+            }
+            else
+            {
+                dc.DrawRotatedText( lines[l], (int)x, (int)y, 90.0 );
+                x += lineHeight;
+            }
+        }
     }
     dc.DestroyClippingRegion();
 }
@@ -8002,7 +7998,7 @@ bool wxGrid::MovePageUp()
 
         int y = GetRowTop(row);
         int newRow = YToRow( y - ch + 1 );
-        if ( newRow == -1 )
+        if ( newRow < 0 )
         {
             newRow = 0;
         }
@@ -10031,7 +10027,5 @@ wxGridEditorCreatedEvent::wxGridEditorCreatedEvent(int id, wxEventType type,
     m_ctrl = ctrl;
 }
 
-
-#endif // !wxUSE_NEW_GRID/wxUSE_NEW_GRID
-
 #endif // wxUSE_GRID
+