Changeset 294:1973f21c5c6f

Show
Ignore:
Timestamp:
08/22/08 09:15:19 (3 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Fix: mouse selection for TextLayout?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/graphics/TextLayout.d

    r288 r294  
    735735                    if (selectionStart <= run.start && run.start <= selectionEnd) extents = true; 
    736736                } else { 
    737                     int endOffset = run.start + run.length - 1
     737                    int endOffset = segmentsText.getAbsoluteCodePointOffset( run.start + run.length, -1 )
    738738                    if (selectionStart <= endOffset && endOffset < selectionEnd && (flags & DWT.FULL_SELECTION) !is 0) { 
    739739                        extents = true; 
     
    800800                        bool partialSelection = hasSelection && !(selectionStart > end || run.start > selectionEnd); 
    801801                        if (partialSelection) { 
    802                             int selStart = Math.max(selectionStart, run.start) - run.start
    803                             int selEnd = Math.min(selectionEnd, end) - run.start
     802                            int selStart = index8to16[ Math.max(selectionStart, run.start) ] - index8to16[run.start]
     803                            int selEnd = index8to16[ Math.min(selectionEnd, end) ] - index8to16[ run.start ]
    804804                            int cChars = index8to16[run.start+run.length] - index8to16[run.start]; // make it wchar 
    805805                            int gGlyphs = run.glyphCount; 
    806806                            int piX; 
    807807                            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); 
    809809                            int runX = (orientation & DWT.RIGHT_TO_LEFT) !is 0 ? run.width - piX : piX; 
    810810                            rect.left = drawX + runX; 
    811811                            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); 
    813813                            runX = (orientation & DWT.RIGHT_TO_LEFT) !is 0 ? run.width - piX : piX; 
    814814                            rect.right = drawX + runX;