]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/grid.cpp
Added an OS/2 section to the sql defines
[wxWidgets.git] / src / generic / grid.cpp
index b8e9d144ccaab8b0bdfbc68a5324519c79633675..dd097a54f59e34a444ecfca5b9e6ea0ba76fe610 100644 (file)
     #include "wx/dcclient.h"
     #include "wx/settings.h"
     #include "wx/log.h"
     #include "wx/dcclient.h"
     #include "wx/settings.h"
     #include "wx/log.h"
-    #include "wx/sizer.h"
-    #include "wx/layout.h"
 #endif
 
 #endif
 
+#include "wx/textfile.h"
 #include "wx/generic/grid.h"
 
 // ----------------------------------------------------------------------------
 #include "wx/generic/grid.h"
 
 // ----------------------------------------------------------------------------
@@ -320,59 +319,50 @@ void wxGridTableBase::SetAttr(const wxGridCellAttr *attr, int row, int col )
     }
 }
 
     }
 }
 
-// FIXME VZ: these should be wxFAIL_MSG(), not wxLogWarning, they're for the
-//           programmer, not the user!
-
 bool wxGridTableBase::InsertRows( size_t pos, size_t numRows )
 {
 bool wxGridTableBase::InsertRows( size_t pos, size_t numRows )
 {
-    wxLogWarning( wxT("Called grid table class function InsertRows(pos=%d, N=%d)\n"
-                  "but your derived table class does not override this function"),
-                  pos, numRows );
+    wxFAIL_MSG( wxT("Called grid table class function InsertRows\n"
+                    "but your derived table class does not override this function") );
 
     return FALSE;
 }
 
 bool wxGridTableBase::AppendRows( size_t numRows )
 {
 
     return FALSE;
 }
 
 bool wxGridTableBase::AppendRows( size_t numRows )
 {
-    wxLogWarning( wxT("Called grid table class function AppendRows(N=%d)\n"
-                  "but your derived table class does not override this function"),
-                  numRows );
+    wxFAIL_MSG( wxT("Called grid table class function AppendRows\n"
+                    "but your derived table class does not override this function"));
 
     return FALSE;
 }
 
 bool wxGridTableBase::DeleteRows( size_t pos, size_t numRows )
 {
 
     return FALSE;
 }
 
 bool wxGridTableBase::DeleteRows( size_t pos, size_t numRows )
 {
-    wxLogWarning( wxT("Called grid table class function DeleteRows(pos=%d, N=%d)\n"
-                  "but your derived table class does not override this function"),
-                  pos, numRows );
+    wxFAIL_MSG( wxT("Called grid table class function DeleteRows\n"
+                    "but your derived table class does not override this function"));
 
     return FALSE;
 }
 
 bool wxGridTableBase::InsertCols( size_t pos, size_t numCols )
 {
 
     return FALSE;
 }
 
 bool wxGridTableBase::InsertCols( size_t pos, size_t numCols )
 {
-    wxLogWarning( wxT("Called grid table class function InsertCols(pos=%d, N=%d)\n"
-                  "but your derived table class does not override this function"),
-                  pos, numCols );
+    wxFAIL_MSG( wxT("Called grid table class function InsertCols\n"
+                  "but your derived table class does not override this function"));
 
     return FALSE;
 }
 
 bool wxGridTableBase::AppendCols( size_t numCols )
 {
 
     return FALSE;
 }
 
 bool wxGridTableBase::AppendCols( size_t numCols )
 {
-    wxLogWarning( wxT("Called grid table class function AppendCols(N=%d)\n"
-                  "but your derived table class does not override this function"),
-                  numCols );
+    wxFAIL_MSG(wxT("Called grid table class function AppendCols\n"
+                   "but your derived table class does not override this function"));
 
     return FALSE;
 }
 
 bool wxGridTableBase::DeleteCols( size_t pos, size_t numCols )
 {
 
     return FALSE;
 }
 
 bool wxGridTableBase::DeleteCols( size_t pos, size_t numCols )
 {
-    wxLogWarning( wxT("Called grid table class function DeleteCols(pos=%d, N=%d)\n"
-                  "but your derived table class does not override this function"),
-                  pos, numCols );
+    wxFAIL_MSG( wxT("Called grid table class function DeleteCols\n"
+                    "but your derived table class does not override this function"));
 
     return FALSE;
 }
 
     return FALSE;
 }
@@ -612,9 +602,11 @@ bool wxGridStringTable::DeleteRows( size_t pos, size_t numRows )
 
     if ( pos >= curNumRows )
     {
 
     if ( pos >= curNumRows )
     {
-        wxLogError( wxT("Called wxGridStringTable::DeleteRows(pos=%d, N=%d)...\n"
-                    "Pos value is invalid for present table with %d rows"),
-                    pos, numRows, curNumRows );
+        wxString errmsg;
+        errmsg.Printf("Called wxGridStringTable::DeleteRows(pos=%d, N=%d)\n"
+                      "Pos value is invalid for present table with %d rows",
+                      pos, numRows, curNumRows );
+        wxFAIL_MSG( wxT(errmsg) );
         return FALSE;
     }
 
         return FALSE;
     }
 
@@ -690,8 +682,8 @@ bool wxGridStringTable::AppendCols( size_t numCols )
     {
         // TODO: something better than this ?
         //
     {
         // TODO: something better than this ?
         //
-        wxLogError( wxT("Unable to append cols to a grid table with no rows.\n"
-                    "Call AppendRows() first") );
+        wxFAIL_MSG( wxT("Unable to append cols to a grid table with no rows.\n"
+                        "Call AppendRows() first") );
         return FALSE;
     }
 
         return FALSE;
     }
 
@@ -724,9 +716,11 @@ bool wxGridStringTable::DeleteCols( size_t pos, size_t numCols )
 
     if ( pos >= curNumCols )
     {
 
     if ( pos >= curNumCols )
     {
-        wxLogError( wxT("Called wxGridStringTable::DeleteCols(pos=%d, N=%d)...\n"
-                    "Pos value is invalid for present table with %d cols"),
-                    pos, numCols, curNumCols );
+        wxString errmsg;
+        errmsg.Printf( "Called wxGridStringTable::DeleteCols(pos=%d, N=%d)...\n"
+                        "Pos value is invalid for present table with %d cols",
+                        pos, numCols, curNumCols );
+        wxFAIL_MSG( wxT( errmsg ) );
         return FALSE;
     }
 
         return FALSE;
     }
 
@@ -1234,7 +1228,7 @@ bool wxGrid::CreateGrid( int numRows, int numCols )
 {
     if ( m_created )
     {
 {
     if ( m_created )
     {
-        wxLogError( wxT("wxGrid::CreateGrid(numRows, numCols) called more than once") );
+        wxFAIL_MSG( wxT("wxGrid::CreateGrid called more than once") );
         return FALSE;
     }
     else
         return FALSE;
     }
     else
@@ -1714,7 +1708,6 @@ void wxGrid::CalcCellsExposed( wxRegion& reg )
         CalcUnscrolledPosition( r.GetLeft(), r.GetTop(), &left, &top );
         CalcUnscrolledPosition( r.GetRight(), r.GetBottom(), &right, &bottom );
 
         CalcUnscrolledPosition( r.GetLeft(), r.GetTop(), &left, &top );
         CalcUnscrolledPosition( r.GetRight(), r.GetBottom(), &right, &bottom );
 
-       left++; top++;
         // find the cells within these bounds
         //
         int row, col;
         // find the cells within these bounds
         //
         int row, col;
@@ -2331,7 +2324,7 @@ bool wxGrid::InsertRows( int pos, int numRows, bool WXUNUSED(updateLabels) )
 
     if ( !m_created )
     {
 
     if ( !m_created )
     {
-        wxLogError( wxT("Called wxGrid::InsertRows() before calling CreateGrid()") );
+        wxFAIL_MSG( wxT("Called wxGrid::InsertRows() before calling CreateGrid()") );
         return FALSE;
     }
 
         return FALSE;
     }
 
@@ -2381,7 +2374,7 @@ bool wxGrid::AppendRows( int numRows, bool WXUNUSED(updateLabels) )
 
     if ( !m_created )
     {
 
     if ( !m_created )
     {
-        wxLogError( wxT("Called wxGrid::AppendRows() before calling CreateGrid()") );
+        wxFAIL_MSG( wxT("Called wxGrid::AppendRows() before calling CreateGrid()") );
         return FALSE;
     }
 
         return FALSE;
     }
 
@@ -2415,7 +2408,7 @@ bool wxGrid::DeleteRows( int pos, int numRows, bool WXUNUSED(updateLabels) )
 
     if ( !m_created )
     {
 
     if ( !m_created )
     {
-        wxLogError( wxT("Called wxGrid::DeleteRows() before calling CreateGrid()") );
+        wxFAIL_MSG( wxT("Called wxGrid::DeleteRows() before calling CreateGrid()") );
         return FALSE;
     }
 
         return FALSE;
     }
 
@@ -2446,7 +2439,7 @@ bool wxGrid::InsertCols( int pos, int numCols, bool WXUNUSED(updateLabels) )
 
     if ( !m_created )
     {
 
     if ( !m_created )
     {
-        wxLogError( wxT("Called wxGrid::InsertCols() before calling CreateGrid()") );
+        wxFAIL_MSG( wxT("Called wxGrid::InsertCols() before calling CreateGrid()") );
         return FALSE;
     }
 
         return FALSE;
     }
 
@@ -2488,7 +2481,7 @@ bool wxGrid::AppendCols( int numCols, bool WXUNUSED(updateLabels) )
 
     if ( !m_created )
     {
 
     if ( !m_created )
     {
-        wxLogError( wxT("Called wxGrid::AppendCols() before calling CreateGrid()") );
+        wxFAIL_MSG( wxT("Called wxGrid::AppendCols() before calling CreateGrid()") );
         return FALSE;
     }
 
         return FALSE;
     }
 
@@ -2522,7 +2515,7 @@ bool wxGrid::DeleteCols( int pos, int numCols, bool WXUNUSED(updateLabels) )
 
     if ( !m_created )
     {
 
     if ( !m_created )
     {
-        wxLogError( wxT("Called wxGrid::DeleteCols() before calling CreateGrid()") );
+        wxFAIL_MSG( wxT("Called wxGrid::DeleteCols() before calling CreateGrid()") );
         return FALSE;
     }
 
         return FALSE;
     }
 
@@ -2670,7 +2663,7 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
     {
         // shouldn't be here - we are going round in circles...
         //
     {
         // shouldn't be here - we are going round in circles...
         //
-        wxLogFatalError( wxT("wxGrid::OnKeyDown called while alread active") );
+        wxFAIL_MSG( wxT("wxGrid::OnKeyDown called while alread active") );
     }
 
     m_inOnKeyDown = TRUE;
     }
 
     m_inOnKeyDown = TRUE;
@@ -2922,13 +2915,13 @@ void wxGrid::DrawCellBorder( wxDC& dc, const wxGridCellCoords& coords )
 
     // right hand border
     //
 
     // right hand border
     //
-    dc.DrawLine( m_colRights[col]-1, m_rowBottoms[row] - m_rowHeights[row],
-                 m_colRights[col]-1, m_rowBottoms[row]-1 );
+    dc.DrawLine( m_colRights[col], m_rowBottoms[row] - m_rowHeights[row],
+                 m_colRights[col], m_rowBottoms[row] );
 
     // bottom border
     //
 
     // bottom border
     //
-    dc.DrawLine( m_colRights[col] - m_colWidths[col], m_rowBottoms[row]-1,
-                 m_colRights[col]-1, m_rowBottoms[row]-1 );
+    dc.DrawLine( m_colRights[col] - m_colWidths[col], m_rowBottoms[row],
+                 m_colRights[col], m_rowBottoms[row] );
 }
 
 
 }
 
 
@@ -3040,13 +3033,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]-1 > bottom )
+        if ( m_rowBottoms[i] > bottom )
         {
             break;
         }
         {
             break;
         }
-        else if ( m_rowBottoms[i]-1 >= top )
+        else if ( m_rowBottoms[i] >= top )
         {
         {
-            dc.DrawLine( left, m_rowBottoms[i]-1, right, m_rowBottoms[i]-1 );
+            dc.DrawLine( left, m_rowBottoms[i], right, m_rowBottoms[i] );
         }
     }
 
         }
     }
 
@@ -3055,13 +3048,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]-1 > right )
+        if ( m_colRights[i] > right )
         {
             break;
         }
         {
             break;
         }
-        else if ( m_colRights[i]-1 >= left )
+        else if ( m_colRights[i] >= left )
         {
         {
-            dc.DrawLine( m_colRights[i]-1, top, m_colRights[i]-1, bottom );
+            dc.DrawLine( m_colRights[i], top, m_colRights[i], bottom );
         }
     }
 }
         }
     }
 }
@@ -3231,13 +3224,15 @@ void wxGrid::DrawTextRectangle( wxDC& dc,
 //
 void wxGrid::StringToLines( const wxString& value, wxArrayString& lines )
 {
 //
 void wxGrid::StringToLines( const wxString& value, wxArrayString& lines )
 {
-    // TODO: this won't work for WXMAC ? (lines end with '\r')
-    //       => use wxTextFile functions then (VZ)
     int startPos = 0;
     int pos;
     int startPos = 0;
     int pos;
-    while ( startPos < (int)value.Length() )
+    wxTextFile tf;
+    wxString eol =  wxTextFile::GetEOL( wxTextFileType_Unix );
+    wxString tVal = wxTextFile::Translate( value, wxTextFileType_Unix );
+    
+    while ( startPos < (int)tVal.Length() )
     {
     {
-        pos = value.Mid(startPos).Find( '\n' );
+        pos = tVal.Mid(startPos).Find( eol );
         if ( pos < 0 )
         {
             break;
         if ( pos < 0 )
         {
             break;
@@ -3248,14 +3243,7 @@ void wxGrid::StringToLines( const wxString& value, wxArrayString& lines )
         }
         else
         {
         }
         else
         {
-            if ( value[startPos+pos-1] == '\r' )
-            {
-                lines.Add( value.Mid(startPos, pos-1) );
-            }
-            else
-            {
-                lines.Add( value.Mid(startPos, pos) );
-            }
+            lines.Add( value.Mid(startPos, pos) );
         }
         startPos += pos+1;
     }
         }
         startPos += pos+1;
     }
@@ -4376,7 +4364,7 @@ int wxGrid::GetColSize( int col )
 
 wxColour wxGrid::GetDefaultCellBackgroundColour()
 {
 
 wxColour wxGrid::GetDefaultCellBackgroundColour()
 {
-    return GetBackgroundColour();
+    return m_gridWin->GetBackgroundColour();
 }
 
 // TODO VZ: this must be optimized to allow only retrieveing attr once!
 }
 
 // TODO VZ: this must be optimized to allow only retrieveing attr once!
@@ -4398,7 +4386,7 @@ wxColour wxGrid::GetCellBackgroundColour(int row, int col)
 
 wxColour wxGrid::GetDefaultCellTextColour()
 {
 
 wxColour wxGrid::GetDefaultCellTextColour()
 {
-    return GetForegroundColour();
+    return m_gridWin->GetForegroundColour();
 }
 
 wxColour wxGrid::GetCellTextColour( int row, int col )
 }
 
 wxColour wxGrid::GetCellTextColour( int row, int col )
@@ -4541,12 +4529,12 @@ void wxGrid::SetColSize( int col, int width )
 
 void wxGrid::SetDefaultCellBackgroundColour( const wxColour& col )
 {
 
 void wxGrid::SetDefaultCellBackgroundColour( const wxColour& col )
 {
-    SetBackgroundColour(col);
+    m_gridWin->SetBackgroundColour(col);
 }
 
 void wxGrid::SetDefaultCellTextColour( const wxColour& col )
 {
 }
 
 void wxGrid::SetDefaultCellTextColour( const wxColour& col )
 {
-    SetForegroundColour(col);
+    m_gridWin->SetForegroundColour(col);
 }
 
 void wxGrid::SetDefaultCellAlignment( int horiz, int vert )
 }
 
 void wxGrid::SetDefaultCellAlignment( int horiz, int vert )