git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6264 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 2000-03-10 18:32:41 +00:00
parent 561911c9b8
commit 6d5fe50cac
4 changed files with 279 additions and 246 deletions

View file

@ -1,3 +1,9 @@
Fri Mar 10 13:36:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSCell.m: fixed formatting to be consistent and conform
to GNU standards.
* Source/NSButtonCell.m: ditto.
2000-03-10 Pascal J. Bourguignon <pjb@imaginet.fr> 2000-03-10 Pascal J. Bourguignon <pjb@imaginet.fr>
* Source/GSUtil.m * Source/GSUtil.m
@ -6,7 +12,6 @@
now, only contains the GSUtil_sizeOfMultilineStringWithFont() now, only contains the GSUtil_sizeOfMultilineStringWithFont()
function. function.
* Source/NSCell.m * Source/NSCell.m
* Source/NSButtonCell.m * Source/NSButtonCell.m
@ -18,7 +23,6 @@
drawInteriorWithFrame:inView:] to handle properly multiline drawInteriorWithFrame:inView:] to handle properly multiline
strings. strings.
* Source/NSPanel.m * Source/NSPanel.m
Added the following features to GSAlertPanel private subclass Added the following features to GSAlertPanel private subclass
@ -47,14 +51,12 @@
windows as high as the screen would be centered at y=0 instead of windows as high as the screen would be centered at y=0 instead of
y=title bar height/2. y=title bar height/2.
* Testing/NSPanelTest * Testing/NSPanelTest
Also, I've added a NSPanelTest application in core/Testing, that Also, I've added a NSPanelTest application in core/Testing, that
will show how nice have become the Alert panels... will show how nice have become the Alert panels...
Fri Mar 10 12:42:44 2000 Nicola Pero <n.pero@mi.flashnet.it> Fri Mar 10 12:42:44 2000 Nicola Pero <n.pero@mi.flashnet.it>
* Source/NSSplitView.m ([-mouseDown:]): Fixed bug. * Source/NSSplitView.m ([-mouseDown:]): Fixed bug.

View file

@ -53,18 +53,18 @@
@implementation NSButtonCell @implementation NSButtonCell
// /*
// Class methods * Class methods
// */
+ (void) initialize + (void) initialize
{ {
if (self == [NSButtonCell class]) if (self == [NSButtonCell class])
[self setVersion: 1]; [self setVersion: 1];
} }
// /*
// Instance methods * Instance methods
// */
- (id) _init - (id) _init
{ {
// Implicitly performed by allocation: // Implicitly performed by allocation:
@ -90,7 +90,7 @@
return self; return self;
} }
- (id) initImageCell: (NSImage *)anImage - (id) initImageCell: (NSImage*)anImage
{ {
[super initImageCell: anImage]; [super initImageCell: anImage];
@ -99,7 +99,7 @@
return [self _init]; return [self _init];
} }
- (id) initTextCell: (NSString *)aString - (id) initTextCell: (NSString*)aString
{ {
[super initTextCell: aString]; [super initTextCell: aString];
@ -116,30 +116,30 @@
[super dealloc]; [super dealloc];
} }
// /*
// Setting the Titles * Setting the Titles
// */
- (NSString *) title - (NSString*) title
{ {
return [self stringValue]; return [self stringValue];
} }
- (NSString *) alternateTitle - (NSString*) alternateTitle
{ {
return _altContents; return _altContents;
} }
- (void) setFont: (NSFont *)fontObject - (void) setFont: (NSFont*)fontObject
{ {
[super setFont: fontObject]; [super setFont: fontObject];
} }
- (void) setTitle: (NSString *)aString - (void) setTitle: (NSString*)aString
{ {
[self setStringValue: aString]; [self setStringValue: aString];
} }
- (void) setAlternateTitle: (NSString *)aString - (void) setAlternateTitle: (NSString*)aString
{ {
NSString* string = [aString copy]; NSString* string = [aString copy];
@ -147,13 +147,13 @@
[string release]; [string release];
if (_control_view) if (_control_view)
if ([_control_view isKindOfClass: [NSControl class]]) if ([_control_view isKindOfClass: [NSControl class]])
[(NSControl *)_control_view updateCell: self]; [(NSControl*)_control_view updateCell: self];
} }
// /*
// Setting the Images * Setting the Images
// */
- (NSImage *) alternateImage - (NSImage*) alternateImage
{ {
return _altImage; return _altImage;
} }
@ -163,7 +163,7 @@
return _cell.image_position; return _cell.image_position;
} }
- (void) setAlternateImage: (NSImage *)anImage - (void) setAlternateImage: (NSImage*)anImage
{ {
ASSIGN(_altImage, anImage); ASSIGN(_altImage, anImage);
} }
@ -173,10 +173,10 @@
_cell.image_position = aPosition; _cell.image_position = aPosition;
} }
// /*
// Setting the Repeat Interval * Setting the Repeat Interval
// */
- (void) getPeriodicDelay: (float *)delay interval: (float *)interval - (void) getPeriodicDelay: (float*)delay interval: (float*)interval
{ {
*delay = _delayInterval; *delay = _delayInterval;
*interval = _repeatInterval; *interval = _repeatInterval;
@ -188,9 +188,9 @@
_repeatInterval = interval; _repeatInterval = interval;
} }
// /*
// Setting the Key Equivalent * Setting the Key Equivalent
// */
- (NSString*) keyEquivalent - (NSString*) keyEquivalent
{ {
return _keyEquivalent; return _keyEquivalent;
@ -230,9 +230,9 @@
ASSIGN(_keyEquivalentFont, [NSFont fontWithName: fontName size: fontSize]); ASSIGN(_keyEquivalentFont, [NSFont fontWithName: fontName size: fontSize]);
} }
// /*
// Modifying Graphic Attributes * Modifying Graphic Attributes
// */
- (BOOL) isTransparent - (BOOL) isTransparent
{ {
return _buttoncell_is_transparent; return _buttoncell_is_transparent;
@ -245,16 +245,18 @@
- (BOOL) isOpaque - (BOOL) isOpaque
{ {
// MacOS-X says we should return !transparent && [self isBordered], /*
// but that's wrong in our case, since if there is no border, * MacOS-X says we should return !transparent && [self isBordered],
// we draw the interior of the cell to fill completely the bounds. * but that's wrong in our case, since if there is no border,
// They are likely to draw differently. * we draw the interior of the cell to fill completely the bounds.
* They are likely to draw differently.
*/
return !_buttoncell_is_transparent; return !_buttoncell_is_transparent;
} }
// /*
// Modifying Graphic Attributes * Modifying Graphic Attributes
// */
- (int) highlightsBy - (int) highlightsBy
{ {
return _highlightsByMask; return _highlightsByMask;
@ -354,10 +356,10 @@
return _cell.state; return _cell.state;
} }
// /*
// Displaying * Displaying
// */
- (NSColor *) textColor - (NSColor*) textColor
{ {
if (_cell.is_disabled == YES) if (_cell.is_disabled == YES)
return [NSColor disabledControlTextColor]; return [NSColor disabledControlTextColor];
@ -490,10 +492,11 @@
imageSize = [imageToDisplay size]; imageSize = [imageToDisplay size];
} }
if (titleToDisplay && (ipos == NSImageAbove || ipos == NSImageBelow)) { if (titleToDisplay && (ipos == NSImageAbove || ipos == NSImageBelow))
titleSize =GSUtil_sizeOfMultilineStringWithFont(titleToDisplay, {
_cell_font); titleSize
} = GSUtil_sizeOfMultilineStringWithFont(titleToDisplay, _cell_font);
}
if (flippedView == YES) if (flippedView == YES)
{ {
@ -524,11 +527,11 @@
imageRect.size.width = imageSize.width; imageRect.size.width = imageSize.width;
imageRect.size.height = cellFrame.size.height; imageRect.size.height = cellFrame.size.height;
if (_cell.is_bordered || _cell.is_bezeled) if (_cell.is_bordered || _cell.is_bezeled)
{ {
imageRect.origin.x += 3; imageRect.origin.x += 3;
imageRect.size.height -= 2; imageRect.size.height -= 2;
imageRect.origin.y += 1; imageRect.origin.y += 1;
} }
titleRect = imageRect; titleRect = imageRect;
titleRect.origin.x += imageSize.width + xDist; titleRect.origin.x += imageSize.width + xDist;
titleRect.size.width = cellFrame.size.width - imageSize.width - xDist; titleRect.size.width = cellFrame.size.width - imageSize.width - xDist;
@ -544,11 +547,11 @@
imageRect.size.width = imageSize.width; imageRect.size.width = imageSize.width;
imageRect.size.height = cellFrame.size.height; imageRect.size.height = cellFrame.size.height;
if (_cell.is_bordered || _cell.is_bezeled) if (_cell.is_bordered || _cell.is_bezeled)
{ {
imageRect.origin.x -= 3; imageRect.origin.x -= 3;
imageRect.size.height -= 2; imageRect.size.height -= 2;
imageRect.origin.y += 1; imageRect.origin.y += 1;
} }
titleRect.origin = cellFrame.origin; titleRect.origin = cellFrame.origin;
titleRect.size.width = cellFrame.size.width - imageSize.width - xDist; titleRect.size.width = cellFrame.size.width - imageSize.width - xDist;
titleRect.size.height = cellFrame.size.height; titleRect.size.height = cellFrame.size.height;
@ -560,8 +563,11 @@
break; break;
case NSImageAbove: case NSImageAbove:
/* In this case, imageRect is all the space we can allocate above the text. /*
The drawing code below will then center the image in imageRect. */ * In this case, imageRect is all the space we can allocate
* above the text.
* The drawing code below will then center the image in imageRect.
*/
titleRect.origin.x = cellFrame.origin.x; titleRect.origin.x = cellFrame.origin.x;
titleRect.origin.y = cellFrame.origin.y; titleRect.origin.y = cellFrame.origin.y;
titleRect.size.width = cellFrame.size.width; titleRect.size.width = cellFrame.size.width;
@ -587,8 +593,11 @@
break; break;
case NSImageBelow: case NSImageBelow:
/* In this case, imageRect is all the space we can allocate below the text. /*
The drawing code below will then center the image in imageRect. */ * In this case, imageRect is all the space we can allocate
* below the text.
* The drawing code below will then center the image in imageRect.
*/
titleRect.origin.x = cellFrame.origin.x; titleRect.origin.x = cellFrame.origin.x;
titleRect.origin.y = cellFrame.origin.y + cellFrame.size.height; titleRect.origin.y = cellFrame.origin.y + cellFrame.size.height;
titleRect.origin.y -= titleSize.height; titleRect.origin.y -= titleSize.height;
@ -655,9 +664,9 @@
NSSize imageSize; NSSize imageSize;
NSSize titleSize; NSSize titleSize;
// /*
// The following code must be kept in sync with -drawInteriorWithFrame * The following code must be kept in sync with -drawInteriorWithFrame
// */
if (_cell.is_highlighted) if (_cell.is_highlighted)
mask = _highlightsByMask; mask = _highlightsByMask;
@ -686,53 +695,56 @@
else else
imageSize = NSZeroSize; imageSize = NSZeroSize;
if(titleToDisplay!=nil){ if (titleToDisplay != nil)
titleSize=GSUtil_sizeOfMultilineStringWithFont(titleToDisplay, {
_cell_font); titleSize
}else{ = GSUtil_sizeOfMultilineStringWithFont(titleToDisplay, _cell_font);
titleSize=NSZeroSize; }
} else
{
titleSize = NSZeroSize;
}
switch (_cell.image_position) switch (_cell.image_position)
{ {
case NSNoImage: case NSNoImage:
s = titleSize; s = titleSize;
break; break;
case NSImageOnly: case NSImageOnly:
s = imageSize; s = imageSize;
break; break;
case NSImageLeft: case NSImageLeft:
case NSImageRight: case NSImageRight:
s.width = imageSize.width + titleSize.width + xDist; s.width = imageSize.width + titleSize.width + xDist;
if (imageSize.height > titleSize.height) if (imageSize.height > titleSize.height)
s.height = imageSize.height; s.height = imageSize.height;
else else
s.height = titleSize.height; s.height = titleSize.height;
break; break;
case NSImageBelow: case NSImageBelow:
case NSImageAbove: case NSImageAbove:
if (imageSize.width > titleSize.width) if (imageSize.width > titleSize.width)
s.width = imageSize.width; s.width = imageSize.width;
else else
s.width = titleSize.width; s.width = titleSize.width;
s.height = imageSize.height + titleSize.height; // + yDist ?? s.height = imageSize.height + titleSize.height; // + yDist ??
break; break;
case NSImageOverlaps: case NSImageOverlaps:
if (imageSize.width > titleSize.width) if (imageSize.width > titleSize.width)
s.width = imageSize.width; s.width = imageSize.width;
else else
s.width = titleSize.width; s.width = titleSize.width;
if (imageSize.height > titleSize.height) if (imageSize.height > titleSize.height)
s.height = imageSize.height; s.height = imageSize.height;
else else
s.height = titleSize.height; s.height = titleSize.height;
break; break;
} }
// Get border size // Get border size
@ -743,7 +755,7 @@
borderSize = NSZeroSize; borderSize = NSZeroSize;
if ((_cell.is_bordered || _cell.is_bezeled) if ((_cell.is_bordered || _cell.is_bezeled)
&& (_cell.image_position != NSImageOnly)) && (_cell.image_position != NSImageOnly))
{ {
borderSize.height += 1; borderSize.height += 1;
borderSize.width += 3; borderSize.width += 3;
@ -760,9 +772,11 @@
{ {
if (_cell.is_bordered) if (_cell.is_bordered)
{ {
// Special case: Buttons have only three different paths for border. /*
// One white path at the top left corner, one black path at the * Special case: Buttons have only three different paths for border.
// bottom right and another in dark gray at the inner bottom right. * One white path at the top left corner, one black path at the
* bottom right and another in dark gray at the inner bottom right.
*/
float yDelta = [_control_view isFlipped] ? 1. : 2.; float yDelta = [_control_view isFlipped] ? 1. : 2.;
return NSMakeRect (theRect.origin.x + 1., return NSMakeRect (theRect.origin.x + 1.,
theRect.origin.y + yDelta, theRect.origin.y + yDelta,
@ -773,9 +787,9 @@
return theRect; return theRect;
} }
// /*
// NSCopying protocol * NSCopying protocol
// */
- (id) copyWithZone: (NSZone*)zone - (id) copyWithZone: (NSZone*)zone
{ {
NSButtonCell *c = [super copyWithZone: zone]; NSButtonCell *c = [super copyWithZone: zone];
@ -794,9 +808,9 @@
return c; return c;
} }
// /*
// NSCoding protocol * NSCoding protocol
// */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
BOOL tmp; BOOL tmp;

View file

@ -103,7 +103,7 @@ static NSColor *shadowCol;
} }
} }
+ (NSMenu *)defaultMenu + (NSMenu*)defaultMenu
{ {
return nil; return nil;
} }
@ -192,11 +192,13 @@ static NSColor *shadowCol;
// TODO // TODO
return nil; return nil;
} }
- (BOOL)hasValidObjectValue
- (BOOL) hasValidObjectValue
{ {
// TODO // TODO
return NO; return NO;
} }
- (double) doubleValue - (double) doubleValue
{ {
return [_contents doubleValue]; return [_contents doubleValue];
@ -217,7 +219,7 @@ static NSColor *shadowCol;
return _contents; return _contents;
} }
- (void) setObjectValue:(id)object - (void) setObjectValue: (id)object
{ {
// TODO // TODO
} }
@ -243,7 +245,7 @@ static NSColor *shadowCol;
ASSIGN(_contents, number_string); ASSIGN(_contents, number_string);
} }
- (void) setStringValue: (NSString *)aString - (void) setStringValue: (NSString*)aString
{ {
NSString *string; NSString *string;
@ -284,14 +286,14 @@ static NSColor *shadowCol;
_cell.type = aType; _cell.type = aType;
switch (_cell.type) switch (_cell.type)
{ {
case NSTextCellType: case NSTextCellType:
ASSIGN(_cell_font, [fontClass userFontOfSize: 0]); ASSIGN(_cell_font, [fontClass userFontOfSize: 0]);
ASSIGN(_contents, @"title"); ASSIGN(_contents, @"title");
break; break;
case NSImageCellType: case NSImageCellType:
TEST_RELEASE(_cell_image); TEST_RELEASE(_cell_image);
_cell_image = nil; _cell_image = nil;
break; break;
} }
} }
@ -368,38 +370,39 @@ static NSColor *shadowCol;
{ {
return _cell.state; return _cell.state;
} }
- (BOOL)allowsMixedState
- (BOOL) allowsMixedState
{ {
return _cell.allows_mixed_state; return _cell.allows_mixed_state;
} }
- (void)setAllowsMixedState:(BOOL)flag - (void) setAllowsMixedState: (BOOL)flag
{ {
_cell.allows_mixed_state = flag; _cell.allows_mixed_state = flag;
} }
- (int)nextState - (int) nextState
{ {
switch (_cell.state) switch (_cell.state)
{ {
case NSOnState: case NSOnState:
return NSOffState; return NSOffState;
case NSOffState: case NSOffState:
if (_cell.allows_mixed_state) if (_cell.allows_mixed_state)
{ {
return NSMixedState; return NSMixedState;
} }
else else
{ {
return NSOnState; return NSOnState;
} }
case NSMixedState: case NSMixedState:
default: default:
return NSOnState; return NSOnState;
} }
} }
- (void)setNextState - (void) setNextState
{ {
[self setState: [self nextState]]; [self setState: [self nextState]];
} }
@ -447,7 +450,7 @@ static NSColor *shadowCol;
_cell.is_editable = flag; _cell.is_editable = flag;
} }
- (void) setFont: (NSFont *)fontObject - (void) setFont: (NSFont*)fontObject
{ {
NSAssert(fontObject == nil || [fontObject isKindOfClass: fontClass], NSAssert(fontObject == nil || [fontObject isKindOfClass: fontClass],
NSInvalidArgumentException); NSInvalidArgumentException);
@ -484,34 +487,34 @@ static NSColor *shadowCol;
return _cell.wraps; return _cell.wraps;
} }
- (void)setAttributedStringValue:(NSAttributedString *)attribStr - (void) setAttributedStringValue: (NSAttributedString*)attribStr
{ {
//TODO //TODO
} }
- (NSAttributedString *)attributedStringValue - (NSAttributedString*) attributedStringValue
{ {
//TODO //TODO
return nil; return nil;
} }
- (void)setAllowsEditingTextAttributes:(BOOL)flag - (void) setAllowsEditingTextAttributes: (BOOL)flag
{ {
//TODO //TODO
} }
- (BOOL)allowsEditingTextAttributes - (BOOL) allowsEditingTextAttributes
{ {
//TODO //TODO
return NO; return NO;
} }
- (void)setImportsGraphics:(BOOL)flag - (void) setImportsGraphics: (BOOL)flag
{ {
//TODO //TODO
} }
- (BOOL)importsGraphics - (BOOL) importsGraphics
{ {
//TODO //TODO
return NO; return NO;
@ -628,12 +631,12 @@ static NSColor *shadowCol;
_cell_float_right = rightDigits; _cell_float_right = rightDigits;
} }
- (void)setFormatter:(NSFormatter *)newFormatter - (void) setFormatter: (NSFormatter*)newFormatter
{ {
//TODO //TODO
} }
- (id)formatter - (id) formatter
{ {
//TODO //TODO
return nil; return nil;
@ -658,20 +661,20 @@ static NSColor *shadowCol;
/* /*
* Menu * Menu
*/ */
- (void)setMenu:(NSMenu *)aMenu - (void) setMenu: (NSMenu*)aMenu
{ {
//TODO //TODO
} }
- (NSMenu *)menu - (NSMenu*) menu
{ {
//TODO //TODO
return nil; return nil;
} }
- (NSMenu *)menuForEvent:(NSEvent *)anEvent - (NSMenu*) menuForEvent: (NSEvent*)anEvent
inRect:(NSRect)cellFrame inRect: (NSRect)cellFrame
ofView:(NSView *)aView ofView: (NSView*)aView
{ {
// TODO // TODO
return [self menu]; return [self menu];
@ -700,44 +703,44 @@ static NSColor *shadowCol;
return !_cell.is_disabled && ([self refusesFirstResponder] == NO); return !_cell.is_disabled && ([self refusesFirstResponder] == NO);
} }
- (void)setShowsFirstResponder:(BOOL)flag - (void) setShowsFirstResponder: (BOOL)flag
{ {
} }
- (BOOL)showsFirstResponder - (BOOL) showsFirstResponder
{ {
return NO; return NO;
} }
- (void)setTitleWithMnemonic:(NSString *)aString - (void) setTitleWithMnemonic: (NSString*)aString
{ {
// Provided for compatibility only // Provided for compatibility only
} }
- (NSString *)mnemonic - (NSString*) mnemonic
{ {
// provided for compatibility only // provided for compatibility only
return @""; return @"";
} }
- (void)setMnemonicLocation:(unsigned int)location - (void) setMnemonicLocation: (unsigned int)location
{ {
// Provided for compatibility only // Provided for compatibility only
} }
- (unsigned int)mnemonicLocation - (unsigned int) mnemonicLocation
{ {
// Provided for compatibiliy only // Provided for compatibiliy only
return NSNotFound; return NSNotFound;
} }
- (BOOL)refusesFirstResponder - (BOOL) refusesFirstResponder
{ {
// Approximate compatibility behaviour // Approximate compatibility behaviour
return _cell.is_disabled; return _cell.is_disabled;
} }
- (void)setRefusesFirstResponder:(BOOL)flag - (void) setRefusesFirstResponder: (BOOL)flag
{ {
// Approximate compatibility behaviour // Approximate compatibility behaviour
_cell.is_disabled = flag; _cell.is_disabled = flag;
@ -767,14 +770,14 @@ static NSColor *shadowCol;
{ {
NS_DURING NS_DURING
{ {
[(NSControl *)cv sendAction: action to: [self target]]; [(NSControl*)cv sendAction: action to: [self target]];
} }
NS_HANDLER NS_HANDLER
{ {
[localException raise]; [localException raise];
} }
NS_ENDHANDLER NS_ENDHANDLER
} }
} }
else // We have no control view. The best we can do is the following. else // We have no control view. The best we can do is the following.
{ {
@ -791,7 +794,7 @@ static NSColor *shadowCol;
[localException raise]; [localException raise];
} }
NS_ENDHANDLER NS_ENDHANDLER
} }
} }
} }
@ -841,7 +844,7 @@ static NSColor *shadowCol;
*/ */
- (BOOL) continueTracking: (NSPoint)lastPoint - (BOOL) continueTracking: (NSPoint)lastPoint
at: (NSPoint)currentPoint at: (NSPoint)currentPoint
inView: (NSView *)controlView inView: (NSView*)controlView
{ {
return YES; return YES;
} }
@ -852,13 +855,13 @@ static NSColor *shadowCol;
return 0; return 0;
} }
- (void) getPeriodicDelay: (float *)delay interval: (float *)interval - (void) getPeriodicDelay: (float*)delay interval: (float*)interval
{ {
*delay = 0.1; *delay = 0.1;
*interval = 0.1; *interval = 0.1;
} }
- (BOOL) startTrackingAt: (NSPoint)startPoint inView: (NSView *)controlView - (BOOL) startTrackingAt: (NSPoint)startPoint inView: (NSView*)controlView
{ {
// If the point is in the view then yes start tracking // If the point is in the view then yes start tracking
if ([controlView mouse: startPoint inRect: [controlView bounds]]) if ([controlView mouse: startPoint inRect: [controlView bounds]])
@ -869,14 +872,14 @@ static NSColor *shadowCol;
- (void) stopTracking: (NSPoint)lastPoint - (void) stopTracking: (NSPoint)lastPoint
at: (NSPoint)stopPoint at: (NSPoint)stopPoint
inView: (NSView *)controlView inView: (NSView*)controlView
mouseIsUp: (BOOL)flag mouseIsUp: (BOOL)flag
{ {
} }
- (BOOL) trackMouse: (NSEvent *)theEvent - (BOOL) trackMouse: (NSEvent*)theEvent
inRect: (NSRect)cellFrame inRect: (NSRect)cellFrame
ofView: (NSView *)controlView ofView: (NSView*)controlView
untilMouseUp: (BOOL)flag untilMouseUp: (BOOL)flag
{ {
NSApplication *theApp = [NSApplication sharedApplication]; NSApplication *theApp = [NSApplication sharedApplication];
@ -1025,7 +1028,7 @@ static NSColor *shadowCol;
/* /*
* Managing the Cursor * Managing the Cursor
*/ */
- (void) resetCursorRect: (NSRect)cellFrame inView: (NSView *)controlView - (void) resetCursorRect: (NSRect)cellFrame inView: (NSView*)controlView
{ {
if (_cell.type == NSTextCellType && _cell.is_disabled == NO if (_cell.type == NSTextCellType && _cell.is_disabled == NO
&& (_cell.is_selectable == YES || _cell.is_editable == YES)) && (_cell.is_selectable == YES || _cell.is_editable == YES))
@ -1064,8 +1067,6 @@ static NSColor *shadowCol;
{ {
} }
- (NSSize) cellSize - (NSSize) cellSize
{ {
NSSize borderSize, s; NSSize borderSize, s;
@ -1088,23 +1089,25 @@ static NSColor *shadowCol;
// Get Content Size // Get Content Size
switch (_cell.type) switch (_cell.type)
{ {
case NSTextCellType: case NSTextCellType:
s=GSUtil_sizeOfMultilineStringWithFont(_contents,_cell_font); s = GSUtil_sizeOfMultilineStringWithFont(_contents, _cell_font);
break; break;
case NSImageCellType:
if (_cell_image == nil) case NSImageCellType:
{ if (_cell_image == nil)
s = NSZeroSize; {
} s = NSZeroSize;
else }
{ else
s = [_cell_image size]; {
} s = [_cell_image size];
break; }
case NSNullCellType: break;
// macosx instead returns a 'very big size' here; we return NSZeroSize
s = NSZeroSize; case NSNullCellType:
break; // macosx instead returns a 'very big size' here; we return NSZeroSize
s = NSZeroSize;
break;
} }
// Add in border size // Add in border size
@ -1136,7 +1139,7 @@ static NSColor *shadowCol;
else else
borderSize = NSZeroSize; borderSize = NSZeroSize;
return NSInsetRect (theRect, borderSize.width, borderSize.height); return NSInsetRect(theRect, borderSize.width, borderSize.height);
} }
- (NSRect) imageRectForBounds: (NSRect)theRect - (NSRect) imageRectForBounds: (NSRect)theRect
@ -1183,7 +1186,7 @@ static NSColor *shadowCol;
return txtCol; return txtCol;
} }
- (void) _drawText: (NSString *) title inFrame: (NSRect) cellFrame - (void) _drawText: (NSString*) title inFrame: (NSRect) cellFrame
{ {
NSColor *textColor; NSColor *textColor;
float titleWidth; float titleWidth;
@ -1266,10 +1269,10 @@ static NSColor *shadowCol;
[title drawInRect: cellFrame withAttributes: dict]; [title drawInRect: cellFrame withAttributes: dict];
} }
// /*
// This drawing is minimal and with no background, * This drawing is minimal and with no background,
// to make it easier for subclass to customize drawing. * to make it easier for subclass to customize drawing.
// */
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView - (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
{ {
if (![controlView window]) if (![controlView window])
@ -1358,10 +1361,13 @@ static NSColor *shadowCol;
if (_cell.is_highlighted != lit) if (_cell.is_highlighted != lit)
{ {
_cell.is_highlighted = lit; _cell.is_highlighted = lit;
// NB: This has a visible effect only if subclasses override drawWithFrame:inView: /*
// to draw something special when the cell is highlighted. * NB: This has a visible effect only if subclasses override
// NSCell simply draws border+text/image and makes no highlighting, * drawWithFrame:inView: to draw something special when the
// for easier subclassing. * cell is highlighted.
* NSCell simply draws border+text/image and makes no highlighting,
* for easier subclassing.
*/
[self drawWithFrame: cellFrame inView: controlView]; [self drawWithFrame: cellFrame inView: controlView];
} }
} }
@ -1370,13 +1376,13 @@ static NSColor *shadowCol;
* Editing Text * Editing Text
*/ */
- (void) editWithFrame: (NSRect)aRect - (void) editWithFrame: (NSRect)aRect
inView: (NSView *)controlView inView: (NSView*)controlView
editor: (NSText *)textObject editor: (NSText*)textObject
delegate: (id)anObject delegate: (id)anObject
event: (NSEvent *)theEvent event: (NSEvent*)theEvent
{ {
if (!controlView || !textObject || !_cell_font || if (!controlView || !textObject || !_cell_font
(_cell.type != NSTextCellType)) || (_cell.type != NSTextCellType))
return; return;
[textObject setFrame: [self titleRectForBounds: aRect]]; [textObject setFrame: [self titleRectForBounds: aRect]];
@ -1397,14 +1403,14 @@ static NSColor *shadowCol;
} }
- (void) selectWithFrame: (NSRect)aRect - (void) selectWithFrame: (NSRect)aRect
inView: (NSView *)controlView inView: (NSView*)controlView
editor: (NSText *)textObject editor: (NSText*)textObject
delegate: (id)anObject delegate: (id)anObject
start: (int)selStart start: (int)selStart
length: (int)selLength length: (int)selLength
{ {
if (!controlView || !textObject || !_cell_font || if (!controlView || !textObject || !_cell_font
(_cell.type != NSTextCellType)) || (_cell.type != NSTextCellType))
return; return;
[textObject setFrame: [self titleRectForBounds: aRect]]; [textObject setFrame: [self titleRectForBounds: aRect]];
@ -1416,13 +1422,13 @@ static NSColor *shadowCol;
[textObject display]; [textObject display];
} }
- (BOOL)sendsActionOnEndEditing - (BOOL) sendsActionOnEndEditing
{ {
//TODO //TODO
return NO; return NO;
} }
- (void)setSendsActionOnEndEditing:(BOOL)flag - (void) setSendsActionOnEndEditing: (BOOL)flag
{ {
//TODO //TODO
} }
@ -1566,13 +1572,13 @@ _sizeForBorderType (NSBorderType aType)
// Returns the size of a border // Returns the size of a border
switch (aType) switch (aType)
{ {
case NSLineBorder: case NSLineBorder:
return NSMakeSize(1, 1); return NSMakeSize(1, 1);
case NSGrooveBorder: case NSGrooveBorder:
case NSBezelBorder: case NSBezelBorder:
return NSMakeSize(2, 2); return NSMakeSize(2, 2);
case NSNoBorder: case NSNoBorder:
default: default:
return NSZeroSize; return NSZeroSize;
} }
} }

View file

@ -42,9 +42,9 @@
@implementation NSSplitView @implementation NSSplitView
// /*
// Instance methods * Instance methods
// */
- (id) initWithFrame: (NSRect)frameRect - (id) initWithFrame: (NSRect)frameRect
{ {
if ((self = [super initWithFrame: frameRect]) != nil) if ((self = [super initWithFrame: frameRect]) != nil)
@ -58,7 +58,8 @@
} }
return self; return self;
} }
- (BOOL) acceptsFirstMouse: (NSEvent *)theEvent
- (BOOL) acceptsFirstMouse: (NSEvent*)theEvent
{ {
return YES; return YES;
} }
@ -115,7 +116,10 @@
r = [prev frame]; r = [prev frame];
else else
{ {
/* This happens if user pressed exactly on the top of the top subview */ /*
* This happens if user pressed exactly on the
* top of the top subview
*/
goto RETURN_LABEL; goto RETURN_LABEL;
} }
if (v) if (v)
@ -138,7 +142,10 @@
r = [prev frame]; r = [prev frame];
else else
{ {
/* This happens if user pressed exactly on the left of the left subview */ /*
* This happens if user pressed exactly on the
* left of the left subview
*/
goto RETURN_LABEL; goto RETURN_LABEL;
} }
if (v) if (v)
@ -413,14 +420,18 @@ RETURN_LABEL:
- (float) dividerThickness - (float) dividerThickness
{ {
// You need to override this method in subclasses to change the /*
// dividerThickness (or, without need for subclassing, invoke * You need to override this method in subclasses to change the
// setDimpleImage:resetDividerThickness:YES below) * dividerThickness (or, without need for subclassing, invoke
* setDimpleImage:resetDividerThickness:YES below)
*/
return 6; return 6;
} }
// FIXME: Perhaps the following two should be removed and _dividerWidth /*
// should be used also for dragging? * FIXME: Perhaps the following two should be removed and _dividerWidth
* should be used also for dragging?
*/
- (float) draggedBarWidth //defaults to 8 - (float) draggedBarWidth //defaults to 8
{ {
return _draggedBarWidth; return _draggedBarWidth;
@ -430,7 +441,7 @@ RETURN_LABEL:
{ {
_draggedBarWidth = newWidth; _draggedBarWidth = newWidth;
} }
//
static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect) static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
{ {
NSPoint p; NSPoint p;
@ -471,7 +482,7 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
return _isVertical; return _isVertical;
} }
- (void) setDimpleImage: (NSImage *)anImage resetDividerThickness: (BOOL)flag - (void) setDimpleImage: (NSImage*)anImage resetDividerThickness: (BOOL)flag
{ {
ASSIGN(_dimpleImage, anImage); ASSIGN(_dimpleImage, anImage);
@ -589,9 +600,9 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
ASSIGN(_backgroundColor, aColor); ASSIGN(_backgroundColor, aColor);
} }
// /*
// NSCoding protocol * NSCoding protocol
// */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];