Show
Ignore:
Timestamp:
05/17/08 11:34:28 (6 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/dnd/DropTargetEffect.d

    r135 r213  
    1818import dwt.graphics.Rectangle; 
    1919import dwt.widgets.Control; 
    20 import dwt.widgets.Item; 
    2120import dwt.widgets.Table; 
     21import dwt.widgets.TableItem; 
    2222import dwt.widgets.Tree; 
    2323import dwt.widgets.TreeItem; 
     
    108108        Point coordinates = new Point(x, y); 
    109109        coordinates = table.toControl(coordinates); 
    110         Item item = table.getItem(coordinates); 
    111         if (item is null) { 
    112             Rectangle area = table.getClientArea(); 
    113             if (area.contains(coordinates)) { 
    114                 // Scan across the width of the table. 
    115                 for (int x1 = area.x; x1 < area.x + area.width; x1++) { 
    116                     Point pt = new Point(x1, coordinates.y); 
    117                     item = table.getItem(pt); 
    118                     if (item !is null) { 
    119                         break; 
    120                     } 
    121                 } 
    122             } 
     110        TableItem item = table.getItem(coordinates); 
     111        if (item !is null) return item; 
     112        Rectangle area = table.getClientArea(); 
     113        int tableBottom = area.y + area.height; 
     114        int itemCount = table.getItemCount(); 
     115        for (int i=table.getTopIndex(); i<itemCount; i++) { 
     116            item = table.getItem(i); 
     117            Rectangle rect = item.getBounds(); 
     118            rect.x = area.x; 
     119            rect.width = area.width; 
     120            if (rect.contains(coordinates)) return item; 
     121            if (rect.y > tableBottom) break; 
    123122        } 
    124         return item
     123        return null
    125124    } 
    126125 
    127126    Widget getItem(Tree tree, int x, int y) { 
    128         Point coordinates = new Point(x, y); 
    129         coordinates = tree.toControl(coordinates); 
    130         Item item = tree.getItem(coordinates); 
     127        Point point = new Point(x, y); 
     128        point = tree.toControl(point); 
     129        TreeItem item = tree.getItem(point); 
    131130        if (item is null) { 
    132131            Rectangle area = tree.getClientArea(); 
    133             if (area.contains(coordinates)) { 
    134                 // Scan across the width of the tree. 
    135                 for (int x1 = area.x; x1 < area.x + area.width; x1++) { 
    136                     Point pt = new Point(x1, coordinates.y); 
    137                     item = tree.getItem(pt); 
    138                     if (item !is null) { 
    139                         break; 
    140                     } 
     132            if (area.contains(point)) { 
     133                int treeBottom = area.y + area.height; 
     134                item = tree.getTopItem(); 
     135                while (item !is null) { 
     136                    Rectangle rect = item.getBounds(); 
     137                    int itemBottom = rect.y + rect.height; 
     138                    if (rect.y <= point.y && point.y < itemBottom) return item; 
     139                    if (itemBottom > treeBottom) break; 
     140                    item = nextItem(tree, item); 
    141141                } 
     142                return null; 
    142143            } 
    143144        } 
     
    147148    TreeItem nextItem(Tree tree, TreeItem item) { 
    148149        if (item is null) return null; 
    149         if (item.getExpanded()) return item.getItem(0); 
     150        if (item.getExpanded() && item.getItemCount() > 0) return item.getItem(0); 
    150151        TreeItem childItem = item; 
    151152        TreeItem parentItem = childItem.getParentItem();