mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:50:48 +00:00
Tidied and fixed a couple of bugs
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3969 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1ffeed382e
commit
b3ffbb9eb1
2 changed files with 194 additions and 125 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
The button cell class
|
||||
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996-1999 Free Software Foundation, Inc.
|
||||
|
||||
Author: Scott Christley <scottc@net-community.com>
|
||||
Ovidiu Predescu <ovidiu@net-community.com>
|
||||
|
@ -11,6 +11,8 @@
|
|||
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
||||
Date: August 1998
|
||||
|
||||
Modified: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
|
@ -56,13 +58,13 @@
|
|||
+ (void) initialize
|
||||
{
|
||||
if (self == [NSButtonCell class])
|
||||
[self setVersion:1]; // Initial version
|
||||
[self setVersion: 1];
|
||||
}
|
||||
|
||||
//
|
||||
// Instance methods
|
||||
//
|
||||
- _init
|
||||
- (id) _init
|
||||
{
|
||||
cell_enabled = YES;
|
||||
transparent = NO;
|
||||
|
@ -76,14 +78,14 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- init
|
||||
- (id) init
|
||||
{
|
||||
[self initTextCell: @"Button"];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- initImageCell:(NSImage *)anImage
|
||||
- (id) initImageCell: (NSImage *)anImage
|
||||
{
|
||||
[super initImageCell: anImage];
|
||||
|
||||
|
@ -92,7 +94,7 @@
|
|||
return [self _init];
|
||||
}
|
||||
|
||||
- initTextCell:(NSString *)aString
|
||||
- (id) initTextCell: (NSString *)aString
|
||||
{
|
||||
[super initTextCell: aString];
|
||||
|
||||
|
@ -112,14 +114,25 @@
|
|||
//
|
||||
// Setting the Titles
|
||||
//
|
||||
- (NSString *)title { return [self stringValue]; }
|
||||
- (NSString *)alternateTitle { return altContents; }
|
||||
- (void)setFont:(NSFont *)fontObject { [super setFont:fontObject]; }
|
||||
- (NSString *) title
|
||||
{
|
||||
return [self stringValue];
|
||||
}
|
||||
|
||||
- (NSString *) alternateTitle
|
||||
{
|
||||
return altContents;
|
||||
}
|
||||
|
||||
- (void) setFont: (NSFont *)fontObject
|
||||
{
|
||||
[super setFont: fontObject];
|
||||
}
|
||||
|
||||
- (void) setTitle: (NSString *)aString
|
||||
{
|
||||
[self setStringValue: aString];
|
||||
[self setState:[self state]]; // update our state
|
||||
[self setState: [self state]];
|
||||
}
|
||||
|
||||
- (void) setAlternateTitle: (NSString *)aString
|
||||
|
@ -128,15 +141,26 @@
|
|||
|
||||
ASSIGN(altContents, _string);
|
||||
[_string release];
|
||||
[self setState:[self state]]; // update our state
|
||||
[self setState: [self state]];
|
||||
}
|
||||
|
||||
//
|
||||
// Setting the Images
|
||||
//
|
||||
- (NSImage *)alternateImage { return altImage; }
|
||||
- (NSCellImagePosition)imagePosition { return image_position; }
|
||||
- (void)setAlternateImage:(NSImage *)anImage { ASSIGN(altImage, anImage); }
|
||||
- (NSImage *) alternateImage
|
||||
{
|
||||
return altImage;
|
||||
}
|
||||
|
||||
- (NSCellImagePosition) imagePosition
|
||||
{
|
||||
return image_position;
|
||||
}
|
||||
|
||||
- (void) setAlternateImage: (NSImage *)anImage
|
||||
{
|
||||
ASSIGN(altImage, anImage);
|
||||
}
|
||||
|
||||
- (void) setImagePosition: (NSCellImagePosition)aPosition
|
||||
{
|
||||
|
@ -225,8 +249,15 @@
|
|||
//
|
||||
// Modifying Graphic Attributes
|
||||
//
|
||||
- (BOOL)isTransparent { return transparent; }
|
||||
- (void)setTransparent:(BOOL)flag { transparent = flag; }
|
||||
- (BOOL) isTransparent
|
||||
{
|
||||
return transparent;
|
||||
}
|
||||
|
||||
- (void) setTransparent: (BOOL)flag
|
||||
{
|
||||
transparent = flag;
|
||||
}
|
||||
|
||||
- (BOOL) isOpaque
|
||||
{
|
||||
|
@ -236,10 +267,20 @@
|
|||
//
|
||||
// Modifying Graphic Attributes
|
||||
//
|
||||
- (int)highlightsBy { return highlightsByMask; }
|
||||
- (void)setHighlightsBy:(int)mask { highlightsByMask = mask; }
|
||||
- (void)setShowsStateBy:(int)mask { showAltStateMask = mask; }
|
||||
- (int) highlightsBy
|
||||
{
|
||||
return highlightsByMask;
|
||||
}
|
||||
|
||||
- (void) setHighlightsBy: (int)mask
|
||||
{
|
||||
highlightsByMask = mask;
|
||||
}
|
||||
|
||||
- (void) setShowsStateBy: (int)mask
|
||||
{
|
||||
showAltStateMask = mask;
|
||||
}
|
||||
|
||||
- (void) setButtonType: (NSButtonType)buttonType
|
||||
{
|
||||
|
@ -289,27 +330,55 @@
|
|||
break;
|
||||
}
|
||||
|
||||
// update our state
|
||||
[self setState: [self state]];
|
||||
}
|
||||
|
||||
- (int)showsStateBy { return showAltStateMask; }
|
||||
- (void)setIntValue:(int)anInt { [self setState:(anInt != 0)]; }
|
||||
- (void)setFloatValue:(float)aFloat { [self setState:(aFloat != 0)]; }
|
||||
- (void)setDoubleValue:(double)aDouble { [self setState:(aDouble != 0)]; }
|
||||
- (int)intValue { return [self state]; }
|
||||
- (float)floatValue { return [self state]; }
|
||||
- (double)doubleValue { return [self state]; }
|
||||
- (int) showsStateBy
|
||||
{
|
||||
return showAltStateMask;
|
||||
}
|
||||
|
||||
- (void) setIntValue: (int)anInt
|
||||
{
|
||||
[self setState: (anInt != 0)];
|
||||
}
|
||||
|
||||
- (void) setFloatValue: (float)aFloat
|
||||
{
|
||||
[self setState: (aFloat != 0)];
|
||||
}
|
||||
|
||||
- (void) setDoubleValue: (double)aDouble
|
||||
{
|
||||
[self setState: (aDouble != 0)];
|
||||
}
|
||||
|
||||
- (int) intValue
|
||||
{
|
||||
return [self state];
|
||||
}
|
||||
|
||||
- (float) floatValue
|
||||
{
|
||||
return [self state];
|
||||
}
|
||||
|
||||
- (double) doubleValue
|
||||
{
|
||||
return [self state];
|
||||
}
|
||||
|
||||
//
|
||||
// Displaying
|
||||
//
|
||||
- (NSColor *) textColor
|
||||
{
|
||||
if ([self isEnabled] == NO)
|
||||
return [NSColor disabledControlTextColor];
|
||||
if (([self state] && ([self showsStateBy] & NSChangeGrayCellMask))
|
||||
|| ([self isHighlighted] && ([self highlightsBy] & NSChangeGrayCellMask)))
|
||||
return [NSColor lightGrayColor];
|
||||
return [NSColor blackColor];
|
||||
return [NSColor selectedControlTextColor];
|
||||
return [NSColor controlTextColor];
|
||||
}
|
||||
|
||||
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
||||
|
@ -386,7 +455,7 @@
|
|||
if (!imageToDisplay)
|
||||
imageToDisplay = [self image];
|
||||
titleToDisplay = [self alternateTitle];
|
||||
if (!titleToDisplay)
|
||||
if (titleToDisplay == nil || [titleToDisplay isEqual: @""])
|
||||
titleToDisplay = [self title];
|
||||
}
|
||||
else
|
||||
|
|
|
@ -541,9 +541,9 @@
|
|||
- (NSColor*) textColor
|
||||
{
|
||||
if ([self isEnabled])
|
||||
return [NSColor blackColor];
|
||||
return [NSColor controlTextColor];
|
||||
else
|
||||
return [NSColor darkGrayColor];
|
||||
return [NSColor disabledControlTextColor];
|
||||
}
|
||||
|
||||
- (void) _drawText: (NSString *) title inFrame: (NSRect) cellFrame
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue