#include "wx/dcscreen.h"
#include "wx/dcclient.h"
#include "wx/toplevel.h"
+ #include "wx/msw/wrapcctl.h"
+ #include "wx/msw/private.h"
+ #include "wx/msw/missing.h"
#endif
#include "wx/imaglist.h"
#include "wx/stockitem.h"
-#include "wx/msw/private.h"
#include "wx/msw/private/button.h"
#include "wx/msw/private/dc.h"
#include "wx/private/window.h"
-#include "wx/msw/missing.h"
using namespace wxMSWImpl;
m_data.himl = GetHimagelistOf(&m_iml);
- // use default margins
+ // no margins by default
m_data.margin.left =
- m_data.margin.right = btn->GetCharWidth();
+ m_data.margin.right =
m_data.margin.top =
- m_data.margin.bottom = btn->GetCharHeight() / 2;
+ m_data.margin.bottom = 0;
- // and default alignment
+ // use default alignment
m_data.uAlign = BUTTON_IMAGELIST_ALIGN_LEFT;
UpdateImageInfo();
wxSize sizeBtn = sizeLabel;
sizeBtn.x += 3*win->GetCharWidth();
- sizeBtn.y = 11*EDIT_HEIGHT_FROM_CHAR_HEIGHT(sizeLabel.y)/10;
// account for the shield UAC icon if we have it
if ( flags & Size_AuthNeeded )
return sizeBtn;
}
-wxSize wxMSWButton::ComputeBestSize(wxControl *btn, int flags)
+wxSize wxMSWButton::ComputeBestFittingSize(wxControl *btn, int flags)
{
wxClientDC dc(btn);
wxSize sizeBtn;
dc.GetMultiLineTextExtent(btn->GetLabelText(), &sizeBtn.x, &sizeBtn.y);
- sizeBtn = GetFittingSize(btn, sizeBtn, flags);
+ return GetFittingSize(btn, sizeBtn, flags);
+}
+
+wxSize wxMSWButton::IncreaseToStdSizeAndCache(wxControl *btn, const wxSize& size)
+{
+ wxSize sizeBtn(size);
// all buttons have at least the standard size unless the user explicitly
// wants them to be of smaller size and used wxBU_EXACTFIT style when
// creating the button
if ( !btn->HasFlag(wxBU_EXACTFIT) )
{
- // The size of a standard button in the dialog units is 50x14, use it.
+ // The 50x14 button size is documented in the "Recommended sizing and
+ // spacing" section of MSDN layout article.
+ //
// Note that we intentionally don't use GetDefaultSize() here, because
// it's inexact -- dialog units depend on this dialog's font.
wxSize sizeDef = btn->ConvertDialogToPixels(wxSize(50, 14));
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();
wxSize wxButton::DoGetBestSize() const
{
+ wxButton * const self = const_cast<wxButton *>(this);
+
wxSize size;
- // account for the text part if we have it or if we don't have any image at
- // all (buttons initially created with empty label should still have a non
- // zero size)
- if ( ShowsLabel() || !m_imageData )
+ // Account for the text part if we have it.
+ if ( ShowsLabel() )
{
int flags = 0;
if ( GetAuthNeeded() )
flags |= wxMSWButton::Size_AuthNeeded;
- size = wxMSWButton::ComputeBestSize(const_cast<wxButton *>(this), flags);
+ size = wxMSWButton::ComputeBestFittingSize(self, flags);
}
if ( m_imageData )
- {
AdjustForBitmapSize(size);
- CacheBestSize(size);
- }
-
- return size;
+ return wxMSWButton::IncreaseToStdSizeAndCache(self, size);
}
/* static */