comparison dwt/graphics/TextLayout.d @ 294:1973f21c5c6f

Fix: mouse selection for TextLayout
author Frank Benoit <benoit@tionex.de>
date Fri, 22 Aug 2008 15:15:19 +0200
parents af37dd280317
children f478f12be363
comparison
equal deleted inserted replaced
293:810b16d6559b 294:1973f21c5c6f
732 } else { 732 } else {
733 StyleItem run = lineRuns[lineRuns.length - 1]; 733 StyleItem run = lineRuns[lineRuns.length - 1];
734 if (run.lineBreak && !run.softBreak) { 734 if (run.lineBreak && !run.softBreak) {
735 if (selectionStart <= run.start && run.start <= selectionEnd) extents = true; 735 if (selectionStart <= run.start && run.start <= selectionEnd) extents = true;
736 } else { 736 } else {
737 int endOffset = run.start + run.length - 1; 737 int endOffset = segmentsText.getAbsoluteCodePointOffset( run.start + run.length, -1 );
738 if (selectionStart <= endOffset && endOffset < selectionEnd && (flags & DWT.FULL_SELECTION) !is 0) { 738 if (selectionStart <= endOffset && endOffset < selectionEnd && (flags & DWT.FULL_SELECTION) !is 0) {
739 extents = true; 739 extents = true;
740 } 740 }
741 } 741 }
742 } 742 }
797 OS.DeleteObject(hBrush); 797 OS.DeleteObject(hBrush);
798 } 798 }
799 } 799 }
800 bool partialSelection = hasSelection && !(selectionStart > end || run.start > selectionEnd); 800 bool partialSelection = hasSelection && !(selectionStart > end || run.start > selectionEnd);
801 if (partialSelection) { 801 if (partialSelection) {
802 int selStart = Math.max(selectionStart, run.start) - run.start; 802 int selStart = index8to16[ Math.max(selectionStart, run.start) ] - index8to16[run.start];
803 int selEnd = Math.min(selectionEnd, end) - run.start; 803 int selEnd = index8to16[ Math.min(selectionEnd, end) ] - index8to16[ run.start ];
804 int cChars = index8to16[run.start+run.length] - index8to16[run.start]; // make it wchar 804 int cChars = index8to16[run.start+run.length] - index8to16[run.start]; // make it wchar
805 int gGlyphs = run.glyphCount; 805 int gGlyphs = run.glyphCount;
806 int piX; 806 int piX;
807 int* advances = run.justify !is null ? run.justify : run.advances; 807 int* advances = run.justify !is null ? run.justify : run.advances;
808 OS.ScriptCPtoX(index8to16[selStart], false, cChars, gGlyphs, run.clusters, run.visAttrs, advances, &run.analysis, &piX); 808 OS.ScriptCPtoX(selStart, false, cChars, gGlyphs, run.clusters, run.visAttrs, advances, &run.analysis, &piX);
809 int runX = (orientation & DWT.RIGHT_TO_LEFT) !is 0 ? run.width - piX : piX; 809 int runX = (orientation & DWT.RIGHT_TO_LEFT) !is 0 ? run.width - piX : piX;
810 rect.left = drawX + runX; 810 rect.left = drawX + runX;
811 rect.top = drawY; 811 rect.top = drawY;
812 OS.ScriptCPtoX(index8to16[selEnd], true, cChars, gGlyphs, run.clusters, run.visAttrs, advances, &run.analysis, &piX); 812 OS.ScriptCPtoX(selEnd, true, cChars, gGlyphs, run.clusters, run.visAttrs, advances, &run.analysis, &piX);
813 runX = (orientation & DWT.RIGHT_TO_LEFT) !is 0 ? run.width - piX : piX; 813 runX = (orientation & DWT.RIGHT_TO_LEFT) !is 0 ? run.width - piX : piX;
814 rect.right = drawX + runX; 814 rect.right = drawX + runX;
815 rect.bottom = drawY + lineHeight; 815 rect.bottom = drawY + lineHeight;
816 if (gdip) { 816 if (gdip) {
817 if (rect.left > rect.right) { 817 if (rect.left > rect.right) {