Implement wxButtonBase::GetDefaultSize()
Implement wxButton::DoGetBestSize() to return at least 68 pixel width unless wxBU_EXACTFIT flag is given. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29658 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
d1adc25737
commit
635f01472e
@ -58,6 +58,7 @@ protected:
|
||||
public:
|
||||
wxString GetLabel() const;
|
||||
void SetLabel(const wxString& label);
|
||||
wxSize DoGetBestSize() const;
|
||||
};
|
||||
|
||||
#endif // __WX_COCOA_BUTTON_H__
|
||||
|
@ -18,9 +18,10 @@
|
||||
|
||||
#include "wx/stockitem.h"
|
||||
#include "wx/cocoa/autorelease.h"
|
||||
#include "wx/cocoa/string.h"
|
||||
|
||||
#import <AppKit/NSButton.h>
|
||||
#include "wx/cocoa/string.h"
|
||||
#import <math.h>
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
|
||||
BEGIN_EVENT_TABLE(wxButton, wxButtonBase)
|
||||
@ -79,9 +80,32 @@ void wxButton::SetLabel(const wxString& label)
|
||||
[GetNSButton() setTitle:wxNSStringWithWxString(wxStripMenuCodes(label))];
|
||||
}
|
||||
|
||||
wxSize wxButtonBase::GetDefaultSize()
|
||||
wxSize wxButton::DoGetBestSize() const
|
||||
{
|
||||
// FIXME: stub
|
||||
return wxDefaultSize;
|
||||
wxSize size = wxButtonBase::DoGetBestSize();
|
||||
if(!HasFlag(wxBU_EXACTFIT))
|
||||
{
|
||||
if(size.x<68)
|
||||
size.x = 68;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
static NSRect MakeNSButtonDefaultRect()
|
||||
{
|
||||
// create at (10.0,10.0) with size 20.0x20.0 (just bogus values)
|
||||
wxObjcAutoRefFromAlloc<NSButton*> defaultButton = [[NSButton alloc]
|
||||
initWithFrame:NSMakeRect(10.0,10.0,20.0,20.0)];
|
||||
[defaultButton setBezelStyle:NSRoundedBezelStyle];
|
||||
[defaultButton setTitle:@""];
|
||||
[defaultButton sizeToFit];
|
||||
return [defaultButton frame];
|
||||
}
|
||||
|
||||
wxSize wxButtonBase::GetDefaultSize()
|
||||
{
|
||||
static NSRect cocoaRect = MakeNSButtonDefaultRect();
|
||||
// Apple HIG says OK/Cancel buttons have default width of 68.
|
||||
return wxSize(68,(int)ceilf(cocoaRect.size.height));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user