* NSApplication.h added windows_need_update as autodisplay ivar.

* NSApplication.m in init set default for main_menu, windows_need_update.
	* NSApplication.m in run added support for OPENSTEP autodisplay mechanism.
	* NSApplication.m _eventMatchingMask: reformat.
	* NSApplication.m nextEventMatchingMask:untilDate:inMode:dequeue:
		move calls to _flushWindows to XDPS backend.
	* NSApplication.m implemented updateWindows.
	* NSApplication.m implemented setWindowsNeedUpdate:.
	* NSApplication.m setMainMenu: test for menu prior to release.
	* NSActionCell.m removed setState: method.
	* NSActionCell.m copyWithZone: optimized ivar copying.
	* NSButtonCell.m added _init and moved common defaults to this method.
	* NSButtonCell.m initImageCell: and initTextCell: minor optimizations.
	* NSButtonCell.m setAlternateTitle: optimize and use ASSIGN macro.
	* NSButtonCell.m setKeyEquivalent: remove [copy release].
	* NSButtonCell.m setKeyEquivalentFont:size: optimize.
	* NSButtonCell.m copyWithZone: optimized ivar copying where possible.
	* NSCell.m _init removed call to [super init].
	* NSCell.m initTextCell: removed duplicate default initializers.
	* NSCell.m setImage: rewrote to use ASSIGN macro.
	* NSCell.m setDoubleValue: rewrote to use ASSIGN macro.
	* NSCell.m setFloatValue: rewrote to use ASSIGN macro.
	* NSCell.m setIntValue: rewrote to use ASSIGN macro.
	* NSCell.m setStringValue: rewrote to use ASSIGN macro.
	* NSCell.m setFont: rewrote to use ASSIGN macro.
	* NSCell.m setRepresentedObject: rewrote to use ASSIGN macro.
	* NSCell.m copyWithZone: optimized ivar copying where possible.
	* NSClipView.m viewBoundsChanged: minor optimization.
	* NSClipView.m viewFrameChanged: minor optimization.
	* NSClipView.m scaleUnitSquareToSize: minor optimization.
	* NSClipView.m setBoundsOrigin: minor optimization.
	* NSClipView.m setBoundsSize: minor optimization.
	* NSClipView.m setFrameSize: minor optimization.
	* NSClipView.m setFrameOrigin: minor optimization.
	* NSClipView.m setFrame: minor optimization.
	* NSClipView.m translateOriginToPoint: minor optimization.
	* NSMatrix.m eliminate retain/release of selected cell via ASSIGN.
	* NSMatrix.m initWithFrame: remove duplicate setting of selected row and
		column.
	* NSMatrix.m removeColumn: rewrite so that col is removed before new
		selection is attempted (needed because selected cell is not retained).
	* NSMatrix.m removeRow: rewrite so that row is removed before new
		selection is attempted (needed because selected cell is not retained).
	* NSMatrix.m deselectAllCells per OS spec try to select a cell at end
		if empty selection is not allowed.
	* NSMatrix.m deselectSelectedCell set default selected row/col to 0.
	* NSMatrix.m mouseDown: optimize for new drawing behaviour.
	* NSMenu.m setSelectedCell: eliminate use of retain/release of selected
		cell via ASSIGN.
	* NSMenuItem.m copyWithZone: optimized ivar copying where possible.
	* NSMenuItem.m dealloc minor optimization.
	* NSMenuItem.m setTarget: minor optimization.
	* NSScroller.m trackScrollButtons: heavily optimized.
	* NSScroller.m sendAction: reimplemented to use sendAction: per spec also
		optimized.
	* NSText.m implemented init method.
	* NSText.m initWithFrame: fixed initialization of ivars which are released
		to retain.
	* NSText.m dealloc add release of retained ivars.
	* NSView.m dealloc add release of retained ivars.
	* NSView.m displayRect: and _addSubviewForNeedingDisplay reformatted code
		and rewrote comments.
	* NSWindow.m setFrame:display: rewrote for clarity.
	* NSWindow.m implemented update method per OPENSTEP spec.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2941 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
far 1998-08-30 16:06:47 +00:00
parent ada8279bee
commit 48b8e5aa73
14 changed files with 628 additions and 528 deletions

View file

@ -1,3 +1,70 @@
Sun Aug 30 1998 Felipe A. Rodriguez <far@ix.netcom.com>
* NSApplication.h added windows_need_update as autodisplay ivar.
* NSApplication.m in init set default for main_menu, windows_need_update.
* NSApplication.m in run added support for OPENSTEP autodisplay mechanism.
* NSApplication.m _eventMatchingMask: reformat.
* NSApplication.m nextEventMatchingMask:untilDate:inMode:dequeue:
move calls to _flushWindows to XDPS backend.
* NSApplication.m implemented updateWindows.
* NSApplication.m implemented setWindowsNeedUpdate:.
* NSApplication.m setMainMenu: test for menu prior to release.
* NSActionCell.m removed setState: method.
* NSActionCell.m copyWithZone: optimized ivar copying.
* NSButtonCell.m added _init and moved common defaults to this method.
* NSButtonCell.m initImageCell: and initTextCell: minor optimizations.
* NSButtonCell.m setAlternateTitle: optimize and use ASSIGN macro.
* NSButtonCell.m setKeyEquivalent: remove [copy release].
* NSButtonCell.m setKeyEquivalentFont:size: optimize.
* NSButtonCell.m copyWithZone: optimized ivar copying where possible.
* NSCell.m _init removed call to [super init].
* NSCell.m initTextCell: removed duplicate default initializers.
* NSCell.m setImage: rewrote to use ASSIGN macro.
* NSCell.m setDoubleValue: rewrote to use ASSIGN macro.
* NSCell.m setFloatValue: rewrote to use ASSIGN macro.
* NSCell.m setIntValue: rewrote to use ASSIGN macro.
* NSCell.m setStringValue: rewrote to use ASSIGN macro.
* NSCell.m setFont: rewrote to use ASSIGN macro.
* NSCell.m setRepresentedObject: rewrote to use ASSIGN macro.
* NSCell.m copyWithZone: optimized ivar copying where possible.
* NSClipView.m viewBoundsChanged: minor optimization.
* NSClipView.m viewFrameChanged: minor optimization.
* NSClipView.m scaleUnitSquareToSize: minor optimization.
* NSClipView.m setBoundsOrigin: minor optimization.
* NSClipView.m setBoundsSize: minor optimization.
* NSClipView.m setFrameSize: minor optimization.
* NSClipView.m setFrameOrigin: minor optimization.
* NSClipView.m setFrame: minor optimization.
* NSClipView.m translateOriginToPoint: minor optimization.
* NSMatrix.m eliminate retain/release of selected cell via ASSIGN.
* NSMatrix.m initWithFrame: remove duplicate setting of selected row and
column.
* NSMatrix.m removeColumn: rewrite so that col is removed before new
selection is attempted (needed because selected cell is not retained).
* NSMatrix.m removeRow: rewrite so that row is removed before new
selection is attempted (needed because selected cell is not retained).
* NSMatrix.m deselectAllCells per OS spec try to select a cell at end
if empty selection is not allowed.
* NSMatrix.m deselectSelectedCell set default selected row/col to 0.
* NSMatrix.m mouseDown: optimize for new drawing behaviour.
* NSMenu.m setSelectedCell: eliminate use of retain/release of selected
cell via ASSIGN.
* NSMenuItem.m copyWithZone: optimized ivar copying where possible.
* NSMenuItem.m dealloc minor optimization.
* NSMenuItem.m setTarget: minor optimization.
* NSScroller.m trackScrollButtons: heavily optimized.
* NSScroller.m sendAction: reimplemented to use sendAction: per spec also
optimized.
* NSText.m implemented init method.
* NSText.m initWithFrame: fixed initialization of ivars which are released
to retain.
* NSText.m dealloc add release of retained ivars.
* NSView.m dealloc add release of retained ivars.
* NSView.m displayRect: and _addSubviewForNeedingDisplay reformatted code
and rewrote comments.
* NSWindow.m setFrame:display: rewrote for clarity.
* NSWindow.m implemented update method per OPENSTEP spec.
Thurs Aug 20 1998 Felipe A. Rodriguez <far@ix.netcom.com> Thurs Aug 20 1998 Felipe A. Rodriguez <far@ix.netcom.com>
* NSTextView.m commented out references to defaultTypingAttributes * NSTextView.m commented out references to defaultTypingAttributes

View file

@ -75,6 +75,7 @@ extern NSString *NSEventTrackingRunLoopMode;
BOOL app_should_quit; BOOL app_should_quit;
BOOL app_is_active; BOOL app_is_active;
BOOL app_is_hidden; BOOL app_is_hidden;
BOOL windows_need_update;
NSImage *app_icon; NSImage *app_icon;
// Reserved for back-end use // Reserved for back-end use

View file

@ -138,17 +138,6 @@
[(NSControl *)control_view updateCell: self]; [(NSControl *)control_view updateCell: self];
} }
//
// Setting the NSCell's State
//
- (void)setState:(int)value
{
[super setState: value];
if (control_view)
if ([control_view isKindOfClass: [NSControl class]])
[(NSControl *)control_view updateCell: self];
}
// //
// Manipulating NSActionCell Values // Manipulating NSActionCell Values
// //
@ -225,9 +214,9 @@
{ {
NSActionCell* c = [super copyWithZone:zone]; NSActionCell* c = [super copyWithZone:zone];
[c setTag:tag]; c->tag = tag;
[c setTarget:target]; c->target = target;
[c setAction:action]; c->action = action;
return c; return c;
} }

View file

@ -7,6 +7,8 @@
Author: Scott Christley <scottc@net-community.com> Author: Scott Christley <scottc@net-community.com>
Date: 1996 Date: 1996
Author: Felipe A. Rodriguez <far@ix.netcom.com>
Date: August 1998
This file is part of the GNUstep GUI Library. This file is part of the GNUstep GUI Library.
@ -116,6 +118,8 @@ static id NSApp;
window_list = [NSMutableArray new]; window_list = [NSMutableArray new];
window_count = 1; window_count = 1;
main_menu = nil;
windows_need_update = YES;
// //
// Event handling setup // Event handling setup
// //
@ -222,8 +226,8 @@ static id NSApp;
- (void)run - (void)run
{ {
NSEvent *e; NSEvent *e;
NSAutoreleasePool* pool; NSAutoreleasePool* pool;
NSDebugLog(@"NSApplication -run\n"); NSDebugLog(@"NSApplication -run\n");
@ -232,24 +236,24 @@ static id NSApp;
app_should_quit = NO; app_should_quit = NO;
app_is_running = YES; app_is_running = YES;
do do {
{
pool = [NSAutoreleasePool new]; pool = [NSAutoreleasePool new];
e = [self nextEventMatchingMask:NSAnyEventMask e = [self nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantFuture] untilDate:[NSDate distantFuture]
inMode:NSDefaultRunLoopMode dequeue:YES]; inMode:NSDefaultRunLoopMode
dequeue:YES];
if (e) if (e)
[self sendEvent: e]; [self sendEvent: e];
else else // if Null event call back
{ [self handleNullEvent]; // end method to handle it
// Null event
// Call the back-end method to handle it if(windows_need_update) // send an update message
[self handleNullEvent]; [self updateWindows]; // to all visible windows
}
[pool release]; [pool release];
} while (!app_should_quit); }
app_is_running = YES; while (!app_should_quit);
NSDebugLog(@"NSApplication end of run loop\n"); NSDebugLog(@"NSApplication end of run loop\n");
} }
@ -410,19 +414,22 @@ static id NSApp;
- (NSEvent*)_eventMatchingMask:(unsigned int)mask - (NSEvent*)_eventMatchingMask:(unsigned int)mask
{ {
NSEvent* event; NSEvent* event;
int i, count = [event_queue count]; int i, count = [event_queue count];
[self getNextEvent]; [self getNextEvent];
/* Get an event from the events queue */ if ((count = [event_queue count])) // Get an event from
if ((count = [event_queue count])) { { // the events queue
for (i = 0; i < count; i++) { for (i = 0; i < count; i++)
{
event = [event_queue objectAtIndex:i]; event = [event_queue objectAtIndex:i];
if ([self event:event matchMask:mask]) { if ([self event:event matchMask:mask])
{
[event retain]; [event retain];
[event_queue removeObjectAtIndex:i]; [event_queue removeObjectAtIndex:i];
[self setCurrentEvent:event]; [self setCurrentEvent:event];
return [event autorelease]; return [event autorelease];
} }
} }
@ -436,10 +443,10 @@ static id NSApp;
inMode:(NSString *)mode inMode:(NSString *)mode
dequeue:(BOOL)flag dequeue:(BOOL)flag
{ {
NSRunLoop* currentLoop = [NSRunLoop currentRunLoop]; NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
NSEventType type; NSEventType type;
NSEvent *event; NSEvent *event;
BOOL done = NO; BOOL done = NO;
event = [self _eventMatchingMask:mask]; event = [self _eventMatchingMask:mask];
if (event) if (event)
@ -447,22 +454,19 @@ static id NSApp;
else if (!expiration) else if (!expiration)
expiration = [NSDate distantFuture]; expiration = [NSDate distantFuture];
// Not in queue so wait for next event while (!done) // Not in queue so wait
while (!done) { { // for next event
NSDate *limitDate, *originalLimitDate; NSDate *limitDate, *originalLimitDate;
// Retain the limitDate so it doesn't get
// flush any windows that need it // release accidentally by runMode:beforeDate:
[NSWindow _flushWindows]; // if a timer which has this date as fire date
[self _flushCommunicationChannels]; // gets released.
/* Retain the limitDate so it doesn't get release accidentally by
runMode:beforeDate: if a timer which has this date as fire date gets
released. */
limitDate = [[currentLoop limitDateForMode:mode] retain]; limitDate = [[currentLoop limitDateForMode:mode] retain];
originalLimitDate = limitDate; originalLimitDate = limitDate;
event = [self _eventMatchingMask:mask]; event = [self _eventMatchingMask:mask];
if (event) { if (event)
{
[limitDate release]; [limitDate release];
break; break;
} }
@ -480,20 +484,12 @@ static id NSApp;
break; break;
} }
// flush any windows that need it
[NSWindow _flushWindows];
[self _flushCommunicationChannels];
type = [event type]; type = [event type];
// Unhide the cursor if necessary // Unhide the cursor if necessary
// but only if its not a null event if (event != gnustep_gui_null_event) // and event is not a null event
if (event != gnustep_gui_null_event) { // do so only if we should
{ if ([NSCursor isHiddenUntilMouseMoves]) // unhide when mouse moves
// Only if we should unhide when mouse moves { // and event is mouse event
if ([NSCursor isHiddenUntilMouseMoves])
{
// Make sure the event is a mouse event before unhiding
if ((type == NSLeftMouseDown) || (type == NSLeftMouseUp) if ((type == NSLeftMouseDown) || (type == NSLeftMouseUp)
|| (type == NSRightMouseDown) || (type == NSRightMouseUp) || (type == NSRightMouseDown) || (type == NSRightMouseUp)
|| (type == NSMouseMoved)) || (type == NSMouseMoved))
@ -712,23 +708,25 @@ static id NSApp;
- (void)setWindowsNeedUpdate:(BOOL)flag - (void)setWindowsNeedUpdate:(BOOL)flag
{ {
windows_need_update = flag;
} }
- (void)updateWindows - (void)updateWindows // send an update message to
{ { // all visible windows
int i, count; int i, count;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// notify that we will update // notify that we will update
[nc postNotificationName: NSApplicationWillUpdateNotification [nc postNotificationName:NSApplicationWillUpdateNotification object:self];
object: self];
for (i = 0, count = [window_list count]; i < count; i++) for (i = 0, count = [window_list count]; i < count; i++)
[[window_list objectAtIndex:i] update]; {
NSWindow *win = [window_list objectAtIndex:i];
if([win isVisible]) // send update only if
[win update]; // window is visible
}
// notify that we did update // notify that we did update
[nc postNotificationName: NSApplicationDidUpdateNotification [nc postNotificationName:NSApplicationDidUpdateNotification object:self];
object: self];
} }
- (NSArray *)windows - (NSArray *)windows
@ -785,6 +783,7 @@ static id NSApp;
// Release old and retain new // Release old and retain new
[aMenu retain]; [aMenu retain];
if(main_menu)
[main_menu release]; [main_menu release];
main_menu = aMenu; main_menu = aMenu;

View file

@ -8,6 +8,8 @@
Author: Scott Christley <scottc@net-community.com> Author: Scott Christley <scottc@net-community.com>
Ovidiu Predescu <ovidiu@net-community.com> Ovidiu Predescu <ovidiu@net-community.com>
Date: 1996 Date: 1996
Author: Felipe A. Rodriguez <far@ix.netcom.com>
Date: August 1998
This file is part of the GNUstep GUI Library. This file is part of the GNUstep GUI Library.
@ -40,8 +42,7 @@
#include <AppKit/NSFont.h> #include <AppKit/NSFont.h>
#include <AppKit/NSImage.h> #include <AppKit/NSImage.h>
#define ASSIGN(a, b) \ #define ASSIGN(a, b) [b retain]; \
[b retain]; \
[a release]; \ [a release]; \
a = b; a = b;
@ -56,45 +57,47 @@
+ (void)initialize + (void)initialize
{ {
if (self == [NSButtonCell class]) if (self == [NSButtonCell class])
{ [self setVersion:1]; // Initial version
// Initial version
[self setVersion:1];
}
} }
// //
// Instance methods // Instance methods
// //
- _init
{
cell_enabled = YES;
transparent = NO;
cell_bordered = YES;
showAltStateMask = NSNoCellMask; // configure as a NSMomentaryPushButton
highlightsByMask = NSPushInCellMask | NSChangeGrayCellMask;
delayInterval = 0.4;
repeatInterval = 0.075;
altContents = nil;
return self;
}
- init - init
{ {
[self initTextCell:@"Button"]; [self initTextCell:@"Button"];
return self; return self;
} }
- initImageCell:(NSImage *)anImage - initImageCell:(NSImage *)anImage
{ {
[super initImageCell:anImage]; [super initImageCell:anImage];
[self setStringValue:@"Button"];
[self setButtonType:NSMomentaryPushButton]; contents = nil;
[self setEnabled:YES];
[self setTransparent:NO]; return [self _init];
[self setBordered:YES];
delayInterval = 0.4;
repeatInterval = 0.075;
return self;
} }
- initTextCell:(NSString *)aString - initTextCell:(NSString *)aString
{ {
[super initTextCell:aString]; [super initTextCell:aString];
altContents = nil;
[self setButtonType:NSMomentaryPushButton]; return [self _init];
[self setEnabled:YES];
[self setTransparent:NO];
[self setBordered:YES];
delayInterval = 0.4;
repeatInterval = 0.075;
return self;
} }
- (void)dealloc - (void)dealloc
@ -103,6 +106,7 @@
[altImage release]; [altImage release];
[keyEquivalent release]; [keyEquivalent release];
[keyEquivalentFont release]; [keyEquivalentFont release];
[super dealloc]; [super dealloc];
} }
@ -116,9 +120,10 @@
- (void)setAlternateTitle:(NSString *)aString - (void)setAlternateTitle:(NSString *)aString
{ {
altContents = [aString copy]; NSString* _string = [aString copy];
// update our state
[self setState:[self state]]; ASSIGN(altContents, _string);
[self setState:[self state]]; // update our state
} }
- (void)setFont:(NSFont *)fontObject - (void)setFont:(NSFont *)fontObject
@ -129,8 +134,7 @@
- (void)setTitle:(NSString *)aString - (void)setTitle:(NSString *)aString
{ {
[self setStringValue:aString]; [self setStringValue:aString];
// update our state [self setState:[self state]]; // update our state
[self setState:[self state]];
} }
- (NSString *)title - (NSString *)title
@ -199,9 +203,9 @@
- (void)setKeyEquivalent:(NSString *)key - (void)setKeyEquivalent:(NSString *)key
{ {
id copy = [key copy]; NSString* _string = [key copy];
ASSIGN(keyEquivalent, copy);
[copy release]; ASSIGN(keyEquivalent, _string);
} }
- (void)setKeyEquivalentModifierMask:(unsigned int)mask - (void)setKeyEquivalentModifierMask:(unsigned int)mask
@ -217,7 +221,9 @@
- (void)setKeyEquivalentFont:(NSString *)fontName - (void)setKeyEquivalentFont:(NSString *)fontName
size:(float)fontSize size:(float)fontSize
{ {
ASSIGN(keyEquivalentFont, [NSFont fontWithName:fontName size:fontSize]); NSFont* font = [NSFont fontWithName:fontName size:fontSize];
ASSIGN(keyEquivalentFont, font);
} }
// //
@ -337,8 +343,7 @@
- (void)drawWithFrame:(NSRect)cellFrame - (void)drawWithFrame:(NSRect)cellFrame
inView:(NSView *)controlView inView:(NSView *)controlView
{ {
// Save last view drawn to control_view = controlView; // Save last view cell was drawn to
control_view = controlView;
} }
// //
@ -352,12 +357,12 @@
{ {
NSButtonCell* c = [super copyWithZone:zone]; NSButtonCell* c = [super copyWithZone:zone];
[c setAlternateTitle:altContents]; c->altContents = [[altContents copy] retain];
[c setAlternateImage:altImage]; ASSIGN(c->altImage, altImage);
[c setKeyEquivalent:keyEquivalent]; c->keyEquivalent = [[keyEquivalent copy] retain];
[c setKeyEquivalentFont:keyEquivalentFont]; ASSIGN(c->keyEquivalentFont, keyEquivalentFont);
[c setKeyEquivalentModifierMask:keyEquivalentModifierMask]; c->keyEquivalentModifierMask = keyEquivalentModifierMask;
[c setTransparent:transparent]; c->transparent = transparent;
c->highlightsByMask = highlightsByMask; c->highlightsByMask = highlightsByMask;
c->showAltStateMask = showAltStateMask; c->showAltStateMask = showAltStateMask;
@ -387,6 +392,7 @@
altImage = [aDecoder decodeObject]; altImage = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &transparent]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &transparent];
NSDebugLog(@"NSButtonCell: finish decoding\n"); NSDebugLog(@"NSButtonCell: finish decoding\n");
return self; return self;
} }

View file

@ -7,6 +7,8 @@
Author: Scott Christley <scottc@net-community.com> Author: Scott Christley <scottc@net-community.com>
Date: 1996 Date: 1996
Author: Felipe A. Rodriguez <far@ix.netcom.com>
Date: August 1998
This file is part of the GNUstep GUI Library. This file is part of the GNUstep GUI Library.
@ -39,6 +41,10 @@
#include <AppKit/NSCell.h> #include <AppKit/NSCell.h>
#include <AppKit/NSEvent.h> #include <AppKit/NSEvent.h>
#define ASSIGN(a, b) [b retain]; \
[a release]; \
a = b;
@implementation NSCell @implementation NSCell
// //
@ -70,7 +76,6 @@
// //
- _init - _init
{ {
self = [super init];
cell_type = NSNullCellType; cell_type = NSNullCellType;
cell_image = nil; cell_image = nil;
cell_font = nil; cell_font = nil;
@ -88,6 +93,7 @@
cell_float_left = 0; cell_float_left = 0;
cell_float_right = 0; cell_float_right = 0;
action_mask = NSLeftMouseUpMask; action_mask = NSLeftMouseUpMask;
return self; return self;
} }
@ -110,6 +116,7 @@
cell_image = [anImage retain]; cell_image = [anImage retain];
image_position = NSImageOnly; image_position = NSImageOnly;
cell_font = [[NSFont userFontOfSize:0] retain]; cell_font = [[NSFont userFontOfSize:0] retain];
return self; return self;
} }
@ -123,11 +130,9 @@
contents = [aString retain]; contents = [aString retain];
cell_type = NSTextCellType; cell_type = NSTextCellType;
text_align = NSCenterTextAlignment; text_align = NSCenterTextAlignment;
cell_image = nil;
image_position = NSNoImage;
cell_float_autorange = YES; cell_float_autorange = YES;
cell_float_left = 0;
cell_float_right = 6; cell_float_right = 6;
return self; return self;
} }
@ -220,14 +225,10 @@
- (void)setImage:(NSImage *)anImage - (void)setImage:(NSImage *)anImage
{ {
// Not an image class --then forget it if (![anImage isKindOfClass:[NSImage class]]) // set the image only
if (![anImage isKindOfClass:[NSImage class]]) return; // if it's an NSImage
return;
// Only set the image if we are an image cell ASSIGN(cell_image, anImage);
[anImage retain];
[cell_image release];
cell_image = anImage;
[self setType:NSImageCellType]; [self setType:NSImageCellType];
} }
@ -256,36 +257,35 @@
- (void)setDoubleValue:(double)aDouble - (void)setDoubleValue:(double)aDouble
{ {
NSNumber* number = [NSNumber numberWithDouble:aDouble]; NSString* number_string = [[NSNumber numberWithDouble:aDouble] stringValue];
[contents release]; ASSIGN(contents, number_string);
contents = [[number stringValue] retain];
} }
- (void)setFloatValue:(float)aFloat - (void)setFloatValue:(float)aFloat
{ {
NSNumber* number = [NSNumber numberWithFloat:aFloat]; NSString* number_string = [[NSNumber numberWithFloat:aFloat] stringValue];
[contents release]; ASSIGN(contents, number_string);
contents = [[number stringValue] retain];
} }
- (void)setIntValue:(int)anInt - (void)setIntValue:(int)anInt
{ {
NSNumber* number = [NSNumber numberWithInt:anInt]; NSString* number_string = [[NSNumber numberWithInt:anInt] stringValue];
[contents release]; ASSIGN(contents, number_string);
contents = [[number stringValue] retain];
} }
- (void)setStringValue:(NSString *)aString - (void)setStringValue:(NSString *)aString
{ {
aString = [aString copy]; NSString* _string;
[contents release];
if (!aString) if (!aString)
contents = @""; _string = @"";
else else
contents = aString; _string = [aString copy];
ASSIGN(contents, _string);
} }
// //
@ -354,13 +354,10 @@
- (void)setFont:(NSFont *)fontObject - (void)setFont:(NSFont *)fontObject
{ {
// Not a font --then forget it if (![fontObject isKindOfClass:[NSFont class]]) // set the font only
if (![fontObject isKindOfClass:[NSFont class]]) return; // if it's an NSFont
return;
[fontObject retain]; ASSIGN(cell_font, fontObject);
[cell_font release];
cell_font = fontObject;
} }
- (void)setSelectable:(BOOL)flag - (void)setSelectable:(BOOL)flag
@ -769,36 +766,32 @@
- (void)setRepresentedObject:(id)anObject - (void)setRepresentedObject:(id)anObject
{ {
[anObject retain]; ASSIGN(represented_object, anObject);
[represented_object release];
represented_object = anObject;
} }
- (id)copyWithZone:(NSZone*)zone - (id)copyWithZone:(NSZone*)zone
{ {
NSCell* c; NSCell* c = [[isa allocWithZone: zone] init];
c = [[isa allocWithZone: zone] init]; c->contents = [[contents copy] retain];
ASSIGN(c->cell_image, cell_image);
[c setStringValue:contents]; ASSIGN(c->cell_font, cell_font);
[c setImage:cell_image]; c->cell_state = cell_state;
[c setFont:cell_font];
[c setState:cell_state];
c->cell_highlighted = cell_highlighted; c->cell_highlighted = cell_highlighted;
[c setEnabled:cell_enabled]; c->cell_enabled = cell_enabled;
[c setEditable:cell_editable]; c->cell_editable = cell_editable;
[c setBordered:cell_bordered]; c->cell_bordered = cell_bordered;
[c setBezeled:cell_bezeled]; c->cell_bezeled = cell_bezeled;
[c setScrollable:cell_scrollable]; c->cell_scrollable = cell_scrollable;
[c setSelectable:cell_selectable]; c->cell_selectable = cell_selectable;
[c setContinuous:cell_continuous]; [c setContinuous:cell_continuous];
[c setFloatingPointFormat:cell_float_autorange c->cell_float_autorange = cell_float_autorange;
left:cell_float_left c->cell_float_left = cell_float_left;
right:cell_float_right]; c->cell_float_right = cell_float_right;
c->image_position = image_position; c->image_position = image_position;
[c setType:cell_type]; c->cell_type = cell_type;
[c setAlignment:text_align]; c->text_align = text_align;
[c setEntryType:entry_type]; c->entry_type = entry_type;
c->control_view = control_view; c->control_view = control_view;
c->cell_size = cell_size; c->cell_size = cell_size;
[c setRepresentedObject:represented_object]; [c setRepresentedObject:represented_object];

View file

@ -167,55 +167,55 @@
- (void)viewBoundsChanged:(NSNotification*)aNotification - (void)viewBoundsChanged:(NSNotification*)aNotification
{ {
[[self superview] reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (void)viewFrameChanged:(NSNotification*)aNotification - (void)viewFrameChanged:(NSNotification*)aNotification
{ {
[self setBoundsOrigin:[self constrainScrollPoint:bounds.origin]]; [self setBoundsOrigin:[self constrainScrollPoint:bounds.origin]];
[[self superview] reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (void)scaleUnitSquareToSize:(NSSize)newUnitSize - (void)scaleUnitSquareToSize:(NSSize)newUnitSize
{ {
[super scaleUnitSquareToSize:newUnitSize]; [super scaleUnitSquareToSize:newUnitSize];
[[self superview] reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (void)setBoundsOrigin:(NSPoint)aPoint - (void)setBoundsOrigin:(NSPoint)aPoint
{ {
[super setBoundsOrigin:aPoint]; [super setBoundsOrigin:aPoint];
[[self superview] reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (void)setBoundsSize:(NSSize)aSize - (void)setBoundsSize:(NSSize)aSize
{ {
[super setBoundsSize:aSize]; [super setBoundsSize:aSize];
[[self superview] reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (void)setFrameSize:(NSSize)aSize - (void)setFrameSize:(NSSize)aSize
{ {
[super setFrameSize:aSize]; [super setFrameSize:aSize];
[[self superview] reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (void)setFrameOrigin:(NSPoint)aPoint - (void)setFrameOrigin:(NSPoint)aPoint
{ {
[super setFrameOrigin:aPoint]; [super setFrameOrigin:aPoint];
[[self superview] reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (void)setFrame:(NSRect)rect - (void)setFrame:(NSRect)rect
{ {
[super setFrame:rect]; [super setFrame:rect];
[[self superview] reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (void)translateOriginToPoint:(NSPoint)aPoint - (void)translateOriginToPoint:(NSPoint)aPoint
{ {
[super translateOriginToPoint:aPoint]; [super translateOriginToPoint:aPoint];
[[self superview] reflectScrolledClipView:self]; [super_view reflectScrolledClipView:self];
} }
- (id)documentView { return _documentView; } - (id)documentView { return _documentView; }

View file

@ -381,7 +381,6 @@ static int mouseDownFlags = 0;
[self setSelectionByRect:YES]; [self setSelectionByRect:YES];
[self setAutosizesCells:YES]; [self setAutosizesCells:YES];
if (mode == NSRadioModeMatrix && numRows && numCols) { if (mode == NSRadioModeMatrix && numRows && numCols) {
selectedRow = selectedColumn = 0;
[self selectCellAtRow:0 column:0]; [self selectCellAtRow:0 column:0];
} }
else else
@ -557,14 +556,17 @@ static int mouseDownFlags = 0;
if (column >= numCols) if (column >= numCols)
return; return;
if (column == selectedColumn)
[self selectCellAtRow:0 column:0];
for (i = 0; i < numRows; i++) for (i = 0; i < numRows; i++)
[[cells objectAtIndex:i] removeObjectAtIndex:column]; [[cells objectAtIndex:i] removeObjectAtIndex:column];
removeColumn (selectedCells, column); removeColumn (selectedCells, column);
numCols--; numCols--;
if (column == selectedColumn)
{
selectedCell = nil;
[self selectCellAtRow:0 column:0];
}
} }
- (void)removeRow:(int)row - (void)removeRow:(int)row
@ -572,12 +574,15 @@ static int mouseDownFlags = 0;
if (row >= numRows) if (row >= numRows)
return; return;
if (row == selectedRow)
[self selectCellAtRow:0 column:0];
[cells removeObjectAtIndex:row]; [cells removeObjectAtIndex:row];
removeRow (selectedCells, row); removeRow (selectedCells, row);
numRows--; numRows--;
if (row == selectedRow)
{
selectedCell = nil;
[self selectCellAtRow:0 column:0];
}
} }
- (void)renewRows:(int)newRows - (void)renewRows:(int)newRows
@ -712,7 +717,7 @@ static int mouseDownFlags = 0;
if (mode == NSRadioModeMatrix) { if (mode == NSRadioModeMatrix) {
if (value) { if (value) {
ASSIGN(selectedCell, aCell); selectedCell = aCell; // select current cell
selectedRow = row; selectedRow = row;
selectedColumn = column; selectedColumn = column;
[selectedCell setState:1]; [selectedCell setState:1];
@ -745,14 +750,17 @@ static int mouseDownFlags = 0;
((tMatrix)selectedCells)->matrix[i][j] = NO; ((tMatrix)selectedCells)->matrix[i][j] = NO;
} }
} }
if(!allowsEmptySelection) // if we don't allow an
[self selectCellAtRow:0 column:0]; // empty selection
} }
- (void)deselectSelectedCell - (void)deselectSelectedCell
{ {
[selectedCell setState:0]; [selectedCell setState:0];
selectedCell = nil; selectedCell = nil;
selectedRow = -1; selectedRow = 0;
selectedColumn = -1; selectedColumn = 0;
} }
- (void)selectAll:(id)sender - (void)selectAll:(id)sender
@ -761,7 +769,7 @@ static int mouseDownFlags = 0;
NSArray* row; NSArray* row;
/* Make the selected cell the cell at (0, 0) */ /* Make the selected cell the cell at (0, 0) */
ASSIGN(selectedCell, [self cellAtRow:0 column:0]); selectedCell = [self cellAtRow:0 column:0]; // select current cell
selectedRow = 0; selectedRow = 0;
selectedColumn = 0; selectedColumn = 0;
@ -792,7 +800,7 @@ static int mouseDownFlags = 0;
else if (!aCell) else if (!aCell)
return; return;
ASSIGN(selectedCell, aCell); selectedCell = aCell; // select current cell
selectedRow = row; selectedRow = row;
selectedColumn = column; selectedColumn = column;
[selectedCell setState:1]; [selectedCell setState:1];
@ -1147,6 +1155,7 @@ BOOL done = NO;
NSRect rect; NSRect rect;
id aCell, previousCell = nil, selectedCellTarget; id aCell, previousCell = nil, selectedCellTarget;
NSRect previousCellRect; NSRect previousCellRect;
NSApplication *app = [NSApplication sharedApplication];
static MPoint anchor = {0, 0}; static MPoint anchor = {0, 0};
mouseDownFlags = [theEvent modifierFlags]; mouseDownFlags = [theEvent modifierFlags];
@ -1174,40 +1183,43 @@ static MPoint anchor = {0, 0};
switch (mode) switch (mode)
{ {
case NSTrackModeMatrix: // in Track mode case NSTrackModeMatrix: // in Track mode the cell
ASSIGN(selectedCell, aCell); // the cell should selectedCell = aCell; // should track the mouse
selectedRow = row; // track the mouse selectedRow = row; // until the cursor either
selectedColumn = column; // until the cursor selectedColumn = column; // leaves the cellframe or
// either leaves // NSLeftMouseUp occurs
if([aCell trackMouse:lastEvent // the cellframe or if([aCell trackMouse:lastEvent
inRect:rect // NSLeftMouseUp inRect:rect
ofView:self ofView:self
untilMouseUp:YES]) // YES if mouse untilMouseUp:YES]) // YES if mouse
done = YES; // went up in cell done = YES; // went up in cell
break; break;
case NSHighlightModeMatrix: case NSHighlightModeMatrix: // Highlight mode is like
[aCell setState:1]; [aCell setState:1]; // Track mode except that
selectedCell = aCell; // the cell is lit before
selectedRow = row; // it begins tracking and
selectedColumn = column; // unlit afterwards
[aCell highlight: YES withFrame: rect inView: self]; [aCell highlight: YES withFrame: rect inView: self];
[self setNeedsDisplayInRect:rect]; // Highlight mode [window flushWindow];
ASSIGN(selectedCell, aCell); // is like Track
selectedRow = row; // mode except that if([aCell trackMouse:lastEvent
selectedColumn = column; // the cell is lit inRect:rect
// before it begins
if([aCell trackMouse:lastEvent // tracking and
inRect:rect // unlit afterwards
ofView:self ofView:self
untilMouseUp:YES]) // YES if mouse untilMouseUp:YES]) // YES if mouse
done = YES; // went up in cell done = YES; // went up in cell
[aCell setState:0]; [aCell setState:0];
[aCell highlight: NO withFrame: rect inView: self]; [aCell highlight: NO withFrame: rect inView: self];
[self setNeedsDisplayInRect:rect]; [window flushWindow];
break; break;
case NSRadioModeMatrix: // Radio mode allows no case NSRadioModeMatrix: // Radio mode allows no
if (previousCell == aCell) // more than one cell if (previousCell == aCell) // more than one cell
break; // to be selected break; // to be selected
if(selectedCell)
{
[selectedCell setState:0]; // deselect previously [selectedCell setState:0]; // deselect previously
if (!previousCell) // selected cell if (!previousCell) // selected cell
previousCellRect = [self cellFrameAtRow:selectedRow previousCellRect = [self cellFrameAtRow:selectedRow
@ -1217,15 +1229,14 @@ static MPoint anchor = {0, 0};
inView:self]; inView:self];
((tMatrix)selectedCells)->matrix[selectedRow] ((tMatrix)selectedCells)->matrix[selectedRow]
[selectedColumn] = NO; [selectedColumn] = NO;
[self setNeedsDisplayInRect:previousCellRect]; }
selectedCell = aCell; // select current cell
ASSIGN(selectedCell, aCell); // select current cell
selectedRow = row; selectedRow = row;
selectedColumn = column; selectedColumn = column;
[aCell setState:1]; [aCell setState:1];
[aCell highlight:YES withFrame:rect inView:self]; [aCell highlight:YES withFrame:rect inView:self];
((tMatrix)selectedCells)->matrix[row][column] = YES; ((tMatrix)selectedCells)->matrix[row][column] = YES;
[self setNeedsDisplayInRect:rect]; [window flushWindow];
break; break;
// List mode allows // List mode allows
case NSListModeMatrix: // multiple cells to be case NSListModeMatrix: // multiple cells to be
@ -1247,7 +1258,7 @@ static MPoint anchor = {0, 0};
// selection to the current cell // selection to the current cell
if (!(modifiers & NSAlternateKeyMask)) if (!(modifiers & NSAlternateKeyMask))
{ {
ASSIGN(selectedCell, aCell); selectedCell = aCell; // select current cell
selectedRow = row; selectedRow = row;
selectedColumn = column; selectedColumn = column;
@ -1256,7 +1267,7 @@ static MPoint anchor = {0, 0};
withFrame:rect withFrame:rect
inView:self]; inView:self];
((tMatrix)selectedCells)->matrix[row][column] =YES; ((tMatrix)selectedCells)->matrix[row][column] =YES;
[self setNeedsDisplayInRect:rect]; [window flushWindow];
break; break;
} }
} }
@ -1269,7 +1280,8 @@ static MPoint anchor = {0, 0};
last:MakePoint (selectedColumn, selectedRow) last:MakePoint (selectedColumn, selectedRow)
current:MakePoint (column, row)]; current:MakePoint (column, row)];
ASSIGN(selectedCell, aCell); [window flushWindow];
selectedCell = aCell; // select current cell
selectedRow = row; selectedRow = row;
selectedColumn = column; selectedColumn = column;
break; break;
@ -1285,8 +1297,7 @@ static MPoint anchor = {0, 0};
while (!shouldProceedEvent) while (!shouldProceedEvent)
{ // Get the next event { // Get the next event
theEvent = [[NSApplication sharedApplication] theEvent = [app nextEventMatchingMask:eventMask
nextEventMatchingMask:eventMask
untilDate:[NSDate distantFuture] untilDate:[NSDate distantFuture]
inMode:NSEventTrackingRunLoopMode inMode:NSEventTrackingRunLoopMode
dequeue:YES]; dequeue:YES];
@ -1294,13 +1305,12 @@ static MPoint anchor = {0, 0};
{ {
case NSPeriodic: case NSPeriodic:
NSDebugLog(@"NSMatrix: got NSPeriodic event\n"); NSDebugLog(@"NSMatrix: got NSPeriodic event\n");
shouldProceedEvent = YES; shouldProceedEvent = YES; // it's time to cycle
break; break; // thru the loop again
case NSLeftMouseUp: case NSLeftMouseUp:
done = YES; done = YES; // Track and Highlight modes do not use
case NSLeftMouseDown: case NSLeftMouseDown: // periodic events so we must break out
default: // if in Track or Highlight modes break default: // and check if the mouse is in a cell
// out and check if mouse is in a cell
if ((mode == NSTrackModeMatrix) || if ((mode == NSTrackModeMatrix) ||
(mode == NSHighlightModeMatrix)) (mode == NSHighlightModeMatrix))
shouldProceedEvent = YES; shouldProceedEvent = YES;
@ -1318,25 +1328,30 @@ static MPoint anchor = {0, 0};
switch (mode) // Finish the selection switch (mode) // Finish the selection
{ // process { // process
case NSTrackModeMatrix:
case NSHighlightModeMatrix:
[selectedCell setState:![selectedCell state]];
case NSRadioModeMatrix: case NSRadioModeMatrix:
if(selectedCell)
[selectedCell highlight:NO withFrame:rect inView:self]; [selectedCell highlight:NO withFrame:rect inView:self];
case NSListModeMatrix: case NSListModeMatrix:
[self setNeedsDisplayInRect:rect]; [self setNeedsDisplayInRect:rect]; // not needed by XRAW
[window flushWindow];
case NSHighlightModeMatrix:
case NSTrackModeMatrix:
break; break;
}
if(selectedCell)
{ // send single click action
if(!(selectedCellTarget = [selectedCell target]))
{ // selected cell has no target so send single
if (target) // click action to matrix's (self's) target
[target performSelector:action withObject:self];
} // in Track and Highlight modes the single } // in Track and Highlight modes the single
// click action has already been sent by the else // click action has already been sent by the
// cell to it's target (if it has one) { // cell to it's target (if it has one)
if ((mode != NSTrackModeMatrix) && (mode != NSHighlightModeMatrix) && if ((mode != NSTrackModeMatrix) && (mode != NSHighlightModeMatrix))
(selectedCellTarget = [selectedCell target]))
[selectedCellTarget performSelector:[selectedCell action] [selectedCellTarget performSelector:[selectedCell action]
withObject:self]; withObject:self];
else // selected cell has no target }
{ // so send single click action
if (target) // to matrix's (self's) target
[target performSelector:action withObject:self];
} }
// click count > 1 indicates a double click // click count > 1 indicates a double click
if (target && doubleAction && ([lastEvent clickCount] > 1)) if (target && doubleAction && ([lastEvent clickCount] > 1))

View file

@ -60,6 +60,11 @@
- (void)_resizeMenuForCellSize; - (void)_resizeMenuForCellSize;
@end @end
//*****************************************************************************
//
// NSMenuMatrix
//
//*****************************************************************************
@implementation NSMenuMatrix @implementation NSMenuMatrix
@ -229,13 +234,19 @@ static NSFont* menuFont = nil;
- (NSSize)cellSize { return cellSize; } - (NSSize)cellSize { return cellSize; }
- (void)setMenu:(NSMenu*)anObject { menu = anObject; } - (void)setMenu:(NSMenu*)anObject { menu = anObject; }
- (void)setSelectedCell:(id)aCell { ASSIGN(selectedCell, aCell); } - (void)setSelectedCell:(id)aCell { selectedCell = aCell; }
- (id)selectedCell { return selectedCell; } - (id)selectedCell { return selectedCell; }
- (NSRect)selectedCellRect { return selectedCellRect; } - (NSRect)selectedCellRect { return selectedCellRect; }
@end /* NSMenuMatrix */ @end /* NSMenuMatrix */
//*****************************************************************************
//
// NSMenu
//
//*****************************************************************************
@implementation NSMenu @implementation NSMenu
// Class variables // Class variables

View file

@ -73,7 +73,7 @@ static BOOL usesUserKeyEquivalents = YES;
[representedObject release]; [representedObject release];
if (hasSubmenu) if (hasSubmenu)
[[self target] release]; [target release];
[super dealloc]; [super dealloc];
} }
@ -86,7 +86,7 @@ static BOOL usesUserKeyEquivalents = YES;
copy->hasSubmenu = hasSubmenu; copy->hasSubmenu = hasSubmenu;
if (hasSubmenu) { if (hasSubmenu) {
id submenu = [[target copyWithZone:zone] autorelease]; id submenu = [[target copyWithZone:zone] autorelease];
[copy setTarget:submenu]; copy->target = [submenu retain];
} }
return copy; return copy;
@ -97,7 +97,7 @@ static BOOL usesUserKeyEquivalents = YES;
hasSubmenu = anObject && [anObject isKindOfClass:[NSMenu class]]; hasSubmenu = anObject && [anObject isKindOfClass:[NSMenu class]];
if (hasSubmenu) { if (hasSubmenu) {
[anObject retain]; [anObject retain];
[[self target] release]; [target release];
} }
[super setTarget:anObject]; [super setTarget:anObject];
} }

View file

@ -6,6 +6,8 @@
Author: Ovidiu Predescu <ovidiu@net-community.com> Author: Ovidiu Predescu <ovidiu@net-community.com>
A completely rewritten version of the original source by Scott Christley. A completely rewritten version of the original source by Scott Christley.
Date: July 1997 Date: July 1997
Author: Felipe A. Rodriguez <far@ix.netcom.com>
Date: August 1998
This file is part of the GNUstep GUI Library. This file is part of the GNUstep GUI Library.
@ -209,7 +211,8 @@ static NSButtonCell* knobCell = nil;
{ {
if (aFloat < 0) if (aFloat < 0)
_floatValue = 0; _floatValue = 0;
else if (aFloat > 1) else
if (aFloat > 1)
_floatValue = 1; _floatValue = 1;
else else
_floatValue = aFloat; _floatValue = aFloat;
@ -435,18 +438,22 @@ static NSButtonCell* knobCell = nil;
- (void)trackScrollButtons:(NSEvent*)theEvent - (void)trackScrollButtons:(NSEvent*)theEvent
{ {
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask NSApplication *theApp = [NSApplication sharedApplication];
| NSLeftMouseDraggedMask | NSMouseMovedMask; unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask |
NSPoint location; NSLeftMouseDraggedMask | NSMouseMovedMask;
NSEventType eventType; NSPoint location;
BOOL shouldReturn = NO; BOOL shouldReturn = NO;
id theCell = nil; id theCell = nil;
NSRect rect;
NSDebugLog (@"trackScrollButtons"); NSDebugLog (@"trackScrollButtons");
do { do {
NSRect rect = [self rectForPart:_hitPart]; location = [self convertPoint:[theEvent locationInWindow]fromView:nil];
_hitPart = [self testPart:location];
rect = [self rectForPart:_hitPart];
switch (_hitPart) { switch (_hitPart) // determine which cell
{ // was hit
case NSScrollerIncrementLine: case NSScrollerIncrementLine:
case NSScrollerIncrementPage: case NSScrollerIncrementPage:
theCell = (_isHorizontal ? rightCell : upCell); theCell = (_isHorizontal ? rightCell : upCell);
@ -462,46 +469,45 @@ static NSButtonCell* knobCell = nil;
break; break;
} }
if (theCell) { if (theCell)
[theCell highlight:YES withFrame:rect inView:self]; // highlight cell { // highlight the cell
[self setNeedsDisplayInRect:rect]; [theCell highlight:YES withFrame:rect inView:self];
[self setNeedsDisplayInRect:rect]; // not needed by XRAW
[window flushWindow];
NSDebugLog (@"tracking cell %x", theCell); NSDebugLog (@"tracking cell %x", theCell);
/* Track the mouse until mouse goes up */ // Track the mouse until mouse goes up
shouldReturn = [theCell trackMouse:theEvent shouldReturn = [theCell trackMouse:theEvent
inRect:rect inRect:rect
ofView:self ofView:self
untilMouseUp:NO]; untilMouseUp:YES];
// unhighlight the cell
/* Now unhighlight the cell */
[theCell highlight:NO withFrame:rect inView:self]; [theCell highlight:NO withFrame:rect inView:self];
#if 1 [self setNeedsDisplayInRect:rect]; // not needed by XRAW
[self setNeedsDisplayInRect:rect]; [window flushWindow];
#else
[theCell drawWithFrame:rect inView:self];
[self setNeedsDisplayInRect:rect];
[[self window] flushWindow];
#endif
} }
if (shouldReturn) if (shouldReturn)
break; break;
theEvent = [[NSApplication sharedApplication] theEvent = [theApp nextEventMatchingMask:eventMask
nextEventMatchingMask:eventMask
untilDate:[NSDate distantFuture] untilDate:[NSDate distantFuture]
inMode:NSEventTrackingRunLoopMode inMode:NSEventTrackingRunLoopMode
dequeue:YES]; dequeue:YES];
eventType = [theEvent type]; }
location = [self convertPoint:[theEvent locationInWindow] fromView:nil]; while ([theEvent type] != NSLeftMouseUp);
_hitPart = [self testPart:location];
} while (eventType != NSLeftMouseUp);
NSDebugLog (@"return from trackScrollButtons"); NSDebugLog (@"return from trackScrollButtons");
} }
- (BOOL)sendAction:(SEL)action to:(id)target - (BOOL)sendAction:(SEL)theAction to:(id)theTarget
{ { // send action to
[target performSelector:action withObject:self]; BOOL ret = [super sendAction:theAction to:theTarget]; // the target on
return YES; // behalf of cell
[self drawKnobSlot]; // lockFocus set in mouseDown method is
[self drawKnob]; // active so we simply redraw the knob and
[window flushWindow]; // slot to reflect the hit scroll button
return ret;
} }
- (void)encodeWithCoder:aCoder - (void)encodeWithCoder:aCoder
@ -517,15 +523,12 @@ static NSButtonCell* knobCell = nil;
NSDebugLog (@"NSScroller drawRect: ((%f, %f), (%f, %f))", NSDebugLog (@"NSScroller drawRect: ((%f, %f), (%f, %f))",
rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
/* Draw the scroller buttons */ // Draw the scroller buttons
[self drawArrow:NSScrollerDecrementArrow highlight:NO]; [self drawArrow:NSScrollerDecrementArrow highlight:NO];
[self drawArrow:NSScrollerIncrementArrow highlight:NO]; [self drawArrow:NSScrollerIncrementArrow highlight:NO];
/* Draw the knob slot */ [self drawKnobSlot]; // Draw knob slot
[self drawKnobSlot]; [self drawKnob]; // Draw the knob
/* Draw the knob */
[self drawKnob];
} }
- (void)drawArrow:(NSScrollerArrow)whichButton - (void)drawArrow:(NSScrollerArrow)whichButton
@ -554,8 +557,7 @@ static NSButtonCell* knobCell = nil;
- (void)drawKnob - (void)drawKnob
{ {
NSRect rect = [self rectForPart:NSScrollerKnob]; [knobCell drawWithFrame:[self rectForPart:NSScrollerKnob] inView:self];
[knobCell drawWithFrame:rect inView:self];
} }
/* The following methods should be implemented in the backend */ /* The following methods should be implemented in the backend */

View file

@ -70,6 +70,11 @@
// //
// Initialization // Initialization
// //
- init
{
return [self initWithFrame:NSZeroRect];
}
- initWithFrame:(NSRect)frameRect - initWithFrame:(NSRect)frameRect
{ {
[super initWithFrame:frameRect]; [super initWithFrame:frameRect];
@ -86,15 +91,17 @@
is_ruler_visible = NO; is_ruler_visible = NO;
is_field_editor = NO; is_field_editor = NO;
draws_background = YES; draws_background = YES;
background_color = [NSColor whiteColor]; background_color = [[NSColor whiteColor] retain];
text_color = [NSColor blackColor]; text_color = [[NSColor blackColor] retain];
default_font = [NSFont userFontOfSize:12]; default_font = [[NSFont userFontOfSize:12] retain];
return self; return self;
} }
- (void)dealloc - (void)dealloc
{ {
[default_font release];
[text_color release];
[background_color release]; [background_color release];
[plainContent release]; [plainContent release];
[rtfContent release]; [rtfContent release];

View file

@ -715,6 +715,7 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
{ // preliminary implementation FIX ME { // preliminary implementation FIX ME
if(autoresizingMask == NSViewNotSizable) // view is not resizable if(autoresizingMask == NSViewNotSizable) // view is not resizable
return; return;
if(autoresizingMask & NSViewWidthSizable) // width resizable? if(autoresizingMask & NSViewWidthSizable) // width resizable?
{ {
frame.size.width = [super_view frame].size.width; frame.size.width = [super_view frame].size.width;
@ -724,6 +725,7 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
if(autoresizingMask & NSViewMinXMargin) if(autoresizingMask & NSViewMinXMargin)
frame.origin.x += [super_view frame].size.width - oldSize.width; frame.origin.x += [super_view frame].size.width - oldSize.width;
} }
if(autoresizingMask & NSViewHeightSizable) // height resizable? if(autoresizingMask & NSViewHeightSizable) // height resizable?
{ {
frame.size.height = [super_view frame].size.height; frame.size.height = [super_view frame].size.height;
@ -815,7 +817,7 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
- (void)displayRect:(NSRect)rect - (void)displayRect:(NSRect)rect
{ {
int i, count; int i, count;
if (!boundsMatrix || !frameMatrix) if (!boundsMatrix || !frameMatrix)
NSLog (@"warning: %@ %p has not have the PS matrices setup!", NSLog (@"warning: %@ %p has not have the PS matrices setup!",
@ -828,24 +830,27 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
[window _setNeedsFlush]; [window _setNeedsFlush];
// [window _view:self needsFlushInRect:rect]; // [window _view:self needsFlushInRect:rect];
[self unlockFocus]; [self unlockFocus];
// Tell subviews to display // Tell subviews to display
for (i = 0, count = [sub_views count]; i < count; ++i) { for (i = 0, count = [sub_views count]; i < count; ++i)
{
NSView* subview = [sub_views objectAtIndex:i]; NSView* subview = [sub_views objectAtIndex:i];
NSRect subviewFrame = subview->frame; NSRect subviewFrame = subview->frame;
NSRect intersection; NSRect intersection;
// If the subview is rotated compute its
/* If the subview is rotated compute its bounding rectangle and use this // bounding rectangle and use this one
one instead of the subview's frame. */ // instead of the subview's frame.
if ([subview->frameMatrix isRotated]) if ([subview->frameMatrix isRotated])
[subview->frameMatrix boundingRectFor:subviewFrame result:&subviewFrame]; [subview->frameMatrix boundingRectFor:subviewFrame
result:&subviewFrame];
/* Determine if the subview's frame intersects "rect" // Determine if the subview's frame
so that we can display the subview. */ // intersects "rect" so that we can display
// the subview.
intersection = NSIntersectionRect (rect, subviewFrame); intersection = NSIntersectionRect (rect, subviewFrame);
if (intersection.origin.x || intersection.origin.y if (intersection.origin.x || intersection.origin.y ||
|| intersection.size.width || intersection.size.height) { intersection.size.width || intersection.size.height)
/* Convert the intersection rectangle to the subview's coordinates */ { // Convert the intersection rectangle to
// the subview's coordinates
intersection = [subview convertRect:intersection fromView:self]; intersection = [subview convertRect:intersection fromView:self];
[subview displayRect:intersection]; [subview displayRect:intersection];
} }
@ -871,34 +876,34 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
} }
- (void)_addSubviewForNeedingDisplay:(NSView*)view - (void)_addSubviewForNeedingDisplay:(NSView*)view
{ { // Add view to the list of
NSView* currentView; NSView* currentView; // sibling subviews that
// need display.
/* Add view in the list of sibling subviews that need display. First
check if view is not already there. */
currentView = _subviewsThatNeedDisplay; currentView = _subviewsThatNeedDisplay;
while (currentView) { while (currentView) // do nothing if the view
if (currentView == view) { // is already in self's
if (currentView == view) // list.
return; return;
currentView = currentView->_nextSiblingSubviewThatNeedsDisplay; currentView = currentView->_nextSiblingSubviewThatNeedsDisplay;
} }
// view is not in the list of subviews that need display.
// Concatenate self's list of subviews that need display to
// the view's list of siblings subviews that need display.
/* view is not in the list of subviews that need display; add it. // find the last element in the view's
To do this concatenate the "view"'s list of siblings to the list of currentView = view; // list of siblings that need display
subviews. Find the last element in the "view"'s list of siblings and
assign to its _nextSiblingSubviewThatNeedsDisplay ivar the first element
of the subviews that need display list in self.
*/
currentView = view;
while (currentView->_nextSiblingSubviewThatNeedsDisplay) while (currentView->_nextSiblingSubviewThatNeedsDisplay)
currentView = currentView->_nextSiblingSubviewThatNeedsDisplay; currentView = currentView->_nextSiblingSubviewThatNeedsDisplay;
currentView->_nextSiblingSubviewThatNeedsDisplay = _subviewsThatNeedDisplay; // link the lists by assigning to view's
// _nextSiblingSubviewThatNeedsDisplay ivar
// self's _subviewsThatNeedDisplay ivar.
currentView->_nextSiblingSubviewThatNeedsDisplay =_subviewsThatNeedDisplay;
_subviewsThatNeedDisplay = view; _subviewsThatNeedDisplay = view;
/* Now add recursively do the same algorithm with self. This way we'll create // Add recursively using the same algorithm with
a subtree of views that need display inside the views hierarchy. */ needs_display = YES; // self. This way we'll create a subtree of views
if (super_view) if (super_view) // that need display inside the views hierarchy.
[super_view _addSubviewForNeedingDisplay:self]; [super_view _addSubviewForNeedingDisplay:self];
} }
@ -935,7 +940,7 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
{ {
needs_display = flag; needs_display = flag;
if (needs_display) { if (needs_display) {
// NSLog (@"NSView setNeedsDisplay:");
invalidatedRectangle = bounds; invalidatedRectangle = bounds;
[window _setNeedsDisplay]; [window _setNeedsDisplay];
@ -946,7 +951,6 @@ static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
- (void)setNeedsDisplayInRect:(NSRect)rect - (void)setNeedsDisplayInRect:(NSRect)rect
{ {
// NSLog (@"NSView setNeedsDisplayInRect:");
needs_display = YES; needs_display = YES;
invalidatedRectangle = NSUnionRect (invalidatedRectangle, rect); invalidatedRectangle = NSUnionRect (invalidatedRectangle, rect);
[window _setNeedsDisplay]; [window _setNeedsDisplay];

View file

@ -583,18 +583,15 @@ static BOOL _needsFlushWindows = YES;
{ {
} }
- (void)setFrame:(NSRect)frameRect - (void)setFrame:(NSRect)frameRect display:(BOOL)flag
display:(BOOL)flag
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
frame = frameRect; frame = frameRect;
// post notification // post notification
[nc postNotificationName: NSWindowDidResizeNotification object: self]; [nc postNotificationName: NSWindowDidResizeNotification object: self];
// display if requested if (flag) // display if requested
if (!flag) return;
[self display]; [self display];
} }
@ -730,7 +727,14 @@ static BOOL _needsFlushWindows = YES;
- (void)update - (void)update
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
if(is_autodisplay && needs_display) // if autodisplay is
{ // enabled
[self _collectFlushRectangles];
[self displayIfNeeded];
[self flushWindowIfNeeded];
}
[nc postNotificationName: NSWindowDidUpdateNotification object: self]; [nc postNotificationName: NSWindowDidUpdateNotification object: self];
} }
@ -1588,10 +1592,12 @@ static BOOL _needsFlushWindows = YES;
windowList = [[NSApplication sharedApplication] windows]; windowList = [[NSApplication sharedApplication] windows];
for (i = 0, count = [windowList count]; i < count; i++) { for (i = 0, count = [windowList count]; i < count; i++)
{
NSWindow* window = [windowList objectAtIndex:i]; NSWindow* window = [windowList objectAtIndex:i];
if (window->needs_display || window->needs_flush) { if (window->needs_display || window->needs_flush)
{
[window _collectFlushRectangles]; [window _collectFlushRectangles];
[window displayIfNeeded]; [window displayIfNeeded];
[window flushWindowIfNeeded]; [window flushWindowIfNeeded];