Menu display improvments

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16040 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2003-02-21 23:50:21 +00:00
parent 1b0e112697
commit cc9e0d4346
5 changed files with 80 additions and 52 deletions

View file

@ -1,3 +1,17 @@
2003-02-21 Serg Stoyan <stoyan@hologr.com>
* Source/NSApplication.m (-activateIgnoringOtherApps:): Remove
main menu display.
(-sendEvent:): Check first if right button down.
(-setMainMenu:): Don't set menu title. Remove menu display.
* Source/NSMenu.m (-init): Default title is process name.
(-initWithTitle:): Observe NSApplicationWillBecomeActiveNotification.
(_showOnActivateApp:): New.
(-display): Set geometry only if not set.
(-setGeometry): New.
* Source/NSPopUpButton.m (-mouseDown:): Send event to NSApp.
2003-02-19 Adam Fedor <fedor@gnu.org>
* Source/NSPrintOperation.m (-_print): Remove locale change (now

View file

@ -182,6 +182,7 @@
/* Shows the menu window on screen */
- (void) display;
- (void) displayTransient;
- (void) setGeometry;
/* Close the associated window menu */
- (void) close;

View file

@ -888,9 +888,6 @@ static NSCell* tileCell = nil;
_hidden_key = nil;
}
[_main_menu update];
[_main_menu display];
if (_unhide_on_activation)
{
[self unhide: nil];
@ -1451,10 +1448,10 @@ See -runModalForWindow:
NSDebugLLog(@"NSEvent", @"Send NSEvent type: %d to window %@",
type, ((window != nil) ? [window description]
: @"No window"));
if (window)
[window sendEvent: theEvent];
else if (type == NSRightMouseDown)
if (type == NSRightMouseDown)
[self rightMouseDown: theEvent];
else if (window)
[window sendEvent: theEvent];
}
}
}
@ -1958,18 +1955,11 @@ image.
ASSIGN(_main_menu, aMenu);
[_main_menu setTitle: [[NSProcessInfo processInfo] processName]];
// Set the title of the window also.
// Set the title of the window.
// This wont be displayed, but the window manager may need it.
[[_main_menu window] setTitle: [[NSProcessInfo processInfo] processName]];
[[_main_menu window] setLevel: NSMainMenuWindowLevel];
[_main_menu sizeToFit];
if ([self isActive])
{
[_main_menu update];
[_main_menu display];
}
[_main_menu setGeometry];
}
- (void) rightMouseDown: (NSEvent*)theEvent

View file

@ -172,7 +172,7 @@ static NSNotificationCenter *nc;
*/
- (id) init
{
return [self initWithTitle: @"Menu"];
return [self initWithTitle: [[NSProcessInfo processInfo] processName]];
}
- (void) dealloc
@ -253,6 +253,11 @@ static NSNotificationCenter *nc;
name: NSApplicationDidFinishLaunchingNotification
object: NSApp];
[nc addObserver: self
selector: @selector(_showOnActivateApp:)
name: NSApplicationWillBecomeActiveNotification
object: NSApp];
return self;
}
@ -1053,6 +1058,16 @@ static NSNotificationCenter *nc;
}
}
- (void) _showOnActivateApp: (NSNotification*)notification
{
if ([NSApp mainMenu] == self)
{
[self display];
// we must make sure that any attached submenu is visible too.
[[self attachedMenu] display];
}
}
- (BOOL) isFollowTransient
{
return _follow_transient;
@ -1110,54 +1125,27 @@ static NSNotificationCenter *nc;
- (void) display
{
NSString *key;
if (_changed)
[self sizeToFit];
if (_superMenu && ![self isTornOff])
{
// query super menu for position
[_aWindow setFrameOrigin: [_superMenu locationForSubmenu: self]];
_superMenu->_attachedMenu = self;
}
else if (nil != (key = [self _locationKey]))
// get geometry only if not set
if ([_aWindow frame].origin.y <= 0)
{
NSUserDefaults *defaults;
NSDictionary *menuLocations;
NSString *location;
defaults = [NSUserDefaults standardUserDefaults];
menuLocations = [defaults objectForKey: NSMenuLocationsKey];
location = [menuLocations objectForKey: key];
if (location && [location isKindOfClass: [NSString class]])
{
[_aWindow setFrameFromString: location];
/*
* May need resize in case saved frame is out of sync
* with number of items in menu.
*/
[self sizeToFit];
if (_superMenu && ![self isTornOff])
{
// query super menu for position
[_aWindow setFrameOrigin: [_superMenu locationForSubmenu: self]];
_superMenu->_attachedMenu = self;
}
else
{
NSPoint aPoint = {0, [[NSScreen mainScreen] frame].size.height
- [_aWindow frame].size.height};
[_aWindow setFrameOrigin: aPoint];
[_bWindow setFrameOrigin: aPoint];
[self setGeometry];
}
}
[_aWindow orderFrontRegardless];
_isPartlyOffScreen = IS_OFFSCREEN(_aWindow);
/*
* If we have just been made visible, we must make sure that any attached
* submenu is visible too.
*/
[[self attachedMenu] display];
}
- (void) displayTransient
@ -1206,6 +1194,40 @@ static NSNotificationCenter *nc;
_isPartlyOffScreen = IS_OFFSCREEN(_bWindow);
}
- (void) setGeometry
{
NSString *key;
NSUserDefaults *defaults;
NSDictionary *menuLocations;
NSString *location;
NSPoint origin;
NSScanner *scanner;
int value;
origin = NSMakePoint (0, [[NSScreen mainScreen] frame].size.height
- [_aWindow frame].size.height);
if (nil != (key = [self _locationKey]))
{
defaults = [NSUserDefaults standardUserDefaults];
menuLocations = [defaults objectForKey: NSMenuLocationsKey];
location = [menuLocations objectForKey: key];
if (location && [location isKindOfClass: [NSString class]])
{
scanner = [NSScanner scannerWithString: location];
[scanner scanInt: &value];
origin.x = value;
[scanner scanInt: &value];
origin.y = value;
}
}
[_aWindow setFrameOrigin: origin];
[_bWindow setFrameOrigin: origin];
}
- (void) close
{
NSMenu *sub = [self attachedMenu];
@ -1221,6 +1243,7 @@ static NSNotificationCenter *nc;
_attachedMenu = sub;
}
[_aWindow orderOut: self];
[_aWindow setFrameOrigin: NSMakePoint (0, 0)];
if (_superMenu)
_superMenu->_attachedMenu = nil;

View file

@ -335,7 +335,7 @@ Class _nspopupbuttonCellClass = 0;
eventNumber: [theEvent eventNumber]
clickCount: [theEvent clickCount]
pressure: [theEvent pressure]];
[menuWindow sendEvent: e];
[NSApp sendEvent: e];
// Selection remains unchanged if selected item is disabled
highlightedItemIndex = [mr highlightedItemIndex];