Skip to content

Commit

Permalink
• changes for full screen support for Lion and up
Browse files Browse the repository at this point in the history
- added menu item under main menu "Window" bound to standard ^⌘F 
- up to now only the RConsole can run in full screen mode
- removed full screen support for script editor windows since the question is answered: how should we handle full screen mode for other windows incl. Quartz? If the app runs in full screen mode all windows will be set to full screen?  Should each window be handled differently? ...


git-svn-id: https://svn.r-project.org/R-packages/trunk/Mac-GUI@6115 694ef91d-65df-0310-b7bb-92e67a308ead
  • Loading branch information
Hans-Jörg Bibiko committed Feb 24, 2012
1 parent 05f8b42 commit 0cf38e2
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 2 deletions.
4 changes: 4 additions & 0 deletions RController.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@
NSString *lastFunctionHintText;

NSString *appSupportPath;

NSMenuItem *toggleFullScreenMenuItem;

}

/* process pending events. if blocking is set to YES then the method waits indefinitely for one event. otherwise only pending events are processed. */
Expand Down Expand Up @@ -209,6 +212,7 @@
-(IBAction) showVignettes:(id)sender;

-(IBAction) clearConsole:(id)sender;
-(IBAction) toggleFullScreenMode:(id)sender;

-(IBAction) searchInHistory:(id)sender;
-(IBAction) activateSearchInHistory:(id)sender;
Expand Down
42 changes: 42 additions & 0 deletions RController.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@
return to_return;
}

#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
// declare the following methods to avoid compiler warnings
@interface NSWindow (SuppressWarnings)
- (void)toggleFullScreen:(id)sender;
@end
#endif


@interface R_WebViewSearchWindow : NSWindow
@end

Expand Down Expand Up @@ -713,10 +721,43 @@ -(void) applicationDidFinishLaunching: (NSNotification *)aNotification
// Register us as service provider
[NSApp setServicesProvider:self];


if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
NSString *label = nil;
if(([[self window] styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask)
label = NLS(@"Exit Full Screen");
else
label = NLS(@"Enter Full Screen");
toggleFullScreenMenuItem = [[NSMenuItem alloc] initWithTitle:label action:@selector(toggleFullScreenMode:) keyEquivalent:@"f"];
[toggleFullScreenMenuItem setKeyEquivalentModifierMask:(NSControlKeyMask | NSCommandKeyMask)];
NSInteger m = [[NSApp mainMenu] numberOfItems]-2; // Window submenu
[[[[NSApp mainMenu] itemAtIndex:m] submenu] insertItem:[NSMenuItem separatorItem] atIndex:0];
[[[[NSApp mainMenu] itemAtIndex:m] submenu] insertItem:toggleFullScreenMenuItem atIndex:0];
}

SLog(@"RController.applicationDidFinishLaunching - show main window");

}

- (void)windowDidEnterFullScreen:(NSNotification *)notification
{
if(toggleFullScreenMenuItem)
[toggleFullScreenMenuItem setTitle:NLS(@"Exit Full Screen")];
}

- (void)windowDidExitFullScreen:(NSNotification *)notification
{
if(toggleFullScreenMenuItem)
[toggleFullScreenMenuItem setTitle:NLS(@"Enter Full Screen")];
}

-(IBAction)toggleFullScreenMode:(id)sender
{
#if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
[[self window] toggleFullScreen:nil];
#endif
}

- (void)updateReInterpretEncodingMenu
{
// Update Re-Open with Encoding submenu
Expand Down Expand Up @@ -1078,6 +1119,7 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)app {

- (void) dealloc
{
if(toggleFullScreenMenuItem) [toggleFullScreenMenuItem release];
if(toolbarStopItem) [toolbarStopItem release];
if(lastFunctionForHint) [lastFunctionForHint release];
[[NSNotificationCenter defaultCenter] removeObserver:self];
Expand Down
2 changes: 1 addition & 1 deletion RDocumentWinCtrl.m
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ - (void) windowDidLoad
SLog(@"RDocumentWinCtrl(%@).windowDidLoad", self);

// Add full screen support for MacOSX Lion or higher
[[self window] setCollectionBehavior:[[self window] collectionBehavior] | NSWindowCollectionBehaviorFullScreenPrimary];
// [[self window] setCollectionBehavior:[[self window] collectionBehavior] | NSWindowCollectionBehaviorFullScreenPrimary];


showMatchingBraces = [Preferences flagForKey:showBraceHighlightingKey withDefault: YES];
Expand Down
2 changes: 1 addition & 1 deletion RTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static inline int RPARSERCONTEXTFORPOSITION (RTextView* self, NSUInteger index)
// declared external
BOOL RTextView_autoCloseBrackets = YES;

#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_5
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
// declare the following methods to avoid compiler warnings
@interface NSTextView (SuppressWarnings)
- (void)swipeWithEvent:(NSEvent *)event;
Expand Down
4 changes: 4 additions & 0 deletions RWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ enum {
NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7,
NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8
};
enum {
NSFullScreenWindowMask = 1 << 14
};
#endif

#define NSAppKitVersionNumber10_6 1038

#import <Cocoa/Cocoa.h>

Expand Down

0 comments on commit 0cf38e2

Please sign in to comment.