wxSize wxButton::DoGetBestSize() const
{
if ( GetId() == wxID_HELP )
- return wxSize( 20 , 20 ) ;
+ return wxSize( 23 , 23 ) ;
wxSize sz = GetDefaultSize() ;
{
case wxWINDOW_VARIANT_NORMAL:
case wxWINDOW_VARIANT_LARGE:
- sz.y = 20 ;
+ sz.y = 23 ;
break;
case wxWINDOW_VARIANT_SMALL:
break;
}
+ wxRect r ;
+
+ m_peer->GetBestRect(&r);
+
+ if ( r.GetWidth() == 0 && r.GetHeight() == 0 )
+ {
+ }
+ sz.x = r.GetWidth();
+ sz.y = r.GetHeight();
+
+ int wBtn = 96;
+
+ if ((wBtn > sz.x) || ( GetWindowStyle() & wxBU_EXACTFIT))
+ sz.x = wBtn;
+
#if wxOSX_USE_CARBON
Rect bestsize = { 0 , 0 , 0 , 0 } ;
m_peer->GetBestRect( &bestsize ) ;
@implementation wxNSButton
-- (id)initWithFrame:(NSRect)frame
++ (void)initialize
{
- [super initWithFrame:frame];
- m_impl = NULL;
- [self setTarget: self];
- [self setAction: @selector(clickedAction:)];
- return self;
-}
-
-- (void) clickedAction: (id) sender
-{
- if ( m_impl )
+ static BOOL initialized = NO;
+ if (!initialized)
{
- wxButton* wxpeer = (wxButton*) m_impl->GetWXPeer();
- if ( wxpeer )
- wxpeer->HandleClicked(0);
+ initialized = YES;
+ wxOSXCocoaClassAddWXMethods( self );
}
}
-- (void)setImplementation: (wxWidgetImpl *) theImplementation
-{
- m_impl = theImplementation;
-}
-
-- (wxWidgetImpl*) implementation
-{
- return m_impl;
-}
-
-- (BOOL) isFlipped
-{
- return YES;
-}
-
- (int) intValue
{
switch ( [self state] )
wxWidgetImplType* wxWidgetImpl::CreateButton( wxWindowMac* wxpeer,
- wxWindowMac* parent,
+ wxWindowMac* WXUNUSED(parent),
wxWindowID id,
- const wxString& label,
+ const wxString& WXUNUSED(label),
const wxPoint& pos,
const wxSize& size,
- long style,
- long extraStyle)
+ long WXUNUSED(style),
+ long WXUNUSED(extraStyle))
{
- NSView* sv = (wxpeer->GetParent()->GetHandle() );
-
- NSRect r = wxToNSRect( sv, wxRect( pos, size) );
- // Rect bounds = wxMacGetBoundsForControl( wxpeer, pos , size ) ;
+ NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
if ( id == wxID_HELP )
}
[v setButtonType:NSMomentaryPushInButton];
- [sv addSubview:v];
wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
- [v setImplementation:c];
return c;
/*
OSStatus err;
void wxWidgetCocoaImpl::SetDefaultButton( bool isDefault )
{
- [m_osxView setKeyEquivalent: isDefault ? @"\r" : nil ];
-// SetData(kControlButtonPart , kControlPushButtonDefaultTag , (Boolean) isDefault ) ;
+ if ( isDefault && [m_osxView isKindOfClass:[NSButton class]] )
+ // NOTE: setKeyEquivalent: nil will trigger an assert
+ // instead do not call in that case.
+ [(NSButton*)m_osxView setKeyEquivalent: @"\r" ];
}
void wxWidgetCocoaImpl::PerformClick()
{
}
-// TODO for the disclosure button : NSDisclosureBezelStyle and the button type to NSOnOffButton.
+wxWidgetImplType* wxWidgetImpl::CreateDisclosureTriangle( wxWindowMac* wxpeer,
+ wxWindowMac* WXUNUSED(parent),
+ wxWindowID WXUNUSED(id),
+ const wxString& label,
+ const wxPoint& pos,
+ const wxSize& size,
+ long WXUNUSED(style),
+ long WXUNUSED(extraStyle))
+{
+ NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
+ wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
+ [v setBezelStyle:NSDisclosureBezelStyle];
+ [v setButtonType:NSOnOffButton];
+ [v setTitle:wxCFStringRef( label).AsNSString()];
+ [v setImagePosition:NSImageRight];
+ wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
+ return c;
+}