]> git.saurik.com Git - wxWidgets.git/commitdiff
Clarify wxButton::AdjustForBitmapSize() semantics in wxMSW.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 14 Feb 2011 22:11:58 +0000 (22:11 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 14 Feb 2011 22:11:58 +0000 (22:11 +0000)
This method should only be called if we do have an image, assert (instead of
silently returning) if it's called when we don't.

Also explain in a comment why do we need to call CacheBestSize() only when we
have an image in DoGetBestSize().

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

include/wx/msw/button.h
src/msw/button.cpp

index 1f5ad27c9b72329db5da84eb9c1e1e44d989314f..ee1d197e9dadd5a2d58b89f7fa554c16489c4635 100644 (file)
@@ -88,8 +88,10 @@ protected:
     virtual void DoSetBitmapMargins(wxCoord x, wxCoord y);
     virtual void DoSetBitmapPosition(wxDirection dir);
 
-    // Increases the passed in size if necessary to account for the
-    // button image, if any
+    // Increases the passed in size to account for the button image.
+    //
+    // Should only be called if we do have a button, i.e. if m_imageData is
+    // non-NULL.
     void AdjustForBitmapSize(wxSize& size) const;
 
     class wxButtonImageData *m_imageData;
index 240e2e981327807505acdd3a142dd1fa794f1acb..cabac36506e4f5eced5343d87d9c8e82fdba61b6 100644 (file)
@@ -531,8 +531,7 @@ void wxButton::SetLabel(const wxString& label)
 
 void wxButton::AdjustForBitmapSize(wxSize &size) const
 {
-    if ( !m_imageData )
-        return;
+    wxCHECK_RET( m_imageData, wxT("shouldn't be called if no image") );
 
     // account for the bitmap size
     const wxSize sizeBmp = m_imageData->GetBitmap(State_Normal).GetSize();
@@ -614,6 +613,8 @@ wxSize wxButton::DoGetBestSize() const
     {
         AdjustForBitmapSize(size);
 
+        // The best size has changed so even if it had been already cached by
+        // ComputeBestSize() call above we still need to update it.
         CacheBestSize(size);
     }