mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Patch by Matt Rice to get popup buttons that support
setUsesItemFromMenu: set to NO. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26036 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d5e445c620
commit
65ceda6b9d
5 changed files with 69 additions and 22 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2008-02-07 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/AppKit/NSMenu.h,
|
||||
* Source/NSMenu.m (-_owningPopUp): New helper method.
|
||||
* Source/NSMenuView.m
|
||||
(-setWindowFrameForAttachingToRect:...popUpSelectedItem:):
|
||||
Special case for popups that don't use an item from the list.
|
||||
* Source/NSPopUpButtonCell.m (-setUsesItemFromMenu:): Create a
|
||||
menu item for the title.
|
||||
* Source/NSPopUpButtonCell.m (-setTitel:): Use the menu item, when
|
||||
not using an item from the menu.
|
||||
Reworked patch by Matt Rice <ratmice@gmail.com>.
|
||||
|
||||
2008-02-04 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Images/common_3DArrowLeft.tiff,
|
||||
|
|
|
@ -750,6 +750,7 @@
|
|||
|
||||
/* Popup behaviour */
|
||||
- (BOOL) _ownedByPopUp;
|
||||
- (NSPopUpButtonCell *)_owningPopUp;
|
||||
- (void) _setOwnedByPopUp: (NSPopUpButtonCell*)popUp;
|
||||
@end
|
||||
#endif
|
||||
|
|
|
@ -1857,6 +1857,11 @@ static BOOL menuBarVisible = YES;
|
|||
return _popUpButtonCell != nil;
|
||||
}
|
||||
|
||||
- (NSPopUpButtonCell *)_owningPopUp
|
||||
{
|
||||
return _popUpButtonCell;
|
||||
}
|
||||
|
||||
- (void)_setOwnedByPopUp: (NSPopUpButtonCell*)popUp
|
||||
{
|
||||
if (_popUpButtonCell != popUp)
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "AppKit/NSMenuView.h"
|
||||
#include "AppKit/NSMenu.h"
|
||||
#include "AppKit/NSButton.h"
|
||||
#include "AppKit/NSPopUpButtonCell.h"
|
||||
#include "AppKit/NSWindow.h"
|
||||
#include "AppKit/PSOperators.h"
|
||||
#include "AppKit/NSImage.h"
|
||||
|
@ -606,17 +607,17 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
|||
|
||||
[self sizeToFit];
|
||||
|
||||
if ([_attachedMenu _ownedByPopUp] == NO)
|
||||
if (_titleView != nil)
|
||||
{
|
||||
if ([_attachedMenu isTornOff] && ![_attachedMenu isTransient])
|
||||
{
|
||||
[_titleView
|
||||
addCloseButtonWithAction: @selector(_performMenuClose:)];
|
||||
}
|
||||
{
|
||||
[_titleView
|
||||
addCloseButtonWithAction: @selector(_performMenuClose:)];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_titleView removeCloseButton];
|
||||
}
|
||||
{
|
||||
[_titleView removeCloseButton];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1076,18 +1077,26 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
|||
}
|
||||
|
||||
// Update position, if needed, using the preferredEdge
|
||||
if (edge == NSMaxYEdge)
|
||||
{
|
||||
screenFrame.origin.y += screenRect.size.height;
|
||||
}
|
||||
else if (edge == NSMaxXEdge)
|
||||
{
|
||||
screenFrame.origin.x += screenRect.size.width;
|
||||
}
|
||||
else if (edge == NSMinXEdge)
|
||||
{
|
||||
screenFrame.origin.x -= screenRect.size.width;
|
||||
}
|
||||
if (edge == NSMinYEdge)
|
||||
{
|
||||
if ([_attachedMenu _ownedByPopUp] &&
|
||||
([[_attachedMenu _owningPopUp] usesItemFromMenu] == NO))
|
||||
{
|
||||
screenFrame.origin.y -= screenRect.size.height;
|
||||
}
|
||||
}
|
||||
else if (edge == NSMaxYEdge)
|
||||
{
|
||||
screenFrame.origin.y += screenRect.size.height;
|
||||
}
|
||||
else if (edge == NSMaxXEdge)
|
||||
{
|
||||
screenFrame.origin.x += screenRect.size.width;
|
||||
}
|
||||
else if (edge == NSMinXEdge)
|
||||
{
|
||||
screenFrame.origin.x -= screenRect.size.width;
|
||||
}
|
||||
|
||||
// Get the frameRect
|
||||
r = [NSWindow frameRectForContentRect: screenFrame
|
||||
|
|
|
@ -243,7 +243,20 @@ static NSImage *_pbc_image[5];
|
|||
*/
|
||||
- (void) setUsesItemFromMenu: (BOOL)flag
|
||||
{
|
||||
_pbcFlags.usesItemFromMenu = flag;
|
||||
if (_pbcFlags.usesItemFromMenu != flag)
|
||||
{
|
||||
_pbcFlags.usesItemFromMenu = flag;
|
||||
if (!flag)
|
||||
{
|
||||
NSMenuItem *anItem;
|
||||
|
||||
anItem = [[NSMenuItem alloc] initWithTitle: [self title]
|
||||
action: NULL
|
||||
keyEquivalent: nil];
|
||||
[self setMenuItem: anItem];
|
||||
RELEASE(anItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -635,7 +648,13 @@ static NSImage *_pbc_image[5];
|
|||
{
|
||||
id <NSMenuItem> anItem;
|
||||
|
||||
if (_pbcFlags.pullsDown)
|
||||
if (!_pbcFlags.usesItemFromMenu)
|
||||
{
|
||||
[_menuItem setTitle: aString];
|
||||
|
||||
return;
|
||||
}
|
||||
else if (_pbcFlags.pullsDown)
|
||||
{
|
||||
if ([_menu numberOfItems] == 0)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue