mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-14 22:51:28 +00:00
Fix for a few edge cases, and added showsStateColumn support to nib2cib.
Reviewed by me.
This commit is contained in:
+14
-7
@@ -64,6 +64,8 @@ var _CPMenuBarVisible = NO,
|
||||
CPString _title;
|
||||
CPString _name;
|
||||
|
||||
CPFont _font;
|
||||
|
||||
float _minimumWidth;
|
||||
|
||||
CPMutableArray _items;
|
||||
@@ -687,11 +689,6 @@ var _CPMenuBarVisible = NO,
|
||||
if (aView && !theWindow)
|
||||
throw "In call to popUpMenuPositioningItem:atLocation:inView:callback:, view is not in any window.";
|
||||
|
||||
var aFont = nil;
|
||||
|
||||
if (!aFont)
|
||||
aFont = [CPFont systemFontOfSize:12.0];
|
||||
|
||||
var delegate = [self delegate];
|
||||
|
||||
if ([delegate respondsToSelector:@selector(menuWillOpen:)])
|
||||
@@ -702,14 +699,14 @@ var _CPMenuBarVisible = NO,
|
||||
aLocation = [theWindow convertBaseToGlobal:[aView convertPoint:aLocation toView:nil]];
|
||||
|
||||
// Create the window for our menu.
|
||||
var menuWindow = [_CPMenuWindow menuWindowWithMenu:self font:aFont];
|
||||
var menuWindow = [_CPMenuWindow menuWindowWithMenu:self font:[self font]];
|
||||
|
||||
[menuWindow setBackgroundStyle:_CPMenuWindowPopUpBackgroundStyle];
|
||||
|
||||
if (anItem)
|
||||
// Don't convert this value to global, we care about the distance (delta) from the
|
||||
// the edge of the window, which is equivalent to its origin.
|
||||
aLocation.y -= [menuWindow rectForItemAtIndex:itemIndex].origin.y;
|
||||
aLocation.y -= [menuWindow deltaYForItemAtIndex:itemIndex];
|
||||
|
||||
// Grab the constraint rect for this view.
|
||||
var constraintRect = [CPMenu _constraintRectForView:aView];
|
||||
@@ -881,6 +878,16 @@ var _CPMenuBarVisible = NO,
|
||||
_menuWindow = aMenuWindow;
|
||||
}
|
||||
|
||||
- (void)setFont:(CPFont)aFont
|
||||
{
|
||||
_font = aFont;
|
||||
}
|
||||
|
||||
- (CPFont)font
|
||||
{
|
||||
return _font;
|
||||
}
|
||||
|
||||
/*!
|
||||
Initiates the action of the menu item that
|
||||
has a keyboard shortcut equivalent to \c anEvent
|
||||
|
||||
@@ -395,6 +395,11 @@ var STICKY_TIME_INTERVAL = 500,
|
||||
return _CPMenuManagerScrollingStateNone;
|
||||
}
|
||||
|
||||
- (float)deltaYForItemAtIndex:(int)anIndex
|
||||
{
|
||||
return TOP_MARGIN + CGRectGetMinY([_menuView rectForItemAtIndex:anIndex]);
|
||||
}
|
||||
|
||||
- (CGPoint)rectForItemAtIndex:(int)anIndex
|
||||
{
|
||||
return [_menuView convertRect:[_menuView rectForItemAtIndex:anIndex] toView:nil];
|
||||
|
||||
@@ -645,6 +645,9 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
|
||||
bounds = [self bounds],
|
||||
minimumWidth = CGRectGetWidth(bounds);
|
||||
|
||||
// FIXME: setFont: should set the font on the menu.
|
||||
[menu setFont:[self font]];
|
||||
|
||||
if ([self pullsDown])
|
||||
{
|
||||
var positionedItem = nil,
|
||||
|
||||
@@ -880,6 +880,8 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
|
||||
// We should pay attention to mouse down and mouse up in conjunction with this.
|
||||
//window.liveResize = YES;
|
||||
|
||||
[CPApp._activeMenu cancelTracking];
|
||||
|
||||
var oldSize = [self contentRect].size;
|
||||
|
||||
[self updateFromNativeContentRect];
|
||||
|
||||
@@ -53,8 +53,7 @@ NS_CPMenuNameMap =
|
||||
if (mappedName)
|
||||
_name = mappedName;
|
||||
|
||||
_showsStateColumn = YES;
|
||||
//_showsStateColumn = ![aCoder containsValueForKey:@"NSMenuExcludeMarkColumn"] || ![aCoder decodeBoolForKey:@"NSMenuExcludeMarkColumn"];
|
||||
_showsStateColumn = ![aCoder containsValueForKey:@"NSMenuExcludeMarkColumn"] || ![aCoder decodeBoolForKey:@"NSMenuExcludeMarkColumn"];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
Reference in New Issue
Block a user