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/CTabItem.d

    r212 r213  
    2424import dwt.graphics.RGB; 
    2525import dwt.graphics.Rectangle; 
     26import dwt.graphics.TextLayout; 
    2627import dwt.widgets.Control; 
    2728import dwt.widgets.Display; 
     
    135136public this (CTabFolder parent, int style, int index) { 
    136137    closeRect = new Rectangle(0, 0, 0, 0); 
    137     super (parent, checkStyle(style)); 
     138    super (parent, style); 
    138139    showClose = (style & DWT.CLOSE) !is 0; 
    139140    parent.createItem (this, index); 
    140 } 
    141 static int checkStyle(int style) { 
    142     return DWT.NONE; 
    143141} 
    144142 
     
    160158    int ellipseWidth = gc.textExtent(ellipses, FLAGS).x; 
    161159    int length = text.length; 
    162     int end = length - 1; 
     160    TextLayout layout = new TextLayout(getDisplay()); 
     161    layout.setText(text); 
     162    int end = layout.getPreviousOffset(length, DWT.MOVEMENT_CLUSTER); 
    163163    while (end > 0) { 
    164164        text = text[ 0 .. end ]; 
    165165        int l = gc.textExtent(text, FLAGS).x; 
    166166        if (l + ellipseWidth <= width) { 
    167             return text ~ ellipses; 
    168         } 
    169         end--; 
    170     } 
    171     return text[ 0 .. 1 ]; 
     167            break; 
     168        } 
     169        end = layout.getPreviousOffset(end, DWT.MOVEMENT_CLUSTER); 
     170    } 
     171    layout.dispose(); 
     172    return end is 0 ? text.substring(0, 1) : text ~ ellipses; 
    172173} 
    173174 
     
    768769} 
    769770/** 
     771 * Returns <code>true</code> to indicate that the receiver's close button should be shown. 
     772 * Otherwise return <code>false</code>. The initial value is defined by the style (DWT.CLOSE) 
     773 * that was used to create the receiver. 
     774 *  
     775 * @return <code>true</code> if the close button should be shown 
     776 * 
     777 * @exception DWTException <ul> 
     778 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 
     779 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 
     780 * </ul> 
     781 *  
     782 * @since 3.4 
     783 */ 
     784public bool getShowClose() { 
     785    checkWidget(); 
     786    return showClose; 
     787} 
     788/** 
    770789 * Returns the receiver's tool tip text, or null if it has 
    771790 * not been set. 
     
    9981017    } 
    9991018} 
     1019/** 
     1020 * Sets to <code>true</code> to indicate that the receiver's close button should be shown. 
     1021 * If the parent (CTabFolder) was created with DWT.CLOSE style, changing this value has 
     1022 * no effect. 
     1023 *  
     1024 * @param close the new state of the close button 
     1025 * 
     1026 * @exception DWTException <ul> 
     1027 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 
     1028 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 
     1029 * </ul> 
     1030 *  
     1031 * @since 3.4 
     1032 */ 
     1033public void setShowClose(bool close) { 
     1034    checkWidget(); 
     1035    if (showClose is close) return; 
     1036    showClose = close; 
     1037    parent.updateItems(); 
     1038    parent.redrawTabs(); 
     1039} 
    10001040public override void setText (String string) { 
    10011041    checkWidget(); 
     
    10251065    toolTipText = string; 
    10261066} 
    1027 
     1067 
     1068