Hi,
Here is a small patch to make NSView posts both frame and bounds
notifications without having to explicitly invoke
-setPostsBoundsChangedNotifications: and -setPostsFrameChangeNotification:.
Although this behavior is not documented in the Cocoa API reference, it is
detailed in the View Programming Guide at section 'Repositioning and
Resizing Views > Notifications' : <
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/WorkingWithAViewHierarchy/WorkingWithAViewHierarchy.html
>
To make the NSView notification behavior works exactly as documented in the
Cocoa API doc is bit more work.
The expected behavior is explained here:
<
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html#//apple_ref/occ/instm/NSView/setPostsBoundsChangedNotifications:>
and
<
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html#//apple_ref/occ/instm/NSView/setPostsFrameChangedNotifications:>.
I think two flags _wasBoundsChanged and _wasFrameChanged need to be added.
Methods like -setFrameOrigin:, -setFrameRotation:, -translateOriginToPoint:
etc.would be changed to set the right flag to YES. Then
-setPostsBoundsChangedNotification: and -setPostsFrameChangedNotification:
can respectively check _wasBoundsChanged and _wasFrameChanged: to decide
whether notifications have to be synthetized and posted immediately.
However I'm not sure these flags should be standalone ivars or put inside
_rFlagsType. Why two ways exist to store boolean ivars in NSView?
If these flags are introduced, they have to be archived, but... Is NSCoder
support still required for new features or is NSKeyedArchiver enough? If
non-keyed arching must be supported, should introducing a new class version
be delayed until the release is ready? My reasoning is that other ivars
could removed/added in the meantime and extra class versions should be
avoided.
Cheers,
Quentin.
Index: Source/NSView.m
===================================================================
--- Source/NSView.m (revision 28415)
+++ Source/NSView.m (working copy)
@@ -548,7 +548,8 @@
//_is_rotated_from_base = NO;
//_is_rotated_or_scaled_from_base = NO;
_rFlags.needs_display = YES;
- //_post_frame_changes = NO;
+ _post_bounds_changes = YES;
+ _post_frame_changes = YES;
_autoresizes_subviews = YES;
_autoresizingMask = NSViewNotSizable;
//_coordinates_valid = NO;
@@ -1783,11 +1784,19 @@
return new;
}
+/**
+ * Sets whether the receiver should post NSViewFrameDidChangeNotification
+ * when its frame changed.
+ */
- (void) setPostsFrameChangedNotifications: (BOOL)flag
{
_post_frame_changes = flag;
}
+/**
+ * Sets whether the receiver should post NSViewBoundsDidChangeNotification
+ * when its bound changed.
+ */
- (void) setPostsBoundsChangedNotifications: (BOOL)flag
{
_post_bounds_changes = flag;
@@ -4683,17 +4692,28 @@
return 0.0;
}
+/**
+ * Returns whether the receiver posts NSViewFrameDidChangeNotification when
+ * its frame changed.
+ *
+ * Returns YES by default (as documented in Cocoa View Programming Guide).
+ */
- (BOOL) postsFrameChangedNotifications
{
return _post_frame_changes;
}
+/**
+ * Returns whether the receiver posts NSViewBoundsDidChangeNotification when
+ * its bound changed.
+ *
+ * Returns YES by default (as documented in Cocoa View Programming Guide).
+ */
- (BOOL) postsBoundsChangedNotifications
{
return _post_bounds_changes;
}
-
/**
* <p>Returns the default menu to be used for instances of the
* current class; if no menu has been set through setMenu:
_______________________________________________
Gnustep-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnustep-dev