mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 20:10:47 +00:00
Horizontal menu related code removed
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16236 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a163a5992a
commit
f572a3f079
3 changed files with 181 additions and 232 deletions
26
ChangeLog
26
ChangeLog
|
@ -1,3 +1,29 @@
|
|||
2003-03-23 Serg Stoyan <stoyan@on.com.ua>
|
||||
* Source/NSMenuView.m: Removed horizontal menu related code.
|
||||
(setHorizontal:): Removed.
|
||||
(isHorizontal:): Removed.
|
||||
(_addLeftBorderOffsetToRect): Removed isHorizontal parameter.
|
||||
(setMenu:): Place [self setNeedsSizing: YES] before [self update].
|
||||
(update): Removed title view removal, because it's not always known
|
||||
owner of menu at this point. Remove title view creating.
|
||||
(sizeToFit:): Reformatting.
|
||||
(innerRect:): Idem.
|
||||
(setWindowFrameForAttachingToRect:onScreen:preferredEdge:popUpSelectedItem:):
|
||||
Title view removal code placed here, because this is only place where
|
||||
non-titled menu can appear.
|
||||
(initWithFrame:): Removed comment about _leftBorderOffset for popups,
|
||||
because we use _leftBorderOffset for regular and popups now. Title view
|
||||
creating added.
|
||||
(rectOfItemAtIndex:): Removed comment about _leftBorderOffset for popups.
|
||||
(indexOfItemAtPoint:): Idem. Add left border offset for popups too. Correct
|
||||
calling of _addLeftBorderOffsetToRect.
|
||||
(setNeedsDisplayForItemAtIndex:): Idem.
|
||||
(rightMouseDown:): Ddded comment.
|
||||
|
||||
* Headers/NSMenuView.h
|
||||
(setHorizontal:): Removed.
|
||||
(isHorizontal:): Removed.
|
||||
|
||||
2003-03-22 Willem Rein Oudshoorn <woudshoo@xs4all.nl>
|
||||
|
||||
* Source/NSMenu.m ([NSMenu -display]): Added optimization of Michael Hanni
|
||||
|
|
|
@ -99,8 +99,8 @@
|
|||
- (id)initAsTearOff;
|
||||
- (void)setMenu:(NSMenu *)menu;
|
||||
- (NSMenu *)menu;
|
||||
- (void)setHorizontal:(BOOL)flag;
|
||||
- (BOOL)isHorizontal;
|
||||
/*- (void)setHorizontal:(BOOL)flag;
|
||||
- (BOOL)isHorizontal;*/
|
||||
- (void)setFont:(NSFont *)font;
|
||||
- (NSFont *)font;
|
||||
- (void)setHighlightedItemIndex:(int)index;
|
||||
|
|
|
@ -72,18 +72,11 @@
|
|||
@implementation NSMenuView
|
||||
|
||||
static NSRect
|
||||
_addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||
_addLeftBorderOffsetToRect(NSRect aRect)
|
||||
{
|
||||
if (isHorizontal == NO)
|
||||
{
|
||||
aRect.origin.x--;
|
||||
aRect.size.width++;
|
||||
}
|
||||
else
|
||||
{
|
||||
aRect.origin.y--;
|
||||
aRect.size.height++;
|
||||
}
|
||||
|
||||
return aRect;
|
||||
}
|
||||
|
||||
|
@ -139,14 +132,18 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
_horizontalEdgePad = 4.;
|
||||
|
||||
/* Set the necessary offset for the menuView. That is, how many pixels
|
||||
* do we need for our left side border line. For regular menus this
|
||||
* equals 1, for popups it is 0.
|
||||
* do we need for our left side border line.
|
||||
*/
|
||||
_leftBorderOffset = 1;
|
||||
|
||||
// Create an array to store our menu item cells.
|
||||
_itemCells = [NSMutableArray new];
|
||||
|
||||
// Add title view. If this menu owned by popup
|
||||
_titleView = [[NSMenuWindowTitleView alloc] init];
|
||||
[self addSubview: _titleView];
|
||||
[_titleView release];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -210,9 +207,10 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
name: NSMenuDidRemoveItemNotification
|
||||
object: _menu];
|
||||
|
||||
[self update];
|
||||
// Force menu view's layout to be recalculated.
|
||||
[self setNeedsSizing: YES];
|
||||
|
||||
[self update];
|
||||
}
|
||||
|
||||
- (NSMenu*) menu
|
||||
|
@ -220,16 +218,6 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
return _menu;
|
||||
}
|
||||
|
||||
- (void) setHorizontal: (BOOL)flag
|
||||
{
|
||||
_horizontal = flag;
|
||||
}
|
||||
|
||||
- (BOOL) isHorizontal
|
||||
{
|
||||
return _horizontal;
|
||||
}
|
||||
|
||||
- (void) setFont: (NSFont*)font
|
||||
{
|
||||
ASSIGN(_font, font);
|
||||
|
@ -469,18 +457,6 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
{
|
||||
NSDebugLLog (@"NSMenu", @"update called on menu view");
|
||||
|
||||
if ([_menu _ownedByPopUp] && _titleView)
|
||||
{
|
||||
[_titleView removeFromSuperview];
|
||||
_titleView = nil;
|
||||
}
|
||||
if (![_menu _ownedByPopUp] && !_titleView)
|
||||
{
|
||||
_titleView = [[NSMenuWindowTitleView alloc] init];
|
||||
[_titleView setMenu: _menu];
|
||||
[self addSubview: _titleView];
|
||||
[_titleView release];
|
||||
}
|
||||
[_titleView setMenu: _menu];
|
||||
|
||||
if (_needsSizing)
|
||||
|
@ -641,18 +617,11 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
_keyEqOffset = _cellSize.width - _keyEqWidth - popupImageWidth;
|
||||
}
|
||||
|
||||
if (_horizontal == NO)
|
||||
{
|
||||
[self setFrameSize: NSMakeSize(_cellSize.width + _leftBorderOffset,
|
||||
(howMany * _cellSize.height) + menuBarHeight)];
|
||||
[self setFrameSize: NSMakeSize (_cellSize.width + _leftBorderOffset,
|
||||
(howMany * _cellSize.height)
|
||||
+ menuBarHeight)];
|
||||
[_titleView setFrame: NSMakeRect (0, howMany * _cellSize.height,
|
||||
NSWidth (_bounds), menuBarHeight)];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setFrameSize: NSMakeSize((howMany * _cellSize.width),
|
||||
_cellSize.height + _leftBorderOffset)];
|
||||
}
|
||||
|
||||
_needsSizing = NO;
|
||||
}
|
||||
|
@ -707,16 +676,10 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
|
||||
- (NSRect) innerRect
|
||||
{
|
||||
if (_horizontal == NO)
|
||||
{
|
||||
return NSMakeRect(_bounds.origin.x + _leftBorderOffset, _bounds.origin.y,
|
||||
_bounds.size.width - _leftBorderOffset, _bounds.size.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NSMakeRect(_bounds.origin.x, _bounds.origin.y + _leftBorderOffset,
|
||||
_bounds.size.width, _bounds.size.height - _leftBorderOffset);
|
||||
}
|
||||
return NSMakeRect(_bounds.origin.x + _leftBorderOffset,
|
||||
_bounds.origin.y,
|
||||
_bounds.size.width - _leftBorderOffset,
|
||||
_bounds.size.height);
|
||||
}
|
||||
|
||||
- (NSRect) rectOfItemAtIndex: (int)index
|
||||
|
@ -730,20 +693,10 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
|
||||
/* When we are a normal menu we fiddle with the origin so that the item
|
||||
* rect is shifted 1 pixel over so we do not draw on the heavy line at
|
||||
* origin.x = 0. However, for popups we don't want this modification of
|
||||
* our rect so our _leftBorderOffset = 0 (set in sizeToFit).
|
||||
* origin.x = 0.
|
||||
*/
|
||||
if (_horizontal == NO)
|
||||
{
|
||||
theRect.origin.y = _cellSize.height * ([_itemCells count] - index - 1);
|
||||
theRect.origin.x = _leftBorderOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
theRect.origin.x = _cellSize.width * index;
|
||||
theRect.origin.y = _leftBorderOffset;
|
||||
}
|
||||
|
||||
theRect.size = _cellSize;
|
||||
|
||||
/* NOTE: This returns the correct NSRect for drawing cells, but nothing
|
||||
|
@ -767,13 +720,7 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
{
|
||||
NSRect aRect = [self rectOfItemAtIndex: i];
|
||||
|
||||
/* We need to modify the rect to take into account the modifications
|
||||
* to origin made by [-rectOfItemAtIndex:] in order to return an
|
||||
* item clicked at the left hand margin. However, for a popup this
|
||||
* calculation is unnecessary since we have no extra margin.
|
||||
*/
|
||||
if (![_menu _ownedByPopUp])
|
||||
aRect = _addLeftBorderOffsetToRect(aRect, _horizontal);
|
||||
aRect = _addLeftBorderOffsetToRect(aRect);
|
||||
|
||||
if (NSMouseInRect(point, aRect, NO))
|
||||
return (int)i;
|
||||
|
@ -788,13 +735,7 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
|
||||
aRect = [self rectOfItemAtIndex: index];
|
||||
|
||||
/* We need to modify the rect to take into account the modifications
|
||||
* to origin made by [-rectOfItemAtIndex:] in order to return an
|
||||
* item clicked at the left hand margin. However, for a popup this
|
||||
* calculation is unnecessary since we have no extra margin.
|
||||
*/
|
||||
if (![_menu _ownedByPopUp])
|
||||
aRect = _addLeftBorderOffsetToRect(aRect, _horizontal);
|
||||
aRect = _addLeftBorderOffsetToRect(aRect);
|
||||
|
||||
[self setNeedsDisplayInRect: aRect];
|
||||
}
|
||||
|
@ -816,16 +757,13 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
else
|
||||
submenuFrame = NSZeroRect;
|
||||
|
||||
if (_horizontal == NO)
|
||||
{
|
||||
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil)
|
||||
== GSWindowMakerInterfaceStyle)
|
||||
{
|
||||
NSRect aRect = [self rectOfItemAtIndex:
|
||||
[_menu indexOfItemWithSubmenu: aSubmenu]];
|
||||
NSPoint subOrigin = [_window convertBaseToScreen:
|
||||
NSMakePoint(aRect.origin.x,
|
||||
aRect.origin.y)];
|
||||
NSMakePoint(aRect.origin.x, aRect.origin.y)];
|
||||
|
||||
return NSMakePoint (NSMaxX(frame),
|
||||
subOrigin.y - NSHeight(submenuFrame) - 3 +
|
||||
|
@ -836,17 +774,6 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
return NSMakePoint(NSMaxX(frame),
|
||||
NSMaxY(frame) - NSHeight(submenuFrame));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSRect aRect = [self rectOfItemAtIndex:
|
||||
[_menu indexOfItemWithSubmenu: aSubmenu]];
|
||||
NSPoint subOrigin = [_window convertBaseToScreen:
|
||||
NSMakePoint(NSMinX(aRect),
|
||||
NSMaxY(aRect))];
|
||||
return NSMakePoint(subOrigin.x,
|
||||
subOrigin.y - NSHeight(submenuFrame));
|
||||
}
|
||||
}
|
||||
|
||||
- (void) resizeWindowWithMaxHeight: (float)maxHeight
|
||||
|
@ -869,6 +796,13 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
cellFrame.origin = [_window convertScreenToBase: screenRect.origin];
|
||||
cellFrame = [self convertRect: cellFrame fromView: nil];
|
||||
|
||||
// Remove title view if we owned by popup button
|
||||
if ([_menu _ownedByPopUp] && _titleView)
|
||||
{
|
||||
[_titleView removeFromSuperview];
|
||||
_titleView = nil;
|
||||
}
|
||||
|
||||
_cellSize = cellFrame.size;
|
||||
[self sizeToFit];
|
||||
|
||||
|
@ -880,36 +814,21 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
{
|
||||
float f;
|
||||
|
||||
if (_horizontal == NO)
|
||||
{
|
||||
f = screenRect.size.height * (items - 1);
|
||||
screenFrame.size.height += f + _leftBorderOffset;
|
||||
screenFrame.origin.y -= f;
|
||||
screenFrame.size.width += _leftBorderOffset;
|
||||
screenFrame.origin.x -= _leftBorderOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
f = screenRect.size.width * (items - 1);
|
||||
screenFrame.size.width += f;
|
||||
}
|
||||
}
|
||||
|
||||
// Move the menu window to screen?
|
||||
// TODO
|
||||
|
||||
// Compute position for popups, if needed
|
||||
if (selectedItemIndex != -1)
|
||||
{
|
||||
if (_horizontal == NO)
|
||||
{
|
||||
screenFrame.origin.y += screenRect.size.height * selectedItemIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
screenFrame.origin.x -= screenRect.size.width * selectedItemIndex;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the frameRect
|
||||
r = [NSWindow frameRectForContentRect: screenFrame
|
||||
|
@ -1168,8 +1087,11 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
*/
|
||||
candidateMenu = [_menu supermenu];
|
||||
while (candidateMenu
|
||||
&& !NSMouseInRect (locationInScreenCoordinates, [[candidateMenu window] frame], NO) // not found yet
|
||||
&& (! ([candidateMenu isTornOff] && ![candidateMenu isTransient])) // no root of display tree
|
||||
&& !NSMouseInRect (locationInScreenCoordinates,
|
||||
[[candidateMenu window] frame],
|
||||
NO) // not found yet
|
||||
&& (! ([candidateMenu isTornOff]
|
||||
&& ![candidateMenu isTransient])) // no root of display tree
|
||||
&& [candidateMenu isAttached]) // has displayed parent
|
||||
{
|
||||
candidateMenu = [candidateMenu supermenu];
|
||||
|
@ -1401,7 +1323,6 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
|
||||
[encoder encodeObject: _itemCells];
|
||||
[encoder encodeObject: _font];
|
||||
[encoder encodeValueOfObjCType: @encode(BOOL) at: &_horizontal];
|
||||
[encoder encodeValueOfObjCType: @encode(float) at: &_horizontalEdgePad];
|
||||
[encoder encodeValueOfObjCType: @encode(NSSize) at: &_cellSize];
|
||||
}
|
||||
|
@ -1416,7 +1337,6 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
withObject: self];
|
||||
|
||||
[decoder decodeValueOfObjCType: @encode(id) at: &_font];
|
||||
[decoder decodeValueOfObjCType: @encode(BOOL) at: &_horizontal];
|
||||
[decoder decodeValueOfObjCType: @encode(float) at: &_horizontalEdgePad];
|
||||
[decoder decodeValueOfObjCType: @encode(NSSize) at: &_cellSize];
|
||||
|
||||
|
@ -1475,8 +1395,10 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
if (attr == nil)
|
||||
{
|
||||
attr = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
[NSFont boldSystemFontOfSize: 0], NSFontAttributeName,
|
||||
[NSColor windowFrameTextColor], NSForegroundColorAttributeName,
|
||||
[NSFont boldSystemFontOfSize: 0],
|
||||
NSFontAttributeName,
|
||||
[NSColor windowFrameTextColor],
|
||||
NSForegroundColorAttributeName,
|
||||
nil];
|
||||
}
|
||||
|
||||
|
@ -1600,6 +1522,7 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
[self setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
// We do not need app menu over menu
|
||||
- (void) rightMouseDown: (NSEvent*)theEvent
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue