Add support to auto hide scrollers.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24730 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2007-02-28 17:53:43 +00:00
parent d2964b147e
commit d4fe1a2399
3 changed files with 87 additions and 28 deletions

View file

@ -1,3 +1,15 @@
2007-02-28 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSScrollView.h: Add ivar
_autohidesScrollers. Move private method to implementation file.
* Source/NSScrollView.m (-init): Remove as this is the same as in
the super class.
* Source/NSScrollView.m (-autohidesScrollers,
-setAutohidesScrollers:, -reflectScrolledClipView:): Add support
for auto hidding of scrollers.
* Source/NSScrollView.m (-initWithCoder:): Decode the value for
_autohidesScrollers.
2007-02-28 Nicola Pero <nicola.pero@meta-innovation.com>
* configure.ac: Use gnustep-config to set GNUSTEP_MAKEFILES

View file

@ -41,11 +41,13 @@
@interface NSScrollView : NSView
{
NSClipView* _contentView;
NSScroller* _horizScroller;
NSScroller* _vertScroller;
NSRulerView* _horizRuler;
NSRulerView* _vertRuler;
NSClipView *_contentView;
NSScroller *_horizScroller;
NSScroller *_vertScroller;
NSRulerView *_horizRuler;
NSRulerView *_vertRuler;
NSClipView *_headerClipView;
NSView *_cornerView;
float _hLineScroll;
float _hPageScroll;
float _vLineScroll;
@ -60,8 +62,7 @@
BOOL _knobMoved;
BOOL _hasHeaderView;
BOOL _hasCornerView;
NSClipView *_headerClipView;
NSView *_cornerView;
BOOL _autohidesScrollers;
}
/* Calculating layout */
@ -136,6 +137,10 @@
- (void)setDrawsBackground:(BOOL)flag;
- (BOOL)drawsBackground;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (BOOL)autohidesScrollers;
- (void)setAutohidesScrollers:(BOOL)flag;
#endif
/* Updating display after scrolling */
- (void)reflectScrolledClipView:(NSClipView*)aClipView;
@ -143,8 +148,6 @@
/* Arranging components */
- (void)tile;
/* GNUstep private methods */
- (void)_synchronizeHeaderAndCornerView;
@end
#endif /* _GNUstep_H_NSScrollView */

View file

@ -52,21 +52,27 @@
typedef struct _scrollViewFlags
{
#ifdef WORDS_BIGENDIAN
unsigned int __unused4:26;
unsigned int hasHScroller:1; // 16
unsigned int hasVScroller:1; // 32
unsigned int __unused4:22;
unsigned int autohidesScrollers:1;
unsigned int __unused1:3;
unsigned int hasHScroller:1;
unsigned int hasVScroller:1;
unsigned int __unused0:2;
NSBorderType border:2;
#else
NSBorderType border:2;
unsigned int __unused0:2;
unsigned int hasVScroller:1; // 32
unsigned int hasHScroller:1; // 16
unsigned int __unused4:26;
unsigned int hasVScroller:1;
unsigned int hasHScroller:1;
unsigned int __unused1:3;
unsigned int autohidesScrollers:1;
unsigned int __unused4:22;
#endif
} GSScrollViewFlags;
@interface NSScrollView (GSPrivate)
/* GNUstep private methods */
- (void) _synchronizeHeaderAndCornerView;
- (void) _themeDidActivate: (NSNotification*)notification;
@end
@ -172,6 +178,8 @@ static float scrollerWidth;
_vPageScroll = 10;
_borderType = NSNoBorder;
_scrollsDynamically = YES;
//_autohidesScrollers = NO;
// FIXME: Not sure here Apple says by default all scrollers are off.
// For compatibility the ruler should be present but not visible.
[self setHasHorizontalRuler: YES];
[self tile];
@ -184,11 +192,6 @@ static float scrollerWidth;
return self;
}
- (id) init
{
return [self initWithFrame: NSZeroRect];
}
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
@ -325,6 +328,16 @@ static float scrollerWidth;
[self tile];
}
- (BOOL) autohidesScrollers
{
return _autohidesScrollers;
}
- (void) setAutohidesScrollers: (BOOL)flag
{
_autohidesScrollers = flag;
}
- (void) scrollWheel: (NSEvent *)theEvent
{
NSRect clipViewBounds;
@ -616,11 +629,24 @@ static float scrollerWidth;
documentFrame = [documentView frame];
}
// FIXME: Should we just hide the scroll bar or remove it?
if ((_autohidesScrollers) && (documentFrame.size.height > clipViewBounds.size.height))
{
[self setHasVerticalScroller: YES];
}
if (_hasVertScroller)
{
if (documentFrame.size.height <= clipViewBounds.size.height)
{
[_vertScroller setEnabled: NO];
if (_autohidesScrollers)
{
[self setHasVerticalScroller: NO];
}
else
{
[_vertScroller setEnabled: NO];
}
}
else
{
@ -641,11 +667,23 @@ static float scrollerWidth;
}
}
if ((_autohidesScrollers) && (documentFrame.size.width > clipViewBounds.size.width))
{
[self setHasHorizontalScroller: YES];
}
if (_hasHorizScroller)
{
if (documentFrame.size.width <= clipViewBounds.size.width)
{
[_horizScroller setEnabled: NO];
if (_autohidesScrollers)
{
[self setHasHorizontalScroller: NO];
}
else
{
[_horizScroller setEnabled: NO];
}
}
else
{
@ -854,8 +892,8 @@ static float scrollerWidth;
bottomEdge = NSMinYEdge;
}
/* Prepare the contentRect by the insetting the borders. */
contentRect = NSInsetRect (_bounds, border.width, border.height);
/* Prepare the contentRect by insetting the borders. */
contentRect = NSInsetRect(_bounds, border.width, border.height);
[self _synchronizeHeaderAndCornerView];
@ -1338,12 +1376,14 @@ static float scrollerWidth;
if ([aDecoder containsValueForKey: @"NSsFlags"])
{
unsigned long flags = [aDecoder decodeIntForKey: @"NSsFlags"];
int flags = [aDecoder decodeInt32ForKey: @"NSsFlags"];
GSScrollViewFlags scrollViewFlags;
// FIXME: Why not just use a cast?
memcpy((void *)&scrollViewFlags,(void *)&flags,sizeof(struct _scrollViewFlags));
_hasVertScroller = scrollViewFlags.hasVScroller;
_hasHorizScroller = scrollViewFlags.hasHScroller;
_autohidesScrollers = scrollViewFlags.autohidesScrollers;
// _scrollsDynamically = (!scrollViewFlags.notDynamic);
// _rulersVisible = scrollViewFlags.rulersVisible;
// _hasHorizRuler = scrollViewFlags.hasHRuler;
@ -1354,6 +1394,7 @@ static float scrollerWidth;
if (content != nil)
{
// FIXME: I think this is not needed as we re-tile anyway.
NSRect frame = [content frame];
float w = [vScroller frame].size.width;
@ -1368,6 +1409,7 @@ static float scrollerWidth;
[content setFrame: frame];
}
// FIXME: No idea what is going on here.
// retain the view and reset the content view...
RETAIN(content);
[self setContentView: content];
@ -1450,6 +1492,10 @@ static float scrollerWidth;
return self;
}
@end
@implementation NSScrollView (GSPrivate)
/* GNUstep private method */
/* we update both of these at the same time during -tile
@ -1512,12 +1558,10 @@ static float scrollerWidth;
}
}
@end
@implementation NSScrollView (GSPrivate)
- (void) _themeDidActivate: (NSNotification*)notification
{
[self tile];
}
@end