mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 12:40:38 +00:00
Initial implementation of NSBrowser and NSBrowserCell.
Numerous bug fixes. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2596 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f0fbcf363d
commit
5592d9996b
18 changed files with 1553 additions and 143 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
Cell class for the NSBrowser
|
||||
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
||||
|
||||
Author: Scott Christley <scottc@net-community.com>
|
||||
Date: 1996
|
||||
|
@ -28,7 +28,42 @@
|
|||
|
||||
#include <gnustep/gui/config.h>
|
||||
#include <AppKit/NSBrowserCell.h>
|
||||
#include <AppKit/NSTextFieldCell.h>
|
||||
#include <AppKit/NSImage.h>
|
||||
|
||||
// Class variables
|
||||
static NSImage *branch_image;
|
||||
static NSImage *highlight_image;
|
||||
|
||||
// Private methods
|
||||
@interface NSBrowserCell (Private)
|
||||
- (void)setBranchImageCell:aCell;
|
||||
- (void)setHighlightBranchImageCell:aCell;
|
||||
- (void)setTextFieldCell:aCell;
|
||||
@end
|
||||
|
||||
@implementation NSBrowserCell (Private)
|
||||
|
||||
- (void)setBranchImageCell:aCell
|
||||
{
|
||||
_branchImage = aCell;
|
||||
}
|
||||
|
||||
- (void)setHighlightBranchImageCell:aCell
|
||||
{
|
||||
_highlightBranchImage = aCell;
|
||||
}
|
||||
|
||||
- (void)setTextFieldCell:aCell
|
||||
{
|
||||
_browserText = aCell;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
//
|
||||
// NSBrowserCell implementation
|
||||
//
|
||||
@implementation NSBrowserCell
|
||||
|
||||
//
|
||||
|
@ -40,6 +75,10 @@
|
|||
{
|
||||
// Initial version
|
||||
[self setVersion:1];
|
||||
|
||||
// The default images
|
||||
branch_image = [NSImage imageNamed: @"common_ArrowRight"];
|
||||
highlight_image = [NSImage imageNamed: @"common_ArrowRightH"];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,59 +87,177 @@
|
|||
//
|
||||
+ (NSImage *)branchImage
|
||||
{
|
||||
return nil;
|
||||
return branch_image;
|
||||
}
|
||||
|
||||
+ (NSImage *)highlightedBranchImage
|
||||
{
|
||||
return nil;
|
||||
return highlight_image;
|
||||
}
|
||||
|
||||
//
|
||||
// Instance methods
|
||||
//
|
||||
|
||||
- init
|
||||
{
|
||||
return [self initTextCell: @"aTitle"];
|
||||
}
|
||||
|
||||
- initTextCell:(NSString *)aString
|
||||
{
|
||||
[super initTextCell: aString];
|
||||
|
||||
// Our image cells
|
||||
_branchImage = [[NSCell alloc] initImageCell: [NSBrowserCell branchImage]];
|
||||
_highlightBranchImage = [[NSCell alloc] initImageCell:
|
||||
[NSBrowserCell highlightedBranchImage]];
|
||||
|
||||
// Our text cell
|
||||
_browserText = [[NSTextFieldCell alloc] initTextCell: aString];
|
||||
[_browserText setEditable: NO];
|
||||
[_browserText setBordered: NO];
|
||||
[_browserText setDrawsBackground: YES];
|
||||
|
||||
_alternateImage = nil;
|
||||
_isLeaf = NO;
|
||||
_isLoaded = NO;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_branchImage release];
|
||||
[_highlightBranchImage release];
|
||||
[_alternateImage release];
|
||||
[_browserText release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id)copyWithZone:(NSZone*)zone
|
||||
{
|
||||
NSBrowserCell* c = [super copyWithZone:zone];
|
||||
|
||||
// Copy the image cells
|
||||
[c setBranchImageCell: [_branchImage copy]];
|
||||
[c setHighlightBranchImageCell: [_branchImage copy]];
|
||||
[c setAlternateImage: _alternateImage];
|
||||
|
||||
// Copy the text cell
|
||||
[c setTextFieldCell: [_browserText copy]];
|
||||
|
||||
[c setLeaf: _isLeaf];
|
||||
[c setLoaded: NO];
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
//
|
||||
// Accessing Graphic Attributes
|
||||
//
|
||||
- (NSImage *)alternateImage
|
||||
{
|
||||
return nil;
|
||||
return _alternateImage;
|
||||
}
|
||||
|
||||
- (void)setAlternateImage:(NSImage *)anImage
|
||||
{}
|
||||
{
|
||||
[anImage retain];
|
||||
[_alternateImage release];
|
||||
_alternateImage = anImage;
|
||||
|
||||
// Set the image in our highlight cell
|
||||
if (_alternateImage)
|
||||
[_highlightBranchImage setImage: _alternateImage];
|
||||
else
|
||||
[_highlightBranchImage setImage: [NSBrowserCell highlightedBranchImage]];
|
||||
}
|
||||
|
||||
//
|
||||
// Placing in the Browser Hierarchy
|
||||
//
|
||||
- (BOOL)isLeaf
|
||||
{
|
||||
return NO;
|
||||
return _isLeaf;
|
||||
}
|
||||
|
||||
- (void)setLeaf:(BOOL)flag
|
||||
{}
|
||||
{
|
||||
_isLeaf = flag;
|
||||
}
|
||||
|
||||
//
|
||||
// Determining Loaded Status
|
||||
//
|
||||
- (BOOL)isLoaded
|
||||
{
|
||||
return NO;
|
||||
return _isLoaded;
|
||||
}
|
||||
|
||||
- (void)setLoaded:(BOOL)flag
|
||||
{}
|
||||
{
|
||||
_isLoaded = flag;
|
||||
}
|
||||
|
||||
//
|
||||
// Setting State
|
||||
//
|
||||
- (void)reset
|
||||
{}
|
||||
{
|
||||
cell_highlighted = NO;
|
||||
cell_state = NO;
|
||||
}
|
||||
|
||||
- (void)set
|
||||
{}
|
||||
{
|
||||
cell_highlighted = YES;
|
||||
cell_state = YES;
|
||||
}
|
||||
|
||||
//
|
||||
// Setting the NSCell's Value
|
||||
//
|
||||
- (double)doubleValue
|
||||
{
|
||||
return [_browserText doubleValue];
|
||||
}
|
||||
|
||||
- (float)floatValue;
|
||||
{
|
||||
return [_browserText floatValue];
|
||||
}
|
||||
|
||||
- (int)intValue
|
||||
{
|
||||
return [_browserText intValue];
|
||||
}
|
||||
|
||||
- (NSString *)stringValue
|
||||
{
|
||||
return [_browserText stringValue];
|
||||
}
|
||||
|
||||
- (void)setDoubleValue:(double)aDouble
|
||||
{
|
||||
[_browserText setDoubleValue: aDouble];
|
||||
}
|
||||
|
||||
- (void)setFloatValue:(float)aFloat
|
||||
{
|
||||
[_browserText setFloatValue: aFloat];
|
||||
}
|
||||
|
||||
- (void)setIntValue:(int)anInt
|
||||
{
|
||||
[_browserText setIntValue: anInt];
|
||||
}
|
||||
|
||||
- (void)setStringValue:(NSString *)aString
|
||||
{
|
||||
[_browserText setStringValue: aString];
|
||||
}
|
||||
|
||||
//
|
||||
// NSCoding protocol
|
||||
|
@ -108,12 +265,24 @@
|
|||
- (void)encodeWithCoder:aCoder
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
|
||||
[aCoder encodeObject: _browserText];
|
||||
[aCoder encodeObject: _branchImage];
|
||||
[aCoder encodeObject: _highlightBranchImage];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLeaf];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
|
||||
}
|
||||
|
||||
- initWithCoder:aDecoder
|
||||
{
|
||||
[super initWithCoder:aDecoder];
|
||||
|
||||
_browserText = [aDecoder decodeObject];
|
||||
_branchImage = [aDecoder decodeObject];
|
||||
_highlightBranchImage = [aDecoder decodeObject];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLeaf];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue