Merged trunk 47600:

wxCocoa: Implement wxTopLevelWindow::SetDefaultItem
Copyright 2007, Software 2000 Ltd.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@47601 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Elliott
2007-07-20 20:41:05 +00:00
parent 729535acbe
commit d4364d403b
2 changed files with 26 additions and 0 deletions

View File

@@ -106,6 +106,8 @@ public:
virtual void SetTitle( const wxString& title); virtual void SetTitle( const wxString& title);
virtual wxString GetTitle() const; virtual wxString GetTitle() const;
// Default button (item)
wxWindow *SetDefaultItem(wxWindow *win);
// Things I may/may not do // Things I may/may not do
// virtual void SetIcon(const wxIcon& icon); // virtual void SetIcon(const wxIcon& icon);

View File

@@ -36,6 +36,8 @@
#include "wx/cocoa/objc/NSView.h" #include "wx/cocoa/objc/NSView.h"
#include "wx/cocoa/objc/NSWindow.h" #include "wx/cocoa/objc/NSWindow.h"
#import <AppKit/NSPanel.h> #import <AppKit/NSPanel.h>
#import <AppKit/NSButtonCell.h>
#import <AppKit/NSControl.h>
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// globals // globals
@@ -354,6 +356,28 @@ wxString wxTopLevelWindowCocoa::GetTitle() const
return wxEmptyString; return wxEmptyString;
} }
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) bool wxTopLevelWindowCocoa::ShowFullScreen(bool show, long style)
{ {
return false; return false;