From 67658876d592bd6a29a0826db1f8d6896073ebba Mon Sep 17 00:00:00 2001 From: Nicholas Small Date: Sun, 4 Jan 2009 14:02:34 +0800 Subject: [PATCH 1/7] Added menu item separators and a + menuBarHeight Signed-off-by: 280north --- AppKit/CPMenu.j | 12 ++++++++++++ AppKit/CPMenuItem.j | 14 +++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/AppKit/CPMenu.j b/AppKit/CPMenu.j index 1179ef946..a200720fd 100644 --- a/AppKit/CPMenu.j +++ b/AppKit/CPMenu.j @@ -179,6 +179,14 @@ var _CPMenuBarVisible = NO, return 0.0; } ++ (float)menuBarHeight +{ + if ([self menuBarVisible]) + return MENUBAR_HEIGHT; + + return 0.0; +} + // Creating a CPMenu Object /*! Initializes the menu with a specified title. @@ -998,6 +1006,10 @@ var STICKY_TIME_INTERVAL = 500, [self setFrameSize:CGSizeMake(LEFT_MARGIN + menuViewSize.width + RIGHT_MARGIN, TOP_MARGIN + menuViewSize.height + BOTTOM_MARGIN)]; + for(var i = 0; i < [aMenu numberOfItems]; i++) + if([[aMenu itemAtIndex:i] isSeparatorItem]) + [[[aMenu itemAtIndex:i] view] setFrameSize:CPSizeMake(menuViewSize.width, 20.0)]; + [_menuView scrollPoint:CGPointMake(0.0, 0.0)]; [_menuClipView setFrame:CGRectMake(LEFT_MARGIN, TOP_MARGIN, menuViewSize.width, menuViewSize.height)]; } diff --git a/AppKit/CPMenuItem.j b/AppKit/CPMenuItem.j index 543f2ca46..9942d1cb0 100644 --- a/AppKit/CPMenuItem.j +++ b/AppKit/CPMenuItem.j @@ -727,7 +727,19 @@ CPControlKeyMask - (id)init { - return [super initWithTitle:@"" action:nil keyEquivalent:@""]; + self = [super initWithTitle:@"" action:nil keyEquivalent:nil]; + + if(self) + { + var view = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 20.0)], + line = [[CPView alloc] initWithFrame:CGRectMake(0.0, 8.0, 1000.0, 1.3)]; + [line setBackgroundColor:[CPColor lightGrayColor]]; + [view addSubview:line]; + + [self setView:view]; + } + + return self; } - (BOOL)isSeparatorItem From 78503a9380be6b8fd762980a883fbc30e114b4d9 Mon Sep 17 00:00:00 2001 From: Nicholas Small Date: Sun, 4 Jan 2009 14:19:04 +0800 Subject: [PATCH 2/7] Fix for disabled menu items still highlighting Signed-off-by: 280north --- AppKit/CPMenuItem.j | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/AppKit/CPMenuItem.j b/AppKit/CPMenuItem.j index 9942d1cb0..bd76f43f3 100644 --- a/AppKit/CPMenuItem.j +++ b/AppKit/CPMenuItem.j @@ -1066,23 +1066,26 @@ var _CPMenuItemSelectionColor = nil, else { - [_imageAndTitleView setTextColor:shouldHighlight ? [CPColor whiteColor] : [self textColor]]; - - if (shouldHighlight) - [self setBackgroundColor:_CPMenuItemSelectionColor]; - else - [self setBackgroundColor:nil]; - - var state = [_menuItem state]; - - switch (state) + if([_menuItem isEnabled]) { - case CPOffState: - case CPOnState: - case CPMixedState: [_stateView setImage:shouldHighlight ? _CPMenuItemDefaultStateHighlightedImages[state] : _CPMenuItemDefaultStateImages[state]]; + [_imageAndTitleView setTextColor:shouldHighlight ? [CPColor whiteColor] : [self textColor]]; + + if (shouldHighlight) + [self setBackgroundColor:_CPMenuItemSelectionColor]; + else + [self setBackgroundColor:nil]; + + var state = [_menuItem state]; + + switch (state) + { + case CPOffState: + case CPOnState: + case CPMixedState: [_stateView setImage:shouldHighlight ? _CPMenuItemDefaultStateHighlightedImages[state] : _CPMenuItemDefaultStateImages[state]]; break; - default: [_stateView setImage:nil]; + default: [_stateView setImage:nil]; + } } } } From 0a8b08ebec8a3dcda1ed5e07c75a628f86240605 Mon Sep 17 00:00:00 2001 From: Nicholas Small Date: Sun, 4 Jan 2009 14:40:14 +0800 Subject: [PATCH 3/7] Fix for flash view transparency Signed-off-by: 280north --- AppKit/CPFlashView.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPFlashView.j b/AppKit/CPFlashView.j index f1cfa724b..1df332902 100644 --- a/AppKit/CPFlashView.j +++ b/AppKit/CPFlashView.j @@ -61,7 +61,7 @@ _DOMEmbedElement = document.createElement("embed"); _DOMEmbedElement.type = "application/x-shockwave-flash"; - _DOMEmbedElement.wmode = "transparent"; + _DOMEmbedElement.setAttribute("wmode", "transparent"); _DOMEmbedElement.width = "100%"; _DOMEmbedElement.height = "100%"; From 08ba49ed4668cea15708b200859bdadcf7afa9db Mon Sep 17 00:00:00 2001 From: Nicholas Small Date: Sun, 4 Jan 2009 15:31:26 +0800 Subject: [PATCH 4/7] Updated all blank key equivalents to nil, which works now Signed-off-by: 280north --- AppKit/CPApplication.j | 6 +++--- AppKit/CPPopUpButton.j | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/AppKit/CPApplication.j b/AppKit/CPApplication.j index 399b272f5..5b79154c3 100644 --- a/AppKit/CPApplication.j +++ b/AppKit/CPApplication.j @@ -135,19 +135,19 @@ CPRunContinuesResponse = -1002; [_mainMenu addItem:openMenuItem]; var saveMenu = [[CPMenu alloc] initWithTitle:@"Save"], - saveMenuItem = [[CPMenuItem alloc] initWithTitle:@"Save" action:@selector(saveDocument:) keyEquivalent:@""]; + saveMenuItem = [[CPMenuItem alloc] initWithTitle:@"Save" action:@selector(saveDocument:) keyEquivalent:nil]; [saveMenuItem setImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPApplication/Save.png"] size:CGSizeMake(16.0, 16.0)]]; [saveMenuItem setAlternateImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPApplication/SaveHighlighted.png"] size:CGSizeMake(16.0, 16.0)]]; [saveMenu addItem:[[CPMenuItem alloc] initWithTitle:@"Save" action:@selector(saveDocument:) keyEquivalent:@"S"]]; - [saveMenu addItem:[[CPMenuItem alloc] initWithTitle:@"Save As" action:@selector(saveDocumentAs:) keyEquivalent:@""]]; + [saveMenu addItem:[[CPMenuItem alloc] initWithTitle:@"Save As" action:@selector(saveDocumentAs:) keyEquivalent:nil]]; [saveMenuItem setSubmenu:saveMenu]; [_mainMenu addItem:saveMenuItem]; - var editMenuItem = [[CPMenuItem alloc] initWithTitle:@"Edit" action:nil keyEquivalent:@""], + var editMenuItem = [[CPMenuItem alloc] initWithTitle:@"Edit" action:nil keyEquivalent:nil], editMenu = [[CPMenu alloc] initWithTitle:@"Edit"], undoMenuItem = [[CPMenuItem alloc] initWithTitle:@"Undo" action:@selector(undo:) keyEquivalent:CPUndoKeyEquivalent], diff --git a/AppKit/CPPopUpButton.j b/AppKit/CPPopUpButton.j index 32eabce09..3721a29de 100644 --- a/AppKit/CPPopUpButton.j +++ b/AppKit/CPPopUpButton.j @@ -143,7 +143,7 @@ var CPPopUpButtonArrowsImage = nil; */ - (void)addItemWithTitle:(CPString)aTitle { - [_menu addItemWithTitle:aTitle action:NULL keyEquivalent:NULL]; + [_menu addItemWithTitle:aTitle action:NULL keyEquivalent:nil]; } /*! @@ -173,7 +173,7 @@ var CPPopUpButtonArrowsImage = nil; if ([items[count] title] == aTitle) [self removeItemAtIndex:count]; - [_menu insertItemWithTitle:aTitle action:NULL keyEquivalent:NULL atIndex:anIndex]; + [_menu insertItemWithTitle:aTitle action:NULL keyEquivalent:nil atIndex:anIndex]; } /*! From 899db8fe0b15f98b8c2660ec203164e747b45a14 Mon Sep 17 00:00:00 2001 From: Nicholas Small Date: Sun, 4 Jan 2009 16:44:39 +0800 Subject: [PATCH 5/7] Fix for disabled menu items still firing actions Signed-off-by: 280north --- AppKit/CPMenu.j | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AppKit/CPMenu.j b/AppKit/CPMenu.j index a200720fd..399a0463f 100644 --- a/AppKit/CPMenu.j +++ b/AppKit/CPMenu.j @@ -651,7 +651,8 @@ var _CPMenuBarVisible = NO, else target = [aMenuItem target]; - [CPApp sendAction:action to:target from:nil]; + if([aMenuItem isEnabled]) + [CPApp sendAction:action to:target from:nil]; } // Managing Display of State Column From 3235cfd288bc13f6d364a2f822025847d9ad166b Mon Sep 17 00:00:00 2001 From: Nicholas Small Date: Sun, 4 Jan 2009 18:37:31 +0800 Subject: [PATCH 6/7] Few fixes for previous menu commits Signed-off-by: 280north --- AppKit/CPMenu.j | 9 +-------- AppKit/CPMenuItem.j | 1 + 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/AppKit/CPMenu.j b/AppKit/CPMenu.j index 399a0463f..ce1b07f9e 100644 --- a/AppKit/CPMenu.j +++ b/AppKit/CPMenu.j @@ -181,10 +181,7 @@ var _CPMenuBarVisible = NO, + (float)menuBarHeight { - if ([self menuBarVisible]) - return MENUBAR_HEIGHT; - - return 0.0; + return MENUBAR_HEIGHT; } // Creating a CPMenu Object @@ -1007,10 +1004,6 @@ var STICKY_TIME_INTERVAL = 500, [self setFrameSize:CGSizeMake(LEFT_MARGIN + menuViewSize.width + RIGHT_MARGIN, TOP_MARGIN + menuViewSize.height + BOTTOM_MARGIN)]; - for(var i = 0; i < [aMenu numberOfItems]; i++) - if([[aMenu itemAtIndex:i] isSeparatorItem]) - [[[aMenu itemAtIndex:i] view] setFrameSize:CPSizeMake(menuViewSize.width, 20.0)]; - [_menuView scrollPoint:CGPointMake(0.0, 0.0)]; [_menuClipView setFrame:CGRectMake(LEFT_MARGIN, TOP_MARGIN, menuViewSize.width, menuViewSize.height)]; } diff --git a/AppKit/CPMenuItem.j b/AppKit/CPMenuItem.j index bd76f43f3..5caa9352a 100644 --- a/AppKit/CPMenuItem.j +++ b/AppKit/CPMenuItem.j @@ -734,6 +734,7 @@ CPControlKeyMask var view = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 20.0)], line = [[CPView alloc] initWithFrame:CGRectMake(0.0, 8.0, 1000.0, 1.3)]; [line setBackgroundColor:[CPColor lightGrayColor]]; + [view setAutoresizingMask:CPViewWidthSizable]; [view addSubview:line]; [self setView:view]; From 78b84be3fdc28f1969f531a6643c96170d6cbcf6 Mon Sep 17 00:00:00 2001 From: nciagra Date: Mon, 5 Jan 2009 05:28:09 +0800 Subject: [PATCH 7/7] Further fixes for separator items Signed-off-by: 280north --- AppKit/CPMenuItem.j | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/AppKit/CPMenuItem.j b/AppKit/CPMenuItem.j index 5caa9352a..bf0656946 100644 --- a/AppKit/CPMenuItem.j +++ b/AppKit/CPMenuItem.j @@ -729,15 +729,9 @@ CPControlKeyMask { self = [super initWithTitle:@"" action:nil keyEquivalent:nil]; - if(self) + if (self) { - var view = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 20.0)], - line = [[CPView alloc] initWithFrame:CGRectMake(0.0, 8.0, 1000.0, 1.3)]; - [line setBackgroundColor:[CPColor lightGrayColor]]; - [view setAutoresizingMask:CPViewWidthSizable]; - [view addSubview:line]; - - [self setView:view]; + [self setEnabled:NO]; } return self; @@ -933,6 +927,17 @@ var _CPMenuItemSelectionColor = nil, var view = [_menuItem view]; + if ([_menuItem isSeparatorItem]) + { + var line = [[CPView alloc] initWithFrame:CGRectMake(0.0, 8.0, 1000.0, 1.3)]; + view = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 20.0)]; + + [view setAutoresizingMask:CPViewWidthSizable]; + [line setBackgroundColor:[CPColor lightGrayColor]]; + + [view addSubview:line]; + } + if (view) { [_imageAndTitleView removeFromSuperview];