]> git.saurik.com Git - wxWidgets.git/commitdiff
Add wxGrid::RefreshAttr() method to force attribute refresh.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 30 Aug 2010 22:18:52 +0000 (22:18 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 30 Aug 2010 22:18:52 +0000 (22:18 +0000)
A cached attribute may continue to be used even though the attribute returned
by a custom wxGridCellAttrProvider has changed so add a method to force wxGrid
to update the attribute by forgetting the cached copy.

Closes #12406.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65451 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/generic/grid.h
interface/wx/grid.h
src/generic/grid.cpp

index b42e57e7cae65634c0a04e26ee4e2492f70df65d..e02f4848e1978efde674d53ebfff3a3c1a8a507e 100644 (file)
@@ -1268,6 +1268,12 @@ public:
     void     SetRowAttr(int row, wxGridCellAttr *attr);
     void     SetColAttr(int col, wxGridCellAttr *attr);
 
+    // the grid can cache attributes for the recently used cells (currently it
+    // only caches one attribute for the most recently used one) and might
+    // notice that its value in the attribute provider has changed -- if this
+    // happens, call this function to force it
+    void RefreshAttr(int row, int col);
+
     // returns the attribute we may modify in place: a new one if this cell
     // doesn't have any yet or the existing one if it does
     //
index 7e8c2584beb92a3c3a834c2d1017bfb7c6de7ac7..6203daa4db98ef58ef32e5f74661b45ebe4fa0b0 100644 (file)
@@ -3846,6 +3846,31 @@ public:
     */
     bool InsertRows(int pos = 0, int numRows = 1, bool updateLabels = true);
 
+    /**
+        Invalidates the cached attribute for the given cell.
+
+        For efficiency reasons, wxGrid may cache the recently used attributes
+        (currently it caches only the single most recently used one, in fact)
+        which can result in the cell appearance not being refreshed even when
+        the attribute returned by your custom wxGridCellAttrProvider-derived
+        class has changed. To force the grid to refresh the cell attribute,
+        this function may be used. Notice that calling it will not result in
+        actually redrawing the cell, you still need to call
+        wxWindow::RefreshRect() to invalidate the area occupied by the cell in
+        the window to do this. Also note that you don't need to call this
+        function if you store the attributes in wxGrid itself, i.e. use its
+        SetAttr() and similar methods, it is only useful when using a separate
+        custom attributes provider.
+
+        @param row
+            The row of the cell whose attribute needs to be queried again.
+        @param col
+            The column of the cell whose attribute needs to be queried again.
+
+        @since 2.9.2
+     */
+    void RefreshAttr(int row, int col);
+
     /**
         Sets the cell attributes for all cells in the specified column.
 
index 34f232f3bdfb6c0ca6313677237497970c32222b..a05a2d519ac37234b4ad0b512c4de1d793bd054e 100644 (file)
@@ -7259,6 +7259,13 @@ void wxGrid::ClearAttrCache()
     }
 }
 
+void wxGrid::RefreshAttr(int row, int col)
+{
+    if ( m_attrCache.row == row && m_attrCache.col == col )
+        ClearAttrCache();
+}
+
+
 void wxGrid::CacheAttr(int row, int col, wxGridCellAttr *attr) const
 {
     if ( attr != NULL )