mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:00:47 +00:00
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:
parent
441fb9b0bd
commit
e8b35c9d11
5 changed files with 80 additions and 52 deletions
14
ChangeLog
14
ChangeLog
|
@ -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>
|
2003-02-19 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
* Source/NSPrintOperation.m (-_print): Remove locale change (now
|
* Source/NSPrintOperation.m (-_print): Remove locale change (now
|
||||||
|
|
|
@ -182,6 +182,7 @@
|
||||||
/* Shows the menu window on screen */
|
/* Shows the menu window on screen */
|
||||||
- (void) display;
|
- (void) display;
|
||||||
- (void) displayTransient;
|
- (void) displayTransient;
|
||||||
|
- (void) setGeometry;
|
||||||
|
|
||||||
/* Close the associated window menu */
|
/* Close the associated window menu */
|
||||||
- (void) close;
|
- (void) close;
|
||||||
|
|
|
@ -888,9 +888,6 @@ static NSCell* tileCell = nil;
|
||||||
_hidden_key = nil;
|
_hidden_key = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
[_main_menu update];
|
|
||||||
[_main_menu display];
|
|
||||||
|
|
||||||
if (_unhide_on_activation)
|
if (_unhide_on_activation)
|
||||||
{
|
{
|
||||||
[self unhide: nil];
|
[self unhide: nil];
|
||||||
|
@ -1451,10 +1448,10 @@ See -runModalForWindow:
|
||||||
NSDebugLLog(@"NSEvent", @"Send NSEvent type: %d to window %@",
|
NSDebugLLog(@"NSEvent", @"Send NSEvent type: %d to window %@",
|
||||||
type, ((window != nil) ? [window description]
|
type, ((window != nil) ? [window description]
|
||||||
: @"No window"));
|
: @"No window"));
|
||||||
if (window)
|
if (type == NSRightMouseDown)
|
||||||
[window sendEvent: theEvent];
|
|
||||||
else if (type == NSRightMouseDown)
|
|
||||||
[self rightMouseDown: theEvent];
|
[self rightMouseDown: theEvent];
|
||||||
|
else if (window)
|
||||||
|
[window sendEvent: theEvent];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1958,18 +1955,11 @@ image.
|
||||||
|
|
||||||
ASSIGN(_main_menu, aMenu);
|
ASSIGN(_main_menu, aMenu);
|
||||||
|
|
||||||
[_main_menu setTitle: [[NSProcessInfo processInfo] processName]];
|
// Set the title of the window.
|
||||||
// Set the title of the window also.
|
|
||||||
// This wont be displayed, but the window manager may need it.
|
// This wont be displayed, but the window manager may need it.
|
||||||
[[_main_menu window] setTitle: [[NSProcessInfo processInfo] processName]];
|
[[_main_menu window] setTitle: [[NSProcessInfo processInfo] processName]];
|
||||||
[[_main_menu window] setLevel: NSMainMenuWindowLevel];
|
[[_main_menu window] setLevel: NSMainMenuWindowLevel];
|
||||||
[_main_menu sizeToFit];
|
[_main_menu setGeometry];
|
||||||
|
|
||||||
if ([self isActive])
|
|
||||||
{
|
|
||||||
[_main_menu update];
|
|
||||||
[_main_menu display];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) rightMouseDown: (NSEvent*)theEvent
|
- (void) rightMouseDown: (NSEvent*)theEvent
|
||||||
|
|
|
@ -172,7 +172,7 @@ static NSNotificationCenter *nc;
|
||||||
*/
|
*/
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
return [self initWithTitle: @"Menu"];
|
return [self initWithTitle: [[NSProcessInfo processInfo] processName]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
|
@ -253,6 +253,11 @@ static NSNotificationCenter *nc;
|
||||||
name: NSApplicationDidFinishLaunchingNotification
|
name: NSApplicationDidFinishLaunchingNotification
|
||||||
object: NSApp];
|
object: NSApp];
|
||||||
|
|
||||||
|
[nc addObserver: self
|
||||||
|
selector: @selector(_showOnActivateApp:)
|
||||||
|
name: NSApplicationWillBecomeActiveNotification
|
||||||
|
object: NSApp];
|
||||||
|
|
||||||
return self;
|
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
|
- (BOOL) isFollowTransient
|
||||||
{
|
{
|
||||||
return _follow_transient;
|
return _follow_transient;
|
||||||
|
@ -1110,54 +1125,27 @@ static NSNotificationCenter *nc;
|
||||||
|
|
||||||
- (void) display
|
- (void) display
|
||||||
{
|
{
|
||||||
NSString *key;
|
|
||||||
|
|
||||||
if (_changed)
|
if (_changed)
|
||||||
[self sizeToFit];
|
[self sizeToFit];
|
||||||
|
|
||||||
if (_superMenu && ![self isTornOff])
|
// get geometry only if not set
|
||||||
{
|
if ([_aWindow frame].origin.y <= 0)
|
||||||
// query super menu for position
|
|
||||||
[_aWindow setFrameOrigin: [_superMenu locationForSubmenu: self]];
|
|
||||||
_superMenu->_attachedMenu = self;
|
|
||||||
}
|
|
||||||
else if (nil != (key = [self _locationKey]))
|
|
||||||
{
|
{
|
||||||
NSUserDefaults *defaults;
|
if (_superMenu && ![self isTornOff])
|
||||||
NSDictionary *menuLocations;
|
{
|
||||||
NSString *location;
|
// query super menu for position
|
||||||
|
[_aWindow setFrameOrigin: [_superMenu locationForSubmenu: self]];
|
||||||
defaults = [NSUserDefaults standardUserDefaults];
|
_superMenu->_attachedMenu = self;
|
||||||
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];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSPoint aPoint = {0, [[NSScreen mainScreen] frame].size.height
|
[self setGeometry];
|
||||||
- [_aWindow frame].size.height};
|
|
||||||
|
|
||||||
[_aWindow setFrameOrigin: aPoint];
|
|
||||||
[_bWindow setFrameOrigin: aPoint];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[_aWindow orderFrontRegardless];
|
[_aWindow orderFrontRegardless];
|
||||||
|
|
||||||
_isPartlyOffScreen = IS_OFFSCREEN(_aWindow);
|
_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
|
- (void) displayTransient
|
||||||
|
@ -1206,6 +1194,40 @@ static NSNotificationCenter *nc;
|
||||||
_isPartlyOffScreen = IS_OFFSCREEN(_bWindow);
|
_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
|
- (void) close
|
||||||
{
|
{
|
||||||
NSMenu *sub = [self attachedMenu];
|
NSMenu *sub = [self attachedMenu];
|
||||||
|
@ -1221,6 +1243,7 @@ static NSNotificationCenter *nc;
|
||||||
_attachedMenu = sub;
|
_attachedMenu = sub;
|
||||||
}
|
}
|
||||||
[_aWindow orderOut: self];
|
[_aWindow orderOut: self];
|
||||||
|
[_aWindow setFrameOrigin: NSMakePoint (0, 0)];
|
||||||
|
|
||||||
if (_superMenu)
|
if (_superMenu)
|
||||||
_superMenu->_attachedMenu = nil;
|
_superMenu->_attachedMenu = nil;
|
||||||
|
|
|
@ -335,7 +335,7 @@ Class _nspopupbuttonCellClass = 0;
|
||||||
eventNumber: [theEvent eventNumber]
|
eventNumber: [theEvent eventNumber]
|
||||||
clickCount: [theEvent clickCount]
|
clickCount: [theEvent clickCount]
|
||||||
pressure: [theEvent pressure]];
|
pressure: [theEvent pressure]];
|
||||||
[menuWindow sendEvent: e];
|
[NSApp sendEvent: e];
|
||||||
|
|
||||||
// Selection remains unchanged if selected item is disabled
|
// Selection remains unchanged if selected item is disabled
|
||||||
highlightedItemIndex = [mr highlightedItemIndex];
|
highlightedItemIndex = [mr highlightedItemIndex];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue