1996-05-30 20:03:15 +00:00
|
|
|
/*
|
|
|
|
NSFormCell.m
|
|
|
|
|
|
|
|
The cell class for the NSForm control
|
|
|
|
|
|
|
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
Author: Ovidiu Predescu <ovidiu@net-community.com>
|
|
|
|
Date: March 1997
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
1996-10-18 17:14:13 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
If not, write to the Free Software Foundation,
|
|
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1996-05-30 20:03:15 +00:00
|
|
|
*/
|
|
|
|
|
1997-09-23 22:43:24 +00:00
|
|
|
#include <gnustep/gui/config.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <AppKit/NSFormCell.h>
|
1997-04-22 18:23:58 +00:00
|
|
|
#include <AppKit/NSFont.h>
|
|
|
|
#include <AppKit/NSTextFieldCell.h>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
@implementation NSFormCell
|
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
/* The title attributes are those inherited from the NSActionCell class. */
|
|
|
|
|
|
|
|
- init
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-10-29 21:56:04 +00:00
|
|
|
return [self initTextCell:@"Field:"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- initTextCell: (NSString *)aString
|
|
|
|
{
|
|
|
|
self = [super initTextCell:@""];
|
|
|
|
[self setBordered:YES];
|
|
|
|
[self setBezeled:YES];
|
|
|
|
[self setAlignment:NSLeftTextAlignment];
|
1997-04-22 18:23:58 +00:00
|
|
|
titleWidth = -1;
|
1997-10-29 21:56:04 +00:00
|
|
|
titleCell = [[NSCell alloc] initTextCell:aString];
|
|
|
|
[titleCell setBordered:NO];
|
|
|
|
[titleCell setBezeled:NO];
|
|
|
|
[titleCell setAlignment:NSRightTextAlignment];
|
1997-04-22 18:23:58 +00:00
|
|
|
return self;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
- (void)dealloc
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-10-29 21:56:04 +00:00
|
|
|
[titleCell release];
|
1997-04-22 18:23:58 +00:00
|
|
|
[super dealloc];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isOpaque
|
|
|
|
{
|
1997-10-29 21:56:04 +00:00
|
|
|
return [super isOpaque] && [titleCell isOpaque];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
- (void)setTitle:(NSString*)aString
|
|
|
|
{
|
1997-10-29 21:56:04 +00:00
|
|
|
[titleCell setStringValue:aString];
|
1997-04-22 18:23:58 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)setTitleAlignment:(NSTextAlignment)mode
|
1997-04-22 18:23:58 +00:00
|
|
|
{
|
1997-10-29 21:56:04 +00:00
|
|
|
[titleCell setAlignment:mode];
|
1997-04-22 18:23:58 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
- (void)setTitleFont:(NSFont*)fontObject
|
|
|
|
{
|
1997-10-29 21:56:04 +00:00
|
|
|
[titleCell setFont:fontObject];
|
1997-04-22 18:23:58 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)setTitleWidth:(float)width
|
1997-04-22 18:23:58 +00:00
|
|
|
{
|
|
|
|
titleWidth = width;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
- (NSString*)title
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-10-29 21:56:04 +00:00
|
|
|
return [titleCell stringValue];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSTextAlignment)titleAlignment
|
|
|
|
{
|
1997-10-29 21:56:04 +00:00
|
|
|
return [titleCell alignment];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
- (NSFont*)titleFont
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-10-29 21:56:04 +00:00
|
|
|
return [titleCell font];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (float)titleWidth
|
|
|
|
{
|
1997-04-22 18:23:58 +00:00
|
|
|
if (titleWidth < 0)
|
1997-10-29 21:56:04 +00:00
|
|
|
return [[titleCell font] widthOfString:[self title]];
|
1997-04-22 18:23:58 +00:00
|
|
|
else
|
|
|
|
return titleWidth;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
- (float)titleWidth:(NSSize)size
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-04-22 18:23:58 +00:00
|
|
|
// TODO
|
1996-05-30 20:03:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
1997-04-22 18:23:58 +00:00
|
|
|
{
|
1997-10-29 21:56:04 +00:00
|
|
|
NSRect titleFrame;
|
|
|
|
NSRect textFrame;
|
1997-04-22 18:23:58 +00:00
|
|
|
|
1997-10-29 21:56:04 +00:00
|
|
|
NSDivideRect(cellFrame, &titleFrame, &textFrame,
|
|
|
|
[self titleWidth] + 4, NSMinXEdge);
|
1997-04-22 18:23:58 +00:00
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
[titleCell drawWithFrame: titleFrame inView: controlView];
|
|
|
|
[super drawWithFrame: textFrame inView: controlView];
|
1997-04-22 18:23:58 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-02 08:58:30 +00:00
|
|
|
[super encodeWithCoder: aCoder];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-02 08:58:30 +00:00
|
|
|
[super initWithCoder: aDecoder];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|