Changed the retain/release policy in NSButton, NSCell, NSControl,

NSSlider and NSTextField classes.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2230 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Scott Christley 1997-03-05 19:46:41 +00:00
parent e3b40cf7bc
commit 91f71eb3ad
11 changed files with 112 additions and 13 deletions

View file

@ -1,3 +1,16 @@
Tue Mar 4 18:05:24 1997 Ovidiu Predescu <ovidiu@bx.logicnet.ro>
* Source/NSFont.m: -minimumAdvancement : New method.
* Source/NSButton.m: -initWithFrame: : Use an autoreleased cell.
* Source/NSButtonCell.m: +prefersTrackingUntilMouseUp : New method.
* Source/NSCell.m: Retain the objects we set in instance variables.
* Source/NSControl.m: -initWithFrame: : Use an autoreleased cell.
* Source/NSEvent.m: -description : New method.
* Source/NSSlider.m: -initWithFrame: : Use an autoreleased cell.
* Source/NSTextField.m: -initWithFrame: : Likewise.
* Source/NSTextFieldCell.m: -drawWithFrame:inView: : Call super's
implementation.
Tue Mar 4 17:04:16 1997 GNUstep Development <gnustep@net-community.com>
* Reinstate NSCursor and NSColorWell changes that got lost.

View file

@ -96,6 +96,7 @@ extern const float *NSFontIdentityMatrix;
- (float)capHeight;
- (float)italicAngle;
- (NSSize)maximumAdvancement;
- (NSSize)minimumAdvancement;
- (float)underlinePosition;
- (float)underlineThickness;
- (float)xHeight;

View file

@ -85,8 +85,7 @@ id gnustep_gui_nsbutton_class = nil;
[super initWithFrame:frameRect];
// set our cell
[[self cell] release];
[self setCell:[[gnustep_gui_nsbutton_class alloc] init]];
[self setCell:[[gnustep_gui_nsbutton_class new] autorelease]];
return self;
}

View file

@ -319,6 +319,11 @@
control_view = controlView;
}
+ (BOOL)prefersTrackingUntilMouseUp
{
return YES;
}
//
// Simulating a Click
//

View file

@ -94,7 +94,7 @@
return nil;
cell_type = NSImageCellType;
cell_image = anImage;
cell_image = [anImage retain];
image_position = NSImageOnly;
cell_font = [[NSFont userFontOfSize:12] retain];
cell_state = NO;
@ -121,7 +121,7 @@
// return nil;
cell_font = [[NSFont userFontOfSize:12] retain];
contents = aString;
contents = [aString retain];
cell_type = NSTextCellType;
text_align = NSCenterTextAlignment;
cell_image = nil;
@ -234,7 +234,9 @@
return;
// Only set the image if we are an image cell
cell_image = [anImage retain];
[anImage retain];
[cell_image release];
cell_image = anImage;
}
//
@ -264,6 +266,7 @@
{
NSNumber* number = [NSNumber numberWithDouble:aDouble];
[contents release];
contents = [[number stringValue] retain];
}
@ -271,6 +274,7 @@
{
NSNumber* number = [NSNumber numberWithFloat:aFloat];
[contents release];
contents = [[number stringValue] retain];
}
@ -278,15 +282,19 @@
{
NSNumber* number = [NSNumber numberWithInt:anInt];
[contents release];
contents = [[number stringValue] retain];
}
- (void)setStringValue:(NSString *)aString
{
[self setType:NSTextCellType];
aString = [aString copy];
[contents release];
if (!aString)
contents = @"";
else
contents = [aString copy];
contents = aString;
}
//
@ -359,7 +367,9 @@
if (![fontObject isKindOfClass:[NSFont class]])
return;
cell_font = [fontObject retain];
[fontObject retain];
[cell_font release];
cell_font = fontObject;
}
- (void)setSelectable:(BOOL)flag

View file

@ -83,7 +83,7 @@ NSString *NSControlTextDidChangeNotification = @"NSControlTextDidChangeNotificat
[super initWithFrame:frameRect];
// create our cell
[self setCell:[[MB_NSCONTROL_CELL_CLASS alloc] init]];
[self setCell:[[MB_NSCONTROL_CELL_CLASS new] autorelease]];
tag = 0;
@ -109,7 +109,7 @@ NSString *NSControlTextDidChangeNotification = @"NSControlTextDidChangeNotificat
NSLog(@"NSControl: copyWithZone\n");
// make sure the new copy also has a new copy of the cell
[c setCell: [cell copy]];
[c setCell: [[cell copy] autorelease]];
return c;
}
@ -127,6 +127,8 @@ NSString *NSControlTextDidChangeNotification = @"NSControlTextDidChangeNotificat
if (![aCell isKindOfClass:[NSCell class]])
return;
[aCell retain];
[cell release];
cell = aCell;
}

View file

@ -575,4 +575,73 @@
return self;
}
- (NSString*)description
{
const char* eventTypes[] = { "leftMouseDown", "leftMouseUp",
"rightMouseDown", "rightMouseUp", "mouseMoved", "leftMouseDragged",
"rightMouseDragged", "mouseEntered", "mouseExited", "keyDown", "keyUp",
"flagsChanged", "periodic", "cursorUpdate"
};
switch (event_type) {
case NSLeftMouseDown:
case NSLeftMouseUp:
case NSRightMouseDown:
case NSRightMouseUp:
case NSMouseMoved:
case NSLeftMouseDragged:
case NSRightMouseDragged:
return [NSString stringWithFormat:
@"NSEvent: eventType = %s, point = { %f, %f }, modifiers = %u,"
@" time = %f, window = %d, dpsContext = %p,"
@" event number = %d, click = %d, pressure = %f",
eventTypes[event_type], location_point.x, location_point.y,
modifier_flags, event_time, window_num, event_context,
event_data.mouse.event_num, event_data.mouse.click,
event_data.mouse.pressure];
break;
case NSMouseEntered:
case NSMouseExited:
return [NSString stringWithFormat:
@"NSEvent: eventType = %s, point = { %f, %f }, modifiers = %u,"
@" time = %f, window = %d, dpsContext = %p, "
@" event number = %d, tracking number = %d, user data = %p",
eventTypes[event_type], location_point.x, location_point.y,
modifier_flags, event_time, window_num, event_context,
event_data.tracking.event_num,
event_data.tracking.tracking_num,
event_data.tracking.user_data];
break;
case NSKeyDown:
case NSKeyUp:
return [NSString stringWithFormat:
@"NSEvent: eventType = %s, point = { %f, %f }, modifiers = %u,"
@" time = %f, window = %d, dpsContext = %p, "
@" repeat = %s, keys = %@, ukeys = %@, keyCode = 0x%x",
eventTypes[event_type], location_point.x, location_point.y,
modifier_flags, event_time, window_num, event_context,
(event_data.key.repeat ? "YES" : "NO"),
event_data.key.char_keys, event_data.key.unmodified_keys,
event_data.key.key_code];
break;
case NSFlagsChanged:
case NSPeriodic:
case NSCursorUpdate:
return [NSString stringWithFormat:
@"NSEvent: eventType = %s, point = { %f, %f }, modifiers = %u,"
@" time = %f, window = %d, dpsContext = %p, "
@" subtype = %d, data1 = %p, data2 = %p",
eventTypes[event_type], location_point.x, location_point.y,
modifier_flags, event_time, window_num, event_context,
event_data.misc.sub_type, event_data.misc.data1,
event_data.misc.data2];
break;
}
return [super description];
}
@end

View file

@ -195,6 +195,7 @@ static void setFont(NSString* key, NSFont* font)
- (float)capHeight { return 0.0; }
- (float)italicAngle { return 0.0; }
- (NSSize)maximumAdvancement { return NSZeroSize; }
- (NSSize)minimumAdvancement { return NSZeroSize; }
- (float)underlinePosition { return 0.0; }
- (float)underlineThickness { return 0.0; }
- (float)xHeight { return 0.0; }

View file

@ -79,8 +79,7 @@ static id MB_NSSLIDER_CLASS = nil;
[super initWithFrame:frameRect];
// set our cell
[[self cell] release];
[self setCell:[[MB_NSSLIDER_CLASS alloc] init]];
[self setCell:[[MB_NSSLIDER_CLASS new] autorelease]];
if (frame.size.width > frame.size.height)
[cell setVertical:NO];
else

View file

@ -80,8 +80,7 @@ static id MB_NSTEXTFIELDCELL_CLASS = nil;
[super initWithFrame:frameRect];
// set our cell
[[self cell] release];
[self setCell:[[MB_NSTEXTFIELDCELL_CLASS alloc] init]];
[self setCell:[[MB_NSTEXTFIELDCELL_CLASS new] autorelease]];
[cell setState:1];
text_cursor = [NSCursor IBeamCursor];

View file

@ -181,6 +181,7 @@
{
// Save last view drawn to
control_view = controlView;
[super drawWithFrame:cellFrame inView:controlView];
}
//