]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/gridctrl.cpp
Added help button
[wxWidgets.git] / src / generic / gridctrl.cpp
index 3098fd5ad597c4a6e4f46c2c26108290a694879a..e4d2608d211e2376ef06a44c2e7aaf0bf7e14578 100644 (file)
@@ -24,7 +24,7 @@
     #include "wx/textctrl.h"
     #include "wx/dc.h"
     #include "wx/combobox.h"
-       #include "wx/settings.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
 // ----------------------------------------------------------------------------
@@ -158,7 +198,7 @@ wxString wxGridCellEnumRenderer::GetString(const wxGrid& grid, int row, int col)
     if ( table->CanGetValueAs(row, col, wxGRID_VALUE_NUMBER) )
     {
         int choiceno = table->GetValueAsLong(row, col);
-        text.Printf(_T("%s"), m_choices[ choiceno ].c_str() );
+        text.Printf(wxT("%s"), m_choices[ choiceno ].c_str() );
     }
     else
     {
@@ -210,7 +250,7 @@ void wxGridCellEnumRenderer::SetParameters(const wxString& params)
 
     m_choices.Empty();
 
-    wxStringTokenizer tk(params, _T(','));
+    wxStringTokenizer tk(params, wxT(','));
     while ( tk.HasMoreTokens() )
     {
         m_choices.Add(tk.GetNextToken());
@@ -265,7 +305,7 @@ wxGridCellAutoWrapStringRenderer::GetTextLines(wxGrid& grid,
     wxCoord max_x = rect.GetWidth();
 
     dc.SetFont(attr.GetFont());
-    wxStringTokenizer tk(data , _T(" \n\t\r"));
+    wxStringTokenizer tk(data , wxT(" \n\t\r"));
     wxString thisline = wxEmptyString;
 
     while ( tk.HasMoreTokens() )
@@ -275,7 +315,7 @@ wxGridCellAutoWrapStringRenderer::GetTextLines(wxGrid& grid,
         //       space at the end of the line. But it
         //       is invisible , simplifies the size calculation
         //       and ensures tokens are separated in the display
-        tok += _T(" ");
+        tok += wxT(" ");
 
         dc.GetTextExtent(tok, &x, &y);
         if ( curr_x + x > max_x)
@@ -338,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
 // ----------------------------------------------------------------------------
@@ -390,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 )
         {
@@ -423,7 +425,7 @@ wxSize wxGridCellStringRenderer::DoGetBestSize(const wxGridCellAttr& attr,
 {
     wxCoord x = 0, y = 0, max_x = 0;
     dc.SetFont(attr.GetFont());
-    wxStringTokenizer tk(text, _T('\n'));
+    wxStringTokenizer tk(text, wxT('\n'));
     while ( tk.HasMoreTokens() )
     {
         dc.GetTextExtent(tk.GetNextToken(), &x, &y);
@@ -552,7 +554,7 @@ wxString wxGridCellNumberRenderer::GetString(const wxGrid& grid, int row, int co
     wxString text;
     if ( table->CanGetValueAs(row, col, wxGRID_VALUE_NUMBER) )
     {
-        text.Printf(_T("%ld"), table->GetValueAsLong(row, col));
+        text.Printf(wxT("%ld"), table->GetValueAsLong(row, col));
     }
     else
     {
@@ -639,21 +641,21 @@ wxString wxGridCellFloatRenderer::GetString(const wxGrid& grid, int row, int col
                 if ( m_precision == -1 )
                 {
                     // default width/precision
-                    m_format = _T("%f");
+                    m_format = wxT("%f");
                 }
                 else
                 {
-                    m_format.Printf(_T("%%.%df"), m_precision);
+                    m_format.Printf(wxT("%%.%df"), m_precision);
                 }
             }
             else if ( m_precision == -1 )
             {
                 // default precision
-                m_format.Printf(_T("%%%d.f"), m_width);
+                m_format.Printf(wxT("%%%d.f"), m_width);
             }
             else
             {
-                m_format.Printf(_T("%%%d.%df"), m_width, m_precision);
+                m_format.Printf(wxT("%%%d.%df"), m_width, m_precision);
             }
         }
 
@@ -705,7 +707,7 @@ void wxGridCellFloatRenderer::SetParameters(const wxString& params)
     }
     else
     {
-        wxString tmp = params.BeforeFirst(_T(','));
+        wxString tmp = params.BeforeFirst(wxT(','));
         if ( !tmp.empty() )
         {
             long width;
@@ -715,11 +717,11 @@ void wxGridCellFloatRenderer::SetParameters(const wxString& params)
             }
             else
             {
-                wxLogDebug(_T("Invalid wxGridCellFloatRenderer width parameter string '%s ignored"), params.c_str());
+                wxLogDebug(wxT("Invalid wxGridCellFloatRenderer width parameter string '%s ignored"), params.c_str());
             }
         }
 
-        tmp = params.AfterFirst(_T(','));
+        tmp = params.AfterFirst(wxT(','));
         if ( !tmp.empty() )
         {
             long precision;
@@ -729,7 +731,7 @@ void wxGridCellFloatRenderer::SetParameters(const wxString& params)
             }
             else
             {
-                wxLogDebug(_T("Invalid wxGridCellFloatRenderer precision parameter string '%s ignored"), params.c_str());
+                wxLogDebug(wxT("Invalid wxGridCellFloatRenderer precision parameter string '%s ignored"), params.c_str());
             }
         }
     }
@@ -741,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),
@@ -755,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;