mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 05:10:38 +00:00
Remove most uses of the method [NSView -removeSubview:].
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33047 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d199cb565e
commit
6c54fd6be5
7 changed files with 50 additions and 21 deletions
|
@ -38,6 +38,20 @@
|
|||
|
||||
#import "NSToolbarFrameworkPrivate.h"
|
||||
|
||||
@interface NSWindow (GSWindowDecorationView)
|
||||
- (void)_clearContentView;
|
||||
@end
|
||||
|
||||
@implementation NSWindow (GSWindowDecorationView)
|
||||
/* This method prevents a recursion when removing the contet view of a window.
|
||||
The method [NSWindow -setContentView:] would again lead to a call to -willRemoveSubview:.
|
||||
*/
|
||||
- (void)_clearContentView
|
||||
{
|
||||
_contentView = nil;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GSWindowDecorationView
|
||||
|
||||
static inline NSRect RectWithSizeScaledByFactor(NSRect aRect, CGFloat factor)
|
||||
|
@ -229,21 +243,19 @@ static inline NSRect RectWithSizeScaledByFactor(NSRect aRect, CGFloat factor)
|
|||
* the old window will automatically disappear (this is how it works
|
||||
* on Apple too).
|
||||
*/
|
||||
- (void) removeSubview: (NSView*)aView
|
||||
- (void) willRemoveSubview: (NSView*)aView
|
||||
{
|
||||
RETAIN(aView);
|
||||
/*
|
||||
* If the content view is removed (for example, because it was added
|
||||
* to another view in another window), we must let the window know.
|
||||
* Otherwise, it would keep trying to resize/manage it as if it was
|
||||
* its content view, while it actually is now in another window!
|
||||
*/
|
||||
[super removeSubview: aView];
|
||||
[super willRemoveSubview: aView];
|
||||
if (aView == [_window contentView])
|
||||
{
|
||||
[_window setContentView: nil];
|
||||
[_window _clearContentView];
|
||||
}
|
||||
RELEASE(aView);
|
||||
}
|
||||
|
||||
- (void) setBackgroundColor: (NSColor *)color
|
||||
|
|
|
@ -773,6 +773,11 @@ static inline NSRect integralRect (NSRect rect, NSView *view)
|
|||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
{
|
||||
self = [super initWithCoder: aDecoder];
|
||||
if (self == nil)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
if ([aDecoder allowsKeyedCoding])
|
||||
{
|
||||
[self setAutoresizesSubviews: YES];
|
||||
|
@ -793,7 +798,6 @@ static inline NSRect integralRect (NSRect rect, NSView *view)
|
|||
if ([[self subviews] count] > 0)
|
||||
{
|
||||
NSRect rect;
|
||||
|
||||
id document = [aDecoder decodeObjectForKey: @"NSDocView"];
|
||||
|
||||
NSAssert([document class] != [NSCustomView class],
|
||||
|
@ -802,14 +806,13 @@ static inline NSRect integralRect (NSRect rect, NSView *view)
|
|||
rect.origin = NSZeroPoint;
|
||||
[document setFrame: rect];
|
||||
RETAIN(document); // prevent it from being released.
|
||||
[self removeSubview: document];
|
||||
[document removeFromSuperview];
|
||||
[self setDocumentView: document];
|
||||
RELEASE(document);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSView *document;
|
||||
BOOL temp;
|
||||
|
||||
[self setAutoresizesSubviews: YES];
|
||||
|
@ -822,9 +825,11 @@ static inline NSRect integralRect (NSRect rect, NSView *view)
|
|||
|
||||
if ([[self subviews] count] > 0)
|
||||
{
|
||||
document = AUTORELEASE(RETAIN([[self subviews] objectAtIndex: 0]));
|
||||
[self removeSubview: document];
|
||||
NSView *document = [[self subviews] objectAtIndex: 0];
|
||||
RETAIN(document); // prevent it from being released.
|
||||
[document removeFromSuperview];
|
||||
[self setDocumentView: document];
|
||||
RELEASE(document);
|
||||
}
|
||||
}
|
||||
return self;
|
||||
|
|
|
@ -547,7 +547,7 @@ static int _gs_gui_color_picker_mode = NSRGBModeColorPanel;
|
|||
return;
|
||||
|
||||
if (_accessoryView != nil)
|
||||
[_splitView removeSubview: _accessoryView];
|
||||
[_accessoryView removeFromSuperview];
|
||||
_accessoryView = aView;
|
||||
[_splitView addSubview: _accessoryView];
|
||||
}
|
||||
|
|
|
@ -1413,7 +1413,7 @@ static BOOL menuBarVisible = YES;
|
|||
if (_view != nil)
|
||||
{
|
||||
// remove the old representation
|
||||
[contentView removeSubview: _view];
|
||||
[_view removeFromSuperview];
|
||||
[_view setMenu: nil];
|
||||
}
|
||||
|
||||
|
|
|
@ -278,7 +278,7 @@ static float scrollerWidth;
|
|||
[self tile];
|
||||
}
|
||||
|
||||
- (void) removeSubview: (NSView *)aView
|
||||
- (void) willRemoveSubview: (NSView *)aView
|
||||
{
|
||||
if (aView == _contentView)
|
||||
{
|
||||
|
@ -292,7 +292,7 @@ static float scrollerWidth;
|
|||
{
|
||||
_cornerView = nil;
|
||||
}
|
||||
[super removeSubview: aView];
|
||||
[super willRemoveSubview: aView];
|
||||
}
|
||||
|
||||
- (void) setHorizontalScroller: (NSScroller*)aScroller
|
||||
|
|
|
@ -900,8 +900,7 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes the receiver from its superviews list of subviews, by
|
||||
* invoking the superviews [-removeSubview:] method.
|
||||
* Removes the receiver from its superviews list of subviews.
|
||||
*/
|
||||
- (void) removeFromSuperviewWithoutNeedingDisplay
|
||||
{
|
||||
|
@ -912,10 +911,9 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
}
|
||||
|
||||
/**
|
||||
<p> Removes the receiver from its superviews list of subviews, by
|
||||
invoking the superviews -removeSubview: method, and marks the
|
||||
rectangle that the reciever occupied in the superview as needing
|
||||
redisplay. </p>
|
||||
<p> Removes the receiver from its superviews list of subviews
|
||||
and marks the rectangle that the reciever occupied in the
|
||||
superview as needing redisplay. </p>
|
||||
|
||||
<p> This is dangerous to use during display, since it alters the
|
||||
rectangles needing display. In this case, you can use the
|
||||
|
@ -925,7 +923,7 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
|||
if (_super_view != nil)
|
||||
{
|
||||
[_super_view setNeedsDisplayInRect: _frame];
|
||||
[_super_view removeSubview: self];
|
||||
[self removeFromSuperviewWithoutNeedingDisplay];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue