Allow automatic OS-provided tabbing to be disabled in wxOSX

macOS 10.12+ implements automatic tabbing in the OS. This adds
entries to the menus and also adds a tab bar. Some applications
might want to disable this, so provide an interface for doing this.

Closes https://github.com/wxWidgets/wxWidgets/pull/1674
This commit is contained in:
Ian McInerney
2019-12-07 12:08:22 +00:00
committed by Vadim Zeitlin
parent 7ecd55f02b
commit b17aa08c26
3 changed files with 27 additions and 0 deletions

View File

@@ -139,6 +139,9 @@ public:
// override this to return false from a non-bundled console app in order to stay in background ...
virtual bool OSXIsGUIApplication() { return true; }
// Allow the user to disable the tab bar support in the application
void OSXEnableAutomaticTabbing(bool enable);
#if wxOSX_USE_COCOA_OR_IPHONE
// immediately before the native event loop launches
virtual void OSXOnWillFinishLaunching();

View File

@@ -1068,6 +1068,21 @@ public:
*/
virtual bool OSXIsGUIApplication();
/**
Enable the automatic tabbing features of macOS.
This feature is native to the operating system. When it is enabled, macOS
will automatically place windows inside tabs and show a tab bar in the
application. Entries are also added to the View menu to show/hide the tab bar.
@onlyfor{wxosx}
@remarks Requires macOS 10.12+, does nothing under earlier OS versions.
@since 3.1.4
*/
bool OSXEnableAutomaticTabbing(bool enable);
//@}
};

View File

@@ -475,6 +475,15 @@ void wxApp::DoCleanUp()
}
}
void wxApp::OSXEnableAutomaticTabbing(bool enable)
{
// Automatic tabbing was first introduced in 10.12
if ( WX_IS_MACOS_AVAILABLE(10, 12) )
{
[NSWindow setAllowsAutomaticWindowTabbing:enable];
}
}
extern // used from src/osx/core/display.cpp
wxRect wxOSXGetMainDisplayClientArea()
{