Add 10.5 methods and new ivar.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28184 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2009-04-07 20:16:53 +00:00
parent 8c03924b6f
commit 3ce8f6bfd3
3 changed files with 643 additions and 481 deletions

View file

@ -1,3 +1,14 @@
2009-04-07 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSSplitView.h
(-maxPossiblePositionOfDividerAtIndex:,
-minPossiblePositionOfDividerAtIndex:,
-setPosition:ofDividerAtIndex:): New MacOSX 10.5 methods.
* Source/NSSplitView.m: Basic implementation of these methods.
* Headers/AppKit/NSSplitView.h: Add ivars, will break binary compatibility.
* Source/NSSplitView.m (-isPaneSplitter, -setIsPaneSplitter:):
Implement these methods.
2009-04-07 Sergii Stoian <stoyan255@gmail.com>
* Source/NSSplitView.m (-mouseDown:): When checking if divider

View file

@ -37,21 +37,22 @@
@interface NSSplitView : NSView
{
id _delegate;
float _dividerWidth;
float _draggedBarWidth;
BOOL _isVertical;
NSImage *_dimpleImage;
NSColor *_backgroundColor;
NSColor *_dividerColor;
BOOL _never_displayed_before;
NSString *_autosaveName;
CGFloat _dividerWidth;
CGFloat _draggedBarWidth;
BOOL _isVertical;
BOOL _never_displayed_before;
BOOL _is_pane_splitter;
}
- (void) setDelegate: (id)anObject;
- (id) delegate;
- (void) adjustSubviews;
- (void) drawDividerInRect: (NSRect)aRect;
- (float) dividerThickness;
- (CGFloat) dividerThickness;
/* Vertical splitview has a vertical split bar */
- (void) setVertical: (BOOL)flag;
@ -61,8 +62,15 @@
- (BOOL) isSubviewCollapsed: (NSView *)subview;
- (BOOL) isPaneSplitter;
- (void) setIsPaneSplitter: (BOOL)flag;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
- (void) setAutosaveName: (NSString *)autosaveName;
- (NSString *) autosaveName;
- (CGFloat) maxPossiblePositionOfDividerAtIndex: (NSInteger)dividerIndex;
- (CGFloat) minPossiblePositionOfDividerAtIndex: (NSInteger)dividerIndex;
- (void) setPosition: (CGFloat)position ofDividerAtIndex: (NSInteger)dividerIndex;
#endif
@end
@ -70,8 +78,8 @@
#if OS_API_VERSION(GS_API_NONE, GS_API_NONE)
@interface NSSplitView (GNUstepExtra)
/* extra methods to make it more usable */
- (float) draggedBarWidth;
- (void) setDraggedBarWidth: (float)newWidth;
- (CGFloat) draggedBarWidth;
- (void) setDraggedBarWidth: (CGFloat)newWidth;
/* if flag is yes, dividerThickness is reset to the height/width of the dimple
image + 1;
*/

View file

@ -76,6 +76,7 @@ static NSNotificationCenter *nc = nil;
_never_displayed_before = YES;
_autoresizes_subviews = NO;
_is_pane_splitter = YES;
}
return self;
}
@ -486,7 +487,7 @@ static NSNotificationCenter *nc = nil;
|| (NSMaxX(r) < NSMinX(oldRect)))
// the two rects don't intersect
{
NSHighlightRect (oldRect);
NSHighlightRect(oldRect);
NSHighlightRect(r);
}
else
@ -848,7 +849,7 @@ static NSNotificationCenter *nc = nil;
}
}
- (float) dividerThickness
- (CGFloat) dividerThickness
{
/*
* You need to override this method in subclasses to change the
@ -905,19 +906,17 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
- (BOOL) isSubviewCollapsed: (NSView *)subview
{
// FIXME
return NO;
return NSIsEmptyRect([subview frame]);
}
- (BOOL) isPaneSplitter
{
/* TODO */
return NO;
return _is_pane_splitter;
}
- (void) setIsPaneSplitter: (BOOL)flag
{
/* TODO */
_is_pane_splitter = flag;
}
- (NSString *) autosaveName
@ -930,6 +929,149 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
ASSIGN(_autosaveName, autosaveName);
}
- (CGFloat) maxPossiblePositionOfDividerAtIndex: (NSInteger)dividerIndex
{
NSArray *subs = [self subviews];
unsigned count = [subs count];
NSView *view;
if ((dividerIndex >= count - 1) || (dividerIndex < 0))
{
if (_isVertical)
{
return NSMaxX([self bounds]);
}
else
{
return NSMaxY([self bounds]);
}
}
view = [subs objectAtIndex: dividerIndex + 1];
if (_isVertical)
{
return NSMaxX([view frame]);
}
else
{
return NSMaxY([view frame]);
}
}
- (CGFloat) minPossiblePositionOfDividerAtIndex: (NSInteger)dividerIndex
{
NSArray *subs = [self subviews];
unsigned count = [subs count];
NSView *view;
if ((dividerIndex >= count - 1) || (dividerIndex < 0))
{
if (_isVertical)
{
return NSMinX([self bounds]);
}
else
{
return NSMinY([self bounds]);
}
}
view = [subs objectAtIndex: dividerIndex];
if (_isVertical)
{
return NSMinX([view frame]);
}
else
{
return NSMinY([view frame]);
}
}
- (void) setPosition: (CGFloat)position
ofDividerAtIndex: (NSInteger)dividerIndex
{
NSArray *subs = [self subviews];
unsigned count = [subs count];
CGFloat old_position;
NSView *prev;
NSView *next;
NSRect r, r1;
if ((dividerIndex >= count - 1) || (dividerIndex < 0))
{
return;
}
if (_delegate &&
[_delegate respondsToSelector:
@selector(splitView:constrainSplitPosition:ofSubviewAt:)])
{
position = [_delegate splitView: self
constrainSplitPosition: position
ofSubviewAt: dividerIndex];
}
// FIXME
[nc postNotificationName: NSSplitViewWillResizeSubviewsNotification
object: self];
prev = [subs objectAtIndex: dividerIndex];
next = [subs objectAtIndex: dividerIndex + 1];
r = [prev frame];
r1 = [next frame];
// Compute the old split position
if (_isVertical == NO)
{
old_position = (NSMaxY(r) + NSMinY(r1)) / 2;
}
else
{
old_position = (NSMaxX(r) + NSMinX(r1)) / 2;
}
// Compute new rectangles
if (_isVertical == NO)
{
r.size.height += position - old_position;
if (NSHeight(r) < 1.)
{
r.size.height = 1.;
}
}
else
{
r.size.width += position - old_position;
if (NSWidth(r) < 1.)
{
r.size.width = 1.;
}
}
if (_isVertical == NO)
{
r1.origin.y += position - old_position;
r1.size.height -= position - old_position;
if (NSHeight(r) < 1.)
{
r.size.height = 1.;
}
}
else
{
r1.origin.x += position - old_position;
r1.size.width -= position - old_position;
if (NSWidth(r1) < 1.)
{
r1.size.width = 1.;
}
}
/* resize the subviews accordingly */
[prev setFrame: r];
[next setFrame: r1];
}
/* Overridden Methods */
- (void) drawRect: (NSRect)r
{
@ -1075,6 +1217,7 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
ASSIGN(_backgroundColor, [NSColor controlBackgroundColor]);
ASSIGN(_dimpleImage, [NSImage imageNamed: @"common_Dimple"]);
_never_displayed_before = YES;
_is_pane_splitter = YES;
}
else
{
@ -1108,13 +1251,13 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
* FIXME: Perhaps the following two should be removed and _dividerWidth
* should be used also for dragging?
*/
- (float) draggedBarWidth
- (CGFloat) draggedBarWidth
{
//defaults to 8
return _draggedBarWidth;
}
- (void) setDraggedBarWidth: (float)newWidth
- (void) setDraggedBarWidth: (CGFloat)newWidth
{
_draggedBarWidth = newWidth;
}