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:
@ -116,9 +116,9 @@
[super dealloc]; [super dealloc];
} }
// /*
// Setting the Titles * Setting the Titles
// */
- (NSString*) title - (NSString*) title
{ {
return [self stringValue]; return [self stringValue];
@ -150,9 +150,9 @@
[(NSControl*)_control_view updateCell: self]; [(NSControl*)_control_view updateCell: self];
} }
// /*
// Setting the Images * Setting the Images
// */
- (NSImage*) alternateImage - (NSImage*) alternateImage
{ {
return _altImage; return _altImage;
@ -173,9 +173,9 @@
_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;
@ -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,9 +356,9 @@
return _cell.state; return _cell.state;
} }
// /*
// Displaying * Displaying
// */
- (NSColor*) textColor - (NSColor*) textColor
{ {
if (_cell.is_disabled == YES) if (_cell.is_disabled == YES)
@ -490,9 +492,10 @@
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)
@ -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,10 +695,13 @@
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);
}
else
{
titleSize = NSZeroSize; titleSize = NSZeroSize;
} }
@ -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

@ -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];
@ -368,6 +370,7 @@ static NSColor *shadowCol;
{ {
return _cell.state; return _cell.state;
} }
- (BOOL) allowsMixedState - (BOOL) allowsMixedState
{ {
return _cell.allows_mixed_state; return _cell.allows_mixed_state;
@ -1064,8 +1067,6 @@ static NSColor *shadowCol;
{ {
} }
- (NSSize) cellSize - (NSSize) cellSize
{ {
NSSize borderSize, s; NSSize borderSize, s;
@ -1091,6 +1092,7 @@ static NSColor *shadowCol;
case NSTextCellType: case NSTextCellType:
s = GSUtil_sizeOfMultilineStringWithFont(_contents, _cell_font); s = GSUtil_sizeOfMultilineStringWithFont(_contents, _cell_font);
break; break;
case NSImageCellType: case NSImageCellType:
if (_cell_image == nil) if (_cell_image == nil)
{ {
@ -1101,6 +1103,7 @@ static NSColor *shadowCol;
s = [_cell_image size]; s = [_cell_image size];
} }
break; break;
case NSNullCellType: case NSNullCellType:
// macosx instead returns a 'very big size' here; we return NSZeroSize // macosx instead returns a 'very big size' here; we return NSZeroSize
s = NSZeroSize; s = NSZeroSize;
@ -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];
} }
} }
@ -1375,8 +1381,8 @@ static NSColor *shadowCol;
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]];
@ -1403,8 +1409,8 @@ static NSColor *shadowCol;
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]];

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,6 +58,7 @@
} }
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;
@ -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];