mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 03:11:18 +00:00
Implement basic drawing of insertion point.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15756 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
60d9c1dec6
commit
6546c340e8
3 changed files with 78 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
2003-01-29 01:40 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
* Headers/gnustep/gui/NSTextView.h, Source/NSTextView.m: Implement
|
||||
basic drawing of insertion point.
|
||||
|
||||
2003-01-28 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* TextConverters/RTF/RTFConsumer.m
|
||||
|
|
|
@ -176,6 +176,7 @@ therefore be stored in the NSLayoutManager to avoid problems.
|
|||
following little period in which the insertion point should not
|
||||
be drawn */
|
||||
BOOL _drawInsertionPointNow;
|
||||
#endif
|
||||
|
||||
|
||||
/* Stores the insertion point rect - updated by
|
||||
|
@ -184,6 +185,7 @@ therefore be stored in the NSLayoutManager to avoid problems.
|
|||
need to be recomputed <eg, relayout>. */
|
||||
NSRect _insertionPointRect;
|
||||
|
||||
#if 0
|
||||
/* This is used when you move the insertion point up or down. The
|
||||
system remembers the horizontal position of the insertion point
|
||||
at the beginning of the process, and always tries to put the
|
||||
|
|
|
@ -2800,26 +2800,95 @@ Figure out how the additional layout stuff is supposed to work.
|
|||
|
||||
if ([self shouldDrawInsertionPoint])
|
||||
{
|
||||
if (NSIntersectsRect(rect, _insertionPointRect))
|
||||
{
|
||||
[self drawInsertionPointInRect: _insertionPointRect
|
||||
color: _insertionPointColor
|
||||
turnedOn: YES];
|
||||
}
|
||||
#if 0 /* TODO: insertion point */
|
||||
unsigned location = _layoutManager->_selected_range.location;
|
||||
|
||||
if (NSLocationInRange (location, drawnRange)
|
||||
|| location == NSMaxRange (drawnRange))
|
||||
{
|
||||
#if 0 /* TODO: insertion point */
|
||||
if (_drawInsertionPointNow && viewIsPrinting != self)
|
||||
{
|
||||
[self drawInsertionPointInRect: _insertionPointRect
|
||||
color: _insertionPointColor
|
||||
turnedOn: YES];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) updateInsertionPointStateAndRestartTimer: (BOOL)restartFlag
|
||||
{
|
||||
/* TODO: this is a basic stopgap implementation; should work fine, but no
|
||||
blinking. need to do a proper one once I know how */
|
||||
|
||||
unsigned int l;
|
||||
BOOL after;
|
||||
NSRange gr;
|
||||
NSRect new;
|
||||
|
||||
if (_layoutManager->_selected_range.length > 0 ||
|
||||
_layoutManager->_selected_range.location == NSNotFound)
|
||||
{
|
||||
_insertionPointRect = NSZeroRect;
|
||||
return;
|
||||
}
|
||||
|
||||
l = _layoutManager->_selected_range.location;
|
||||
if (l == [self textLength])
|
||||
{
|
||||
if (l == 0)
|
||||
{
|
||||
/* TODO */
|
||||
new = NSZeroRect;
|
||||
new.size.width = 1;
|
||||
new.size.height = 14;
|
||||
new.origin.y = 0;
|
||||
goto adjust;
|
||||
}
|
||||
l--;
|
||||
after = YES;
|
||||
}
|
||||
else
|
||||
after = NO;
|
||||
|
||||
gr = [_layoutManager glyphRangeForCharacterRange: NSMakeRange(l,1)
|
||||
actualCharacterRange: NULL];
|
||||
|
||||
new = [_layoutManager boundingRectForGlyphRange: gr
|
||||
inTextContainer: _textContainer];
|
||||
|
||||
if (after)
|
||||
{
|
||||
new.origin.x += new.size.width - 1;
|
||||
}
|
||||
new.size.width = 1;
|
||||
|
||||
adjust:
|
||||
new.origin.y++;
|
||||
new.size.height -= 2;
|
||||
|
||||
new.origin.x += _textContainerOrigin.x;
|
||||
new.origin.y += _textContainerOrigin.y;
|
||||
|
||||
printf("at %i (%i) got (%g %g)+(%g %g)\n",l,after,
|
||||
new.origin.x,new.origin.y,new.size.width,new.size.height);
|
||||
|
||||
if (!NSEqualRects(new, _insertionPointRect))
|
||||
{
|
||||
printf("not equal, redisplaying\n");
|
||||
[self setNeedsDisplayInRect: _insertionPointRect];
|
||||
_insertionPointRect = new;
|
||||
[self setNeedsDisplayInRect: _insertionPointRect];
|
||||
}
|
||||
|
||||
#if 0 /* TODO */
|
||||
/* Update insertion point rect */
|
||||
NSRange charRange;
|
||||
|
|
Loading…
Reference in a new issue