osx: Add the full screen button to the main window

Originally committed to SVN as r6879.
This commit is contained in:
Thomas Goyne 2012-05-26 20:16:08 +00:00
parent 1da7502d6e
commit cde9a34425
5 changed files with 49 additions and 1 deletions

View file

@ -18,7 +18,7 @@ LIBS += $(LIBS_UCHARDET)
LDFLAGS += $(LDFLAGS_CCMALLOC) LDFLAGS += $(LDFLAGS_CCMALLOC)
ifdef BUILD_DARWIN ifeq (yes, $(BUILD_DARWIN))
LIBS += -lz LIBS += -lz
SRC += osx_utils.mm SRC += osx_utils.mm
endif endif

View file

@ -200,6 +200,7 @@ FrameMain::FrameMain (wxArrayString args)
context->ass->LoadDefault(); context->ass->LoadDefault();
StartupLog("Display main window"); StartupLog("Display main window");
AddFullScreenButton(this);
Show(); Show();
SetDisplayMode(1, 1); SetDisplayMode(1, 1);

38
aegisub/src/osx_utils.mm Normal file
View file

@ -0,0 +1,38 @@
// Copyright (c) 2012, Thomas Goyne <plorkyeran@aegisub.org>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//
// Aegisub Project http://www.aegisub.org/
//
// $Id$
/// @file osx_utils.mm
/// @see utils.h
/// @ingroup utils
///
#include "config.h"
#include <wx/window.h>
#import <AppKit/AppKit.h>
void AddFullScreenButton(wxWindow *window) {
NSWindow *nsWindow = [window->GetHandle() window];
if (![nsWindow respondsToSelector:@selector(toggleFullScreen:)])
return;
NSWindowCollectionBehavior collectionBehavior = [nsWindow collectionBehavior];
collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary;
[nsWindow setCollectionBehavior:collectionBehavior];
}

View file

@ -421,3 +421,9 @@ void CleanCache(wxString const& directory, wxString const& file_type, int64_t ma
LOG_D("utils/clean_cache") << "thread started successfully"; LOG_D("utils/clean_cache") << "thread started successfully";
} }
// OS X implementation in osx_utils.mm
#ifndef __WXOSX_COCOA__
void AddFullScreenButton(wxWindow *window) {
}
#endif

View file

@ -94,6 +94,9 @@ int AegiStringToFix(const wxString &str,size_t decimalPlaces,int start=0,int end
/// running process. /// running process.
void RestartAegisub(); void RestartAegisub();
/// Add the OS X 10.7+ full-screen button to a window
void AddFullScreenButton(wxWindow *window);
/// Forward a mouse wheel event to the window under the mouse if needed /// Forward a mouse wheel event to the window under the mouse if needed
/// @param source The initial target of the wheel event /// @param source The initial target of the wheel event
/// @param evt The event /// @param evt The event