mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
Replace NSTextView's provisional implementation of
-centerSelectionInVisibleArea: by a correct one. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27365 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
daedd434bb
commit
8279ffddbb
2 changed files with 38 additions and 4 deletions
|
@ -5,6 +5,9 @@
|
|||
* Source/NSTextView.m: Fix inconsistent naming of (private)
|
||||
NSTextStorage category.
|
||||
|
||||
* Source/NSTextView_actions.m (-centerSelectionInVisibleArea):
|
||||
Replace the provisional implementation by a correct one.
|
||||
|
||||
2008-12-20 22:13-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Source/GSNibLoading.m: Read objects/accessibility and oids
|
||||
|
|
|
@ -1324,10 +1324,41 @@ and layout is left-to-right */
|
|||
|
||||
- (void) centerSelectionInVisibleArea: (id)sender
|
||||
{
|
||||
/* FIXME: This does not really implement what the method's name suggests,
|
||||
but it is at least better than nothing.
|
||||
*/
|
||||
[self scrollRangeToVisible: [self selectedRange]];
|
||||
NSRange range;
|
||||
NSPoint new;
|
||||
NSRect rect, vRect;
|
||||
|
||||
vRect = [self visibleRect];
|
||||
range = [self selectedRange];
|
||||
if (range.length == 0)
|
||||
{
|
||||
rect =
|
||||
[_layoutManager insertionPointRectForCharacterIndex: range.location
|
||||
inTextContainer: _textContainer];
|
||||
}
|
||||
else
|
||||
{
|
||||
range = [_layoutManager glyphRangeForCharacterRange: range
|
||||
actualCharacterRange: NULL];
|
||||
rect = [_layoutManager boundingRectForGlyphRange: range
|
||||
inTextContainer: _textContainer];
|
||||
}
|
||||
|
||||
if (NSWidth(_bounds) <= NSWidth(vRect))
|
||||
new.x = 0;
|
||||
else if (NSWidth(rect) > NSWidth(vRect))
|
||||
new.x = NSMinX(rect);
|
||||
else
|
||||
new.x = NSMinX(rect) - (NSWidth(vRect) - NSWidth(rect)) / 2;
|
||||
|
||||
if (NSHeight(_bounds) <= NSHeight(vRect))
|
||||
new.y = 0;
|
||||
else if (NSHeight(rect) > NSHeight(vRect))
|
||||
new.y = NSMinY(rect);
|
||||
else
|
||||
new.y = NSMinY(rect) - (NSHeight(vRect) - NSHeight(rect)) / 2;
|
||||
|
||||
[self scrollPoint: new];
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue