mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 16:51:18 +00:00
White space clean up.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26080 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
86fdb04504
commit
d8b13a0a6d
2 changed files with 297 additions and 286 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2008-02-17 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/NSMenuView.m: White space cleanup.
|
||||||
|
|
||||||
2008-02-16 20:43-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
2008-02-16 20:43-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* Source/NSCell.m: Correction for bug#22332.
|
* Source/NSCell.m: Correction for bug#22332.
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
#include <Foundation/Foundation.h>
|
#include <Foundation/Foundation.h>
|
||||||
|
|
||||||
typedef struct _GSCellRect {
|
typedef struct _GSCellRect {
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
} GSCellRect;
|
} GSCellRect;
|
||||||
|
|
||||||
#define GSI_ARRAY_TYPES 0
|
#define GSI_ARRAY_TYPES 0
|
||||||
|
@ -61,9 +61,9 @@ typedef struct _GSCellRect {
|
||||||
#endif
|
#endif
|
||||||
#include <GNUstepBase/GSIArray.h>
|
#include <GNUstepBase/GSIArray.h>
|
||||||
|
|
||||||
static NSMapTable *viewInfo = 0;
|
static NSMapTable *viewInfo = 0;
|
||||||
|
|
||||||
#define cellRects ((GSIArray)NSMapGet(viewInfo, self))
|
#define cellRects ((GSIArray)NSMapGet(viewInfo, self))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
NSMenuView contains:
|
NSMenuView contains:
|
||||||
|
@ -82,7 +82,7 @@ static NSMapTable *viewInfo = 0;
|
||||||
@implementation NSMenuView (Private)
|
@implementation NSMenuView (Private)
|
||||||
- (BOOL) _rootIsHorizontal: (BOOL*)isAppMenu
|
- (BOOL) _rootIsHorizontal: (BOOL*)isAppMenu
|
||||||
{
|
{
|
||||||
NSMenu *m = _attachedMenu;
|
NSMenu *m = _attachedMenu;
|
||||||
|
|
||||||
/* Determine root menu of this menu hierarchy */
|
/* Determine root menu of this menu hierarchy */
|
||||||
while ([m supermenu] != nil)
|
while ([m supermenu] != nil)
|
||||||
|
@ -93,7 +93,7 @@ static NSMapTable *viewInfo = 0;
|
||||||
{
|
{
|
||||||
if (m == [NSApp mainMenu])
|
if (m == [NSApp mainMenu])
|
||||||
{
|
{
|
||||||
*isAppMenu = YES;
|
*isAppMenu = YES;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -165,6 +165,8 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
- (id) initWithFrame: (NSRect)aFrame
|
- (id) initWithFrame: (NSRect)aFrame
|
||||||
{
|
{
|
||||||
self = [super initWithFrame: aFrame];
|
self = [super initWithFrame: aFrame];
|
||||||
|
if (!self)
|
||||||
|
return nil;
|
||||||
|
|
||||||
[self setFont: [NSFont menuFontOfSize: 0.0]];
|
[self setFont: [NSFont menuFontOfSize: 0.0]];
|
||||||
|
|
||||||
|
@ -174,7 +176,7 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
/* Set the necessary offset for the menuView. That is, how many pixels
|
/* Set the necessary offset for the menuView. That is, how many pixels
|
||||||
* do we need for our left side border line.
|
* do we need for our left side border line.
|
||||||
*/
|
*/
|
||||||
_leftBorderOffset = 1;
|
_leftBorderOffset = 1;
|
||||||
|
|
||||||
// Create an array to store our menu item cells.
|
// Create an array to store our menu item cells.
|
||||||
_itemCells = [NSMutableArray new];
|
_itemCells = [NSMutableArray new];
|
||||||
|
@ -185,7 +187,9 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
- (id) initAsTearOff
|
- (id) initAsTearOff
|
||||||
{
|
{
|
||||||
[self initWithFrame: NSZeroRect];
|
[self initWithFrame: NSZeroRect];
|
||||||
|
if (!self)
|
||||||
|
return nil;
|
||||||
|
|
||||||
if (_attachedMenu)
|
if (_attachedMenu)
|
||||||
[_attachedMenu setTornOff: YES];
|
[_attachedMenu setTornOff: YES];
|
||||||
|
|
||||||
|
@ -198,13 +202,13 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
if (_attachedMenu != nil)
|
if (_attachedMenu != nil)
|
||||||
{
|
{
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver: self
|
[[NSNotificationCenter defaultCenter] removeObserver: self
|
||||||
name: nil
|
name: nil
|
||||||
object: _attachedMenu];
|
object: _attachedMenu];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clean the pointer to us stored into the _itemCells. */
|
/* Clean the pointer to us stored into the _itemCells. */
|
||||||
[_itemCells makeObjectsPerformSelector: @selector(setMenuView:)
|
[_itemCells makeObjectsPerformSelector: @selector(setMenuView:)
|
||||||
withObject: nil];
|
withObject: nil];
|
||||||
|
|
||||||
RELEASE(_itemCells);
|
RELEASE(_itemCells);
|
||||||
RELEASE(_font);
|
RELEASE(_font);
|
||||||
|
@ -213,7 +217,7 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
* Get rid of any cached cell rects.
|
* Get rid of any cached cell rects.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
GSIArray a = NSMapGet(viewInfo, self);
|
GSIArray a = NSMapGet(viewInfo, self);
|
||||||
|
|
||||||
if (a != 0)
|
if (a != 0)
|
||||||
{
|
{
|
||||||
|
@ -231,9 +235,9 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
*/
|
*/
|
||||||
- (void) setMenu: (NSMenu*)menu
|
- (void) setMenu: (NSMenu*)menu
|
||||||
{
|
{
|
||||||
NSNotificationCenter *theCenter = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *theCenter = [NSNotificationCenter defaultCenter];
|
||||||
unsigned count;
|
unsigned count;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
if (_attachedMenu != nil)
|
if (_attachedMenu != nil)
|
||||||
{
|
{
|
||||||
|
@ -249,13 +253,13 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
{
|
{
|
||||||
// Add this menu view to the menu's list of observers.
|
// Add this menu view to the menu's list of observers.
|
||||||
[theCenter addObserver: self
|
[theCenter addObserver: self
|
||||||
selector: @selector(itemChanged:)
|
selector: @selector(itemChanged:)
|
||||||
name: NSMenuDidChangeItemNotification
|
name: NSMenuDidChangeItemNotification
|
||||||
object: _attachedMenu];
|
object: _attachedMenu];
|
||||||
|
|
||||||
[theCenter addObserver: self
|
[theCenter addObserver: self
|
||||||
selector: @selector(itemAdded:)
|
selector: @selector(itemAdded:)
|
||||||
name: NSMenuDidAddItemNotification
|
name: NSMenuDidAddItemNotification
|
||||||
object: _attachedMenu];
|
object: _attachedMenu];
|
||||||
|
|
||||||
[theCenter addObserver: self
|
[theCenter addObserver: self
|
||||||
|
@ -267,15 +271,15 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
count = [[[self menu] itemArray] count];
|
count = [[[self menu] itemArray] count];
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
NSNumber *n = [NSNumber numberWithInt: i];
|
NSNumber *n = [NSNumber numberWithInt: i];
|
||||||
NSDictionary *d;
|
NSDictionary *d;
|
||||||
|
|
||||||
d = [NSDictionary dictionaryWithObject: n forKey: @"NSMenuItemIndex"];
|
d = [NSDictionary dictionaryWithObject: n forKey: @"NSMenuItemIndex"];
|
||||||
|
|
||||||
[self itemAdded: [NSNotification
|
[self itemAdded: [NSNotification
|
||||||
notificationWithName: NSMenuDidAddItemNotification
|
notificationWithName: NSMenuDidAddItemNotification
|
||||||
object: self
|
object: self
|
||||||
userInfo: d]];
|
userInfo: d]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force menu view's layout to be recalculated.
|
// Force menu view's layout to be recalculated.
|
||||||
|
@ -292,21 +296,21 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
{
|
{
|
||||||
if (flag == YES && _horizontal == NO)
|
if (flag == YES && _horizontal == NO)
|
||||||
{
|
{
|
||||||
GSIArray a = NSZoneMalloc(NSDefaultMallocZone(), sizeof(GSIArray_t));
|
GSIArray a = NSZoneMalloc(NSDefaultMallocZone(), sizeof(GSIArray_t));
|
||||||
|
|
||||||
GSIArrayInitWithZoneAndCapacity(a, NSDefaultMallocZone(), 8);
|
GSIArrayInitWithZoneAndCapacity(a, NSDefaultMallocZone(), 8);
|
||||||
NSMapInsert(viewInfo, self, a);
|
NSMapInsert(viewInfo, self, a);
|
||||||
}
|
}
|
||||||
else if (flag == NO && _horizontal == YES)
|
else if (flag == NO && _horizontal == YES)
|
||||||
{
|
{
|
||||||
GSIArray a = NSMapGet(viewInfo, self);
|
GSIArray a = NSMapGet(viewInfo, self);
|
||||||
|
|
||||||
if (a != 0)
|
if (a != 0)
|
||||||
{
|
{
|
||||||
GSIArrayEmpty(a);
|
GSIArrayEmpty(a);
|
||||||
NSZoneFree(NSDefaultMallocZone(), a);
|
NSZoneFree(NSDefaultMallocZone(), a);
|
||||||
NSMapRemove(viewInfo, self);
|
NSMapRemove(viewInfo, self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_horizontal = flag;
|
_horizontal = flag;
|
||||||
|
@ -373,7 +377,7 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setMenuItemCell: (NSMenuItemCell *)cell
|
- (void) setMenuItemCell: (NSMenuItemCell *)cell
|
||||||
forItemAtIndex: (int)index
|
forItemAtIndex: (int)index
|
||||||
{
|
{
|
||||||
NSMenuItem *anItem = [_items_link objectAtIndex: index];
|
NSMenuItem *anItem = [_items_link objectAtIndex: index];
|
||||||
|
|
||||||
|
@ -434,7 +438,7 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
- (void) itemChanged: (NSNotification*)notification
|
- (void) itemChanged: (NSNotification*)notification
|
||||||
{
|
{
|
||||||
int index = [[[notification userInfo] objectForKey: @"NSMenuItemIndex"]
|
int index = [[[notification userInfo] objectForKey: @"NSMenuItemIndex"]
|
||||||
intValue];
|
intValue];
|
||||||
NSMenuItemCell *aCell = [_itemCells objectAtIndex: index];
|
NSMenuItemCell *aCell = [_itemCells objectAtIndex: index];
|
||||||
|
|
||||||
// Enabling of the item may have changed
|
// Enabling of the item may have changed
|
||||||
|
@ -449,10 +453,10 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
|
|
||||||
- (void) itemAdded: (NSNotification*)notification
|
- (void) itemAdded: (NSNotification*)notification
|
||||||
{
|
{
|
||||||
int index = [[[notification userInfo]
|
int index = [[[notification userInfo]
|
||||||
objectForKey: @"NSMenuItemIndex"] intValue];
|
objectForKey: @"NSMenuItemIndex"] intValue];
|
||||||
NSMenuItem *anItem = [_items_link objectAtIndex: index];
|
NSMenuItem *anItem = [_items_link objectAtIndex: index];
|
||||||
id aCell = [NSMenuItemCell new];
|
id aCell = [NSMenuItemCell new];
|
||||||
int wasHighlighted = _highlightedItemIndex;
|
int wasHighlighted = _highlightedItemIndex;
|
||||||
|
|
||||||
// FIXME do we need to differentiate between popups and non popups
|
// FIXME do we need to differentiate between popups and non popups
|
||||||
|
@ -488,7 +492,7 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
{
|
{
|
||||||
int wasHighlighted = [self highlightedItemIndex];
|
int wasHighlighted = [self highlightedItemIndex];
|
||||||
int index = [[[notification userInfo] objectForKey: @"NSMenuItemIndex"]
|
int index = [[[notification userInfo] objectForKey: @"NSMenuItemIndex"]
|
||||||
intValue];
|
intValue];
|
||||||
|
|
||||||
if (index <= wasHighlighted)
|
if (index <= wasHighlighted)
|
||||||
{
|
{
|
||||||
|
@ -568,8 +572,8 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
*/
|
*/
|
||||||
- (void) update
|
- (void) update
|
||||||
{
|
{
|
||||||
BOOL needTitleView;
|
BOOL needTitleView;
|
||||||
BOOL rootIsAppMenu;
|
BOOL rootIsAppMenu;
|
||||||
|
|
||||||
NSDebugLLog (@"NSMenu", @"update called on menu view");
|
NSDebugLLog (@"NSMenu", @"update called on menu view");
|
||||||
|
|
||||||
|
@ -647,24 +651,24 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
_cellSize.height = scRect.size.height;
|
_cellSize.height = scRect.size.height;
|
||||||
|
|
||||||
for (i = 0; i < howMany; i++)
|
for (i = 0; i < howMany; i++)
|
||||||
{
|
{
|
||||||
GSCellRect elem;
|
GSCellRect elem;
|
||||||
NSMenuItemCell *aCell = [_itemCells objectAtIndex: i];
|
NSMenuItemCell *aCell = [_itemCells objectAtIndex: i];
|
||||||
float titleWidth = [aCell titleWidth];
|
float titleWidth = [aCell titleWidth];
|
||||||
|
|
||||||
if ([aCell imageWidth])
|
if ([aCell imageWidth])
|
||||||
{
|
{
|
||||||
titleWidth += [aCell imageWidth] + GSCellTextImageXDist;
|
titleWidth += [aCell imageWidth] + GSCellTextImageXDist;
|
||||||
}
|
}
|
||||||
|
|
||||||
elem.rect = NSMakeRect (currentX,
|
elem.rect = NSMakeRect (currentX,
|
||||||
0,
|
0,
|
||||||
(titleWidth + (2 * _horizontalEdgePad)),
|
(titleWidth + (2 * _horizontalEdgePad)),
|
||||||
_cellSize.height);
|
_cellSize.height);
|
||||||
GSIArrayAddItem(cellRects, (GSIArrayItem)elem);
|
GSIArrayAddItem(cellRects, (GSIArrayItem)elem);
|
||||||
|
|
||||||
currentX += titleWidth + (2 * _horizontalEdgePad);
|
currentX += titleWidth + (2 * _horizontalEdgePad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -680,95 +684,95 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
|
|
||||||
// Popup menu doesn't need title bar
|
// Popup menu doesn't need title bar
|
||||||
if (![_attachedMenu _ownedByPopUp] && _titleView)
|
if (![_attachedMenu _ownedByPopUp] && _titleView)
|
||||||
{
|
{
|
||||||
NSMenu *m = [_attachedMenu supermenu];
|
NSMenu *m = [_attachedMenu supermenu];
|
||||||
NSMenuView *r = [m menuRepresentation];
|
NSMenuView *r = [m menuRepresentation];
|
||||||
|
|
||||||
neededImageAndTitleWidth = [_titleView titleSize].width;
|
neededImageAndTitleWidth = [_titleView titleSize].width;
|
||||||
if (r != nil && [r isHorizontal] == YES)
|
if (r != nil && [r isHorizontal] == YES)
|
||||||
{
|
{
|
||||||
NSMenuItemCell *msr;
|
NSMenuItemCell *msr;
|
||||||
|
|
||||||
msr = [r menuItemCellForItemAtIndex:
|
msr = [r menuItemCellForItemAtIndex:
|
||||||
[m indexOfItemWithTitle: [_attachedMenu title]]];
|
[m indexOfItemWithTitle: [_attachedMenu title]]];
|
||||||
neededImageAndTitleWidth
|
neededImageAndTitleWidth
|
||||||
= [msr titleWidth] + GSCellTextImageXDist;
|
= [msr titleWidth] + GSCellTextImageXDist;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_titleView)
|
if (_titleView)
|
||||||
menuBarHeight = [[self class] menuBarHeight];
|
menuBarHeight = [[self class] menuBarHeight];
|
||||||
else
|
else
|
||||||
menuBarHeight += _leftBorderOffset;
|
menuBarHeight += _leftBorderOffset;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
menuBarHeight += _leftBorderOffset;
|
menuBarHeight += _leftBorderOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < howMany; i++)
|
for (i = 0; i < howMany; i++)
|
||||||
{
|
{
|
||||||
float aStateImageWidth;
|
float aStateImageWidth;
|
||||||
float aTitleWidth;
|
float aTitleWidth;
|
||||||
float anImageWidth;
|
float anImageWidth;
|
||||||
float anImageAndTitleWidth;
|
float anImageAndTitleWidth;
|
||||||
float aKeyEquivalentWidth;
|
float aKeyEquivalentWidth;
|
||||||
NSMenuItemCell *aCell = [_itemCells objectAtIndex: i];
|
NSMenuItemCell *aCell = [_itemCells objectAtIndex: i];
|
||||||
|
|
||||||
// State image area.
|
// State image area.
|
||||||
aStateImageWidth = [aCell stateImageWidth];
|
aStateImageWidth = [aCell stateImageWidth];
|
||||||
|
|
||||||
// Title and Image area.
|
// Title and Image area.
|
||||||
aTitleWidth = [aCell titleWidth];
|
aTitleWidth = [aCell titleWidth];
|
||||||
anImageWidth = [aCell imageWidth];
|
anImageWidth = [aCell imageWidth];
|
||||||
|
|
||||||
// Key equivalent area.
|
// Key equivalent area.
|
||||||
aKeyEquivalentWidth = [aCell keyEquivalentWidth];
|
aKeyEquivalentWidth = [aCell keyEquivalentWidth];
|
||||||
|
|
||||||
switch ([aCell imagePosition])
|
switch ([aCell imagePosition])
|
||||||
{
|
{
|
||||||
case NSNoImage:
|
case NSNoImage:
|
||||||
anImageAndTitleWidth = aTitleWidth;
|
anImageAndTitleWidth = aTitleWidth;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSImageOnly:
|
case NSImageOnly:
|
||||||
anImageAndTitleWidth = anImageWidth;
|
anImageAndTitleWidth = anImageWidth;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSImageLeft:
|
case NSImageLeft:
|
||||||
case NSImageRight:
|
case NSImageRight:
|
||||||
anImageAndTitleWidth
|
anImageAndTitleWidth
|
||||||
= anImageWidth + aTitleWidth + GSCellTextImageXDist;
|
= anImageWidth + aTitleWidth + GSCellTextImageXDist;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSImageBelow:
|
case NSImageBelow:
|
||||||
case NSImageAbove:
|
case NSImageAbove:
|
||||||
case NSImageOverlaps:
|
case NSImageOverlaps:
|
||||||
default:
|
default:
|
||||||
if (aTitleWidth > anImageWidth)
|
if (aTitleWidth > anImageWidth)
|
||||||
anImageAndTitleWidth = aTitleWidth;
|
anImageAndTitleWidth = aTitleWidth;
|
||||||
else
|
else
|
||||||
anImageAndTitleWidth = anImageWidth;
|
anImageAndTitleWidth = anImageWidth;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aStateImageWidth > neededStateImageWidth)
|
if (aStateImageWidth > neededStateImageWidth)
|
||||||
neededStateImageWidth = aStateImageWidth;
|
neededStateImageWidth = aStateImageWidth;
|
||||||
|
|
||||||
if (anImageAndTitleWidth > neededImageAndTitleWidth)
|
if (anImageAndTitleWidth > neededImageAndTitleWidth)
|
||||||
neededImageAndTitleWidth = anImageAndTitleWidth;
|
neededImageAndTitleWidth = anImageAndTitleWidth;
|
||||||
|
|
||||||
if (aKeyEquivalentWidth > neededKeyEquivalentWidth)
|
if (aKeyEquivalentWidth > neededKeyEquivalentWidth)
|
||||||
neededKeyEquivalentWidth = aKeyEquivalentWidth;
|
neededKeyEquivalentWidth = aKeyEquivalentWidth;
|
||||||
|
|
||||||
// Title view width less than item's left part width
|
// Title view width less than item's left part width
|
||||||
if ((anImageAndTitleWidth + aStateImageWidth)
|
if ((anImageAndTitleWidth + aStateImageWidth)
|
||||||
> neededImageAndTitleWidth)
|
> neededImageAndTitleWidth)
|
||||||
wideTitleView = 0;
|
wideTitleView = 0;
|
||||||
|
|
||||||
// Popup menu has only one item with nibble or arrow image
|
// Popup menu has only one item with nibble or arrow image
|
||||||
if (anImageWidth)
|
if (anImageWidth)
|
||||||
popupImageWidth = anImageWidth;
|
popupImageWidth = anImageWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache the needed widths.
|
// Cache the needed widths.
|
||||||
_stateImageWidth = neededStateImageWidth;
|
_stateImageWidth = neededStateImageWidth;
|
||||||
|
@ -777,59 +781,59 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
|
|
||||||
accumulatedOffset = _horizontalEdgePad;
|
accumulatedOffset = _horizontalEdgePad;
|
||||||
if (howMany)
|
if (howMany)
|
||||||
{
|
{
|
||||||
// Calculate the offsets and cache them.
|
// Calculate the offsets and cache them.
|
||||||
if (neededStateImageWidth)
|
if (neededStateImageWidth)
|
||||||
{
|
{
|
||||||
_stateImageOffset = accumulatedOffset;
|
_stateImageOffset = accumulatedOffset;
|
||||||
accumulatedOffset += neededStateImageWidth += _horizontalEdgePad;
|
accumulatedOffset += neededStateImageWidth += _horizontalEdgePad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (neededImageAndTitleWidth)
|
if (neededImageAndTitleWidth)
|
||||||
{
|
{
|
||||||
_imageAndTitleOffset = accumulatedOffset;
|
_imageAndTitleOffset = accumulatedOffset;
|
||||||
accumulatedOffset += neededImageAndTitleWidth;
|
accumulatedOffset += neededImageAndTitleWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wideTitleView)
|
if (wideTitleView)
|
||||||
{
|
{
|
||||||
_keyEqOffset = accumulatedOffset = neededImageAndTitleWidth
|
_keyEqOffset = accumulatedOffset = neededImageAndTitleWidth
|
||||||
+ (3 * _horizontalEdgePad);
|
+ (3 * _horizontalEdgePad);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_keyEqOffset = accumulatedOffset += (2 * _horizontalEdgePad);
|
_keyEqOffset = accumulatedOffset += (2 * _horizontalEdgePad);
|
||||||
}
|
}
|
||||||
accumulatedOffset += neededKeyEquivalentWidth + _horizontalEdgePad;
|
accumulatedOffset += neededKeyEquivalentWidth + _horizontalEdgePad;
|
||||||
|
|
||||||
if ([_attachedMenu supermenu] != nil && neededKeyEquivalentWidth < 8)
|
if ([_attachedMenu supermenu] != nil && neededKeyEquivalentWidth < 8)
|
||||||
{
|
{
|
||||||
accumulatedOffset += 8 - neededKeyEquivalentWidth;
|
accumulatedOffset += 8 - neededKeyEquivalentWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
accumulatedOffset += neededImageAndTitleWidth + 3 + 2;
|
accumulatedOffset += neededImageAndTitleWidth + 3 + 2;
|
||||||
if ([_attachedMenu supermenu] != nil)
|
if ([_attachedMenu supermenu] != nil)
|
||||||
accumulatedOffset += 15;
|
accumulatedOffset += 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate frame size.
|
// Calculate frame size.
|
||||||
if (![_attachedMenu _ownedByPopUp])
|
if (![_attachedMenu _ownedByPopUp])
|
||||||
{
|
{
|
||||||
// Add the border width: 1 for left, 2 for right sides
|
// Add the border width: 1 for left, 2 for right sides
|
||||||
_cellSize.width = accumulatedOffset + 3;
|
_cellSize.width = accumulatedOffset + 3;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_keyEqOffset = _cellSize.width - _keyEqWidth - popupImageWidth;
|
_keyEqOffset = _cellSize.width - _keyEqWidth - popupImageWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self setFrameSize: NSMakeSize(_cellSize.width + _leftBorderOffset,
|
[self setFrameSize: NSMakeSize(_cellSize.width + _leftBorderOffset,
|
||||||
(howMany * _cellSize.height)
|
(howMany * _cellSize.height)
|
||||||
+ menuBarHeight)];
|
+ menuBarHeight)];
|
||||||
[_titleView setFrame: NSMakeRect (0, howMany * _cellSize.height,
|
[_titleView setFrame: NSMakeRect (0, howMany * _cellSize.height,
|
||||||
NSWidth (_bounds), menuBarHeight)];
|
NSWidth (_bounds), menuBarHeight)];
|
||||||
}
|
}
|
||||||
_needsSizing = NO;
|
_needsSizing = NO;
|
||||||
}
|
}
|
||||||
|
@ -887,16 +891,16 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
if (_horizontal == NO)
|
if (_horizontal == NO)
|
||||||
{
|
{
|
||||||
return NSMakeRect (_bounds.origin.x + _leftBorderOffset,
|
return NSMakeRect (_bounds.origin.x + _leftBorderOffset,
|
||||||
_bounds.origin.y,
|
_bounds.origin.y,
|
||||||
_bounds.size.width - _leftBorderOffset,
|
_bounds.size.width - _leftBorderOffset,
|
||||||
_bounds.size.height);
|
_bounds.size.height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return NSMakeRect (_bounds.origin.x,
|
return NSMakeRect (_bounds.origin.x,
|
||||||
_bounds.origin.y + _leftBorderOffset,
|
_bounds.origin.y + _leftBorderOffset,
|
||||||
_bounds.size.width,
|
_bounds.size.width,
|
||||||
_bounds.size.height - _leftBorderOffset);
|
_bounds.size.height - _leftBorderOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -975,41 +979,41 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
if (_horizontal == NO)
|
if (_horizontal == NO)
|
||||||
{
|
{
|
||||||
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle",
|
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle",
|
||||||
[aSubmenu menuRepresentation])
|
[aSubmenu menuRepresentation])
|
||||||
== GSWindowMakerInterfaceStyle)
|
== GSWindowMakerInterfaceStyle)
|
||||||
{
|
{
|
||||||
NSRect aRect = [self rectOfItemAtIndex:
|
NSRect aRect = [self rectOfItemAtIndex:
|
||||||
[_attachedMenu indexOfItemWithSubmenu: aSubmenu]];
|
|
||||||
NSPoint subOrigin = [_window convertBaseToScreen:
|
|
||||||
NSMakePoint(aRect.origin.x, aRect.origin.y)];
|
|
||||||
|
|
||||||
return NSMakePoint (NSMaxX(frame),
|
|
||||||
subOrigin.y - NSHeight(submenuFrame) - 3 +
|
|
||||||
2*[NSMenuView menuBarHeight]);
|
|
||||||
}
|
|
||||||
else if ([self _rootIsHorizontal: 0] == YES)
|
|
||||||
{
|
|
||||||
NSRect aRect = [self rectOfItemAtIndex:
|
|
||||||
[_attachedMenu indexOfItemWithSubmenu: aSubmenu]];
|
[_attachedMenu indexOfItemWithSubmenu: aSubmenu]];
|
||||||
NSPoint subOrigin = [_window convertBaseToScreen:
|
NSPoint subOrigin = [_window convertBaseToScreen:
|
||||||
|
NSMakePoint(aRect.origin.x, aRect.origin.y)];
|
||||||
|
|
||||||
|
return NSMakePoint (NSMaxX(frame),
|
||||||
|
subOrigin.y - NSHeight(submenuFrame) - 3 +
|
||||||
|
2*[NSMenuView menuBarHeight]);
|
||||||
|
}
|
||||||
|
else if ([self _rootIsHorizontal: 0] == YES)
|
||||||
|
{
|
||||||
|
NSRect aRect = [self rectOfItemAtIndex:
|
||||||
|
[_attachedMenu indexOfItemWithSubmenu: aSubmenu]];
|
||||||
|
NSPoint subOrigin = [_window convertBaseToScreen:
|
||||||
NSMakePoint(aRect.origin.x, aRect.origin.y)];
|
NSMakePoint(aRect.origin.x, aRect.origin.y)];
|
||||||
// FIXME ... why is the offset +1 needed below?
|
// FIXME ... why is the offset +1 needed below?
|
||||||
return NSMakePoint (NSMaxX(frame),
|
return NSMakePoint (NSMaxX(frame),
|
||||||
subOrigin.y - NSHeight(submenuFrame) + aRect.size.height + 1);
|
subOrigin.y - NSHeight(submenuFrame) + aRect.size.height + 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return NSMakePoint(NSMaxX(frame),
|
return NSMakePoint(NSMaxX(frame),
|
||||||
NSMaxY(frame) - NSHeight(submenuFrame));
|
NSMaxY(frame) - NSHeight(submenuFrame));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSRect aRect = [self rectOfItemAtIndex:
|
NSRect aRect = [self rectOfItemAtIndex:
|
||||||
[_attachedMenu indexOfItemWithSubmenu: aSubmenu]];
|
[_attachedMenu indexOfItemWithSubmenu: aSubmenu]];
|
||||||
NSPoint subOrigin = [_window convertBaseToScreen:
|
NSPoint subOrigin = [_window convertBaseToScreen:
|
||||||
NSMakePoint(NSMinX(aRect),
|
NSMakePoint(NSMinX(aRect),
|
||||||
NSMinY(aRect))];
|
NSMinY(aRect))];
|
||||||
|
|
||||||
return NSMakePoint(subOrigin.x, subOrigin.y - NSHeight(submenuFrame));
|
return NSMakePoint(subOrigin.x, subOrigin.y - NSHeight(submenuFrame));
|
||||||
}
|
}
|
||||||
|
@ -1087,11 +1091,11 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
}
|
}
|
||||||
else if (edge == NSMaxYEdge)
|
else if (edge == NSMaxYEdge)
|
||||||
{
|
{
|
||||||
screenFrame.origin.y += screenRect.size.height;
|
screenFrame.origin.y += screenRect.size.height;
|
||||||
}
|
}
|
||||||
else if (edge == NSMaxXEdge)
|
else if (edge == NSMaxXEdge)
|
||||||
{
|
{
|
||||||
screenFrame.origin.x += screenRect.size.width;
|
screenFrame.origin.x += screenRect.size.width;
|
||||||
}
|
}
|
||||||
else if (edge == NSMinXEdge)
|
else if (edge == NSMinXEdge)
|
||||||
{
|
{
|
||||||
|
@ -1138,8 +1142,8 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
// Draw the menu cells.
|
// Draw the menu cells.
|
||||||
for (i = 0; i < howMany; i++)
|
for (i = 0; i < howMany; i++)
|
||||||
{
|
{
|
||||||
NSRect aRect;
|
NSRect aRect;
|
||||||
NSMenuItemCell *aCell;
|
NSMenuItemCell *aCell;
|
||||||
|
|
||||||
aRect = [self rectOfItemAtIndex: i];
|
aRect = [self rectOfItemAtIndex: i];
|
||||||
if (NSIntersectsRect(rect, aRect) == YES)
|
if (NSIntersectsRect(rect, aRect) == YES)
|
||||||
|
@ -1178,7 +1182,7 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
candidateMenu = superMenu;
|
candidateMenu = superMenu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
oldHighlightedIndex = [targetMenuView highlightedItemIndex];
|
oldHighlightedIndex = [targetMenuView highlightedItemIndex];
|
||||||
[targetMenuView setHighlightedItemIndex: indexToHighlight];
|
[targetMenuView setHighlightedItemIndex: indexToHighlight];
|
||||||
|
|
||||||
|
@ -1201,18 +1205,18 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
|
|
||||||
- (BOOL) trackWithEvent: (NSEvent*)event
|
- (BOOL) trackWithEvent: (NSEvent*)event
|
||||||
{
|
{
|
||||||
unsigned eventMask = NSPeriodicMask;
|
unsigned eventMask = NSPeriodicMask;
|
||||||
NSDate *theDistantFuture = [NSDate distantFuture];
|
NSDate *theDistantFuture = [NSDate distantFuture];
|
||||||
NSPoint lastLocation = {0,0};
|
NSPoint lastLocation = {0,0};
|
||||||
BOOL justAttachedNewSubmenu = NO;
|
BOOL justAttachedNewSubmenu = NO;
|
||||||
BOOL subMenusNeedRemoving = YES;
|
BOOL subMenusNeedRemoving = YES;
|
||||||
BOOL shouldFinish = YES;
|
BOOL shouldFinish = YES;
|
||||||
int delayCount = 0;
|
int delayCount = 0;
|
||||||
int indexOfActionToExecute = -1;
|
int indexOfActionToExecute = -1;
|
||||||
int firstIndex = -1;
|
int firstIndex = -1;
|
||||||
NSEvent *original;
|
NSEvent *original;
|
||||||
NSEventType type;
|
NSEventType type;
|
||||||
NSEventType end;
|
NSEventType end;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The original event is unused except to determine whether the method
|
* The original event is unused except to determine whether the method
|
||||||
|
@ -1261,24 +1265,24 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
{
|
{
|
||||||
if (type == end)
|
if (type == end)
|
||||||
{
|
{
|
||||||
shouldFinish = YES;
|
shouldFinish = YES;
|
||||||
}
|
}
|
||||||
if (type == NSPeriodic || event == original)
|
if (type == NSPeriodic || event == original)
|
||||||
{
|
{
|
||||||
NSPoint location;
|
NSPoint location;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
location = [_window mouseLocationOutsideOfEventStream];
|
location = [_window mouseLocationOutsideOfEventStream];
|
||||||
index = [self indexOfItemAtPoint: location];
|
index = [self indexOfItemAtPoint: location];
|
||||||
|
|
||||||
if (event == original)
|
if (event == original)
|
||||||
{
|
{
|
||||||
firstIndex = index;
|
firstIndex = index;
|
||||||
}
|
}
|
||||||
if (index != firstIndex)
|
if (index != firstIndex)
|
||||||
{
|
{
|
||||||
shouldFinish = YES;
|
shouldFinish = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 1 - if menus is only partly visible and the mouse is at the
|
* 1 - if menus is only partly visible and the mouse is at the
|
||||||
|
@ -1293,8 +1297,8 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
* GNUstep screen coordinates start with 1.
|
* GNUstep screen coordinates start with 1.
|
||||||
*/
|
*/
|
||||||
if (pointerLoc.x == 0 || pointerLoc.y == 1
|
if (pointerLoc.x == 0 || pointerLoc.y == 1
|
||||||
|| pointerLoc.x == [[_window screen] frame].size.width - 1
|
|| pointerLoc.x == [[_window screen] frame].size.width - 1
|
||||||
|| pointerLoc.y == [[_window screen] frame].size.height)
|
|| pointerLoc.y == [[_window screen] frame].size.height)
|
||||||
[_attachedMenu shiftOnScreen];
|
[_attachedMenu shiftOnScreen];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1304,7 +1308,7 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
* flag to NO.
|
* flag to NO.
|
||||||
*/
|
*/
|
||||||
if (justAttachedNewSubmenu && index != -1
|
if (justAttachedNewSubmenu && index != -1
|
||||||
&& index != _highlightedItemIndex)
|
&& index != _highlightedItemIndex)
|
||||||
{
|
{
|
||||||
if (location.x - lastLocation.x > MOVE_THRESHOLD_DELTA)
|
if (location.x - lastLocation.x > MOVE_THRESHOLD_DELTA)
|
||||||
{
|
{
|
||||||
|
@ -1324,9 +1328,9 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
// 3 - If we have moved outside this menu, take appropriate action
|
// 3 - If we have moved outside this menu, take appropriate action
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
{
|
{
|
||||||
NSPoint locationInScreenCoordinates;
|
NSPoint locationInScreenCoordinates;
|
||||||
NSWindow *windowUnderMouse;
|
NSWindow *windowUnderMouse;
|
||||||
NSMenu *candidateMenu;
|
NSMenu *candidateMenu;
|
||||||
|
|
||||||
subMenusNeedRemoving = NO;
|
subMenusNeedRemoving = NO;
|
||||||
|
|
||||||
|
@ -1343,24 +1347,24 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
*/
|
*/
|
||||||
candidateMenu = [_attachedMenu supermenu];
|
candidateMenu = [_attachedMenu supermenu];
|
||||||
while (candidateMenu
|
while (candidateMenu
|
||||||
&& !NSMouseInRect (locationInScreenCoordinates,
|
&& !NSMouseInRect (locationInScreenCoordinates,
|
||||||
[[candidateMenu window] frame], NO) // not found yet
|
[[candidateMenu window] frame], NO) // not found yet
|
||||||
&& (! ([candidateMenu isTornOff]
|
&& (! ([candidateMenu isTornOff]
|
||||||
&& ![candidateMenu isTransient])) // no root of display tree
|
&& ![candidateMenu isTransient])) // no root of display tree
|
||||||
&& [candidateMenu isAttached]) // has displayed parent
|
&& [candidateMenu isAttached]) // has displayed parent
|
||||||
{
|
{
|
||||||
candidateMenu = [candidateMenu supermenu];
|
candidateMenu = [candidateMenu supermenu];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (candidateMenu != nil
|
if (candidateMenu != nil
|
||||||
&& NSMouseInRect (locationInScreenCoordinates,
|
&& NSMouseInRect (locationInScreenCoordinates,
|
||||||
[[candidateMenu window] frame], NO))
|
[[candidateMenu window] frame], NO))
|
||||||
{
|
{
|
||||||
BOOL candidateMenuResult;
|
BOOL candidateMenuResult;
|
||||||
|
|
||||||
// The call to fetch attachedMenu is not needed. But putting
|
// The call to fetch attachedMenu is not needed. But putting
|
||||||
// it here avoids flicker when we go back to an ancestor
|
// it here avoids flicker when we go back to an ancestor
|
||||||
// menu and the attached menu is already correct.
|
// menu and the attached menu is already correct.
|
||||||
[[[candidateMenu attachedMenu] menuRepresentation]
|
[[[candidateMenu attachedMenu] menuRepresentation]
|
||||||
detachSubmenu];
|
detachSubmenu];
|
||||||
|
|
||||||
|
@ -1372,14 +1376,14 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
|
|
||||||
candidateMenuResult = [[candidateMenu menuRepresentation]
|
candidateMenuResult = [[candidateMenu menuRepresentation]
|
||||||
trackWithEvent: original];
|
trackWithEvent: original];
|
||||||
return candidateMenuResult;
|
return candidateMenuResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3b - Check if we enter the attached submenu
|
// 3b - Check if we enter the attached submenu
|
||||||
windowUnderMouse = [[_attachedMenu attachedMenu] window];
|
windowUnderMouse = [[_attachedMenu attachedMenu] window];
|
||||||
if (windowUnderMouse != nil
|
if (windowUnderMouse != nil
|
||||||
&& NSMouseInRect (locationInScreenCoordinates,
|
&& NSMouseInRect (locationInScreenCoordinates,
|
||||||
[windowUnderMouse frame], NO))
|
[windowUnderMouse frame], NO))
|
||||||
{
|
{
|
||||||
BOOL wasTransient = [_attachedMenu isTransient];
|
BOOL wasTransient = [_attachedMenu isTransient];
|
||||||
BOOL subMenuResult;
|
BOOL subMenuResult;
|
||||||
|
@ -1387,7 +1391,7 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
subMenuResult
|
subMenuResult
|
||||||
= [[self attachedMenuView] trackWithEvent: original];
|
= [[self attachedMenuView] trackWithEvent: original];
|
||||||
if (subMenuResult
|
if (subMenuResult
|
||||||
&& wasTransient == [_attachedMenu isTransient])
|
&& wasTransient == [_attachedMenu isTransient])
|
||||||
{
|
{
|
||||||
[self detachSubmenu];
|
[self detachSubmenu];
|
||||||
}
|
}
|
||||||
|
@ -1491,15 +1495,15 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
{
|
{
|
||||||
#if 1
|
#if 1
|
||||||
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", self)
|
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", self)
|
||||||
== NSMacintoshInterfaceStyle)
|
== NSMacintoshInterfaceStyle)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* FIXME ... always remove submenus in mac mode ... this is not
|
* FIXME ... always remove submenus in mac mode ... this is not
|
||||||
* quite the way the mac behaves, but it's closer than the normal
|
* quite the way the mac behaves, but it's closer than the normal
|
||||||
* behavior.
|
* behavior.
|
||||||
*/
|
*/
|
||||||
subMenusNeedRemoving = YES;
|
subMenusNeedRemoving = YES;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (subMenusNeedRemoving)
|
if (subMenusNeedRemoving)
|
||||||
{
|
{
|
||||||
|
@ -1512,16 +1516,16 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", self)
|
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", self)
|
||||||
== NSMacintoshInterfaceStyle)
|
== NSMacintoshInterfaceStyle)
|
||||||
{
|
{
|
||||||
NSMenu *tmp = _attachedMenu;
|
NSMenu *tmp = _attachedMenu;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if ([tmp isEqual: [NSApp mainMenu]] == NO)
|
if ([tmp isEqual: [NSApp mainMenu]] == NO)
|
||||||
{
|
{
|
||||||
[tmp close];
|
[tmp close];
|
||||||
}
|
}
|
||||||
tmp = [tmp supermenu];
|
tmp = [tmp supermenu];
|
||||||
}
|
}
|
||||||
while (tmp != nil);
|
while (tmp != nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1542,20 +1546,20 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This method is called when the user clicks on a button in the menu.
|
This method is called when the user clicks on a button in the menu.
|
||||||
Or, if a right click happens and the app menu is brought up.
|
Or, if a right click happens and the app menu is brought up.
|
||||||
|
|
||||||
The original position is stored, so we can restore the position of menu.
|
The original position is stored, so we can restore the position of menu.
|
||||||
The position of the menu can change during the event tracking because
|
The position of the menu can change during the event tracking because
|
||||||
the menu will automatillay move when parts are outside the screen and
|
the menu will automatillay move when parts are outside the screen and
|
||||||
the user move the mouse pointer to the edge of the screen.
|
the user move the mouse pointer to the edge of the screen.
|
||||||
*/
|
*/
|
||||||
- (void) mouseDown: (NSEvent*)theEvent
|
- (void) mouseDown: (NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
NSRect currentFrame;
|
NSRect currentFrame;
|
||||||
NSRect originalFrame;
|
NSRect originalFrame;
|
||||||
NSPoint currentTopLeft;
|
NSPoint currentTopLeft;
|
||||||
NSPoint originalTopLeft = NSZeroPoint; /* Silence compiler. */
|
NSPoint originalTopLeft = NSZeroPoint; /* Silence compiler. */
|
||||||
BOOL restorePosition;
|
BOOL restorePosition;
|
||||||
/*
|
/*
|
||||||
* Only for non transient menus do we want
|
* Only for non transient menus do we want
|
||||||
* to remember the position.
|
* to remember the position.
|
||||||
|
@ -1581,7 +1585,7 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
|
|
||||||
if (NSEqualPoints(currentTopLeft, originalTopLeft) == NO)
|
if (NSEqualPoints(currentTopLeft, originalTopLeft) == NO)
|
||||||
{
|
{
|
||||||
NSPoint origin = currentFrame.origin;
|
NSPoint origin = currentFrame.origin;
|
||||||
|
|
||||||
origin.x += (originalTopLeft.x - currentTopLeft.x);
|
origin.x += (originalTopLeft.x - currentTopLeft.x);
|
||||||
origin.y += (originalTopLeft.y - currentTopLeft.y);
|
origin.y += (originalTopLeft.y - currentTopLeft.y);
|
||||||
|
@ -1623,12 +1627,15 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
- (id) initWithCoder: (NSCoder*)decoder
|
- (id) initWithCoder: (NSCoder*)decoder
|
||||||
{
|
{
|
||||||
self = [super initWithCoder: decoder];
|
self = [super initWithCoder: decoder];
|
||||||
|
if (!self)
|
||||||
|
return nil;
|
||||||
|
|
||||||
if ([decoder allowsKeyedCoding] == NO)
|
if ([decoder allowsKeyedCoding] == NO)
|
||||||
{
|
{
|
||||||
[decoder decodeValueOfObjCType: @encode(id) at: &_itemCells];
|
[decoder decodeValueOfObjCType: @encode(id) at: &_itemCells];
|
||||||
|
|
||||||
[_itemCells makeObjectsPerformSelector: @selector(setMenuView:)
|
[_itemCells makeObjectsPerformSelector: @selector(setMenuView:)
|
||||||
withObject: self];
|
withObject: self];
|
||||||
|
|
||||||
[decoder decodeValueOfObjCType: @encode(id) at: &_font];
|
[decoder decodeValueOfObjCType: @encode(id) at: &_font];
|
||||||
[decoder decodeValueOfObjCType: @encode(BOOL) at: &_horizontal];
|
[decoder decodeValueOfObjCType: @encode(BOOL) at: &_horizontal];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue