mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 20:31:56 +00:00
Monor tidyups
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5116 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a62d5596c9
commit
4b2933e3ce
3 changed files with 695 additions and 665 deletions
|
@ -1,3 +1,8 @@
|
|||
Tue Nov 2 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSCell.m: Updated to notice changes in system colors,
|
||||
also optimised a little by caching some classes.
|
||||
|
||||
Sat Oct 30 1999 Nicola Pero <n.pero@mi.flashnet.it>
|
||||
|
||||
Still work in progress, but this is a first preview
|
||||
|
|
|
@ -49,19 +49,36 @@
|
|||
#include <AppKit/NSColor.h>
|
||||
#include <AppKit/PSOperators.h>
|
||||
|
||||
static Class colorClass;
|
||||
static Class cellClass;
|
||||
static Class fontClass;
|
||||
static Class imageClass;
|
||||
|
||||
static NSColor *bgCol;
|
||||
static NSColor *hbgCol;
|
||||
static NSColor *txtCol;
|
||||
static NSColor *dtxtCol;
|
||||
static NSColor *clearCol = nil;
|
||||
static NSColor *clearCol;
|
||||
static NSColor *shadowCol;
|
||||
|
||||
@interface NSCell (PrivateColor)
|
||||
+ (void) _systemColorsChanged: (NSNotification*)n;
|
||||
@end
|
||||
|
||||
@implementation NSCell (PrivateColor)
|
||||
+ (void) _systemColorsChanged: (NSNotification*)n
|
||||
{
|
||||
ASSIGN(bgCol, [colorClass controlBackgroundColor]);
|
||||
ASSIGN(hbgCol, [colorClass selectedControlColor]);
|
||||
ASSIGN(txtCol, [colorClass controlTextColor]);
|
||||
ASSIGN(dtxtCol, [colorClass disabledControlTextColor]);
|
||||
ASSIGN(clearCol, [colorClass clearColor]);
|
||||
ASSIGN(shadowCol, [colorClass controlDarkShadowColor]);
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSCell
|
||||
|
||||
static Class imageClass;
|
||||
static Class cellClass;
|
||||
|
||||
/*
|
||||
* Class methods
|
||||
*/
|
||||
|
@ -70,8 +87,20 @@ static Class cellClass;
|
|||
if (self == [NSCell class])
|
||||
{
|
||||
[self setVersion: 1];
|
||||
imageClass = [NSImage class];
|
||||
colorClass = [NSColor class];
|
||||
cellClass = [NSCell class];
|
||||
fontClass = [NSFont class];
|
||||
imageClass = [NSImage class];
|
||||
/*
|
||||
* Watch for changes to system colors, and simulate an initial change
|
||||
* in order to set up our defaults.
|
||||
*/
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(_systemColorsChanged:)
|
||||
name: NSSystemColorsDidChangeNotification
|
||||
object: nil];
|
||||
[self _systemColorsChanged: nil];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,20 +131,10 @@ static Class cellClass;
|
|||
cell_float_left = 0;
|
||||
cell_float_right = 0;
|
||||
action_mask = NSLeftMouseUpMask;
|
||||
|
||||
if (clearCol == nil)
|
||||
{
|
||||
bgCol = RETAIN([NSColor controlBackgroundColor]);
|
||||
hbgCol = RETAIN([NSColor selectedControlColor]);
|
||||
txtCol = RETAIN([NSColor controlTextColor]);
|
||||
dtxtCol = RETAIN([NSColor disabledControlTextColor]);
|
||||
clearCol = RETAIN([NSColor clearColor]);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- init
|
||||
- (id) init
|
||||
{
|
||||
return [self initTextCell: @""];
|
||||
}
|
||||
|
@ -132,7 +151,7 @@ static Class cellClass;
|
|||
cell_type = NSImageCellType;
|
||||
cell_image = RETAIN(anImage);
|
||||
image_position = NSImageOnly;
|
||||
cell_font = RETAIN([NSFont userFontOfSize: 0]);
|
||||
cell_font = RETAIN([fontClass userFontOfSize: 0]);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -143,7 +162,7 @@ static Class cellClass;
|
|||
|
||||
[self _init];
|
||||
|
||||
cell_font = RETAIN([NSFont userFontOfSize: 0]);
|
||||
cell_font = RETAIN([fontClass userFontOfSize: 0]);
|
||||
contents = RETAIN(aString);
|
||||
cell_type = NSTextCellType;
|
||||
text_align = NSCenterTextAlignment;
|
||||
|
@ -437,7 +456,7 @@ static Class cellClass;
|
|||
|
||||
- (void) setFont: (NSFont *)fontObject
|
||||
{
|
||||
NSAssert(fontObject == nil || [fontObject isKindOfClass: [NSFont class]],
|
||||
NSAssert(fontObject == nil || [fontObject isKindOfClass: fontClass],
|
||||
NSInvalidArgumentException);
|
||||
|
||||
ASSIGN(cell_font, fontObject);
|
||||
|
@ -757,7 +776,7 @@ static Class cellClass;
|
|||
// draw the border if needed
|
||||
if ([self isBordered])
|
||||
{
|
||||
[[NSColor controlDarkShadowColor] set];
|
||||
[shadowCol set];
|
||||
NSFrameRect(cellFrame);
|
||||
}
|
||||
else if ([self isBezeled])
|
||||
|
@ -1097,7 +1116,7 @@ static Class cellClass;
|
|||
*/
|
||||
- (NSComparisonResult) compare: (id)otherCell
|
||||
{
|
||||
if ([otherCell isKindOfClass: [NSCell class]] == NO)
|
||||
if ([otherCell isKindOfClass: cellClass] == NO)
|
||||
[NSException raise: NSBadComparisonException
|
||||
format: @"NSCell comparison with non-NSCell"];
|
||||
if (cell_type != NSTextCellType
|
||||
|
|
|
@ -305,16 +305,22 @@ static NSRange MakeRangeFromAbs(int a1,int a2)
|
|||
}
|
||||
|
||||
- (BOOL) areMultipleFontsInRange: (NSRange) aRange
|
||||
{ NSRange longestRange;
|
||||
[self attribute: NSFontAttributeName atIndex: aRange.location longestEffectiveRange: &longestRange inRange: aRange];
|
||||
if (NSEqualRanges(NSIntersectionRange(longestRange,aRange),aRange)) return NO;
|
||||
else return YES;
|
||||
{
|
||||
NSRange longestRange;
|
||||
|
||||
[self attribute: NSFontAttributeName atIndex: aRange.location
|
||||
longestEffectiveRange: &longestRange inRange: aRange];
|
||||
if (NSEqualRanges(NSIntersectionRange(longestRange, aRange), aRange))
|
||||
return NO;
|
||||
else
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface _GNUSeekableArrayEnumerator: NSObject
|
||||
{ unsigned currentIndex;
|
||||
{
|
||||
unsigned currentIndex;
|
||||
NSArray *array;
|
||||
}
|
||||
- initWithArray: (NSArray*) anArray;
|
||||
|
@ -465,8 +471,8 @@ static NSRange MakeRangeFromAbs(int a1,int a2)
|
|||
if ((!sendType || [sendType isEqual: NSStringPboardType]) &&
|
||||
(!returnType || [returnType isEqual: NSStringPboardType]))
|
||||
{
|
||||
if (([self selectedRange].length || !sendType) &&
|
||||
([self isEditable] || !returnType))
|
||||
if (([self selectedRange].length || !sendType)
|
||||
&& ([self isEditable] || !returnType))
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue