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> 2009-04-07 Sergii Stoian <stoyan255@gmail.com>
* Source/NSSplitView.m (-mouseDown:): When checking if divider * Source/NSSplitView.m (-mouseDown:): When checking if divider

View file

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

View file

@ -76,6 +76,7 @@ static NSNotificationCenter *nc = nil;
_never_displayed_before = YES; _never_displayed_before = YES;
_autoresizes_subviews = NO; _autoresizes_subviews = NO;
_is_pane_splitter = YES;
} }
return self; return self;
} }
@ -848,7 +849,7 @@ static NSNotificationCenter *nc = nil;
} }
} }
- (float) dividerThickness - (CGFloat) dividerThickness
{ {
/* /*
* You need to override this method in subclasses to change the * 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 - (BOOL) isSubviewCollapsed: (NSView *)subview
{ {
// FIXME return NSIsEmptyRect([subview frame]);
return NO;
} }
- (BOOL) isPaneSplitter - (BOOL) isPaneSplitter
{ {
/* TODO */ return _is_pane_splitter;
return NO;
} }
- (void) setIsPaneSplitter: (BOOL)flag - (void) setIsPaneSplitter: (BOOL)flag
{ {
/* TODO */ _is_pane_splitter = flag;
} }
- (NSString *) autosaveName - (NSString *) autosaveName
@ -930,6 +929,149 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
ASSIGN(_autosaveName, autosaveName); 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 */ /* Overridden Methods */
- (void) drawRect: (NSRect)r - (void) drawRect: (NSRect)r
{ {
@ -1075,6 +1217,7 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
ASSIGN(_backgroundColor, [NSColor controlBackgroundColor]); ASSIGN(_backgroundColor, [NSColor controlBackgroundColor]);
ASSIGN(_dimpleImage, [NSImage imageNamed: @"common_Dimple"]); ASSIGN(_dimpleImage, [NSImage imageNamed: @"common_Dimple"]);
_never_displayed_before = YES; _never_displayed_before = YES;
_is_pane_splitter = YES;
} }
else else
{ {
@ -1108,13 +1251,13 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
* FIXME: Perhaps the following two should be removed and _dividerWidth * FIXME: Perhaps the following two should be removed and _dividerWidth
* should be used also for dragging? * should be used also for dragging?
*/ */
- (float) draggedBarWidth - (CGFloat) draggedBarWidth
{ {
//defaults to 8 //defaults to 8
return _draggedBarWidth; return _draggedBarWidth;
} }
- (void) setDraggedBarWidth: (float)newWidth - (void) setDraggedBarWidth: (CGFloat)newWidth
{ {
_draggedBarWidth = newWidth; _draggedBarWidth = newWidth;
} }