mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-04 14:30:41 +00:00
Draw background for the selected range.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15730 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f7460d1d63
commit
c40ca09105
2 changed files with 58 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2003-01-27 00:01 Alexander Malmberg <alexander@malmberg.org>
|
||||||
|
|
||||||
|
* Source/NSLayoutManager.m (-drawBackgroundForGlyphRange:atPoint:):
|
||||||
|
Draw background for the selected range.
|
||||||
|
|
||||||
2003-01-26 21:16 Alexander Malmberg <alexander@malmberg.org>
|
2003-01-26 21:16 Alexander Malmberg <alexander@malmberg.org>
|
||||||
|
|
||||||
* Source/NSLayoutManager.m
|
* Source/NSLayoutManager.m
|
||||||
|
|
|
@ -558,7 +558,7 @@ container */
|
||||||
{
|
{
|
||||||
NSTextContainer *textContainer;
|
NSTextContainer *textContainer;
|
||||||
glyph_run_t *glyph_run;
|
glyph_run_t *glyph_run;
|
||||||
unsigned int glyph_pos, char_pos;
|
unsigned int glyph_pos, char_pos, first_char_pos;
|
||||||
int i, j;
|
int i, j;
|
||||||
NSRect *rects;
|
NSRect *rects;
|
||||||
int count;
|
int count;
|
||||||
|
@ -593,6 +593,7 @@ container */
|
||||||
glyph_run = run_for_glyph_index(range.location, glyphs, &glyph_pos, &char_pos);
|
glyph_run = run_for_glyph_index(range.location, glyphs, &glyph_pos, &char_pos);
|
||||||
i = range.location - glyph_pos;
|
i = range.location - glyph_pos;
|
||||||
last_color = nil;
|
last_color = nil;
|
||||||
|
first_char_pos = char_pos;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
rects = [self rectArrayForGlyphRange:
|
rects = [self rectArrayForGlyphRange:
|
||||||
|
@ -622,6 +623,7 @@ container */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glyph_pos += glyph_run->head.glyph_length;
|
glyph_pos += glyph_run->head.glyph_length;
|
||||||
char_pos += glyph_run->head.char_length;
|
char_pos += glyph_run->head.char_length;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
@ -629,6 +631,56 @@ container */
|
||||||
if (i + glyph_pos >= range.location + range.length)
|
if (i + glyph_pos >= range.location + range.length)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_selected_range.length || _selected_range.location == NSNotFound)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_selected_range.location >= char_pos ||
|
||||||
|
_selected_range.location + _selected_range.length <= first_char_pos)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The selection (might) intersect our glyph range. */
|
||||||
|
{
|
||||||
|
NSRange r = [self glyphRangeForCharacterRange: _selected_range
|
||||||
|
actualCharacterRange: NULL];
|
||||||
|
NSRange sel = r;
|
||||||
|
|
||||||
|
if (r.location < range.location)
|
||||||
|
{
|
||||||
|
r.length -= range.location - r.location;
|
||||||
|
r.location = range.location;
|
||||||
|
}
|
||||||
|
if (r.location + r.length > range.location + range.length)
|
||||||
|
{
|
||||||
|
r.length = range.location + range.length - r.location;
|
||||||
|
}
|
||||||
|
if (r.length <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* TODO: use the text view's selected text attributes */
|
||||||
|
color = [NSColor selectedTextBackgroundColor];
|
||||||
|
if (!color)
|
||||||
|
return;
|
||||||
|
|
||||||
|
rects = [self rectArrayForGlyphRange: r
|
||||||
|
withinSelectedGlyphRange: sel
|
||||||
|
inTextContainer: textContainer
|
||||||
|
rectCount: &count];
|
||||||
|
|
||||||
|
if (count)
|
||||||
|
{
|
||||||
|
[color set];
|
||||||
|
for (j = 0; j < count; j++, rects++)
|
||||||
|
{
|
||||||
|
DPSrectfill(ctxt,
|
||||||
|
rects->origin.x + containerOrigin.x,
|
||||||
|
rects->origin.y + containerOrigin.y,
|
||||||
|
rects->size.width, rects->size.height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue