]> git.saurik.com Git - wxWidgets.git/commitdiff
Take into account cell's own size, not only the
authorRobert Roebling <robert@roebling.de>
Thu, 23 Mar 2006 19:00:53 +0000 (19:00 +0000)
committerRobert Roebling <robert@roebling.de>
Thu, 23 Mar 2006 19:00:53 +0000 (19:00 +0000)
    space allocated to it (mostly much more).

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

src/generic/datavgen.cpp

index 4317d495d6260aface6c68d198d78823b763952f..ddb1a5bc4edbdbe4bba29a8066b4957c04fccf47 100644 (file)
@@ -706,7 +706,19 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &event )
             wxVariant value;
             model->GetValue( value, col->GetModelColumn(), item );
             cell->SetValue( value );
-            cell->Render( cell_rect, &dc, 0 );
+            wxSize size = cell->GetSize();
+            // cannot be bigger than allocated space
+            size.x = wxMin( size.x, cell_rect.width );
+            size.y = wxMin( size.y, cell_rect.height );
+            // TODO: check for left/right/centre alignment here
+            wxRect item_rect;
+            // for now: centre
+            item_rect.x = cell_rect.x + (cell_rect.width / 2) - (size.x / 2);
+            item_rect.y = cell_rect.y + (cell_rect.height / 2) - (size.y / 2);
+            
+            item_rect.width = size.x;
+            item_rect.height= size.y;
+            cell->Render( item_rect, &dc, 0 );
         }
         
         cell_rect.x += cell_rect.width;