Implement wxBitmapButton::DoGetBestSize

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26239 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-03-16 22:17:07 +00:00
parent c046274e38
commit c0831a3c31
4 changed files with 69 additions and 10 deletions

View File

@@ -278,6 +278,34 @@ Checking in src/msw/tbar95.cpp;
new revision: 1.121; previous revision: 1.120
done
38. Implement wxBitmapButton::DoGetBestSize
Checking in include/wx/gtk/bmpbuttn.h;
/pack/cvsroots/wxwidgets/wxWidgets/include/wx/gtk/bmpbuttn.h,v <-- bmpbuttn.h
new revision: 1.24; previous revision: 1.23
done
Checking in src/gtk/bmpbuttn.cpp;
/pack/cvsroots/wxwidgets/wxWidgets/src/gtk/bmpbuttn.cpp,v <-- bmpbuttn.cpp
new revision: 1.46; previous revision: 1.45
done
Checking in include/wx/msw/bmpbuttn.h;
/pack/cvsroots/wxwidgets/wxWidgets/include/wx/msw/bmpbuttn.h,v <-- bmpbuttn.h
new revision: 1.12; previous revision: 1.11
done
Checking in src/msw/bmpbuttn.cpp;
/pack/cvsroots/wxwidgets/wxWidgets/src/msw/bmpbuttn.cpp,v <-- bmpbuttn.cpp
new revision: 1.45; previous revision: 1.44
done
Checking in include/wx/mac/bmpbuttn.h;
/pack/cvsroots/wxwidgets/wxWidgets/include/wx/mac/bmpbuttn.h,v <-- bmpbuttn.h
new revision: 1.10; previous revision: 1.9
done
Checking in src/mac/bmpbuttn.cpp;
/pack/cvsroots/wxwidgets/wxWidgets/src/mac/bmpbuttn.cpp,v <-- bmpbuttn.cpp
new revision: 1.26; previous revision: 1.25
done
=======

View File

@@ -56,6 +56,9 @@ public:
virtual void DrawButtonFocus( WXHDC dc, int left, int top, int right, int bottom, bool sel );
virtual void DrawButtonDisable( WXHDC dc, int left, int top, int right, int bottom, bool with_marg );
*/
protected:
virtual wxSize DoGetBestSize() const;
};
#endif

View File

@@ -51,11 +51,14 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
int width = size.x;
int height = size.y;
if ( width == -1 && bitmap.Ok())
width = bitmap.GetWidth() + 2*m_marginX;
if ( height == -1 && bitmap.Ok())
height = bitmap.GetHeight() + 2*m_marginY;
if ( bitmap.Ok() )
{
wxSize newSize = DoGetBestSize();
if ( width == -1 )
width = newSize.x;
if ( height == -1 )
height = newSize.y;
}
Rect bounds ;
Str255 title ;
@@ -97,3 +100,14 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
}
}
wxSize wxBitmapButton::DoGetBestSize() const
{
wxSize best;
if (m_bmpNormal.Ok())
{
best.x = m_bmpNormal.GetWidth() + 2*m_marginX;
best.y = m_bmpNormal.GetHeight() + 2*m_marginY;
}
return best;
}

View File

@@ -51,11 +51,14 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
int width = size.x;
int height = size.y;
if ( width == -1 && bitmap.Ok())
width = bitmap.GetWidth() + 2*m_marginX;
if ( height == -1 && bitmap.Ok())
height = bitmap.GetHeight() + 2*m_marginY;
if ( bitmap.Ok() )
{
wxSize newSize = DoGetBestSize();
if ( width == -1 )
width = newSize.x;
if ( height == -1 )
height = newSize.y;
}
Rect bounds ;
Str255 title ;
@@ -97,3 +100,14 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
}
}
wxSize wxBitmapButton::DoGetBestSize() const
{
wxSize best;
if (m_bmpNormal.Ok())
{
best.x = m_bmpNormal.GetWidth() + 2*m_marginX;
best.y = m_bmpNormal.GetHeight() + 2*m_marginY;
}
return best;
}