Show
Ignore:
Timestamp:
05/17/08 11:34:28 (8 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Update to SWT 3.4M7

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/custom/StyledTextRenderer.d

    r212 r213  
    2828import dwt.graphics.TextStyle; 
    2929import dwt.widgets.Display; 
     30import dwt.widgets.IME; 
    3031import dwt.widgets.ScrollBar; 
    3132import dwt.custom.StyledText; 
     
    392393    int selectionEnd = selection.y - lineOffset; 
    393394    Rectangle client = styledText.getClientArea(); 
    394     Color lineBackground = getLineBackground(lineIndex, widgetBackground); 
     395    Color lineBackground = getLineBackground(lineIndex, null); 
    395396    StyledTextEvent event = styledText.getLineBackgroundData(lineOffset, line); 
    396397    if (event !is null && event.lineBackground !is null) lineBackground = event.lineBackground; 
    397  
    398398    int height = layout.getBounds().height; 
    399     gc.setBackground(lineBackground); 
    400     styledText.drawBackground(gc, client.x, paintY, client.width, height); 
    401  
     399    if (lineBackground !is null) { 
     400        gc.setBackground(lineBackground); 
     401        gc.fillRectangle(client.x, paintY, client.width, height); 
     402    } else { 
     403        gc.setBackground(widgetBackground); 
     404        styledText.drawBackground(gc, client.x, paintY, client.width, height); 
     405    } 
    402406    gc.setForeground(widgetForeground); 
    403     gc.setBackground(lineBackground); 
    404407    if (selectionStart is selectionEnd || (selectionEnd <= 0 && selectionStart > lineLength - 1)) { 
    405408        layout.draw(gc, paintX, paintY); 
     
    664667    style = newStyles[newStyles.length - 1]; 
    665668    if (end < style.start + style.length - 1) { 
    666         if (!includeRanges || ranges is null) newStyles[newStyles.length - 1] = style = cast(StyleRange)style.clone(); 
    667         style.length = end - style.start + 1; 
     669        if (end < style.start) { 
     670            StyleRange[] tmp = new StyleRange[newStyles.length - 1]; 
     671            System.arraycopy(newStyles, 0, tmp, 0, newStyles.length - 1); 
     672            newStyles = tmp; 
     673        } else { 
     674            if (!includeRanges || ranges is null) newStyles[newStyles.length - 1] = style = cast(StyleRange)style.clone(); 
     675            style.length = end - style.start + 1; 
     676        } 
    668677    } 
    669678    return newStyles; 
     
    869878    } 
    870879    if (lastOffset < length) layout.setStyle(null, lastOffset, length); 
     880    if (styledText !is null && styledText.ime !is null) { 
     881        IME ime = styledText.ime; 
     882        int compositionOffset = ime.getCompositionOffset(); 
     883        if (compositionOffset !is -1) { 
     884            int commitCount = ime.getCommitCount(); 
     885            int compositionLength = ime.getText().length; 
     886            if (compositionLength !is commitCount) { 
     887                int compositionLine = content.getLineAtOffset(compositionOffset); 
     888                if (compositionLine is lineIndex) { 
     889                    int[] imeRanges = ime.getRanges(); 
     890                    TextStyle[] imeStyles = ime.getStyles(); 
     891                    if (imeRanges.length > 0) { 
     892                        for (int i = 0; i < imeStyles.length; i++) { 
     893                            int start = imeRanges[i*2] - lineOffset; 
     894                            int end = imeRanges[i*2+1] - lineOffset; 
     895                            TextStyle imeStyle = imeStyles[i], userStyle; 
     896                            for (int j = start; j <= end; j++) { 
     897                                userStyle = layout.getStyle(j); 
     898                                if (userStyle is null && j > 0) userStyle = layout.getStyle(j - 1); 
     899                                if (userStyle is null && j + 1 < length) userStyle = layout.getStyle(j + 1); 
     900                                if (userStyle is null) { 
     901                                    layout.setStyle(imeStyle, j, j); 
     902                                } else { 
     903                                    TextStyle newStyle = new TextStyle(imeStyle); 
     904                                    if (newStyle.font is null) newStyle.font = userStyle.font; 
     905                                    if (newStyle.foreground is null) newStyle.foreground = userStyle.foreground; 
     906                                    if (newStyle.background is null) newStyle.background = userStyle.background; 
     907                                    layout.setStyle(newStyle, j, j); 
     908                                } 
     909                            } 
     910                        } 
     911                    } else { 
     912                        int start = compositionOffset - lineOffset; 
     913                        int end = start + compositionLength - 1; 
     914                        TextStyle userStyle = layout.getStyle(start); 
     915                        if (userStyle is null) { 
     916                            if (start > 0) userStyle = layout.getStyle(start - 1); 
     917                            if (userStyle is null && end + 1 < length) userStyle = layout.getStyle(end + 1); 
     918                            if (userStyle !is null) { 
     919                                TextStyle newStyle = new TextStyle(); 
     920                                newStyle.font = userStyle.font; 
     921                                newStyle.foreground = userStyle.foreground; 
     922                                newStyle.background = userStyle.background; 
     923                                layout.setStyle(newStyle, start, end); 
     924                            } 
     925                        } 
     926                    } 
     927                } 
     928            } 
     929        } 
     930    } 
     931 
    871932    if (styledText !is null && styledText.isFixedLineHeight()) { 
    872933        int index = -1;