1997-04-22 18:23:58 +00:00
|
|
|
/*
|
1996-05-30 20:03:15 +00:00
|
|
|
NSForm.m
|
|
|
|
|
|
|
|
Form class, a text field with a label
|
|
|
|
|
|
|
|
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-02-18 00:29:25 +00:00
|
|
|
#include <AppKit/NSForm.h>
|
1997-04-22 18:23:58 +00:00
|
|
|
#include <AppKit/NSFormCell.h>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
@implementation NSForm
|
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
- (NSFormCell*)addEntry:(NSString*)title
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-04-22 18:23:58 +00:00
|
|
|
return [self insertEntry:title atIndex:[self numberOfRows]];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
- (NSFormCell*)insertEntry:(NSString*)title
|
1996-05-30 20:03:15 +00:00
|
|
|
atIndex:(int)index
|
|
|
|
{
|
1997-04-22 18:23:58 +00:00
|
|
|
[self insertRow:index];
|
|
|
|
return [self cellAtRow:index column:0];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)removeEntryAtIndex:(int)index
|
1997-04-22 18:23:58 +00:00
|
|
|
{
|
|
|
|
[self removeRow:index];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setBezeled:(BOOL)flag
|
|
|
|
{
|
|
|
|
int i, count = [self numberOfRows];
|
|
|
|
|
|
|
|
/* Set the bezeled attribute to the cell prototype */
|
|
|
|
[[self prototype] setBezeled:flag];
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
[[self cellAtRow:i column:0] setBezeled:flag];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setBordered:(BOOL)flag
|
|
|
|
{
|
|
|
|
int i, count = [self numberOfRows];
|
|
|
|
|
|
|
|
/* Set the bordered attribute to the cell prototype */
|
|
|
|
[[self prototype] setBordered:flag];
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
[[self cellAtRow:i column:0] setBordered:flag];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setEntryWidth:(float)width
|
|
|
|
{
|
|
|
|
NSSize size = [self cellSize];
|
|
|
|
|
|
|
|
size.width = width;
|
|
|
|
[self setCellSize:size];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)setInterlineSpacing:(float)spacing
|
1997-04-22 18:23:58 +00:00
|
|
|
{
|
|
|
|
[self setIntercellSpacing:NSMakeSize(0, spacing)];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
/* For the title attributes we use the corresponding attributes from the cell.
|
|
|
|
For the text attributes we use instead the attributes inherited from the
|
|
|
|
NSCell class. */
|
|
|
|
- (void)setTitleAlignment:(NSTextAlignment)aMode
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-04-22 18:23:58 +00:00
|
|
|
int i, count = [self numberOfRows];
|
|
|
|
|
|
|
|
/* Set the title alignment attribute to the cell prototype */
|
|
|
|
[[self prototype] setTitleAlignment:aMode];
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
[[self cellAtRow:i column:0] setTitleAlignment:aMode];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
- (void)setTextAlignment:(int)aMode
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-04-22 18:23:58 +00:00
|
|
|
int i, count = [self numberOfRows];
|
|
|
|
|
|
|
|
/* Set the text alignment attribute to the cell prototype */
|
|
|
|
[[self prototype] setAlignment:aMode];
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
[[self cellAtRow:i column:0] setAlignment:aMode];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
- (void)setTitleFont:(NSFont*)fontObject
|
|
|
|
{
|
|
|
|
int i, count = [self numberOfRows];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
/* Set the title font attribute to the cell prototype */
|
|
|
|
[[self prototype] setTitleFont:fontObject];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
[[self cellAtRow:i column:0] setTitleFont:fontObject];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
- (void)setTextFont:(NSFont*)fontObject
|
|
|
|
{
|
|
|
|
int i, count = [self numberOfRows];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
/* Set the text font attribute to the cell prototype */
|
|
|
|
[[self prototype] setFont:fontObject];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
[[self cellAtRow:i column:0] setFont:fontObject];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
- (int)indexOfCellWithTag:(int)aTag
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-04-22 18:23:58 +00:00
|
|
|
int i, count = [self numberOfRows];
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
if ([[self cellAtRow:i column:0] tag] == aTag)
|
|
|
|
return i;
|
|
|
|
return -1;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
- (int)indexOfSelectedItem
|
|
|
|
{
|
|
|
|
return [self selectedRow];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (id)cellAtIndex:(int)index
|
|
|
|
{
|
1997-04-22 18:23:58 +00:00
|
|
|
return [self cellAtRow:index column:0];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)drawCellAtIndex:(int)index
|
1997-04-22 18:23:58 +00:00
|
|
|
{
|
|
|
|
id theCell = [self cellAtIndex:index];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
[theCell drawWithFrame:[self cellFrameAtRow:index column:0]
|
|
|
|
inView:self];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
- (void)drawCellAtRow:(int)row column:(int)column
|
|
|
|
{
|
|
|
|
[self drawCellAtIndex:row];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)selectTextAtIndex:(int)index
|
1996-05-30 20:03:15 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)encodeWithCoder:aCoder
|
|
|
|
{
|
|
|
|
[super encodeWithCoder:aCoder];
|
|
|
|
}
|
|
|
|
|
|
|
|
- initWithCoder:aDecoder
|
|
|
|
{
|
|
|
|
[super initWithCoder:aDecoder];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|