Fix NSFormCell drawing and sizing

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4906 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-09-18 04:12:02 +00:00
parent 4d92dd99d1
commit 3ed0bfd3d6
2 changed files with 27 additions and 1 deletions

View file

@ -1,3 +1,9 @@
Sat Sep 18 1999 Nicola Pero <n.pero@mi.flashnet.it>
* Source/NSFormCell.m ([-initTextCell:]): Follow the doc: init
bezeled. ([-drawWithFrame:inView:]): Tiny fix to have some space
between title and text. ([-cellSize]): New method
Thu Sep 16 8:38:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk> Thu Sep 16 8:38:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSBrowserCell.m: Fix for positioning of leaf images. * Source/NSBrowserCell.m: Fix for positioning of leaf images.

View file

@ -43,7 +43,6 @@
- initTextCell: (NSString *)aString - initTextCell: (NSString *)aString
{ {
self = [super initTextCell:@""]; self = [super initTextCell:@""];
[self setBordered:YES];
[self setBezeled:YES]; [self setBezeled:YES];
[self setAlignment:NSLeftTextAlignment]; [self setAlignment:NSLeftTextAlignment];
titleWidth = -1; titleWidth = -1;
@ -114,6 +113,25 @@
return 0; return 0;
} }
- (NSSize)cellSize
{
NSSize returnedSize;
NSSize titleSize = [titleCell cellSize];
NSSize textSize = [super cellSize];
textSize.width = [cell_font widthOfString: @"minimum"];
textSize.height = [cell_font pointSize] + (2 * yDist)
+ 2 * ([NSCell sizeForBorderType: NSBezelBorder].height);
returnedSize.width = titleSize.width + 4 + textSize.width;
if (titleSize.height > textSize.height)
returnedSize.height = titleSize.height;
else
returnedSize.height = textSize.height;
return returnedSize;
}
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView - (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
{ {
NSRect titleFrame; NSRect titleFrame;
@ -121,6 +139,7 @@
NSDivideRect(cellFrame, &titleFrame, &textFrame, NSDivideRect(cellFrame, &titleFrame, &textFrame,
[self titleWidth] + 4, NSMinXEdge); [self titleWidth] + 4, NSMinXEdge);
titleFrame.size.width -= 4;
[titleCell drawWithFrame: titleFrame inView: controlView]; [titleCell drawWithFrame: titleFrame inView: controlView];
[super drawWithFrame: textFrame inView: controlView]; [super drawWithFrame: textFrame inView: controlView];
@ -139,3 +158,4 @@
} }
@end @end