mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-21 09:31:01 +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>
|
Tue Oct 19 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
* Source/NSApplication.m: ([-terminate:]) modification based on
|
* Source/NSApplication.m: ([-terminate:]) modification based on
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
float menuv_keyEqWidth;
|
float menuv_keyEqWidth;
|
||||||
BOOL menuv_needsSizing;
|
BOOL menuv_needsSizing;
|
||||||
NSSize cellSize;
|
NSSize cellSize;
|
||||||
|
float i_titleWidth;
|
||||||
@private
|
@private
|
||||||
id menuv_popb;
|
id menuv_popb;
|
||||||
id menuv_items_link;
|
id menuv_items_link;
|
||||||
|
@ -117,6 +118,7 @@
|
||||||
cellSize: (NSSize)aSize;
|
cellSize: (NSSize)aSize;
|
||||||
- (void) setPopUpButton: (NSPopUpButton *)popb;
|
- (void) setPopUpButton: (NSPopUpButton *)popb;
|
||||||
- (NSPopUpButton *) popupButton;
|
- (NSPopUpButton *) popupButton;
|
||||||
|
- (void)setTitleWidth:(float)titleWidth;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -77,6 +77,7 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations";
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
return [self initWithTitle: @"Menu"];
|
return [self initWithTitle: @"Menu"];
|
||||||
|
//return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithPopUpButton: (NSPopUpButton *)popb
|
- (id) initWithPopUpButton: (NSPopUpButton *)popb
|
||||||
|
@ -134,6 +135,7 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations";
|
||||||
NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
|
||||||
NSApplication* theApp = [NSApplication sharedApplication];
|
NSApplication* theApp = [NSApplication sharedApplication];
|
||||||
NSRect winRect = {{0, 0}, {20, 17}};
|
NSRect winRect = {{0, 0}, {20, 17}};
|
||||||
|
//float titleWidth = 0;
|
||||||
|
|
||||||
[super init];
|
[super init];
|
||||||
|
|
||||||
|
@ -366,7 +368,9 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations";
|
||||||
|
|
||||||
- (id <NSMenuItem>) itemAtIndex: (int)index
|
- (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];
|
return [menu_items objectAtIndex: index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -717,8 +721,9 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations";
|
||||||
NSRect mFrame;
|
NSRect mFrame;
|
||||||
NSSize size;
|
NSSize size;
|
||||||
|
|
||||||
[menu_view sizeToFit];
|
|
||||||
|
|
||||||
|
//-setTitleWidth: ends up calling -sizeToFit.
|
||||||
|
[menu_view setTitleWidth:[[NSFont systemFontOfSize:12] widthOfString:menu_title]];
|
||||||
mFrame = [menu_view frame];
|
mFrame = [menu_view frame];
|
||||||
|
|
||||||
size.width = mFrame.size.width;
|
size.width = mFrame.size.width;
|
||||||
|
|
|
@ -59,6 +59,7 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
||||||
- (id)initWithFrame: (NSRect)aFrame
|
- (id)initWithFrame: (NSRect)aFrame
|
||||||
{
|
{
|
||||||
cellSize = NSMakeSize(110,20);
|
cellSize = NSMakeSize(110,20);
|
||||||
|
i_titleWidth = 110;
|
||||||
menuv_highlightedItemIndex = -1;
|
menuv_highlightedItemIndex = -1;
|
||||||
|
|
||||||
return [super initWithFrame: aFrame];
|
return [super initWithFrame: aFrame];
|
||||||
|
@ -315,12 +316,23 @@ static float GSMenuBarHeight = 25.0; // a guess.
|
||||||
return menuv_needsSizing;
|
return menuv_needsSizing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
================
|
||||||
|
-setTitleWidth:
|
||||||
|
================
|
||||||
|
*/
|
||||||
|
- (void)setTitleWidth:(float)titleWidth
|
||||||
|
{
|
||||||
|
i_titleWidth = titleWidth;
|
||||||
|
[self sizeToFit];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)sizeToFit
|
- (void)sizeToFit
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int howMany = [menuv_items_link count];
|
int howMany = [menuv_items_link count];
|
||||||
int howHigh = (howMany * cellSize.height);
|
int howHigh = (howMany * cellSize.height);
|
||||||
float neededWidth = 0;
|
float neededWidth = i_titleWidth;
|
||||||
|
|
||||||
for (i=0;i<howMany;i++)
|
for (i=0;i<howMany;i++)
|
||||||
{
|
{
|
||||||
|
@ -901,7 +913,7 @@ cell do the following */
|
||||||
|
|
||||||
-(void) performKeyEquivalent: (NSEvent *)theEvent
|
-(void) performKeyEquivalent: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
return [menuv_menu performKeyEquivalent: theEvent];
|
[menuv_menu performKeyEquivalent: theEvent];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue