mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 05:10:58 +00:00
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:
parent
1c8d394839
commit
10ada90f30
11 changed files with 112 additions and 13 deletions
13
ChangeLog
13
ChangeLog
|
@ -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>
|
Tue Mar 4 17:04:16 1997 GNUstep Development <gnustep@net-community.com>
|
||||||
|
|
||||||
* Reinstate NSCursor and NSColorWell changes that got lost.
|
* Reinstate NSCursor and NSColorWell changes that got lost.
|
||||||
|
|
|
@ -96,6 +96,7 @@ extern const float *NSFontIdentityMatrix;
|
||||||
- (float)capHeight;
|
- (float)capHeight;
|
||||||
- (float)italicAngle;
|
- (float)italicAngle;
|
||||||
- (NSSize)maximumAdvancement;
|
- (NSSize)maximumAdvancement;
|
||||||
|
- (NSSize)minimumAdvancement;
|
||||||
- (float)underlinePosition;
|
- (float)underlinePosition;
|
||||||
- (float)underlineThickness;
|
- (float)underlineThickness;
|
||||||
- (float)xHeight;
|
- (float)xHeight;
|
||||||
|
|
|
@ -85,8 +85,7 @@ id gnustep_gui_nsbutton_class = nil;
|
||||||
[super initWithFrame:frameRect];
|
[super initWithFrame:frameRect];
|
||||||
|
|
||||||
// set our cell
|
// set our cell
|
||||||
[[self cell] release];
|
[self setCell:[[gnustep_gui_nsbutton_class new] autorelease]];
|
||||||
[self setCell:[[gnustep_gui_nsbutton_class alloc] init]];
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,6 +319,11 @@
|
||||||
control_view = controlView;
|
control_view = controlView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (BOOL)prefersTrackingUntilMouseUp
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Simulating a Click
|
// Simulating a Click
|
||||||
//
|
//
|
||||||
|
|
|
@ -94,7 +94,7 @@
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
cell_type = NSImageCellType;
|
cell_type = NSImageCellType;
|
||||||
cell_image = anImage;
|
cell_image = [anImage retain];
|
||||||
image_position = NSImageOnly;
|
image_position = NSImageOnly;
|
||||||
cell_font = [[NSFont userFontOfSize:12] retain];
|
cell_font = [[NSFont userFontOfSize:12] retain];
|
||||||
cell_state = NO;
|
cell_state = NO;
|
||||||
|
@ -121,7 +121,7 @@
|
||||||
// return nil;
|
// return nil;
|
||||||
|
|
||||||
cell_font = [[NSFont userFontOfSize:12] retain];
|
cell_font = [[NSFont userFontOfSize:12] retain];
|
||||||
contents = aString;
|
contents = [aString retain];
|
||||||
cell_type = NSTextCellType;
|
cell_type = NSTextCellType;
|
||||||
text_align = NSCenterTextAlignment;
|
text_align = NSCenterTextAlignment;
|
||||||
cell_image = nil;
|
cell_image = nil;
|
||||||
|
@ -234,7 +234,9 @@
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Only set the image if we are an image cell
|
// 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];
|
NSNumber* number = [NSNumber numberWithDouble:aDouble];
|
||||||
|
|
||||||
|
[contents release];
|
||||||
contents = [[number stringValue] retain];
|
contents = [[number stringValue] retain];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,6 +274,7 @@
|
||||||
{
|
{
|
||||||
NSNumber* number = [NSNumber numberWithFloat:aFloat];
|
NSNumber* number = [NSNumber numberWithFloat:aFloat];
|
||||||
|
|
||||||
|
[contents release];
|
||||||
contents = [[number stringValue] retain];
|
contents = [[number stringValue] retain];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,15 +282,19 @@
|
||||||
{
|
{
|
||||||
NSNumber* number = [NSNumber numberWithInt:anInt];
|
NSNumber* number = [NSNumber numberWithInt:anInt];
|
||||||
|
|
||||||
|
[contents release];
|
||||||
contents = [[number stringValue] retain];
|
contents = [[number stringValue] retain];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setStringValue:(NSString *)aString
|
- (void)setStringValue:(NSString *)aString
|
||||||
{
|
{
|
||||||
|
[self setType:NSTextCellType];
|
||||||
|
aString = [aString copy];
|
||||||
|
[contents release];
|
||||||
if (!aString)
|
if (!aString)
|
||||||
contents = @"";
|
contents = @"";
|
||||||
else
|
else
|
||||||
contents = [aString copy];
|
contents = aString;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -359,7 +367,9 @@
|
||||||
if (![fontObject isKindOfClass:[NSFont class]])
|
if (![fontObject isKindOfClass:[NSFont class]])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cell_font = [fontObject retain];
|
[fontObject retain];
|
||||||
|
[cell_font release];
|
||||||
|
cell_font = fontObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setSelectable:(BOOL)flag
|
- (void)setSelectable:(BOOL)flag
|
||||||
|
|
|
@ -83,7 +83,7 @@ NSString *NSControlTextDidChangeNotification = @"NSControlTextDidChangeNotificat
|
||||||
[super initWithFrame:frameRect];
|
[super initWithFrame:frameRect];
|
||||||
|
|
||||||
// create our cell
|
// create our cell
|
||||||
[self setCell:[[MB_NSCONTROL_CELL_CLASS alloc] init]];
|
[self setCell:[[MB_NSCONTROL_CELL_CLASS new] autorelease]];
|
||||||
|
|
||||||
tag = 0;
|
tag = 0;
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ NSString *NSControlTextDidChangeNotification = @"NSControlTextDidChangeNotificat
|
||||||
NSLog(@"NSControl: copyWithZone\n");
|
NSLog(@"NSControl: copyWithZone\n");
|
||||||
|
|
||||||
// make sure the new copy also has a new copy of the cell
|
// make sure the new copy also has a new copy of the cell
|
||||||
[c setCell: [cell copy]];
|
[c setCell: [[cell copy] autorelease]];
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +127,8 @@ NSString *NSControlTextDidChangeNotification = @"NSControlTextDidChangeNotificat
|
||||||
if (![aCell isKindOfClass:[NSCell class]])
|
if (![aCell isKindOfClass:[NSCell class]])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
[aCell retain];
|
||||||
|
[cell release];
|
||||||
cell = aCell;
|
cell = aCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -575,4 +575,73 @@
|
||||||
return self;
|
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
|
@end
|
||||||
|
|
|
@ -195,6 +195,7 @@ static void setFont(NSString* key, NSFont* font)
|
||||||
- (float)capHeight { return 0.0; }
|
- (float)capHeight { return 0.0; }
|
||||||
- (float)italicAngle { return 0.0; }
|
- (float)italicAngle { return 0.0; }
|
||||||
- (NSSize)maximumAdvancement { return NSZeroSize; }
|
- (NSSize)maximumAdvancement { return NSZeroSize; }
|
||||||
|
- (NSSize)minimumAdvancement { return NSZeroSize; }
|
||||||
- (float)underlinePosition { return 0.0; }
|
- (float)underlinePosition { return 0.0; }
|
||||||
- (float)underlineThickness { return 0.0; }
|
- (float)underlineThickness { return 0.0; }
|
||||||
- (float)xHeight { return 0.0; }
|
- (float)xHeight { return 0.0; }
|
||||||
|
|
|
@ -79,8 +79,7 @@ static id MB_NSSLIDER_CLASS = nil;
|
||||||
[super initWithFrame:frameRect];
|
[super initWithFrame:frameRect];
|
||||||
|
|
||||||
// set our cell
|
// set our cell
|
||||||
[[self cell] release];
|
[self setCell:[[MB_NSSLIDER_CLASS new] autorelease]];
|
||||||
[self setCell:[[MB_NSSLIDER_CLASS alloc] init]];
|
|
||||||
if (frame.size.width > frame.size.height)
|
if (frame.size.width > frame.size.height)
|
||||||
[cell setVertical:NO];
|
[cell setVertical:NO];
|
||||||
else
|
else
|
||||||
|
|
|
@ -80,8 +80,7 @@ static id MB_NSTEXTFIELDCELL_CLASS = nil;
|
||||||
[super initWithFrame:frameRect];
|
[super initWithFrame:frameRect];
|
||||||
|
|
||||||
// set our cell
|
// set our cell
|
||||||
[[self cell] release];
|
[self setCell:[[MB_NSTEXTFIELDCELL_CLASS new] autorelease]];
|
||||||
[self setCell:[[MB_NSTEXTFIELDCELL_CLASS alloc] init]];
|
|
||||||
[cell setState:1];
|
[cell setState:1];
|
||||||
text_cursor = [NSCursor IBeamCursor];
|
text_cursor = [NSCursor IBeamCursor];
|
||||||
|
|
||||||
|
|
|
@ -181,6 +181,7 @@
|
||||||
{
|
{
|
||||||
// Save last view drawn to
|
// Save last view drawn to
|
||||||
control_view = controlView;
|
control_view = controlView;
|
||||||
|
[super drawWithFrame:cellFrame inView:controlView];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue