1996-05-30 20:03:15 +00:00
|
|
|
/*
|
|
|
|
NSTextFieldCell.m
|
|
|
|
|
|
|
|
Cell class for the text field entry control
|
|
|
|
|
|
|
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Scott Christley <scottc@net-community.com>
|
|
|
|
Date: 1996
|
|
|
|
|
|
|
|
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-08-18 17:10:23 +00:00
|
|
|
#include <Foundation/NSString.h>
|
1996-05-30 20:03:15 +00:00
|
|
|
#include <Foundation/NSArray.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <AppKit/NSTextFieldCell.h>
|
|
|
|
#include <AppKit/NSTextField.h>
|
|
|
|
#include <AppKit/NSWindow.h>
|
|
|
|
#include <AppKit/NSApplication.h>
|
|
|
|
#include <AppKit/NSColor.h>
|
|
|
|
#include <AppKit/NSFont.h>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// TextFieldCell implementation
|
|
|
|
//
|
|
|
|
@implementation NSTextFieldCell
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Class methods
|
|
|
|
//
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
+ (void) initialize
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
if (self == [NSTextFieldCell class])
|
|
|
|
{
|
1999-04-01 06:47:43 +00:00
|
|
|
[self setVersion: 1];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Instance methods
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Initialization
|
|
|
|
//
|
1999-04-01 06:47:43 +00:00
|
|
|
- (id) init
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:47:43 +00:00
|
|
|
[self initTextCell: @""];
|
1996-05-30 20:03:15 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
- (id) initTextCell: (NSString *)aString
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:47:43 +00:00
|
|
|
[super initTextCell: aString];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
[self setAlignment: NSLeftTextAlignment];
|
1999-03-09 05:30:15 +00:00
|
|
|
[self setBackgroundColor: [NSColor textBackgroundColor]];
|
|
|
|
[self setTextColor: [NSColor textColor]];
|
1999-04-01 06:47:43 +00:00
|
|
|
[self setFont: [NSFont systemFontOfSize: 0]];
|
1999-03-16 16:56:02 +00:00
|
|
|
draw_background = NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
- (void) dealloc
|
1997-08-16 23:47:24 +00:00
|
|
|
{
|
|
|
|
[background_color release];
|
|
|
|
[text_color release];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
- (id) copyWithZone: (NSZone*)zone
|
1997-08-16 23:47:24 +00:00
|
|
|
{
|
1999-03-02 08:58:30 +00:00
|
|
|
NSTextFieldCell *c = [super copyWithZone: zone];
|
1997-08-16 23:47:24 +00:00
|
|
|
|
|
|
|
[c setBackgroundColor: background_color];
|
|
|
|
[c setTextColor: text_color];
|
1997-10-31 01:24:08 +00:00
|
|
|
[c setDrawsBackground: draw_background];
|
1997-08-16 23:47:24 +00:00
|
|
|
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// Modifying Graphic Attributes
|
|
|
|
//
|
1999-04-01 06:47:43 +00:00
|
|
|
- (NSColor *) backgroundColor
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return background_color;
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
- (BOOL) drawsBackground
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return draw_background;
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
- (void) setBackgroundColor: (NSColor *)aColor
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-08-16 23:47:24 +00:00
|
|
|
[aColor retain];
|
|
|
|
[background_color release];
|
1996-05-30 20:03:15 +00:00
|
|
|
background_color = aColor;
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
- (void) setDrawsBackground: (BOOL)flag
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
draw_background = flag;
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
- (void) setTextColor: (NSColor *)aColor
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-08-16 23:47:24 +00:00
|
|
|
[aColor retain];
|
|
|
|
[text_color release];
|
1996-05-30 20:03:15 +00:00
|
|
|
text_color = aColor;
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
- (id) setUpFieldEditorAttributes: (id)textObject
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
- (NSColor *) textColor
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return text_color;
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
- (void) setFont: (NSFont *)fontObject
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:47:43 +00:00
|
|
|
[super setFont: fontObject];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Editing Text
|
|
|
|
//
|
1999-04-01 06:47:43 +00:00
|
|
|
- (void) selectText: (id)sender
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
- (double) doubleValue
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return [super doubleValue];
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
- (void) setDoubleValue: (double)aDouble
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:47:43 +00:00
|
|
|
[super setDoubleValue: aDouble];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
- (float) floatValue
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return [super floatValue];
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
- (void) setFloatValue: (float)aFloat
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:47:43 +00:00
|
|
|
[super setFloatValue: aFloat];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
- (int) intValue
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return [super intValue];
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
- (void) setIntValue: (int)anInt
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:47:43 +00:00
|
|
|
[super setIntValue: anInt];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
- (NSString *) stringValue
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return [super stringValue];
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:47:43 +00:00
|
|
|
- (void) setStringValue: (NSString *)aString
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:47:43 +00:00
|
|
|
[super setStringValue: aString];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-03 09:31:27 +00:00
|
|
|
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
|
|
|
{
|
|
|
|
if (draw_background)
|
|
|
|
{
|
1999-09-21 05:10:54 +00:00
|
|
|
[controlView lockFocus];
|
1999-03-03 09:31:27 +00:00
|
|
|
[background_color set];
|
1999-09-11 05:25:53 +00:00
|
|
|
NSRectFill ([self drawingRectForBounds: cellFrame]);
|
1999-09-21 05:10:54 +00:00
|
|
|
[controlView unlockFocus];
|
1999-03-03 09:31:27 +00:00
|
|
|
}
|
|
|
|
[super drawInteriorWithFrame: cellFrame inView: controlView];
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// NSCoding protocol
|
|
|
|
//
|
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
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &background_color];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &text_color];
|
1996-05-30 20:03:15 +00:00
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &draw_background];
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &background_color];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &text_color];
|
1996-05-30 20:03:15 +00:00
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &draw_background];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|