mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-20 22:06:42 +00:00
Added stuff so that NSMenu won't get sized to smaller than it's title width.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5043 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d24294cb85
commit
ad22faa6a2
4 changed files with 33 additions and 6 deletions
|
@ -1,3 +1,11 @@
|
|||
Tue Oct 19 11:33:46 1999 Lyndon Tremblay <humasect@coolmail.com>
|
||||
|
||||
* Source/NSMenuView.m: ([-sizeToFit]) added handling for title width.
|
||||
([-setTitleWidth:]) new private function called by NSMenu to
|
||||
make the menu not get smaller than menu title.
|
||||
* Source/NSMenu.m: (-[sizeToFit]) added handling for title width.
|
||||
* Headers/AppKit/NSMenuView.h: added declaration for -setTitleWidth.
|
||||
|
||||
Tue Oct 19 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSApplication.m: ([-terminate:]) modification based on
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
float menuv_keyEqWidth;
|
||||
BOOL menuv_needsSizing;
|
||||
NSSize cellSize;
|
||||
float i_titleWidth;
|
||||
@private
|
||||
id menuv_popb;
|
||||
id menuv_items_link;
|
||||
|
@ -117,6 +118,7 @@
|
|||
cellSize: (NSSize)aSize;
|
||||
- (void) setPopUpButton: (NSPopUpButton *)popb;
|
||||
- (NSPopUpButton *) popupButton;
|
||||
- (void)setTitleWidth:(float)titleWidth;
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
|
|
@ -77,6 +77,7 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations";
|
|||
- (id) init
|
||||
{
|
||||
return [self initWithTitle: @"Menu"];
|
||||
//return self;
|
||||
}
|
||||
|
||||
- (id) initWithPopUpButton: (NSPopUpButton *)popb
|
||||
|
@ -134,6 +135,7 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations";
|
|||
NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
|
||||
NSApplication* theApp = [NSApplication sharedApplication];
|
||||
NSRect winRect = {{0, 0}, {20, 17}};
|
||||
//float titleWidth = 0;
|
||||
|
||||
[super init];
|
||||
|
||||
|
@ -366,7 +368,9 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations";
|
|||
|
||||
- (id <NSMenuItem>) itemAtIndex: (int)index
|
||||
{
|
||||
// FIXME should raise an exception if out of range.
|
||||
if (index >= [menu_items count] || index < 0)
|
||||
[NSException raise:NSRangeException format:@"menu index %i out of range",
|
||||
index];
|
||||
return [menu_items objectAtIndex: index];
|
||||
}
|
||||
|
||||
|
@ -717,8 +721,9 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations";
|
|||
NSRect mFrame;
|
||||
NSSize size;
|
||||
|
||||
[menu_view sizeToFit];
|
||||
|
||||
|
||||
//-setTitleWidth: ends up calling -sizeToFit.
|
||||
[menu_view setTitleWidth:[[NSFont systemFontOfSize:12] widthOfString:menu_title]];
|
||||
mFrame = [menu_view frame];
|
||||
|
||||
size.width = mFrame.size.width;
|
||||
|
|
|
@ -59,13 +59,14 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
- (id)initWithFrame: (NSRect)aFrame
|
||||
{
|
||||
cellSize = NSMakeSize(110,20);
|
||||
i_titleWidth = 110;
|
||||
menuv_highlightedItemIndex = -1;
|
||||
|
||||
return [super initWithFrame: aFrame];
|
||||
}
|
||||
|
||||
- (id)initWithFrame: (NSRect)aFrame
|
||||
cellSize: (NSSize)aSize
|
||||
cellSize: (NSSize)aSize
|
||||
{
|
||||
[self initWithFrame:aFrame];
|
||||
|
||||
|
@ -315,12 +316,23 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
|||
return menuv_needsSizing;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
-setTitleWidth:
|
||||
================
|
||||
*/
|
||||
- (void)setTitleWidth:(float)titleWidth
|
||||
{
|
||||
i_titleWidth = titleWidth;
|
||||
[self sizeToFit];
|
||||
}
|
||||
|
||||
- (void)sizeToFit
|
||||
{
|
||||
int i;
|
||||
int howMany = [menuv_items_link count];
|
||||
int howHigh = (howMany * cellSize.height);
|
||||
float neededWidth = 0;
|
||||
float neededWidth = i_titleWidth;
|
||||
|
||||
for (i=0;i<howMany;i++)
|
||||
{
|
||||
|
@ -901,7 +913,7 @@ cell do the following */
|
|||
|
||||
-(void) performKeyEquivalent: (NSEvent *)theEvent
|
||||
{
|
||||
return [menuv_menu performKeyEquivalent: theEvent];
|
||||
[menuv_menu performKeyEquivalent: theEvent];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue