X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/29efc6e4a478652d6f59fb3f5ca7990d78a8ead4..9b49405777342458dc1666001865eef7309b6c30:/src/generic/gridctrl.cpp diff --git a/src/generic/gridctrl.cpp b/src/generic/gridctrl.cpp index d1df91d099..54a79a9b0d 100644 --- a/src/generic/gridctrl.cpp +++ b/src/generic/gridctrl.cpp @@ -24,11 +24,54 @@ #include "wx/textctrl.h" #include "wx/dc.h" #include "wx/combobox.h" + #include "wx/settings.h" + #include "wx/log.h" + #include "wx/checkbox.h" #endif // WX_PRECOMP #include "wx/tokenzr.h" #include "wx/renderer.h" + +// ---------------------------------------------------------------------------- +// wxGridCellRenderer +// ---------------------------------------------------------------------------- + +void wxGridCellRenderer::Draw(wxGrid& grid, + wxGridCellAttr& attr, + wxDC& dc, + const wxRect& rect, + int WXUNUSED(row), int WXUNUSED(col), + bool isSelected) +{ + dc.SetBackgroundMode( wxBRUSHSTYLE_SOLID ); + + wxColour clr; + if ( grid.IsThisEnabled() ) + { + if ( isSelected ) + { + if ( grid.HasFocus() ) + clr = grid.GetSelectionBackground(); + else + clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW); + } + else + { + clr = attr.GetBackgroundColour(); + } + } + else // grey out fields if the grid is disabled + { + clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE); + } + + dc.SetBrush(clr); + dc.SetPen( *wxTRANSPARENT_PEN ); + dc.DrawRectangle(rect); +} + + // ---------------------------------------------------------------------------- // wxGridCellDateTimeRenderer // ---------------------------------------------------------------------------- @@ -277,9 +320,19 @@ wxGridCellAutoWrapStringRenderer::GetTextLines(wxGrid& grid, dc.GetTextExtent(tok, &x, &y); if ( curr_x + x > max_x) { - lines.Add( wxString(thisline) ); - thisline = tok; - curr_x=x; + if ( curr_x == 0 ) + { + // this means that a single token is wider than the maximal + // width -- still use it as is as we need to show at least the + // part of it which fits + lines.Add(tok); + } + else + { + lines.Add(thisline); + thisline = tok; + curr_x = x; + } } else { @@ -325,44 +378,6 @@ wxGridCellAutoWrapStringRenderer::GetBestSize(wxGrid& grid, } -// ---------------------------------------------------------------------------- -// wxGridCellRenderer -// ---------------------------------------------------------------------------- - -void wxGridCellRenderer::Draw(wxGrid& grid, - wxGridCellAttr& attr, - wxDC& dc, - const wxRect& rect, - int WXUNUSED(row), int WXUNUSED(col), - bool isSelected) -{ - dc.SetBackgroundMode( wxBRUSHSTYLE_SOLID ); - - wxColour clr; - if ( grid.IsEnabled() ) - { - if ( isSelected ) - { - if ( grid.HasFocus() ) - clr = grid.GetSelectionBackground(); - else - clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW); - } - else - { - clr = attr.GetBackgroundColour(); - } - } - else // grey out fields if the grid is disabled - { - clr = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE); - } - - dc.SetBrush(clr); - dc.SetPen( *wxTRANSPARENT_PEN ); - dc.DrawRectangle(rect); -} - // ---------------------------------------------------------------------------- // wxGridCellStringRenderer // ---------------------------------------------------------------------------- @@ -377,7 +392,7 @@ void wxGridCellStringRenderer::SetTextColoursAndFont(const wxGrid& grid, // TODO some special colours for attr.IsReadOnly() case? // different coloured text when the grid is disabled - if ( grid.IsEnabled() ) + if ( grid.IsThisEnabled() ) { if ( isSelected ) { @@ -728,11 +743,6 @@ void wxGridCellFloatRenderer::SetParameters(const wxString& params) wxSize wxGridCellBoolRenderer::ms_sizeCheckMark; -// FIXME these checkbox size calculations are really ugly... - -// between checkmark and box -static const wxCoord wxGRID_CHECKMARK_MARGIN = 2; - wxSize wxGridCellBoolRenderer::GetBestSize(wxGrid& grid, wxGridCellAttr& WXUNUSED(attr), wxDC& WXUNUSED(dc), @@ -742,18 +752,7 @@ wxSize wxGridCellBoolRenderer::GetBestSize(wxGrid& grid, // compute it only once (no locks for MT safeness in GUI thread...) if ( !ms_sizeCheckMark.x ) { - // get checkbox size - wxCheckBox *checkbox = new wxCheckBox(&grid, wxID_ANY, wxEmptyString); - wxSize size = checkbox->GetBestSize(); - wxCoord checkSize = size.y + 2 * wxGRID_CHECKMARK_MARGIN; - -#if defined(__WXMOTIF__) - checkSize -= size.y / 2; -#endif - - delete checkbox; - - ms_sizeCheckMark.x = ms_sizeCheckMark.y = checkSize; + ms_sizeCheckMark = wxRendererNative::Get().GetCheckBoxSize(&grid); } return ms_sizeCheckMark;