Incorporated bug fixes from Benhur Stein.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2587 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
ovidiu 1997-10-29 21:56:04 +00:00
parent c277083404
commit 9b0ceb4edd
8 changed files with 70 additions and 41 deletions

View file

@ -1,3 +1,23 @@
Wed Oct 29 12:22:22 1997 Ovidiu Predescu <ovidiu@net-community.com>
Bug fixes for NSForm and NSFormCell from Benhur Stein
<Benhur-de-Oliveira.Stein@imag.fr>.
* Headers/gnustep/gui/NSFormCell.h: The text field cell is keeping the
value now not the title. Changed drawInteriorWithFrame:inView: to
drawWithFrame:inView:.
* Source/NSForm.m: Likewise.
* Source/NSFormCell.m: Likewise.
(drawInteriorWithFrame:inView:): Changed to drawWithFrame:inView:.
* Source/NSCell.m (init): Make a text cell by default.
(_init): Invoke super's init.
* Source/NSView.m (opaqueAncestor): Implemented.
(visibleRect): Intersect the super view's visible rectangle with the
receiver's bounds instead of the receiver's frame.
* GNUmakefile: Fixed typo.
* Source/GNUmakefile: Changed the name of the variables to work with
the new multi-library building capabilities of library.make.
Tue Oct 28 11:24:40 1997 Ovidiu Predescu <ovidiu@net-community.com> Tue Oct 28 11:24:40 1997 Ovidiu Predescu <ovidiu@net-community.com>
* Makefile: Changed to GNUmakefile. * Makefile: Changed to GNUmakefile.

View file

@ -32,7 +32,7 @@ include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/common.make
# #
# The list of subproject directories # The list of subproject directories
# #
SUBPROJECTS = Source Images Tools SUBPROJECTS = Source Images Testing
-include GNUmakefile.preamble -include GNUmakefile.preamble

View file

@ -31,12 +31,10 @@
#include <AppKit/NSActionCell.h> #include <AppKit/NSActionCell.h>
@class NSTextFieldCell;
@interface NSFormCell : NSActionCell <NSCoding> @interface NSFormCell : NSActionCell <NSCoding>
{ {
float titleWidth; float titleWidth;
NSTextFieldCell* textCell; NSCell* titleCell;
} }
// //
@ -60,8 +58,8 @@
// //
// Displaying // Displaying
// //
- (void)drawInteriorWithFrame:(NSRect)cellFrame - (void)drawWithFrame:(NSRect)cellFrame
inView:(NSView*)controlView; inView:(NSView*)controlView;
// //
// NSCoding protocol // NSCoding protocol

View file

@ -34,7 +34,7 @@ include ../Version
LIBRARY_NAME=libgnustep-gui LIBRARY_NAME=libgnustep-gui
# The Objective-C source files to be compiled # The Objective-C source files to be compiled
OBJC_FILES = libgnustep-gui.m \ libgnustep-gui_OBJC_FILES = libgnustep-gui.m \
NSActionCell.m \ NSActionCell.m \
NSApplication.m \ NSApplication.m \
NSBitmapImageRep.m \ NSBitmapImageRep.m \
@ -104,10 +104,10 @@ tiff.m \
externs.m externs.m
# NSPasteboard.m # NSPasteboard.m
HEADER_FILES_DIR = ../Headers libgnustep-gui_HEADER_FILES_DIR = ../Headers
HEADER_FILES_INSTALL_DIR = /gnustep/gui libgnustep-gui_HEADER_FILES_INSTALL_DIR = /gnustep/gui
HEADER_FILES = \ libgnustep-gui_HEADER_FILES = \
AppKit/AppKit.h \ AppKit/AppKit.h \
AppKit/NSActionCell.h \ AppKit/NSActionCell.h \
AppKit/NSApplication.h \ AppKit/NSApplication.h \

View file

@ -70,6 +70,7 @@
// //
- _init - _init
{ {
self = [super init];
cell_type = NSNullCellType; cell_type = NSNullCellType;
cell_image = nil; cell_image = nil;
cell_font = nil; cell_font = nil;
@ -92,9 +93,7 @@
- init - init
{ {
self = [super init]; return [self initTextCell:@""];
[self _init];
return self;
} }
- (id)initImageCell:(NSImage *)anImage - (id)initImageCell:(NSImage *)anImage

View file

@ -64,8 +64,13 @@ static Class defaultCellClass = nil;
- (NSFormCell*)insertEntry:(NSString*)title - (NSFormCell*)insertEntry:(NSString*)title
atIndex:(int)index atIndex:(int)index
{ {
NSFormCell *new_cell = [[[isa cellClass] alloc] initTextCell:title];
[self insertRow:index]; [self insertRow:index];
return [self cellAtRow:index column:0]; [self putCell:new_cell atRow:index column:0];
[new_cell release];
return new_cell;
} }
- (void)removeEntryAtIndex:(int)index - (void)removeEntryAtIndex:(int)index

View file

@ -37,40 +37,47 @@
- init - init
{ {
self = [super init]; return [self initTextCell:@"Field:"];
[self setBordered:NO]; }
[self setBezeled:NO];
- initTextCell: (NSString *)aString
{
self = [super initTextCell:@""];
[self setBordered:YES];
[self setBezeled:YES];
[self setAlignment:NSLeftTextAlignment];
titleWidth = -1; titleWidth = -1;
textCell = [NSTextFieldCell new]; titleCell = [[NSCell alloc] initTextCell:aString];
[textCell setBordered:YES]; [titleCell setBordered:NO];
[textCell setBezeled:YES]; [titleCell setBezeled:NO];
[titleCell setAlignment:NSRightTextAlignment];
return self; return self;
} }
- (void)dealloc - (void)dealloc
{ {
[textCell release]; [titleCell release];
[super dealloc]; [super dealloc];
} }
- (BOOL)isOpaque - (BOOL)isOpaque
{ {
return [super isOpaque] && [textCell isOpaque]; return [super isOpaque] && [titleCell isOpaque];
} }
- (void)setTitle:(NSString*)aString - (void)setTitle:(NSString*)aString
{ {
[self setStringValue:aString]; [titleCell setStringValue:aString];
} }
- (void)setTitleAlignment:(NSTextAlignment)mode - (void)setTitleAlignment:(NSTextAlignment)mode
{ {
[self setAlignment:mode]; [titleCell setAlignment:mode];
} }
- (void)setTitleFont:(NSFont*)fontObject - (void)setTitleFont:(NSFont*)fontObject
{ {
[self setFont:fontObject]; [titleCell setFont:fontObject];
} }
- (void)setTitleWidth:(float)width - (void)setTitleWidth:(float)width
@ -80,23 +87,23 @@
- (NSString*)title - (NSString*)title
{ {
return [self stringValue]; return [titleCell stringValue];
} }
- (NSTextAlignment)titleAlignment - (NSTextAlignment)titleAlignment
{ {
return [self alignment]; return [titleCell alignment];
} }
- (NSFont*)titleFont - (NSFont*)titleFont
{ {
return [self font]; return [titleCell font];
} }
- (float)titleWidth - (float)titleWidth
{ {
if (titleWidth < 0) if (titleWidth < 0)
return [[self font] widthOfString:[self title]]; return [[titleCell font] widthOfString:[self title]];
else else
return titleWidth; return titleWidth;
} }
@ -107,20 +114,17 @@
return 0; return 0;
} }
- (void)drawInteriorWithFrame:(NSRect)cellFrame - (void)drawWithFrame:(NSRect)cellFrame
inView:(NSView*)controlView inView:(NSView*)controlView
{ {
NSRect titleRect = cellFrame; NSRect titleFrame;
NSRect textRect; NSRect textFrame;
titleRect.size.width = [self titleWidth] + 4; NSDivideRect(cellFrame, &titleFrame, &textFrame,
[super drawInteriorWithFrame:titleRect inView:controlView]; [self titleWidth] + 4, NSMinXEdge);
textRect.origin.x = cellFrame.origin.x + titleRect.size.width; [titleCell drawWithFrame:titleFrame inView:controlView];
textRect.origin.y = cellFrame.origin.y; [super drawWithFrame:textFrame inView:controlView];
textRect.size.width = cellFrame.size.width - titleRect.size.width;
textRect.size.height = cellFrame.size.height;
[textCell drawInteriorWithFrame:textRect inView:controlView];
} }
- (void)encodeWithCoder:aCoder - (void)encodeWithCoder:aCoder

View file

@ -259,7 +259,10 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
- (NSView *)opaqueAncestor - (NSView *)opaqueAncestor
{ {
return nil; if ([self isOpaque] || !super_view)
return self;
else
return [super_view opaqueAncestor];
} }
- (void)removeFromSuperview - (void)removeFromSuperview
@ -833,7 +836,7 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
NSRect superviewsVisibleRect NSRect superviewsVisibleRect
= [self convertRect:[super_view visibleRect] fromView:super_view]; = [self convertRect:[super_view visibleRect] fromView:super_view];
return NSIntersectionRect (superviewsVisibleRect, frame); return NSIntersectionRect (superviewsVisibleRect, bounds);
} }
} }