From: Michael Bedward Date: Thu, 10 Feb 2000 03:50:51 +0000 (+0000) Subject: Added wxTextFile functions to make multi-line text formatting portable. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/2433bb2ed1168c422f6c9ea82b2f7744f18cb1f6 Added wxTextFile functions to make multi-line text formatting portable. Fixed cell background colour problem. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5942 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 5645963f3b..d739372196 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -31,8 +31,7 @@ #include "wx/dcclient.h" #include "wx/settings.h" #include "wx/log.h" - #include "wx/sizer.h" - #include "wx/layout.h" + #include "wx/textfile.h" #endif #include "wx/generic/grid.h" @@ -3225,13 +3224,14 @@ void wxGrid::DrawTextRectangle( wxDC& dc, // 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; - while ( startPos < (int)value.Length() ) + 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; @@ -3242,14 +3242,7 @@ void wxGrid::StringToLines( const wxString& value, wxArrayString& lines ) } 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; } @@ -4370,7 +4363,7 @@ int wxGrid::GetColSize( int col ) wxColour wxGrid::GetDefaultCellBackgroundColour() { - return GetBackgroundColour(); + return m_gridWin->GetBackgroundColour(); } // TODO VZ: this must be optimized to allow only retrieveing attr once! @@ -4392,7 +4385,7 @@ wxColour wxGrid::GetCellBackgroundColour(int row, int col) wxColour wxGrid::GetDefaultCellTextColour() { - return GetForegroundColour(); + return m_gridWin->GetForegroundColour(); } wxColour wxGrid::GetCellTextColour( int row, int col ) @@ -4535,12 +4528,12 @@ void wxGrid::SetColSize( int col, int width ) void wxGrid::SetDefaultCellBackgroundColour( const wxColour& col ) { - SetBackgroundColour(col); + m_gridWin->SetBackgroundColour(col); } void wxGrid::SetDefaultCellTextColour( const wxColour& col ) { - SetForegroundColour(col); + m_gridWin->SetForegroundColour(col); } void wxGrid::SetDefaultCellAlignment( int horiz, int vert )