mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 18:11:06 +00:00
Tidied to get rid of pretty useless private method
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4871 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c112f1be56
commit
0dd419d272
6 changed files with 166 additions and 109 deletions
|
@ -1,3 +1,10 @@
|
|||
Sat Sep 11 11:20:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Headers/AppKit/NSCell.h: Removed ([-_drawImage:inFrame:])
|
||||
* Source/NSCell.m: Removed ([-_drawImage:inFrame:])
|
||||
* Source/NSButtonCell.m: Don't use ([-_drawImage:inFrame:])
|
||||
* Source/NSPopUpButtonCell.m: Don't use ([-_drawImage:inFrame:])
|
||||
|
||||
Sat Sep 11 1999 Nicola Pero <n.pero@mi.flashnet.it>
|
||||
|
||||
* Source/NSControl.m ([-sizeToFit]): implemented method.
|
||||
|
|
|
@ -356,7 +356,6 @@ enum {
|
|||
//
|
||||
@interface NSCell (PrivateMethods)
|
||||
|
||||
- (void) _drawImage: (NSImage*)anImage inFrame: (NSRect)aRect;
|
||||
- (void) _drawText: (NSString*)aString inFrame: (NSRect)aRect;
|
||||
|
||||
@end
|
||||
|
|
|
@ -415,9 +415,10 @@
|
|||
BOOL showAlternate = NO;
|
||||
unsigned mask;
|
||||
NSImage *imageToDisplay;
|
||||
NSRect imageRect;
|
||||
NSString *titleToDisplay;
|
||||
NSRect titleRect;
|
||||
NSSize imageSize = {0, 0};
|
||||
NSRect rect;
|
||||
NSColor *backgroundColor = nil;
|
||||
|
||||
// transparent buttons never draw
|
||||
|
@ -430,14 +431,14 @@
|
|||
if ([self state])
|
||||
{
|
||||
if ( [self showsStateBy]
|
||||
& (NSChangeGrayCellMask | NSChangeBackgroundCellMask) )
|
||||
& (NSChangeGrayCellMask | NSChangeBackgroundCellMask) )
|
||||
backgroundColor = [NSColor selectedControlColor];
|
||||
}
|
||||
|
||||
if ([self isHighlighted])
|
||||
{
|
||||
if ( [self highlightsBy]
|
||||
& (NSChangeGrayCellMask | NSChangeBackgroundCellMask) )
|
||||
& (NSChangeGrayCellMask | NSChangeBackgroundCellMask) )
|
||||
backgroundColor = [NSColor selectedControlColor];
|
||||
}
|
||||
|
||||
|
@ -448,11 +449,13 @@
|
|||
[backgroundColor set];
|
||||
NSRectFill(cellFrame);
|
||||
|
||||
// Determine the image and the title that will be
|
||||
// displayed. If the NSContentsCellMask is set the
|
||||
// image and title are swapped only if state is 1 or
|
||||
// if highlighting is set (when a button is pushed it's
|
||||
// content is changed to the face of reversed state).
|
||||
/*
|
||||
* Determine the image and the title that will be
|
||||
* displayed. If the NSContentsCellMask is set the
|
||||
* image and title are swapped only if state is 1 or
|
||||
* if highlighting is set (when a button is pushed it's
|
||||
* content is changed to the face of reversed state).
|
||||
*/
|
||||
if ([self isHighlighted])
|
||||
mask = [self highlightsBy];
|
||||
else
|
||||
|
@ -481,70 +484,77 @@
|
|||
[imageToDisplay setBackgroundColor: backgroundColor];
|
||||
}
|
||||
|
||||
rect = NSMakeRect (cellFrame.origin.x, cellFrame.origin.y,
|
||||
imageSize.width, imageSize.height);
|
||||
|
||||
switch ([self imagePosition])
|
||||
{
|
||||
case NSNoImage:
|
||||
// draw title only
|
||||
[self _drawText: titleToDisplay inFrame: cellFrame];
|
||||
break;
|
||||
imageToDisplay = nil;
|
||||
titleRect = cellFrame;
|
||||
break;
|
||||
|
||||
case NSImageOnly:
|
||||
// draw image only
|
||||
[self _drawImage: imageToDisplay inFrame: cellFrame];
|
||||
break;
|
||||
titleToDisplay = nil;
|
||||
imageRect = cellFrame;
|
||||
break;
|
||||
|
||||
case NSImageLeft:
|
||||
// draw image to the left of the title
|
||||
rect.origin = cellFrame.origin;
|
||||
rect.size.width = imageSize.width;
|
||||
rect.size.height = cellFrame.size.height;
|
||||
[self _drawImage: imageToDisplay inFrame: rect];
|
||||
imageRect.origin = cellFrame.origin;
|
||||
imageRect.size.width = imageSize.width;
|
||||
imageRect.size.height = cellFrame.size.height;
|
||||
|
||||
// draw title
|
||||
rect.origin.x += imageSize.width + xDist;
|
||||
rect.size.width = cellFrame.size.width - imageSize.width - xDist;
|
||||
[self _drawText: titleToDisplay inFrame: rect];
|
||||
break;
|
||||
titleRect = imageRect;
|
||||
titleRect.origin.x += imageSize.width + xDist;
|
||||
titleRect.size.width = cellFrame.size.width - imageSize.width - xDist;
|
||||
break;
|
||||
|
||||
case NSImageRight:
|
||||
// draw image to the right of the title
|
||||
rect.origin.x = NSMaxX (cellFrame) - imageSize.width;
|
||||
rect.origin.y = cellFrame.origin.y;
|
||||
rect.size.width = imageSize.width;
|
||||
rect.size.height = cellFrame.size.height;
|
||||
[self _drawImage: imageToDisplay inFrame: rect];
|
||||
imageRect.origin.x = NSMaxX(cellFrame) - imageSize.width;
|
||||
imageRect.origin.y = cellFrame.origin.y;
|
||||
imageRect.size.width = imageSize.width;
|
||||
imageRect.size.height = cellFrame.size.height;
|
||||
|
||||
// draw title
|
||||
rect.origin = cellFrame.origin;
|
||||
rect.size.width = cellFrame.size.width - imageSize.width - xDist;
|
||||
rect.size.height = cellFrame.size.height;
|
||||
[self _drawText: titleToDisplay inFrame: rect];
|
||||
break;
|
||||
titleRect.origin = cellFrame.origin;
|
||||
titleRect.size.width = cellFrame.size.width - imageSize.width - xDist;
|
||||
titleRect.size.height = cellFrame.size.height;
|
||||
break;
|
||||
|
||||
case NSImageBelow:
|
||||
// draw image below title
|
||||
cellFrame.size.height /= 2;
|
||||
[self _drawImage: imageToDisplay inFrame: cellFrame];
|
||||
cellFrame.origin.y += cellFrame.size.height;
|
||||
[self _drawText: titleToDisplay inFrame: cellFrame];
|
||||
break;
|
||||
imageRect = cellFrame;
|
||||
imageRect.size.height /= 2;
|
||||
titleRect = imageRect;
|
||||
titleRect.origin.y += titleRect.size.height;
|
||||
break;
|
||||
|
||||
case NSImageAbove:
|
||||
// draw image above title
|
||||
cellFrame.size.height /= 2;
|
||||
[self _drawText: titleToDisplay inFrame: cellFrame];
|
||||
cellFrame.origin.y += cellFrame.size.height;
|
||||
[self _drawImage: imageToDisplay inFrame: cellFrame];
|
||||
break;
|
||||
titleRect = cellFrame;
|
||||
titleRect.size.height /= 2;
|
||||
imageRect = titleRect;
|
||||
imageRect.origin.y += imageRect.size.height;
|
||||
break;
|
||||
|
||||
case NSImageOverlaps:
|
||||
// draw title over the image
|
||||
[self _drawImage: imageToDisplay inFrame: cellFrame];
|
||||
[self _drawText: titleToDisplay inFrame: cellFrame];
|
||||
break;
|
||||
titleRect = cellFrame;
|
||||
imageRect = cellFrame;
|
||||
break;
|
||||
}
|
||||
if (imageToDisplay != nil)
|
||||
{
|
||||
NSSize size;
|
||||
NSPoint position;
|
||||
|
||||
size = [imageToDisplay size];
|
||||
position.x = MAX(NSMidX(imageRect) - (size.width/2.),0.);
|
||||
position.y = MAX(NSMidY(imageRect) - (size.height/2.),0.);
|
||||
/*
|
||||
* Images are always drawn with their bottom-left corner at the origin
|
||||
* so we must adjust the position to take account of a flipped view.
|
||||
*/
|
||||
if ([control_view isFlipped])
|
||||
position.y += size.height;
|
||||
[imageToDisplay compositeToPoint: position operation: NSCompositeCopy];
|
||||
}
|
||||
if (titleToDisplay != nil)
|
||||
{
|
||||
[self _drawText: titleToDisplay inFrame: titleRect];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -681,34 +681,6 @@ static Class cellClass;
|
|||
[title drawInRect: cellFrame withAttributes: dict];
|
||||
}
|
||||
|
||||
static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
|
||||
{
|
||||
NSPoint p;
|
||||
p.x = MAX(NSMidX(outerRect) - (innerSize.width/2.),0.);
|
||||
p.y = MAX(NSMidY(outerRect) - (innerSize.height/2.),0.);
|
||||
return p;
|
||||
}
|
||||
|
||||
// Draw image centered in frame.
|
||||
- (void) _drawImage: (NSImage *) image inFrame: (NSRect) cellFrame
|
||||
{
|
||||
NSSize size;
|
||||
NSPoint position;
|
||||
|
||||
if (!image)
|
||||
return;
|
||||
|
||||
size = [image size];
|
||||
position = centerSizeInRect(size, cellFrame);
|
||||
/*
|
||||
* Images are always drawn with their bottom-left corner at the origin
|
||||
* so we must adjust the position to take account of a flipped view.
|
||||
*/
|
||||
if ([control_view isFlipped])
|
||||
position.y += size.height;
|
||||
[image compositeToPoint: position operation: NSCompositeCopy];
|
||||
}
|
||||
|
||||
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
||||
{
|
||||
cellFrame = [self drawingRectForBounds: cellFrame];
|
||||
|
@ -732,13 +704,31 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
|
|||
switch ([self type])
|
||||
{
|
||||
case NSTextCellType:
|
||||
[self _drawText: [self stringValue] inFrame: cellFrame];
|
||||
break;
|
||||
[self _drawText: [self stringValue] inFrame: cellFrame];
|
||||
break;
|
||||
|
||||
case NSImageCellType:
|
||||
[self _drawImage: cell_image inFrame: cellFrame];
|
||||
break;
|
||||
if (cell_image)
|
||||
{
|
||||
NSSize size;
|
||||
NSPoint position;
|
||||
|
||||
size = [cell_image size];
|
||||
position.x = MAX(NSMidX(cellFrame) - (size.width/2.),0.);
|
||||
position.y = MAX(NSMidY(cellFrame) - (size.height/2.),0.);
|
||||
/*
|
||||
* Images are always drawn with their bottom-left corner
|
||||
* at the origin so we must adjust the position to take
|
||||
* account of a flipped view.
|
||||
*/
|
||||
if ([control_view isFlipped])
|
||||
position.y += size.height;
|
||||
[cell_image compositeToPoint: position operation: NSCompositeCopy];
|
||||
}
|
||||
break;
|
||||
|
||||
case NSNullCellType:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -255,6 +255,7 @@ static BOOL usesUserKeyEquivalents = YES;
|
|||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
NSRect floodRect = cellFrame;
|
||||
NSString *keyQ = nil;
|
||||
NSColor *backColor;
|
||||
|
||||
NSDrawButton(cellFrame, cellFrame);
|
||||
|
||||
|
@ -265,12 +266,13 @@ static BOOL usesUserKeyEquivalents = YES;
|
|||
|
||||
if (cell_highlighted)
|
||||
{
|
||||
[[NSColor selectedMenuItemColor] set];
|
||||
backColor = [NSColor selectedMenuItemColor];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[NSColor controlColor] set];
|
||||
backColor = [NSColor controlColor];
|
||||
}
|
||||
[backColor set];
|
||||
NSRectFill(floodRect);
|
||||
|
||||
if ([self isEnabled])
|
||||
|
@ -293,14 +295,30 @@ static BOOL usesUserKeyEquivalents = YES;
|
|||
DPSmoveto(ctxt, cellFrame.origin.x + 5, cellFrame.origin.y + 6);
|
||||
DPSshow(ctxt, [[self title] cString]);
|
||||
|
||||
if (mcell_has_submenu) {
|
||||
floodRect.origin.x = cellFrame.size.width - 12;
|
||||
floodRect.origin.y += 5;
|
||||
floodRect.size.height = 7;
|
||||
floodRect.size.width = 7;
|
||||
if (mcell_has_submenu)
|
||||
{
|
||||
NSSize size;
|
||||
NSPoint position;
|
||||
NSImage *im = [NSImage imageNamed:@"common_3DArrowRight"];
|
||||
|
||||
[self _drawImage:[NSImage imageNamed:@"common_3DArrowRight"] inFrame:floodRect];
|
||||
} else if (keyQ = [self keyEquivalent]) {
|
||||
floodRect.origin.x = cellFrame.size.width - 12;
|
||||
floodRect.origin.y += 5;
|
||||
floodRect.size.height = 7;
|
||||
floodRect.size.width = 7;
|
||||
|
||||
[im setBackgroundColor: backColor];
|
||||
size = [im size];
|
||||
position.x = MAX(NSMidX(floodRect) - (size.width/2.),0.);
|
||||
position.y = MAX(NSMidY(floodRect) - (size.height/2.),0.);
|
||||
/*
|
||||
* Images are always drawn with their bottom-left corner at the origin
|
||||
* so we must adjust the position to take account of a flipped view.
|
||||
*/
|
||||
if ([control_view isFlipped])
|
||||
position.y += size.height;
|
||||
[im compositeToPoint: position operation: NSCompositeCopy];
|
||||
}
|
||||
else if (keyQ = [self keyEquivalent]) {
|
||||
floodRect.origin.x = cellFrame.size.width - 12;
|
||||
floodRect.origin.y += 5;
|
||||
floodRect.size.height = 7;
|
||||
|
|
|
@ -60,6 +60,8 @@
|
|||
inView: (NSView*)view
|
||||
{
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
NSColor *backColor;
|
||||
NSImage *toDraw = nil;
|
||||
NSRect rect = cellFrame;
|
||||
NSRect arect = cellFrame;
|
||||
NSPoint point;
|
||||
|
@ -73,17 +75,31 @@
|
|||
|
||||
if (cell_highlighted)
|
||||
{
|
||||
[[NSColor selectedMenuItemColor] set];
|
||||
backColor = [NSColor selectedMenuItemColor];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[NSColor controlColor] set];
|
||||
backColor = [NSColor controlColor];
|
||||
}
|
||||
[backColor set];
|
||||
NSRectFill(arect);
|
||||
|
||||
if (cell_image)
|
||||
{
|
||||
[self _drawImage:cell_image inFrame:cellFrame];
|
||||
NSSize size;
|
||||
NSPoint position;
|
||||
|
||||
[cell_image setBackgroundColor: backColor];
|
||||
size = [cell_image size];
|
||||
position.x = MAX(NSMidX(cellFrame) - (size.width/2.),0.);
|
||||
position.y = MAX(NSMidY(cellFrame) - (size.height/2.),0.);
|
||||
/*
|
||||
* Images are always drawn with their bottom-left corner at the origin
|
||||
* so we must adjust the position to take account of a flipped view.
|
||||
*/
|
||||
if ([control_view isFlipped])
|
||||
position.y += size.height;
|
||||
[cell_image compositeToPoint: position operation: NSCompositeCopy];
|
||||
|
||||
rect.size.width = 5; // calc image rect
|
||||
rect.size.height = 11;
|
||||
|
@ -125,16 +141,16 @@
|
|||
if ([[[popb selectedItem] representedObject] isEqual: contents])
|
||||
{
|
||||
if ([popb pullsDown] == NO)
|
||||
[super _drawImage:[NSImage imageNamed:@"common_Nibble"] inFrame:rect];
|
||||
toDraw = [NSImage imageNamed:@"common_Nibble"];
|
||||
else
|
||||
[super _drawImage:[NSImage imageNamed:@"common_3DArrowDown"] inFrame:rect];
|
||||
toDraw = [NSImage imageNamed:@"common_3DArrowDown"];
|
||||
}
|
||||
else if ([[[popb selectedItem] representedObject] isEqual: cell_image])
|
||||
{
|
||||
if ([popb pullsDown] == NO)
|
||||
[super _drawImage:[NSImage imageNamed:@"common_UpAndDownArrowSmall.tiff"] inFrame:rect];
|
||||
toDraw = [NSImage imageNamed:@"common_UpAndDownArrowSmall.tiff"];
|
||||
else
|
||||
[super _drawImage:[NSImage imageNamed:@"common_DownArrowSmall"] inFrame:rect];
|
||||
toDraw = [NSImage imageNamed:@"common_DownArrowSmall"];
|
||||
}
|
||||
}
|
||||
else if ([view isKindOfClass:[NSPopUpButton class]])
|
||||
|
@ -143,17 +159,34 @@
|
|||
isEqual: contents])
|
||||
{
|
||||
if ([(NSPopUpButton *)view pullsDown] == NO)
|
||||
[super _drawImage:[NSImage imageNamed:@"common_Nibble"] inFrame:rect];
|
||||
toDraw = [NSImage imageNamed:@"common_Nibble"];
|
||||
else
|
||||
[super _drawImage:[NSImage imageNamed:@"common_3DArrowDown"] inFrame:rect];
|
||||
toDraw = [NSImage imageNamed:@"common_3DArrowDown"];
|
||||
}
|
||||
else if ([[[(NSPopUpButton *)view selectedItem] representedObject] isEqual: cell_image])
|
||||
{
|
||||
if ([(NSPopUpButton *)view pullsDown] == NO)
|
||||
[super _drawImage:[NSImage imageNamed:@"common_UpAndDownArrowSmall"] inFrame:rect];
|
||||
toDraw = [NSImage imageNamed:@"common_UpAndDownArrowSmall"];
|
||||
else
|
||||
[super _drawImage:[NSImage imageNamed:@"common_DownArrowSmall"] inFrame:rect];
|
||||
toDraw = [NSImage imageNamed:@"common_DownArrowSmall"];
|
||||
}
|
||||
}
|
||||
if (toDraw != nil)
|
||||
{
|
||||
NSSize size;
|
||||
NSPoint position;
|
||||
|
||||
[toDraw setBackgroundColor: backColor];
|
||||
size = [toDraw size];
|
||||
position.x = MAX(NSMidX(rect) - (size.width/2.),0.);
|
||||
position.y = MAX(NSMidY(rect) - (size.height/2.),0.);
|
||||
/*
|
||||
* Images are always drawn with their bottom-left corner at the origin
|
||||
* so we must adjust the position to take account of a flipped view.
|
||||
*/
|
||||
if ([control_view isFlipped])
|
||||
position.y += size.height;
|
||||
[toDraw compositeToPoint: position operation: NSCompositeCopy];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue