Changeset 240:ce446666f5a2

Show
Ignore:
Timestamp:
05/12/08 13:13:01 (4 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/DWT.d

    r238 r240  
    650650    public static const int PaintItem = 42; 
    651651 
     652    /** 
     653     * The IME composition event type (value is 43). 
     654     * <p> 
     655     * The IME composition event is sent to allow 
     656     * custom text editors to implement in-line 
     657     * editing of international text. 
     658     * </p> 
     659     * 
     660     * The detail field indicates the action to be taken: 
     661     * <p><ul> 
     662     * <li>{@link DWT#COMPOSITION_CHANGED}</li> 
     663     * <li>{@link DWT#COMPOSITION_OFFSET}</li> 
     664     * <li>{@link DWT#COMPOSITION_SELECTION}</li> 
     665     * </ul></p> 
     666     * 
     667     * @see dwt.widgets.Widget#addListener 
     668     * @see dwt.widgets.Display#addFilter 
     669     * @see dwt.widgets.Event 
     670     * 
     671     * @since 3.4 
     672     */ 
     673    public static const int ImeComposition = 43; 
     674 
    652675    /* Event Details */ 
     676 
     677    /** 
     678     * The IME composition event detail that indicates 
     679     * a change in the IME composition. The text field 
     680     * of the event is the new composition text. 
     681     * The start and end indicate the offsets where the 
     682     * composition text should be inserted. 
     683     * The styles and ranges are stored in the IME 
     684     * object (value is 1). 
     685     * 
     686     * @see DWT#ImeComposition 
     687     * 
     688     * @since 3.4 
     689     */ 
     690    public static const int COMPOSITION_CHANGED = 1; 
     691 
     692    /** 
     693     * The IME composition event detail that indicates 
     694     * that the IME needs the offset for a given location. 
     695     * The x and y fields of the event are used by the 
     696     * application to determine the offset. 
     697     * 
     698     * The index field of the event should be set to the 
     699     * text offset at that location. The count field should 
     700     * be set to indicate whether the location is closer to 
     701     * the leading edge (0) or the trailing edge (1) (value is 2). 
     702     * 
     703     * @see DWT#ImeComposition 
     704     * @see dwt.graphics.TextLayout#getOffset(int, int, int[]) 
     705     * 
     706     * @since 3.4 
     707     */ 
     708    public static const int COMPOSITION_OFFSET = 2; 
     709 
     710    /** 
     711     * The IME composition event detail that indicates 
     712     * that IME needs the selected text and its start 
     713     * and end offsets (value is 3). 
     714     * 
     715     * @see DWT#ImeComposition 
     716     * 
     717     * @since 3.4 
     718     */ 
     719    public static const int COMPOSITION_SELECTION = 3; 
    653720 
    654721    /** 
     
    11431210     */ 
    11441211    public static const int V_SCROLL = 1 << 9; 
     1212 
     1213    /** 
     1214     * Style constant for no scrollbar behavior (value is 1&lt;&lt;4). 
     1215     * <p> 
     1216     * When neither H_SCROLL or V_SCROLL are specified, controls 
     1217     * are free to create the default scroll bars for the control. 
     1218     * Using NO_SCROLL overrides the default and forces the control 
     1219     * to have no scroll bars. 
     1220     * 
     1221     * <b>Used By:</b><ul> 
     1222     * <li><code>Tree</code></li> 
     1223     * <li><code>Table</code></li> 
     1224     * </ul></p> 
     1225     * 
     1226     * @since 3.4 
     1227     */ 
     1228    public static const int NO_SCROLL = 1 << 4; 
    11451229 
    11461230    /** 
     
    12991383    /** 
    13001384     * Style constant for no focus from the mouse behavior (value is 1&lt;&lt;19). 
     1385     * <p> 
     1386     * Normally, when the user clicks on a control, focus is assigned to that 
     1387     * control, providing the control has no children.  Some controls, such as 
     1388     * tool bars and sashes, don't normally take focus when the mouse is clicked 
     1389     * or accept focus when assigned from within the program.  This style allows 
     1390     * Composites to implement "no focus" mouse behavior. 
     1391     * 
    13011392     * <br>Note that this is a <em>HINT</em>. 
     1393     * </p> 
    13021394     * <p><b>Used By:</b><ul> 
    13031395     * <li><code>Composite</code></li> 
     
    13141406     * sent with a GC clipped to only the new areas to be painted. Without this 
    13151407     * style, the entire client area will be repainted. 
     1408     * 
     1409     * <br>Note that this is a <em>HINT</em>. 
    13161410     * </p><p><b>Used By:</b><ul> 
    13171411     * <li><code>Composite</code></li> 
     
    13221416    /** 
    13231417     * Style constant for no paint event merging behavior (value is 1&lt;&lt;21). 
     1418     * 
     1419     * <br>Note that this is a <em>HINT</em>. 
    13241420     * <p><b>Used By:</b><ul> 
    13251421     * <li><code>Composite</code></li> 
     
    14191515 
    14201516    /** 
     1517     * Style constant for transparent behavior (value is 1&lt;&lt;30). 
     1518     * <p> 
     1519     * By default, before a widget paints, the client area is filled with the current background. 
     1520     * When this style is specified, the background is not filled and widgets that are obscured 
     1521     * will draw through. 
     1522     * </p><p><b>Used By:</b><ul> 
     1523     * <li><code>Composite</code></li> 
     1524     * </ul></p> 
     1525     * 
     1526     * @since 3.4 
     1527     * 
     1528     * WARNING: THIS API IS UNDER CONSTRUCTION AND SHOULD NOT BE USED 
     1529     */ 
     1530    public static const int TRANSPARENT = 1 << 30; 
     1531 
     1532    /** 
    14211533     * Style constant for align up behavior (value is 1&lt;&lt;7, 
    14221534     * since align UP and align TOP are considered the same). 
     
    14241536     * <li><code>Button</code> with <code>ARROW</code> style</li> 
    14251537     * <li><code>Tracker</code></li> 
     1538     * <li><code>Table</code></li> 
     1539     * <li><code>Tree</code></li> 
    14261540     * </ul></p> 
    14271541     */ 
    14281542    public static const int UP = 1 << 7; 
     1543 
     1544    /** 
     1545     * Style constant to indicate single underline (value is 0). 
     1546     * <p><b>Used By:</b><ul> 
     1547     * <li><code>TextStyle</code></li> 
     1548     * </ul></p> 
     1549     * 
     1550     * @since 3.4 
     1551     */ 
     1552    public static const int UNDERLINE_SINGLE = 0; 
     1553 
     1554    /** 
     1555     * Style constant to indicate double underline (value is 1). 
     1556     * <p><b>Used By:</b><ul> 
     1557     * <li><code>TextStyle</code></li> 
     1558     * </ul></p> 
     1559     * 
     1560     * @since 3.4 
     1561     */ 
     1562    public static const int UNDERLINE_DOUBLE = 1; 
     1563 
     1564    /** 
     1565     * Style constant to indicate error underline (value is 2). 
     1566     * <p><b>Used By:</b><ul> 
     1567     * <li><code>TextStyle</code></li> 
     1568     * </ul></p> 
     1569     * 
     1570     * @since 3.4 
     1571     */ 
     1572    public static const int UNDERLINE_ERROR = 2; 
     1573 
     1574    /** 
     1575     * Style constant to indicate squiggle underline (value is 3). 
     1576     * <p><b>Used By:</b><ul> 
     1577     * <li><code>TextStyle</code></li> 
     1578     * </ul></p> 
     1579     * 
     1580     * @since 3.4 
     1581     */ 
     1582    public static const int UNDERLINE_SQUIGGLE = 3; 
     1583 
     1584    /** 
     1585     * Style constant to indicate solid border (value is 1). 
     1586     * <p><b>Used By:</b><ul> 
     1587     * <li><code>TextStyle</code></li> 
     1588     * </ul></p> 
     1589     * 
     1590     * @since 3.4 
     1591     */ 
     1592    public static const int BORDER_SOLID = 1; 
     1593 
     1594    /** 
     1595     * Style constant to indicate dashed border (value is 2). 
     1596     * <p><b>Used By:</b><ul> 
     1597     * <li><code>TextStyle</code></li> 
     1598     * </ul></p> 
     1599     * 
     1600     * @since 3.4 
     1601     */ 
     1602    public static const int BORDER_DASH = 2; 
     1603 
     1604    /** 
     1605     * Style constant to indicate dotted border (value is 4). 
     1606     * <p><b>Used By:</b><ul> 
     1607     * <li><code>TextStyle</code></li> 
     1608     * </ul></p> 
     1609     * 
     1610     * @since 3.4 
     1611     */ 
     1612    public static const int BORDER_DOT = 4; 
    14291613 
    14301614    /** 
     
    14431627     * <li><code>Button</code> with <code>ARROW</code> style</li> 
    14441628     * <li><code>Tracker</code></li> 
     1629     * <li><code>Table</code></li> 
     1630     * <li><code>Tree</code></li> 
    14451631     * </ul></p> 
    14461632     */ 
     
    29803166 
    29813167    /** 
     3168     * Constant to indicate an error state (value is 1). 
     3169     * <p><b>Used By:</b><ul> 
     3170     * <li><code>ProgressBar</code></li> 
     3171     * </ul></p> 
     3172     * 
     3173     * @since 3.4 
     3174     */ 
     3175    public static const int ERROR = 1; 
     3176 
     3177    /** 
     3178     * Constant to a indicate a paused state (value is 4). 
     3179     * <p><b>Used By:</b><ul> 
     3180     * <li><code>ProgressBar</code></li> 
     3181     * </ul></p> 
     3182     * 
     3183     * @since 3.4 
     3184     */ 
     3185    public static const int PAUSED = 1 << 2; 
     3186 
     3187    /** 
    29823188     * The font style constant indicating a normal weight, non-italic font 
    2983      * (value is 0). 
     3189     * (value is 0). This constant is also used with <code>ProgressBar</code> 
     3190     * to indicate a normal state. 
     3191     * <p><b>Used By:</b><ul> 
     3192     * <li><code>ProgressBar</code></li> 
     3193     * </ul></p> 
    29843194     */ 
    29853195    public static const int NORMAL = 0; 
  • dwt/accessibility/AccessibleObject.d

    r238 r240  
    473473                    case ACC.ROLE_SEPARATOR: return ATK.ATK_ROLE_SEPARATOR; 
    474474                    case ACC.ROLE_SLIDER: return ATK.ATK_ROLE_SLIDER; 
    475                     case ACC.ROLE_TABLE: return ATK.ATK_ROLE_TABLE
    476                     case ACC.ROLE_TABLECELL: return ATK.ATK_ROLE_TABLE_CELL
     475                    case ACC.ROLE_TABLE: return ATK.ATK_ROLE_LIST
     476                    case ACC.ROLE_TABLECELL: return ATK.ATK_ROLE_LIST_ITEM
    477477                    case ACC.ROLE_TABLECOLUMNHEADER: return ATK.ATK_ROLE_TABLE_COLUMN_HEADER; 
    478478                    case ACC.ROLE_TABLEROWHEADER: return ATK.ATK_ROLE_TABLE_ROW_HEADER; 
  • dwt/custom/CCombo.d

    r238 r240  
    5252static import tango.text.convert.Format; 
    5353import dwt.dwthelper.utils; 
     54import dwt.dwthelper.Runnable; 
    5455 
    5556/** 
     
    153154            } 
    154155            if (getShell () is event.widget) { 
    155                 handleFocus (DWT.FocusOut); 
     156                getDisplay().asyncExec(new class() Runnable { 
     157                    public void run() { 
     158                        if (isDisposed()) return; 
     159                        handleFocus (DWT.FocusOut); 
     160                    } 
     161                }); 
    156162            } 
    157163        } 
     
    166172    }; 
    167173 
    168     int [] comboEvents = [DWT.Dispose, DWT.Move, DWT.Resize]; 
     174    int [] comboEvents = [DWT.Dispose, DWT.FocusIn, DWT.Move, DWT.Resize]; 
    169175    for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener); 
    170176 
    171     int [] textEvents = [DWT.KeyDown, DWT.KeyUp, DWT.MenuDetect, DWT.Modify, DWT.MouseDown, DWT.MouseUp, DWT.Traverse, DWT.FocusIn, DWT.Verify]; 
     177    int [] textEvents = [DWT.DefaultSelection, DWT.KeyDown, DWT.KeyUp, DWT.MenuDetect, DWT.Modify, DWT.MouseDown, DWT.MouseUp, DWT.MouseDoubleClick, DWT.MouseWheel, DWT.Traverse, DWT.FocusIn, DWT.Verify]; 
    172178    for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener); 
    173179 
    174     int [] arrowEvents = [DWT.Selection, DWT.FocusIn]; 
     180    int [] arrowEvents = [DWT.MouseDown, DWT.MouseUp, DWT.Selection, DWT.FocusIn]; 
    175181    for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener); 
    176182 
     
    180186static int checkStyle (int style) { 
    181187    int mask = DWT.BORDER | DWT.READ_ONLY | DWT.FLAT | DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT; 
    182     return style & mask
     188    return DWT.NO_FOCUS | (style & mask)
    183189} 
    184190/** 
     
    319325            break; 
    320326        } 
     327        case DWT.MouseDown: { 
     328            Event mouseEvent = new Event (); 
     329            mouseEvent.button = event.button; 
     330            mouseEvent.count = event.count; 
     331            mouseEvent.stateMask = event.stateMask; 
     332            mouseEvent.time = event.time; 
     333            mouseEvent.x = event.x; mouseEvent.y = event.y; 
     334            notifyListeners (DWT.MouseDown, mouseEvent); 
     335            event.doit = mouseEvent.doit; 
     336            break; 
     337        } 
     338        case DWT.MouseUp: { 
     339            Event mouseEvent = new Event (); 
     340            mouseEvent.button = event.button; 
     341            mouseEvent.count = event.count; 
     342            mouseEvent.stateMask = event.stateMask; 
     343            mouseEvent.time = event.time; 
     344            mouseEvent.x = event.x; mouseEvent.y = event.y; 
     345            notifyListeners (DWT.MouseUp, mouseEvent); 
     346            event.doit = mouseEvent.doit; 
     347            break; 
     348        } 
    321349        case DWT.Selection: { 
     350            text.setFocus(); 
    322351            dropDown (!isDropped ()); 
    323352            break; 
     
    363392            list = null; 
    364393            arrow = null; 
     394            break; 
     395        case DWT.FocusIn: 
     396            Control focusControl = getDisplay ().getFocusControl (); 
     397            if (focusControl is arrow || focusControl is list) return; 
     398            if (isDropped()) { 
     399                list.setFocus(); 
     400            } else { 
     401                text.setFocus(); 
     402            } 
    365403            break; 
    366404        case DWT.Move: 
     
    466504public void deselect (int index) { 
    467505    checkWidget (); 
    468     list.deselect (index); 
     506    if (0 <= index && index < list.getItemCount () && 
     507            index is list.getSelectionIndex() && 
     508            text.getText().equals(list.getItem(index))) { 
     509        text.setText("");  //$NON-NLS-1$ 
     510        list.deselect (index); 
     511    } 
    469512} 
    470513/** 
     
    484527public void deselectAll () { 
    485528    checkWidget (); 
     529    text.setText("");  //$NON-NLS-1$ 
    486530    list.deselectAll (); 
    487531} 
     
    490534    if (!drop) { 
    491535        popup.setVisible (false); 
    492         if (!isDisposed ()&& arrow.isFocusControl()) { 
     536        if (!isDisposed () && isFocusControl()) { 
    493537            text.setFocus(); 
    494538        } 
     
    528572    popup.setBounds (x, y, width, height); 
    529573    popup.setVisible (true); 
    530     list.setFocus (); 
     574    if (isFocusControl()) list.setFocus (); 
    531575} 
    532576/* 
     
    655699    checkWidget (); 
    656700    return list.getItems (); 
     701} 
     702/** 
     703 * Returns <code>true</code> if the receiver's list is visible, 
     704 * and <code>false</code> otherwise. 
     705 * <p> 
     706 * If one of the receiver's ancestors is not visible or some 
     707 * other condition makes the receiver not visible, this method 
     708 * may still indicate that it is considered visible even though 
     709 * it may not actually be showing. 
     710 * </p> 
     711 * 
     712 * @return the receiver's list's visibility state 
     713 * 
     714 * @exception DWTException <ul> 
     715 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 
     716 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 
     717 * </ul> 
     718 * 
     719 * @since 3.4 
     720 */ 
     721public bool getListVisible () { 
     722    checkWidget (); 
     723    return isDropped(); 
    657724} 
    658725public override Menu getMenu() { 
     
    906973        public void getLocation (AccessibleControlEvent e) { 
    907974            Rectangle location = getBounds (); 
    908             Point pt = toDisplay (location.x, location.y); 
     975            Point pt = getParent().toDisplay (location.x, location.y); 
    909976            e.x = pt.x; 
    910977            e.y = pt.y; 
     
    10031070                    event.doit = false; 
    10041071                    break; 
     1072                case DWT.TRAVERSE_TAB_NEXT: 
     1073                case DWT.TRAVERSE_TAB_PREVIOUS: 
     1074                    event.doit = text.traverse(event.detail); 
     1075                    event.detail = DWT.TRAVERSE_NONE; 
     1076                    if (event.doit) dropDown(false); 
     1077                    return; 
    10051078                default: 
    10061079            } 
     
    10941167             * it again. To prevent the popup from showing again, we will let the selection 
    10951168             * event of the arrow button hide the popup. 
     1169             * In Windows, hiding the popup during the deactivate causes the deactivate 
     1170             * to be called twice and the selection event to be disappear. 
    10961171             */ 
    1097             if ("gtk".equals(DWT.getPlatform())) { 
     1172            if (!"carbon".equals(DWT.getPlatform())) { 
    10981173                Point point = arrow.toControl(getDisplay().getCursorLocation()); 
    10991174                Point size = arrow.getSize(); 
     
    13181393public override bool setFocus () { 
    13191394    checkWidget(); 
     1395    if (!isEnabled () || !isVisible ()) return false; 
    13201396    if (isFocusControl ()) return true; 
    13211397    return text.setFocus (); 
     
    13941470    checkWidget (); 
    13951471    return; 
     1472} 
     1473/** 
     1474 * Marks the receiver's list as visible if the argument is <code>true</code>, 
     1475 * and marks it invisible otherwise. 
     1476 * <p> 
     1477 * If one of the receiver's ancestors is not visible or some 
     1478 * other condition makes the receiver not visible, marking 
     1479 * it visible may not actually cause it to be displayed. 
     1480 * </p> 
     1481 * 
     1482 * @param visible the new visibility state 
     1483 * 
     1484 * @exception DWTException <ul> 
     1485 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 
     1486 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 
     1487 * </ul> 
     1488 * 
     1489 * @since 3.4 
     1490 */ 
     1491public void setListVisible (bool visible) { 
     1492    checkWidget (); 
     1493    dropDown(visible); 
    13961494} 
    13971495public override void setMenu(Menu menu) { 
     
    15271625            break; 
    15281626        } 
     1627        case DWT.DefaultSelection: { 
     1628            dropDown (false); 
     1629            Event e = new Event (); 
     1630            e.time = event.time; 
     1631            e.stateMask = event.stateMask; 
     1632            notifyListeners (DWT.DefaultSelection, e); 
     1633            break; 
     1634        } 
    15291635        case DWT.KeyDown: { 
    15301636            Event keyEvent = new Event (); 
     
    15371643            event.doit = keyEvent.doit; 
    15381644            if (!event.doit) break; 
    1539  
    1540             if (event.character is DWT.CR) { 
    1541                 dropDown (false); 
    1542                 Event selectionEvent = new Event (); 
    1543                 selectionEvent.time = event.time; 
    1544                 selectionEvent.stateMask = event.stateMask; 
    1545                 notifyListeners (DWT.DefaultSelection, selectionEvent); 
    1546                 if (isDisposed ()) break; 
    1547             } 
    1548  
    15491645            if (event.keyCode is DWT.ARROW_UP || event.keyCode is DWT.ARROW_DOWN) { 
    15501646                event.doit = false; 
     
    16001696        } 
    16011697        case DWT.MouseDown: { 
     1698            Event mouseEvent = new Event (); 
     1699            mouseEvent.button = event.button; 
     1700            mouseEvent.count = event.count; 
     1701            mouseEvent.stateMask = event.stateMask; 
     1702            mouseEvent.time = event.time; 
     1703            mouseEvent.x = event.x; mouseEvent.y = event.y; 
     1704            notifyListeners (DWT.MouseDown, mouseEvent); 
     1705            if (isDisposed ()) break; 
     1706            event.doit = mouseEvent.doit; 
     1707            if (!event.doit) break; 
    16021708            if (event.button !is 1) return; 
    16031709            if (text.getEditable ()) return; 
     
    16091715        } 
    16101716        case DWT.MouseUp: { 
     1717            Event mouseEvent = new Event (); 
     1718            mouseEvent.button = event.button; 
     1719            mouseEvent.count = event.count; 
     1720            mouseEvent.stateMask = event.stateMask; 
     1721            mouseEvent.time = event.time; 
     1722            mouseEvent.x = event.x; mouseEvent.y = event.y; 
     1723            notifyListeners (DWT.MouseUp, mouseEvent); 
     1724            if (isDisposed ()) break; 
     1725            event.doit = mouseEvent.doit; 
     1726            if (!event.doit) break; 
    16111727            if (event.button !is 1) return; 
    16121728            if (text.getEditable ()) return; 
     
    16141730            break; 
    16151731        } 
     1732        case DWT.MouseDoubleClick: { 
     1733            Event mouseEvent = new Event (); 
     1734            mouseEvent.button = event.button; 
     1735            mouseEvent.count = event.count; 
     1736            mouseEvent.stateMask = event.stateMask; 
     1737            mouseEvent.time = event.time; 
     1738            mouseEvent.x = event.x; mouseEvent.y = event.y; 
     1739            notifyListeners (DWT.MouseDoubleClick, mouseEvent); 
     1740            break; 
     1741        } 
     1742        case DWT.MouseWheel: { 
     1743            Event keyEvent = new Event (); 
     1744            keyEvent.time = event.time; 
     1745            keyEvent.keyCode = event.count > 0 ? DWT.ARROW_UP : DWT.ARROW_DOWN; 
     1746            keyEvent.stateMask = event.stateMask; 
     1747            notifyListeners (DWT.KeyDown, keyEvent); 
     1748            if (isDisposed ()) break; 
     1749            event.doit = keyEvent.doit; 
     1750            if (!event.doit) break; 
     1751            if (event.count !is 0) { 
     1752                event.doit = false; 
     1753                int oldIndex = getSelectionIndex (); 
     1754                if (event.count > 0) { 
     1755                    select (Math.max (oldIndex - 1, 0)); 
     1756                } else { 
     1757                    select (Math.min (oldIndex + 1, getItemCount () - 1)); 
     1758                } 
     1759                if (oldIndex !is getSelectionIndex ()) { 
     1760                    Event e = new Event(); 
     1761                    e.time = event.time; 
     1762                    e.stateMask = event.stateMask; 
     1763                    notifyListeners (DWT.Selection, e); 
     1764                } 
     1765                if (isDisposed ()) break; 
     1766            } 
     1767            break; 
     1768        } 
    16161769        case DWT.Traverse: { 
    16171770            switch (event.detail) { 
    1618                 case DWT.TRAVERSE_RETURN: 
    16191771                case DWT.TRAVERSE_ARROW_PREVIOUS: 
    16201772                case DWT.TRAVERSE_ARROW_NEXT: 
     
    16241776                    event.doit = false; 
    16251777                    break; 
     1778                case DWT.TRAVERSE_TAB_PREVIOUS: 
     1779                    event.doit = traverse(DWT.TRAVERSE_TAB_PREVIOUS); 
     1780                    event.detail = DWT.TRAVERSE_NONE; 
     1781                    return; 
    16261782                default: 
    16271783            } 
    1628  
    16291784            Event e = new Event (); 
    16301785            e.time = event.time; 
  • dwt/custom/CLabel.d

    r238 r240  
    3434import dwt.graphics.Point; 
    3535import dwt.graphics.Rectangle; 
     36import dwt.graphics.TextLayout; 
    3637import dwt.widgets.Canvas; 
    3738import dwt.widgets.Composite; 
     
    798799    int mid = (max+min)/2 - 1; 
    799800    if (mid <= 0) return t; 
     801    TextLayout layout = new TextLayout (getDisplay()); 
     802    layout.setText(t); 
     803    mid = validateOffset(layout, mid); 
    800804    while (min < mid && mid < max) { 
    801805        String s1 = t[0 .. mid].dup; 
    802         String s2 = t[l-mid .. l].dup
     806        String s2 = t.substring(validateOffset(layout, l-mid), l)
    803807        int l1 = gc.textExtent(s1, DRAW_FLAGS).x; 
    804808        int l2 = gc.textExtent(s2, DRAW_FLAGS).x; 
    805809        if (l1+w+l2 > width) { 
    806810            max = mid; 
    807             mid = (max+min)/2
     811            mid = validateOffset(layout, (max+min)/2)
    808812        } else if (l1+w+l2 < width) { 
    809813            min = mid; 
    810             mid = (max+min)/2
     814            mid = validateOffset(layout, (max+min)/2)
    811815        } else { 
    812816            min = max; 
    813817        } 
    814818    } 
    815     if (mid is 0) return t; 
    816     return t[ 0 .. mid ] ~ ELLIPSIS ~ t[ l-mid .. l ]; 
    817 
    818  
     819    String result = mid is 0 ? t : t.substring(0, mid) ~ ELLIPSIS ~ t.substring(validateOffset(layout, l-mid), l); 
     820    layout.dispose(); 
     821    return result; 
     822
     823int validateOffset(TextLayout layout, int offset) { 
     824    int nextOffset = layout.getNextOffset(offset, DWT.MOVEMENT_CLUSTER); 
     825    if (nextOffset !is offset) return layout.getPreviousOffset(nextOffset, DWT.MOVEMENT_CLUSTER); 
     826    return offset; 
     827
    819828private String[] splitString(String text) { 
    820829    String[] lines = new String[1]; 
  • dwt/custom/CTabFolder.d

    r238 r240  
    15441544    style |= single ? DWT.SINGLE : DWT.MULTI; 
    15451545    if (borderLeft !is 0) style |= DWT.BORDER; 
     1546    style &= ~DWT.CLOSE; 
     1547    if (showClose) style |= DWT.CLOSE; 
    15461548    return style; 
    15471549} 
     
    17181720        public void getLocation(AccessibleControlEvent e) { 
    17191721            Rectangle location = null; 
     1722            Point pt = null; 
    17201723            int childID = e.childID; 
    17211724            if (childID is ACC.CHILDID_SELF) { 
    17221725                location = getBounds(); 
    1723             } else if (childID >= 0 && childID < items.length) { 
    1724                 location = items[childID].getBounds(); 
    1725             } else if (showChevron && childID is items.length + CHEVRON_CHILD_ID) { 
    1726                 location = chevronRect; 
    1727             } else if (showMin && childID is items.length + MINIMIZE_CHILD_ID) { 
    1728                 loc