]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/button.mm
fixing native font info support bugs
[wxWidgets.git] / src / osx / cocoa / button.mm
index bbf249361fd37c04b6e01e050378f3cd05ef3511..750218176bd66b002ba794b9ee9fd6e9bad75bcb 100644 (file)
@@ -26,7 +26,7 @@
 wxSize wxButton::DoGetBestSize() const
 {
     if ( GetId() == wxID_HELP )
-        return wxSize( 20 , 20 ) ;
+        return wxSize( 23 , 23 ) ;
 
     wxSize sz = GetDefaultSize() ;
 
@@ -123,40 +123,16 @@ wxSize wxButton::GetDefaultSize()
 
 @implementation wxNSButton
 
-- (id)initWithFrame:(NSRect)frame
++ (void)initialize
 {
-    [super initWithFrame:frame];
-    impl = NULL;
-    [self setTarget: self];
-    [self setAction: @selector(clickedAction:)];
-    return self;
-}
-
-- (void) clickedAction: (id) sender
-{
-    if ( impl )
+    static BOOL initialized = NO;
+    if (!initialized) 
     {
-        wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
-        if ( wxpeer )
-            wxpeer->HandleClicked(0);
+        initialized = YES;
+        wxOSXCocoaClassAddWXMethods( self );
     }
 }
 
-- (void)setImplementation: (wxWidgetImpl *) theImplementation
-{
-    impl = theImplementation;
-}
-
-- (wxWidgetImpl*) implementation
-{
-    return impl;
-}
-
-- (BOOL) isFlipped
-{
-    return YES;
-}
-
 - (int) intValue
 {
     switch ( [self state] )
@@ -190,13 +166,13 @@ wxSize wxButton::GetDefaultSize()
 
 
 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)
 {
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
@@ -212,7 +188,6 @@ wxWidgetImplType* wxWidgetImpl::CreateButton( wxWindowMac* wxpeer,
     
     [v setButtonType:NSMomentaryPushInButton];
     wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
-    [v setImplementation:c];
     return c;
 /*
     OSStatus err;
@@ -267,8 +242,10 @@ wxWidgetImplType* wxWidgetImpl::CreateButton( wxWindowMac* wxpeer,
 
 void wxWidgetCocoaImpl::SetDefaultButton( bool isDefault )
 { 
-    if ( [m_osxView isKindOfClass:[NSButton class]] )
-        [(NSButton*)m_osxView setKeyEquivalent: isDefault ? @"\r" : nil ];
+    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() 
@@ -276,13 +253,13 @@ void wxWidgetCocoaImpl::PerformClick()
 }
 
 wxWidgetImplType* wxWidgetImpl::CreateDisclosureTriangle( wxWindowMac* wxpeer, 
-                                    wxWindowMac* parent
-                                    wxWindowID id
+                                    wxWindowMac* WXUNUSED(parent)
+                                    wxWindowID WXUNUSED(id)
                                     const wxString& label,
                                     const wxPoint& pos, 
                                     const wxSize& size,
-                                    long style
-                                    long extraStyle
+                                    long WXUNUSED(style)
+                                    long WXUNUSED(extraStyle)
 {
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
     wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
@@ -291,6 +268,5 @@ wxWidgetImplType* wxWidgetImpl::CreateDisclosureTriangle( wxWindowMac* wxpeer,
     [v setTitle:wxCFStringRef( label).AsNSString()];
     [v setImagePosition:NSImageRight];
     wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
-    [v setImplementation:c];
     return c;
 }