]> git.saurik.com Git - wxWidgets.git/blobdiff - src/cocoa/toplevel.mm
blind OS/2 compilation fix in wxSetWorkingDirectory()
[wxWidgets.git] / src / cocoa / toplevel.mm
index fbcf064b1b7d938a27f21c1e3f399111150519fb..f2e44d4b44e36da529cded0376d5552409f5dbbd 100644 (file)
@@ -36,6 +36,9 @@
 #include "wx/cocoa/objc/NSView.h"
 #include "wx/cocoa/objc/NSWindow.h"
 #import <AppKit/NSPanel.h>
 #include "wx/cocoa/objc/NSView.h"
 #include "wx/cocoa/objc/NSWindow.h"
 #import <AppKit/NSPanel.h>
+#import <AppKit/NSButtonCell.h>
+#import <AppKit/NSControl.h>
+
 // ----------------------------------------------------------------------------
 // globals
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // globals
 // ----------------------------------------------------------------------------
@@ -139,7 +142,7 @@ bool wxTopLevelWindowCocoa::Create(wxWindow *parent,
     else
         newWindow = [[WXNSWindow alloc] initWithContentRect:cocoaRect styleMask:cocoaStyle backing:NSBackingStoreBuffered defer:NO];
     // Make sure the default content view is a WXNSView
     else
         newWindow = [[WXNSWindow alloc] initWithContentRect:cocoaRect styleMask:cocoaStyle backing:NSBackingStoreBuffered defer:NO];
     // Make sure the default content view is a WXNSView
-    [newWindow setContentView: [[WXNSView alloc] initWithFrame: [[newWindow contentView] frame]]];
+    [newWindow setContentView: [[WX_GET_OBJC_CLASS(WXNSView) alloc] initWithFrame: [[newWindow contentView] frame]]];
     // Associate the window and view
     SetNSWindow(newWindow);
 
     // Associate the window and view
     SetNSWindow(newWindow);
 
@@ -352,6 +355,28 @@ wxString wxTopLevelWindowCocoa::GetTitle() const
     return wxStringWithNSString([m_cocoaNSWindow title]);
 }
 
     return wxStringWithNSString([m_cocoaNSWindow title]);
 }
 
+wxWindow* wxTopLevelWindowCocoa::SetDefaultItem(wxWindow *win)
+{
+    wxWindow *old = wxTopLevelWindowBase::SetDefaultItem(win);
+    NSView *newView = win->GetNSView();
+
+    NSCell *newCell;
+    // newView does not have to be an NSControl, we only cast to NSControl*
+    // to silence the warning about cell not being implemented.
+    if(newView != nil && [newView respondsToSelector:@selector(cell)])
+        newCell = [(NSControl*)newView cell];
+    else
+        newCell = nil;
+
+    if(newCell != nil && ![newCell isKindOfClass:[NSButtonCell class]])
+    {   // It's not an NSButtonCell, set the default to nil.
+        newCell = nil;
+    }
+
+    [GetNSWindow() setDefaultButtonCell:(NSButtonCell*)newCell];
+    return old;
+}
+
 bool wxTopLevelWindowCocoa::ShowFullScreen(bool show, long style)
 {
     return false;
 bool wxTopLevelWindowCocoa::ShowFullScreen(bool show, long style)
 {
     return false;