diff --git a/docs/changes.txt b/docs/changes.txt index 58906a5396..cc2babda77 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -173,6 +173,7 @@ wxOSX/Cocoa: - Use more efficient FSEvents (10.7+) in wxFileSystemWatcher (Roberto Perpuly). - Implement wxWindow::Disable() for non-native controls too (Steve Browne). +- Implement wxTopLevelWindow::EnableCloseButton() (John Roberts). - Fix wxEVT_CHAR for non-BMP Unicode characters (ARATA Mizuki). - Add support for wxEVT_COMBOBOX_DROPDOWN and wxEVT_COMBOBOX_CLOSEUP events (Igor Korot). diff --git a/include/wx/osx/cocoa/private.h b/include/wx/osx/cocoa/private.h index cc929ae6bf..d545e7a8de 100644 --- a/include/wx/osx/cocoa/private.h +++ b/include/wx/osx/cocoa/private.h @@ -231,6 +231,8 @@ public : virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) ; + virtual bool EnableCloseButton(bool enable) wxOVERRIDE; + virtual bool IsMaximized() const; virtual bool IsIconized() const; diff --git a/include/wx/osx/core/private.h b/include/wx/osx/core/private.h index 9b1c371562..dc620aebfc 100644 --- a/include/wx/osx/core/private.h +++ b/include/wx/osx/core/private.h @@ -847,6 +847,8 @@ public : virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) = 0; + virtual bool EnableCloseButton(bool enable) = 0; + virtual bool IsMaximized() const = 0; virtual bool IsIconized() const= 0; diff --git a/include/wx/osx/toplevel.h b/include/wx/osx/toplevel.h index 33bdffa201..b129827318 100644 --- a/include/wx/osx/toplevel.h +++ b/include/wx/osx/toplevel.h @@ -74,6 +74,10 @@ public: virtual void SetTitle( const wxString& title); virtual wxString GetTitle() const; + // EnableCloseButton(false) used to disable the "Close" + // button on the title bar + virtual bool EnableCloseButton(bool enable = true) wxOVERRIDE; + virtual void SetLabel(const wxString& label) { SetTitle( label ); } virtual wxString GetLabel() const { return GetTitle(); } diff --git a/interface/wx/toplevel.h b/interface/wx/toplevel.h index 2a34071aa6..c07ec6ccc8 100644 --- a/interface/wx/toplevel.h +++ b/interface/wx/toplevel.h @@ -142,8 +142,6 @@ public: corner of a dialog) and the Close entry of the system menu (most often in the left upper corner of the dialog). - Currently only implemented for wxMSW and wxGTK. - Returns @true if operation was successful. This may be wrong on X11 (including GTK+) where the window manager may not support this operation and there is no way to find out. diff --git a/src/osx/cocoa/nonownedwnd.mm b/src/osx/cocoa/nonownedwnd.mm index 97186983b1..fbb0407757 100644 --- a/src/osx/cocoa/nonownedwnd.mm +++ b/src/osx/cocoa/nonownedwnd.mm @@ -939,6 +939,13 @@ void wxNonOwnedWindowCocoaImpl::SetTitle( const wxString& title, wxFontEncoding [m_macWindow setTitle:wxCFStringRef( title , encoding ).AsNSString()]; } +bool wxNonOwnedWindowCocoaImpl::EnableCloseButton(bool enable) +{ + [[m_macWindow standardWindowButton:NSWindowCloseButton] setEnabled:enable]; + + return true; +} + bool wxNonOwnedWindowCocoaImpl::IsMaximized() const { if (([m_macWindow styleMask] & NSResizableWindowMask) != 0) diff --git a/src/osx/toplevel_osx.cpp b/src/osx/toplevel_osx.cpp index cd54839bc9..3f9ef35893 100644 --- a/src/osx/toplevel_osx.cpp +++ b/src/osx/toplevel_osx.cpp @@ -205,6 +205,16 @@ bool wxTopLevelWindowMac::IsFullScreen() const return m_nowpeer->IsFullScreen(); } +bool wxTopLevelWindowMac::EnableCloseButton(bool enable) +{ + // Unlike in wxMSW, wxSYSTEM_MENU is not sufficient to show + // a close button unless combined with one of the resize buttons. + if ( HasFlag(wxCLOSE_BOX) ) + return m_nowpeer->EnableCloseButton( enable); + + return false; +} + void wxTopLevelWindowMac::RequestUserAttention(int flags) { return m_nowpeer->RequestUserAttention(flags);