mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Implemented pageUp: and pageDown:
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@14709 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fc2f4ee85c
commit
72d35ad13a
3 changed files with 234 additions and 6 deletions
|
@ -1,3 +1,12 @@
|
|||
Thu Oct 10 19:56:29 2002 Nicola Pero <n.pero@mi.flashnet.it>
|
||||
|
||||
* Source/NSScrollView.m ([-scrollPageUp:]): Implemented.
|
||||
([-scrollPageDown:]): Implemented. ([-pageUp:]):
|
||||
Implemented. ([-pageDown:]): Implemented.
|
||||
* Source/NSTextView.m ([-pageDown:]): Implemented.
|
||||
([-pageUp:]): Implemented.
|
||||
(Patch by David Ayers <d.ayers@inode.at>).
|
||||
|
||||
Thu Oct 10 19:16:40 2002 Nicola Pero <n.pero@mi.flashnet.it>
|
||||
|
||||
* Source/NSFontManager.m ([NSFontManager -fontMenu:]): Use 't'
|
||||
|
|
|
@ -344,7 +344,102 @@ static float scrollerWidth;
|
|||
[_vertRuler setNeedsDisplay: YES];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls the receiver by simply invoking scrollPageUp:
|
||||
*/
|
||||
- (void) pageUp: (id)sender
|
||||
{
|
||||
[self scrollPageUp: sender];
|
||||
}
|
||||
|
||||
/*
|
||||
* This code is based on _doScroll: and still may need some tuning.
|
||||
*/
|
||||
- (void) scrollPageUp: (id)sender
|
||||
{
|
||||
NSRect clipViewBounds;
|
||||
NSPoint point;
|
||||
float amount;
|
||||
|
||||
if (_contentView == nil)
|
||||
{
|
||||
clipViewBounds = NSZeroRect;
|
||||
}
|
||||
else
|
||||
{
|
||||
clipViewBounds = [_contentView bounds];
|
||||
}
|
||||
point = clipViewBounds.origin;
|
||||
/*
|
||||
* Take verticalPageScroll into accout, but try to make sure
|
||||
* that amount is never negative (ie do not scroll backwards.)
|
||||
*
|
||||
* FIXME: It seems _doScroll and scrollWheel: should also take
|
||||
* care not to do negative scrolling.
|
||||
*/
|
||||
amount = clipViewBounds.size.height - _vPageScroll;
|
||||
amount = (amount < 0) ? 0 : amount;
|
||||
|
||||
if (_contentView != nil && !_contentView->_rFlags.flipped_view)
|
||||
{
|
||||
amount = -amount;
|
||||
}
|
||||
point.y = clipViewBounds.origin.y - amount;
|
||||
[_contentView scrollToPoint: point];
|
||||
if (_rulersVisible == YES && _hasVertRuler == YES)
|
||||
{
|
||||
[_vertRuler setNeedsDisplay: YES];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls the receiver by simply invoking scrollPageUp:
|
||||
*/
|
||||
- (void) pageDown: (id)sender
|
||||
{
|
||||
[self scrollPageDown: sender];
|
||||
}
|
||||
|
||||
/*
|
||||
* This code is based on _doScroll:. and still may need some tuning.
|
||||
*/
|
||||
- (void) scrollPageDown: (id)sender
|
||||
{
|
||||
NSRect clipViewBounds;
|
||||
NSPoint point;
|
||||
float amount;
|
||||
|
||||
if (_contentView == nil)
|
||||
{
|
||||
clipViewBounds = NSZeroRect;
|
||||
}
|
||||
else
|
||||
{
|
||||
clipViewBounds = [_contentView bounds];
|
||||
}
|
||||
point = clipViewBounds.origin;
|
||||
/*
|
||||
* Take verticalPageScroll into accout, but try to make sure
|
||||
* that amount is never negativ (ie do not scroll backwards.)
|
||||
*
|
||||
* FIXME: It seems _doScroll and scrollWheel: should also take
|
||||
* care not to do negative scrolling.
|
||||
*/
|
||||
amount = clipViewBounds.size.height - _vPageScroll;
|
||||
amount = (amount < 0) ? 0 : amount;
|
||||
if (_contentView != nil && !_contentView->_rFlags.flipped_view)
|
||||
{
|
||||
amount = -amount;
|
||||
}
|
||||
point.y = clipViewBounds.origin.y + amount;
|
||||
[_contentView scrollToPoint: point];
|
||||
|
||||
if (_rulersVisible == YES && _hasVertRuler == YES)
|
||||
{
|
||||
[_vertRuler setNeedsDisplay: YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _doScroll: (NSScroller*)scroller
|
||||
|
|
|
@ -3078,18 +3078,142 @@ afterString in order over charRange. */
|
|||
[self setSelectedRange: NSMakeRange (newLocation, 0) ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to move the selection/insertion point down one page of the
|
||||
* visible rect in the receiver while trying to maintain the
|
||||
* horizontal position of the last vertical movement.
|
||||
* If the receiver is a field editor, this method returns immediatly.
|
||||
*/
|
||||
- (void) pageDown: (id)sender
|
||||
{
|
||||
// TODO
|
||||
NSLog(@"Method %s is not implemented for class %s",
|
||||
"pageDown:", "NSTextView");
|
||||
float cachedInsertPointX;
|
||||
float scrollDelta;
|
||||
float oldOriginY;
|
||||
float newOriginY;
|
||||
unsigned glyphIDX;
|
||||
unsigned charIDX;
|
||||
NSPoint iPoint;
|
||||
|
||||
if (_tf.is_field_editor)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Save the current horizontal position cache as we will implictly
|
||||
* change it later.
|
||||
*/
|
||||
cachedInsertPointX = _originalInsertPoint;
|
||||
|
||||
/*
|
||||
* Scroll; also determine how far to move the insertion point.
|
||||
*/
|
||||
oldOriginY = NSMinY([self visibleRect]);
|
||||
[[self enclosingScrollView] pageDown: sender];
|
||||
newOriginY = NSMinY([self visibleRect]);
|
||||
scrollDelta = newOriginY - oldOriginY;
|
||||
|
||||
if (scrollDelta == 0)
|
||||
{
|
||||
/* TODO/FIXME: If no scroll was done, it means we are in the
|
||||
* last page of the document already - should we move the
|
||||
* insertion point to the last line when the user clicks
|
||||
* 'PageDown' in that case ?
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate new insertion point.
|
||||
*/
|
||||
iPoint.x = _originalInsertPoint - _textContainerInset.width;
|
||||
iPoint.y = NSMidY(_insertionPointRect) - _textContainerInset.height;
|
||||
iPoint.y += scrollDelta;
|
||||
|
||||
/*
|
||||
* Ask the layout manager to compute where to go.
|
||||
*/
|
||||
glyphIDX = [_layoutManager glyphIndexForPoint: iPoint
|
||||
inTextContainer: _textContainer];
|
||||
charIDX = [_layoutManager characterIndexForGlyphAtIndex: glyphIDX];
|
||||
|
||||
/*
|
||||
* Move the insertion point (implicitly changing
|
||||
* _originalInsertPoint).
|
||||
*/
|
||||
[self setSelectedRange: NSMakeRange(charIDX, 0)];
|
||||
|
||||
/*
|
||||
* Restore the _originalInsertPoint because we do not want it to
|
||||
* change between moveUp:/moveDown:/pageUp:/pageDown: operations.
|
||||
*/
|
||||
_originalInsertPoint = cachedInsertPointX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to move the selection/insertion point up one page of the
|
||||
* visible rect in the receiver while trying to maintain the
|
||||
* horizontal position of the last vertical movement.
|
||||
* If the receiver is a field editor, this method returns immediatly.
|
||||
*/
|
||||
- (void) pageUp: (id)sender
|
||||
{
|
||||
// TODO
|
||||
NSLog(@"Method %s is not implemented for class %s",
|
||||
"pageUp:", "NSTextView");
|
||||
float cachedInsertPointX;
|
||||
float scrollDelta;
|
||||
float oldOriginY;
|
||||
float newOriginY;
|
||||
unsigned glyphIDX;
|
||||
unsigned charIDX;
|
||||
NSPoint iPoint;
|
||||
|
||||
if (_tf.is_field_editor)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Save the current horizontal position cache as we will implictly
|
||||
* change it later.
|
||||
*/
|
||||
cachedInsertPointX = _originalInsertPoint;
|
||||
|
||||
/*
|
||||
* Scroll; also determine how far to move the insertion point.
|
||||
*/
|
||||
oldOriginY = NSMinY([self visibleRect]);
|
||||
[[self enclosingScrollView] pageUp: sender];
|
||||
newOriginY = NSMinY([self visibleRect]);
|
||||
scrollDelta = newOriginY - oldOriginY;
|
||||
|
||||
if (scrollDelta == 0)
|
||||
{
|
||||
/* TODO/FIXME: If no scroll was done, it means we are in the
|
||||
* first page of the document already - should we move the
|
||||
* insertion point to the first line when the user clicks
|
||||
* 'PageUp' in that case ?
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate new insertion point.
|
||||
*/
|
||||
iPoint.x = _originalInsertPoint - _textContainerInset.width;
|
||||
iPoint.y = NSMidY(_insertionPointRect) - _textContainerInset.height;
|
||||
iPoint.y += scrollDelta;
|
||||
|
||||
/*
|
||||
* Ask the layout manager to compute where to go.
|
||||
*/
|
||||
glyphIDX = [_layoutManager glyphIndexForPoint: iPoint
|
||||
inTextContainer: _textContainer];
|
||||
charIDX = [_layoutManager characterIndexForGlyphAtIndex: glyphIDX];
|
||||
|
||||
/*
|
||||
* Move the insertion point (implicitly changing
|
||||
* _originalInsertPoint).
|
||||
*/
|
||||
[self setSelectedRange: NSMakeRange(charIDX, 0)];
|
||||
|
||||
/*
|
||||
* Restore the _originalInsertPoint because we do not want it to
|
||||
* change between moveUp:/moveDown:/pageUp:/pageDown: operations.
|
||||
*/
|
||||
_originalInsertPoint = cachedInsertPointX;
|
||||
}
|
||||
|
||||
- (void) scrollLineDown: (id)sender
|
||||
|
|
Loading…
Reference in a new issue