Menu location fixes.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@12205 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2002-01-23 16:32:20 +00:00
parent 47950c836d
commit 7435386c19
4 changed files with 46 additions and 10 deletions

View file

@ -1,3 +1,12 @@
2002-01-23 Adam Fedor <fedor@gnu.org>
* Source/NSInterfaceStyle.m (NSInterfaceStyleForKey): Use default
style if no key for style is located. Don't cache key in this case.
* Source/NSMenu.m (-nestedSetFrameOrigin:aPoint): Use
locationForSubmenu to get submenu location.
* Source/NSMenuView.m (-locationForSubmenu:): Fix
location of submenu for GSWindowMakerInterfaceStyle.
2002-01-22 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSWorkspace.h: new ivar

View file

@ -63,6 +63,28 @@ typedef struct {
@defs(NSResponder)
} *accessToResponder;
/**
<p>
Returns the interface style the responder should use, which affects
how a UI element (such as a button or menu) is displayed. If the
responder has an interface style set, the key is ignored and the
responder's interface style is returned. Otherwise the style
associated with the key is returned (if set), otherwise the default
style is returned. In no case will the style <code>NSNoInterfaceStyle</code>
be returned.
</p>
<p>
Styles can be set using the user defaults system. Currently available
styles are <code>NSNextStepInterfaceStyle</code>,
<code>NSMacintoshInterfaceStyle</code>,
<code>NSWindows95InterfaceStyle</code>,
<code>GSWindowMakerInterfaceStyle</code>. You can set a default style
for all UI elements using the <code>NSInterfaceStyleDefault</code> key:
<example>
defaults write NSGlobalDomain NSInterfaceStyleDefault GSWindowMakerInterfaceStyle
</example>
</p>
*/
extern NSInterfaceStyle
NSInterfaceStyleForKey(NSString *key, NSResponder *responder)
{
@ -108,9 +130,10 @@ NSInterfaceStyleForKey(NSString *key, NSResponder *responder)
if (def == nil
|| (style = styleFromString(def)) == NSNoInterfaceStyle)
{
style = NSNextStepInterfaceStyle;
style = defStyle;
}
NSMapInsert(styleMap, (void*)key, (void*)style);
if (style != NSNoInterfaceStyle)
NSMapInsert(styleMap, (void*)key, (void*)style);
}
return style;
}

View file

@ -1216,10 +1216,14 @@ static NSNotificationCenter *nc;
return (NSWindow *)_aWindow;
}
/**
Set the frame origin of the receiver to aPoint. If a submenu of
the receiver is attached. The frame origin of the submenu is set
appropriately.
*/
- (void) nestedSetFrameOrigin: (NSPoint) aPoint
{
NSWindow *theWindow = _follow_transient ? _bWindow : _aWindow;
NSRect frame;
// Move ourself and get our width.
[theWindow setFrameOrigin: aPoint];
@ -1227,11 +1231,7 @@ static NSNotificationCenter *nc;
// Do the same for attached menus.
if (_attachedMenu)
{
frame = [theWindow frame];
// First locate the origin.
aPoint.x += frame.size.width;
aPoint.y += frame.size.height
- [_attachedMenu->_aWindow frame].size.height;
aPoint = [self locationForSubmenu: _attachedMenu];
[_attachedMenu nestedSetFrameOrigin: aPoint];
}
}

View file

@ -608,6 +608,10 @@
[self setNeedsDisplayInRect: aRect];
}
/**
Returns the correct frame origin for aSubmenu based on the location
of the receiver. This location may depend on the current NSInterfaceStyle.
*/
- (NSPoint) locationForSubmenu: (NSMenu *)aSubmenu
{
NSRect frame = [_window frame];
@ -621,7 +625,6 @@
else
submenuFrame = NSZeroRect;
// FIXME: Fix this to support styles when the menus move.
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil)
== GSWindowMakerInterfaceStyle)
{
@ -632,7 +635,8 @@
aRect.origin.y)];
return NSMakePoint (frame.origin.x + frame.size.width,
subOrigin.y - (submenuFrame.size.height - 43));
subOrigin.y - (submenuFrame.size.height + 3 -
2*[NSMenuView menuBarHeight]));
}
else
{