git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24697 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2007-02-27 06:07:01 +00:00
parent 7c77ac64a1
commit 701853d407
2 changed files with 116 additions and 30 deletions

View file

@ -1,9 +1,16 @@
2007-02-26 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSLayoutManager.m: ([drawGlyphsForGlyphRange:atPoint:])
Implement selected text color ... use the value set in the textview
or if that is not supplied, fall back to selectedTextColor.
Fix ([drawBackgroundForGlyphRange:atPoint:]) to use
([textViewForBeginningOfSelection]) to determine selected text color.
2007-02-22 Matt Rice <ratmice@gmail.com> 2007-02-22 Matt Rice <ratmice@gmail.com>
* Source/NSAlert.m (-_initWithoutGModel): Add missing nil * Source/NSAlert.m (-_initWithoutGModel): Add missing nil
at end of call to -dictionaryWithObjectsAndKeys: at end of call to -dictionaryWithObjectsAndKeys:
2007-02-22 Sergii Stoian <stoyan255@gmail.com> 2007-02-22 Sergii Stoian <stoyan255@gmail.com>
* Source/NSWindow.m: (_lossOfKeyOrMainWindow): Add sanity checks. * Source/NSWindow.m: (_lossOfKeyOrMainWindow): Add sanity checks.
@ -56,7 +63,7 @@
* Source/NSDocument.m (runModalSavePanel:withAccessoryView:): Only * Source/NSDocument.m (runModalSavePanel:withAccessoryView:): Only
set accessory view when not nil. Workaround for bug #19031. set accessory view when not nil. Workaround for bug #19031.
2007-02-16 Richard Frith-Macdoanld <rfm@gnu.org> 2007-02-16 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSMenuItSemCell.m: fixup glitch with drawing of horizontal * Source/NSMenuItSemCell.m: fixup glitch with drawing of horizontal
menu items overwriting menu border. menu items overwriting menu border.
@ -177,7 +184,7 @@
* Source/NSTableView (-mouseDown:): Compute the selection immediately * Source/NSTableView (-mouseDown:): Compute the selection immediately
instead of at the end of the loop. instead of at the end of the loop.
2007-02-04 Richard Frith-Macdoanld <rfm@gnu.org> 2007-02-04 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSImageView.m: fix minor error in dragging offset. * Source/NSImageView.m: fix minor error in dragging offset.
@ -191,7 +198,7 @@
depending on whether the mouse went up inside the menu or not. depending on whether the mouse went up inside the menu or not.
Fixes bug #18946 Fixes bug #18946
2007-01-31 Richard Frith-Macdoanld <rfm@gnu.org> 2007-01-31 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSFontInfo.m: * Source/GSFontInfo.m:
* Source/NSFont.m: * Source/NSFont.m:
@ -251,7 +258,7 @@
* Source/GSTheme.m (-buttonBorderForStyle:state:, * Source/GSTheme.m (-buttonBorderForStyle:state:,
-drawButton:view:style:state:): Handle some of the bezel styles. -drawButton:view:style:state:): Handle some of the bezel styles.
2007-01-24 Richard Frith-Macdoanld <rfm@gnu.org> 2007-01-24 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/AppKit/NSButtonCell.h: Fix documentation error. * Headers/AppKit/NSButtonCell.h: Fix documentation error.
* Headers/AppKit/NSMenu.h: Tidy a litte, fix errors in documentation * Headers/AppKit/NSMenu.h: Tidy a litte, fix errors in documentation
@ -317,7 +324,7 @@
* Source/NSPopUpButton.m (-keyDown:): Handle selection of first * Source/NSPopUpButton.m (-keyDown:): Handle selection of first
entry correctly. Patch by Phillipe Roussel <p.o.roussel@free.fr> entry correctly. Patch by Phillipe Roussel <p.o.roussel@free.fr>
2007-01-19 Richard Frith-Macdoanld <rfm@gnu.org> 2007-01-19 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSDocument.m: fix include path (bug #18829) * Source/NSDocument.m: fix include path (bug #18829)
@ -422,7 +429,7 @@
* Source/NSTableView.m (rectOfColumn:): Use the height of the rows, * Source/NSTableView.m (rectOfColumn:): Use the height of the rows,
not the bounds. not the bounds.
2006-12-27 Richard Frith-Macdoanld <rfm@gnu.org> 2006-12-27 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/Additions/GNUstepGUI/GSTheme.h: Store images in dictionary. * Headers/Additions/GNUstepGUI/GSTheme.h: Store images in dictionary.
* Source/GSTheme.m: Improve handling of named images. * Source/GSTheme.m: Improve handling of named images.
@ -470,7 +477,7 @@
* Source/NSBitmapImageRep.m: Autogsdoc comments * Source/NSBitmapImageRep.m: Autogsdoc comments
2006-12-08 Richard Frith-Macdoanld <rfm@gnu.org> 2006-12-08 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSInputManager.m: * Source/NSInputManager.m:
Use help function key to enter context help mode rather than Use help function key to enter context help mode rather than
@ -580,7 +587,7 @@
to moveForward: and moveBackward: to moveForward: and moveBackward:
2006-11-19 Richard Frith-Macdoanld <rfm@gnu.org> 2006-11-19 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSAffineTransform.m: * Source/NSAffineTransform.m:
* Headers/AppKit/NSAffineTransform.h: * Headers/AppKit/NSAffineTransform.h:
@ -592,11 +599,11 @@
Update to use transformStruct accessor method rather than trying to Update to use transformStruct accessor method rather than trying to
work with the affine transform ivars directly. work with the affine transform ivars directly.
2006-11-18 Richard Frith-Macdoanld <rfm@gnu.org> 2006-11-18 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSScrollView.m: Adjust corner view when scroller is on right. * Source/NSScrollView.m: Adjust corner view when scroller is on right.
2006-11-17 Richard Frith-Macdoanld <rfm@gnu.org> 2006-11-17 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSTheme.m: * Source/GSTheme.m:
* Source/NSButtonCell.m: * Source/NSButtonCell.m:
@ -3857,7 +3864,7 @@
(-trackMouse:inRect:ofView:untilMouseUp:): ... to here. This fixes (-trackMouse:inRect:ofView:untilMouseUp:): ... to here. This fixes
bug #9824. bug #9824.
2005-02-14 Richard Frith-Macdoanld <rfm@gnu.org> 2005-02-14 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSTitleView.m (-mouseDown:): Post an * Source/GSTitleView.m (-mouseDown:): Post an
NSWindowDidMoveNotification at end of method if window was dragged. NSWindowDidMoveNotification at end of method if window was dragged.

View file

@ -1214,8 +1214,8 @@ container
if (!_selected_range.length || _selected_range.location == NSNotFound) if (!_selected_range.length || _selected_range.location == NSNotFound)
return; return;
if (_selected_range.location >= char_pos || if (_selected_range.location >= char_pos
_selected_range.location + _selected_range.length <= first_char_pos) || _selected_range.location + _selected_range.length <= first_char_pos)
{ {
return; return;
} }
@ -1242,9 +1242,9 @@ container
} }
/* Use the text view's selected text attributes */ /* Use the text view's selected text attributes */
if ((ftv = [self firstTextView])) if ((ftv = [self textViewForBeginningOfSelection]))
color = [[ftv selectedTextAttributes] color = [[ftv selectedTextAttributes]
objectForKey:NSBackgroundColorAttributeName]; objectForKey: NSBackgroundColorAttributeName];
if (!color) if (!color)
color = [NSColor selectedTextBackgroundColor]; color = [NSColor selectedTextBackgroundColor];
@ -1288,7 +1288,9 @@ container
NSDictionary *attributes; NSDictionary *attributes;
NSFont *f; NSFont *f;
NSColor *color, *new_color; NSColor *color, *run_color;
NSRange selectedGlyphRange;
BOOL currentGlyphIsSelected;
glyph_run_t *glyph_run; glyph_run_t *glyph_run;
unsigned int glyph_pos, char_pos; unsigned int glyph_pos, char_pos;
@ -1303,6 +1305,7 @@ container
cache in sync with the actual color. cache in sync with the actual color.
*/ */
NSColor *defaultTextColor = [NSColor textColor]; NSColor *defaultTextColor = [NSColor textColor];
NSColor *selectedTextColor = defaultTextColor;
#define GBUF_SIZE 16 /* TODO: tweak */ #define GBUF_SIZE 16 /* TODO: tweak */
NSGlyph gbuf[GBUF_SIZE]; NSGlyph gbuf[GBUF_SIZE];
@ -1315,6 +1318,21 @@ container
return; return;
[self _doLayoutToGlyph: range.location + range.length - 1]; [self _doLayoutToGlyph: range.location + range.length - 1];
/* Find the selected range of glyphs as it overlaps with the range we
* are about to display.
*/
if (_selected_range.length == 0)
{
selectedGlyphRange.location = 0;
selectedGlyphRange.length = 0;
}
else
{
selectedGlyphRange = [self glyphRangeForCharacterRange: _selected_range
actualCharacterRange: 0];
}
selectedGlyphRange = NSIntersectionRange(selectedGlyphRange, range);
if ([ctxt isDrawingToScreen]) if ([ctxt isDrawingToScreen])
gbuf_size = GBUF_SIZE; gbuf_size = GBUF_SIZE;
else else
@ -1343,12 +1361,32 @@ container
lp++, j++; lp++, j++;
glyph_run = run_for_glyph_index(lp->pos, glyphs, &glyph_pos, &char_pos); glyph_run = run_for_glyph_index(lp->pos, glyphs, &glyph_pos, &char_pos);
currentGlyphIsSelected = NSLocationInRange(lp->pos, selectedGlyphRange);
glyph = glyph_run->glyphs + lp->pos - glyph_pos; glyph = glyph_run->glyphs + lp->pos - glyph_pos;
attributes = [_textStorage attributesAtIndex: char_pos attributes = [_textStorage attributesAtIndex: char_pos
effectiveRange: NULL]; effectiveRange: NULL];
color = [attributes valueForKey: NSForegroundColorAttributeName]; run_color = [attributes valueForKey: NSForegroundColorAttributeName];
if (!color) if (run_color == nil)
color = defaultTextColor; run_color = defaultTextColor;
if (selectedGlyphRange.length > 0)
{
/* Get the text view's color setting for selected text as we will
* be needing to draw some selected glyphs.
*/
selectedTextColor = [[[self textViewForBeginningOfSelection]
selectedTextAttributes] objectForKey: NSForegroundColorAttributeName];
/* FIXME ... should we fall back to using selectedTextColor or
* defaultTextColor?
*/
if (selectedTextColor == nil)
{
selectedTextColor = [NSColor selectedTextColor];
}
}
color = (currentGlyphIsSelected ? selectedTextColor : run_color);
[color set]; [color set];
f = glyph_run->font; f = glyph_run->font;
[f set]; [f set];
@ -1359,6 +1397,39 @@ container
gbuf_len = 0; gbuf_len = 0;
for (g = lp->pos; g < range.location + range.length; g++, glyph++) for (g = lp->pos; g < range.location + range.length; g++, glyph++)
{ {
if (currentGlyphIsSelected != NSLocationInRange(g, selectedGlyphRange))
{
/* When we change between drawing selected and unselected glyphs
* we must flush any glyphs from the buffer and change trhe color
* we use for the text.
*/
if (gbuf_len)
{
DPSmoveto(ctxt, gbuf_point.x, gbuf_point.y);
GSShowGlyphs(ctxt, gbuf, gbuf_len);
DPSnewpath(ctxt);
gbuf_len = 0;
}
if (currentGlyphIsSelected == YES)
{
currentGlyphIsSelected = NO;
if (color != run_color)
{
color = run_color;
[color set];
}
}
else
{
currentGlyphIsSelected = YES;
if (color != selectedTextColor)
{
color = selectedTextColor;
[color set];
}
}
}
if (g == lp->pos + lp->length) if (g == lp->pos + lp->length)
{ {
if (gbuf_len) if (gbuf_len)
@ -1390,11 +1461,19 @@ container
glyph_run = (glyph_run_t *)glyph_run->head.next; glyph_run = (glyph_run_t *)glyph_run->head.next;
attributes = [_textStorage attributesAtIndex: char_pos attributes = [_textStorage attributesAtIndex: char_pos
effectiveRange: NULL]; effectiveRange: NULL];
new_color = [attributes valueForKey: NSForegroundColorAttributeName]; run_color = [attributes valueForKey: NSForegroundColorAttributeName];
if (!new_color) if (run_color == nil)
new_color = defaultTextColor; {
run_color = defaultTextColor;
}
glyph = glyph_run->glyphs; glyph = glyph_run->glyphs;
if (glyph_run->font != f || new_color != color)
/* If the font has changed or the color has changed (and we are
* not drawing using the selected text color) then we must flush
* any buffered glyphs and set the new font and color.
*/
if (glyph_run->font != f
|| (currentGlyphIsSelected == NO && run_color != color))
{ {
if (gbuf_len) if (gbuf_len)
{ {
@ -1403,16 +1482,16 @@ container
DPSnewpath(ctxt); DPSnewpath(ctxt);
gbuf_len = 0; gbuf_len = 0;
} }
if (color != new_color)
{
color = new_color;
[color set];
}
if (f != glyph_run->font) if (f != glyph_run->font)
{ {
f = glyph_run->font; f = glyph_run->font;
[f set]; [f set];
} }
if (currentGlyphIsSelected == NO && run_color != color)
{
color = run_color;
[color set];
}
} }
} }
if (!glyph->isNotShown && glyph->g && glyph->g != NSControlGlyph) if (!glyph->isNotShown && glyph->g && glyph->g != NSControlGlyph)