mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
* Source/GSNibLoading.m: Rollback of previous change. Found a
minor problem. * Source/NSDrawer.m: Improvements to NSDrawer handling. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27911 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
32c4192f32
commit
e6719574e3
3 changed files with 151 additions and 13 deletions
|
@ -1,3 +1,9 @@
|
|||
2009-02-18 02:45-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Source/GSNibLoading.m: Rollback of previous change. Found a
|
||||
minor problem.
|
||||
* Source/NSDrawer.m: Improvements to NSDrawer handling.
|
||||
|
||||
2009-02-17 23:09-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Source/GSNibLoading.m: use the new code committed to NSMenu to
|
||||
|
|
|
@ -71,6 +71,10 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
- (Class) replacementClassForClassName: (NSString *)className;
|
||||
@end
|
||||
|
||||
@interface NSApplication (NibCompatibility)
|
||||
- (void) _setMainMenu: (NSMenu*)aMenu;
|
||||
@end
|
||||
|
||||
@interface NSView (NibCompatibility)
|
||||
- (void) _fixSubviews;
|
||||
@end
|
||||
|
@ -90,6 +94,114 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
@interface _NSCornerView : NSView
|
||||
@end
|
||||
|
||||
@interface NSMenu (NibCompatibility)
|
||||
- (void) _setMain: (BOOL)isMain;
|
||||
@end
|
||||
@interface NSMenu (GNUstepPrivate)
|
||||
- (void) _setGeometry;
|
||||
@end
|
||||
|
||||
@implementation NSMenu (NibCompatibility)
|
||||
// FIXME: Why can't this be merged with setMain: ?
|
||||
- (void) _setMain: (BOOL)isMain
|
||||
{
|
||||
if (isMain)
|
||||
{
|
||||
NSMenuView *oldRep;
|
||||
NSInterfaceStyle oldStyle;
|
||||
NSInterfaceStyle newStyle;
|
||||
NSString *processName;
|
||||
|
||||
if([self numberOfItems] == 0)
|
||||
return;
|
||||
|
||||
oldRep = [self menuRepresentation];
|
||||
oldStyle = [oldRep interfaceStyle];
|
||||
newStyle = NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil);
|
||||
processName = [[NSProcessInfo processInfo] processName];
|
||||
|
||||
/*
|
||||
* If necessary, rebuild menu for (different) style
|
||||
*/
|
||||
if (oldStyle != newStyle)
|
||||
{
|
||||
NSMenuView *newRep;
|
||||
|
||||
newRep = [[NSMenuView alloc] initWithFrame: NSZeroRect];
|
||||
if (newStyle == NSMacintoshInterfaceStyle
|
||||
|| newStyle == NSWindows95InterfaceStyle)
|
||||
{
|
||||
[newRep setHorizontal: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[newRep setHorizontal: NO];
|
||||
}
|
||||
[newRep setInterfaceStyle: newStyle];
|
||||
[self setMenuRepresentation: newRep];
|
||||
RELEASE(newRep);
|
||||
}
|
||||
|
||||
[[self window] setTitle: processName];
|
||||
[[self window] setLevel: NSMainMenuWindowLevel];
|
||||
|
||||
// if it's a standard menu, transform it to be more NeXT'ish/GNUstep-like
|
||||
if(_menu.horizontal == NO)
|
||||
{
|
||||
NSString *infoString = NSLocalizedString (@"Info", @"Info");
|
||||
NSString *quitString = [NSString stringWithFormat: @"%@ %@",
|
||||
NSLocalizedString (@"Quit", @"Quit"), processName];
|
||||
NSMenuItem *quitItem = [[NSMenuItem alloc] initWithTitle: quitString
|
||||
action: @selector(terminate:)
|
||||
keyEquivalent: @"q"];
|
||||
NSMenuItem *appItem;
|
||||
|
||||
appItem = (NSMenuItem*)[self itemAtIndex: 0]; // Info item.
|
||||
|
||||
[self addItem: quitItem];
|
||||
[self setTitle: processName];
|
||||
[appItem setTitle: infoString];
|
||||
[[appItem submenu] setTitle: infoString];
|
||||
}
|
||||
|
||||
[self _setGeometry];
|
||||
[self sizeToFit];
|
||||
|
||||
if ([NSApp isActive])
|
||||
{
|
||||
[self display];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[self close];
|
||||
[[self window] setLevel: NSSubmenuWindowLevel];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSApplication (NibCompatibility)
|
||||
- (void) _setMainMenu: (NSMenu*)aMenu
|
||||
{
|
||||
if (_main_menu == aMenu)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_main_menu != nil)
|
||||
{
|
||||
[_main_menu setMain: NO];
|
||||
}
|
||||
|
||||
ASSIGN(_main_menu, aMenu);
|
||||
|
||||
if (_main_menu != nil)
|
||||
{
|
||||
[_main_menu _setMain: YES];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSView (NibCompatibility)
|
||||
- (void) _setWindow: (id) w
|
||||
{
|
||||
|
@ -1762,7 +1874,7 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
if (menu != nil)
|
||||
{
|
||||
menu = [self instantiateObject: menu];
|
||||
[NSApp setMainMenu: menu];
|
||||
[NSApp _setMainMenu: menu];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ static NSNotificationCenter *nc = nil;
|
|||
- (NSDrawer *) drawer;
|
||||
|
||||
// handle notifications...
|
||||
- (void) handleWindowDidBecomeKey: (NSNotification *)notification;
|
||||
- (void) handleWindowClose: (NSNotification *)notification;
|
||||
- (void) handleWindowMiniaturize: (NSNotification *)notification;
|
||||
- (void) handleWindowMove: (NSNotification *)notification;
|
||||
|
@ -145,39 +146,42 @@ static NSNotificationCenter *nc = nil;
|
|||
NSRectEdge edge = [_drawer preferredEdge];
|
||||
int state = [_drawer state];
|
||||
BOOL opened = (state == NSDrawerOpenState);
|
||||
NSSize size = [_drawer maxContentSize];
|
||||
NSSize size = [_parentWindow frame].size; // [_drawer maxContentSize];
|
||||
newFrame.size.width = [_drawer minContentSize].width;
|
||||
|
||||
if (edge == NSMinXEdge) // left
|
||||
{
|
||||
newFrame.size.height -= total;
|
||||
newFrame.origin.y += [_drawer trailingOffset];
|
||||
newFrame.origin.y += [_drawer trailingOffset] - (total/2);
|
||||
newFrame.origin.x -= (opened)?size.width:0;
|
||||
}
|
||||
else if (edge == NSMinYEdge) // bottom
|
||||
{
|
||||
newFrame.size.width -= total;
|
||||
newFrame.origin.x += [_drawer leadingOffset];
|
||||
newFrame.origin.x += [_drawer leadingOffset] + (total/2);
|
||||
newFrame.origin.y -= (opened)?size.height:0;
|
||||
}
|
||||
else if (edge == NSMaxXEdge) // right
|
||||
{
|
||||
newFrame.size.height -= total;
|
||||
newFrame.origin.y += [_drawer trailingOffset];
|
||||
newFrame.origin.y += [_drawer trailingOffset] - (total/2);
|
||||
newFrame.origin.x += (opened)?size.width:0;
|
||||
}
|
||||
else if (edge == NSMaxYEdge) // top
|
||||
{
|
||||
newFrame.size.width -= total;
|
||||
newFrame.origin.x += [_drawer leadingOffset];
|
||||
newFrame.origin.x += [_drawer leadingOffset] + (total/2);
|
||||
newFrame.origin.y += (opened)?size.height:0;
|
||||
}
|
||||
|
||||
return newFrame;
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (BOOL) canBecomeKeyWindow
|
||||
{
|
||||
return NO;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) canBecomeMainWindow
|
||||
|
@ -185,6 +189,7 @@ static NSNotificationCenter *nc = nil;
|
|||
return NO;
|
||||
}
|
||||
|
||||
/*
|
||||
- (void) orderFront: (id)sender
|
||||
{
|
||||
NSPoint holdOrigin = [self frame].origin;
|
||||
|
@ -195,10 +200,11 @@ static NSNotificationCenter *nc = nil;
|
|||
tempFrame.origin = newOrigin;
|
||||
[self setFrame: tempFrame display: NO];
|
||||
[super orderFront: sender];
|
||||
[_parentWindow orderWindow: NSWindowAbove relativeTo: [self windowNumber]];
|
||||
// [_parentWindow orderWindow: NSWindowAbove relativeTo: [self windowNumber]];
|
||||
tempFrame.origin = holdOrigin;
|
||||
[self setFrame: tempFrame display: YES];
|
||||
// [self setFrame: tempFrame display: YES];
|
||||
}
|
||||
*/
|
||||
|
||||
- (void) startTimer
|
||||
{
|
||||
|
@ -235,9 +241,9 @@ static NSNotificationCenter *nc = nil;
|
|||
|
||||
- (void) openOnEdge
|
||||
{
|
||||
NSRect frame = [self frameFromParentWindowFrame];
|
||||
// NSRect frame = [self frameFromParentWindowFrame];
|
||||
|
||||
[self setFrame: frame display: YES];
|
||||
// [self setFrame: frame display: YES];
|
||||
[self slide];
|
||||
[self orderFront: self];
|
||||
[self startTimer];
|
||||
|
@ -264,7 +270,7 @@ static NSNotificationCenter *nc = nil;
|
|||
{
|
||||
NSRect frame = [self frame];
|
||||
NSRectEdge edge = [_drawer preferredEdge];
|
||||
NSSize size = [_drawer maxContentSize];
|
||||
NSSize size = frame.size; // [_drawer maxContentSize];
|
||||
|
||||
[super setParentWindow: nil];
|
||||
if (edge == NSMinXEdge) // left
|
||||
|
@ -320,6 +326,15 @@ static NSNotificationCenter *nc = nil;
|
|||
[self _resetWindowPosition];
|
||||
}
|
||||
|
||||
- (void) handleWindowDidBecomeKey: (NSNotification *)notification
|
||||
{
|
||||
if([_drawer state] == NSDrawerOpenState)
|
||||
{
|
||||
[self _resetWindowPosition];
|
||||
[self orderFront: self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setParentWindow: (NSWindow *)window
|
||||
{
|
||||
if (_parentWindow != window)
|
||||
|
@ -351,7 +366,12 @@ static NSNotificationCenter *nc = nil;
|
|||
[nc addObserver: self
|
||||
selector: @selector(handleWindowMove:)
|
||||
name: NSWindowDidResizeNotification
|
||||
object: _parentWindow];
|
||||
object: _parentWindow];
|
||||
|
||||
[nc addObserver: self
|
||||
selector: @selector(handleWindowDidBecomeKey:)
|
||||
name: NSWindowDidBecomeKeyNotification
|
||||
object: _parentWindow];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue